public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer] tui: fix search domain parsing from runtime environment info
Date: Mon, 21 Aug 2023 10:53:59 +0200	[thread overview]
Message-ID: <20230821085409.166781-1-c.heiss@proxmox.com> (raw)

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 |  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<Fqdn>,
+    pub domain: Option<String>,
 
     /// List of stringified IP addresses.
     #[serde(default)]
@@ -446,11 +445,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())
-}
-- 
2.41.0





             reply	other threads:[~2023-08-21  8:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21  8:53 Christoph Heiss [this message]
2023-08-23  8:39 ` [pve-devel] applied: " Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230821085409.166781-1-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal