[pve-devel] [PATCH installer] tui: fix search domain parsing from runtime environment info
Christoph Heiss
c.heiss at proxmox.com
Mon Aug 21 10:53:59 CEST 2023
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 at proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss at 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
More information about the pve-devel
mailing list