public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH installer] tui: fix search domain parsing from runtime environment info
@ 2023-08-21  8:53 Christoph Heiss
  2023-08-23  8:39 ` [pve-devel] applied: " Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Heiss @ 2023-08-21  8:53 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH installer] tui: fix search domain parsing from runtime environment info
  2023-08-21  8:53 [pve-devel] [PATCH installer] tui: fix search domain parsing from runtime environment info Christoph Heiss
@ 2023-08-23  8:39 ` Wolfgang Bumiller
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2023-08-23  8:39 UTC (permalink / raw)
  To: Christoph Heiss; +Cc: pve-devel

applied, thanks




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-23  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-21  8:53 [pve-devel] [PATCH installer] tui: fix search domain parsing from runtime environment info Christoph Heiss
2023-08-23  8:39 ` [pve-devel] applied: " Wolfgang Bumiller

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