]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: fix search domain parsing from runtime environment info
authorChristoph Heiss <c.heiss@proxmox.com>
Mon, 21 Aug 2023 08:53:59 +0000 (10:53 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 23 Aug 2023 08:38:14 +0000 (10:38 +0200)
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 "<product>.example.invalid" as FQDN, instead of
"<product>.<searchdomain>" as it should.

Fixes: 55dc67c ("tui: fix FQDN validation")
Reported-by: Aaron Lauterer <a.lauterer@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-tui-installer/src/options.rs
proxmox-tui-installer/src/setup.rs

index f18c8133bc669d04b676394be7a17ca5eb175752..a0a81c9d5451f15b03258e3e89eddabb3b41ec15 100644 (file)
@@ -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 {
index 46b47cdd6657b6517bf95a31b3e27030b95ddf29..942e3194c96f1193b7d17b855825f8dca211e797 100644 (file)
@@ -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)]
@@ -412,8 +412,7 @@ pub struct NetworkInfo {
 
 #[derive(Clone, Deserialize)]
 pub struct Dns {
-    #[serde(deserialize_with = "deserialize_invalid_value_as_none")]
-    pub domain: Option<Fqdn>,
+    pub domain: Option<String>,
 
     /// List of stringified IP addresses.
     #[serde(default)]
@@ -450,11 +449,3 @@ pub struct Interface {
     #[serde(deserialize_with = "deserialize_cidr_list")]
     pub addresses: Option<Vec<CidrAddress>>,
 }
-
-fn deserialize_invalid_value_as_none<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error>
-where
-    D: Deserializer<'de>,
-    T: Deserialize<'de>,
-{
-    Ok(Deserialize::deserialize(deserializer).ok())
-}