From c7d3d928f7293d125a8bb7f658639a769ee2c591 Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Tue, 20 Jun 2023 10:51:26 +0200 Subject: [PATCH] tui: use network domain as default administrator email domain Signed-off-by: Christoph Heiss --- proxmox-tui-installer/src/main.rs | 2 +- proxmox-tui-installer/src/options.rs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs index 0588f9f..d985642 100644 --- a/proxmox-tui-installer/src/main.rs +++ b/proxmox-tui-installer/src/main.rs @@ -177,7 +177,7 @@ fn main() { options: InstallerOptions { bootdisk: BootdiskOptions::defaults_from(&runtime_info.disks[0]), timezone: TimezoneOptions::defaults_from(&runtime_info, &locales), - password: PasswordOptions::default(), + password: PasswordOptions::defaults_from(&runtime_info), network: NetworkOptions::from(&runtime_info.network), reboot: false, }, diff --git a/proxmox-tui-installer/src/options.rs b/proxmox-tui-installer/src/options.rs index 64437e6..9f6408c 100644 --- a/proxmox-tui-installer/src/options.rs +++ b/proxmox-tui-installer/src/options.rs @@ -318,10 +318,18 @@ pub struct PasswordOptions { pub root_password: String, } -impl Default for PasswordOptions { - fn default() -> Self { +impl PasswordOptions { + pub fn defaults_from(info: &RuntimeInfo) -> Self { + let domain = info + .network + .dns + .domain + .clone() + // Safety: The provided default domain will always be valid. + .unwrap_or_else(|| Fqdn::from("example.invalid").unwrap()); + Self { - email: "mail@example.invalid".to_owned(), + email: format!("mail@{domain}"), root_password: String::new(), } } -- 2.39.5