From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E7EA5D73F for ; Mon, 21 Aug 2023 10:54:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C2FBE14DC5 for ; Mon, 21 Aug 2023 10:54:14 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 21 Aug 2023 10:54:14 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E4A3942A1B for ; Mon, 21 Aug 2023 10:54:13 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Mon, 21 Aug 2023 10:53:59 +0200 Message-ID: <20230821085409.166781-1-c.heiss@proxmox.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.040 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH installer] tui: fix search domain parsing from runtime environment info X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2023 08:54:44 -0000 Commit 55dc67c ("tui: fix FQDN validation") mostly fixed FQDN validation, but missed a case when the search domain only has one component. As Fqdn::from() requires at least two components to pass validation, the search domain parsing from the runtime environment info provided by the low-level installer failed. This resulted in that the network dialog defaulted to ".example.invalid" as FQDN, instead of "." as it should. Fixes: 55dc67c ("tui: fix FQDN validation") Reported-by: Aaron Lauterer Signed-off-by: Christoph Heiss --- proxmox-tui-installer/src/options.rs | 5 +++-- proxmox-tui-installer/src/setup.rs | 13 ++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/proxmox-tui-installer/src/options.rs b/proxmox-tui-installer/src/options.rs index dab1730..b321e9c 100644 --- a/proxmox-tui-installer/src/options.rs +++ b/proxmox-tui-installer/src/options.rs @@ -365,8 +365,9 @@ impl From<&NetworkInfo> for NetworkOptions { if let Some(domain) = &info.dns.domain { let hostname = crate::current_product().default_hostname(); - this.fqdn = - Fqdn::from(&format!("{hostname}.{domain}")).unwrap_or_else(|_| domain.clone()); + if let Ok(fqdn) = Fqdn::from(&format!("{hostname}.{domain}")) { + this.fqdn = fqdn; + } } if let Some(routes) = &info.routes { diff --git a/proxmox-tui-installer/src/setup.rs b/proxmox-tui-installer/src/setup.rs index e51bb4d..522bf8d 100644 --- a/proxmox-tui-installer/src/setup.rs +++ b/proxmox-tui-installer/src/setup.rs @@ -15,7 +15,7 @@ use crate::{ AdvancedBootdiskOptions, BtrfsRaidLevel, Disk, FsType, InstallerOptions, ZfsBootdiskOptions, ZfsChecksumOption, ZfsCompressOption, ZfsRaidLevel, }, - utils::{CidrAddress, Fqdn}, + utils::CidrAddress, }; #[allow(clippy::upper_case_acronyms)] @@ -408,8 +408,7 @@ pub struct NetworkInfo { #[derive(Clone, Deserialize)] pub struct Dns { - #[serde(deserialize_with = "deserialize_invalid_value_as_none")] - pub domain: Option, + pub domain: Option, /// List of stringified IP addresses. #[serde(default)] @@ -446,11 +445,3 @@ pub struct Interface { #[serde(deserialize_with = "deserialize_cidr_list")] pub addresses: Option>, } - -fn deserialize_invalid_value_as_none<'de, D, T>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, - T: Deserialize<'de>, -{ - Ok(Deserialize::deserialize(deserializer).ok()) -} -- 2.41.0