From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 2/3] auto: answer: deserialize empty domain name as `None`
Date: Tue, 15 Jul 2025 15:55:40 +0200 [thread overview]
Message-ID: <20250715135620.1023136-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250715135620.1023136-1-c.heiss@proxmox.com>
This handles the case where users set `global.fqdn.domain = ""`, which
would result incorrect parsing and finally resulting in the FQDN of the
target machine being set to `<productname>.example.invalid`.
Reported on the community forum [0].
[0] https://forum.proxmox.com/threads/auto-install-fetching-fqdn-through-dhcp-does-not-set-search-domain-correctly.168369/
Fixes: a37e044 ("fix #5811: auto: add option to retrieve FQDN from DHCP configuration")
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
proxmox-auto-installer/src/answer.rs | 13 +++++++++++++
proxmox-auto-installer/tests/parse-answer.rs | 1 +
...n_from_dhcp_empty_dhcp_domain_setting.json | 19 +++++++++++++++++++
...n_from_dhcp_empty_dhcp_domain_setting.toml | 17 +++++++++++++++++
4 files changed, 50 insertions(+)
create mode 100644 proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.json
create mode 100644 proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.toml
diff --git a/proxmox-auto-installer/src/answer.rs b/proxmox-auto-installer/src/answer.rs
index b461976..88f4c87 100644
--- a/proxmox-auto-installer/src/answer.rs
+++ b/proxmox-auto-installer/src/answer.rs
@@ -90,6 +90,7 @@ pub struct FqdnExtendedConfig {
#[serde(default)]
pub source: FqdnSourceMode,
/// Domain to use if none is received via DHCP.
+ #[serde(default, deserialize_with = "deserialize_non_empty_string_maybe")]
pub domain: Option<String>,
}
@@ -444,3 +445,15 @@ pub enum KeyboardLayout {
}
serde_plain::derive_display_from_serialize!(KeyboardLayout);
+
+fn deserialize_non_empty_string_maybe<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
+where
+ D: serde::Deserializer<'de>,
+{
+ let val: Option<String> = Deserialize::deserialize(deserializer)?;
+
+ match val {
+ Some(s) if !s.is_empty() => Ok(Some(s)),
+ _ => Ok(None),
+ }
+}
diff --git a/proxmox-auto-installer/tests/parse-answer.rs b/proxmox-auto-installer/tests/parse-answer.rs
index 88f30aa..a354f21 100644
--- a/proxmox-auto-installer/tests/parse-answer.rs
+++ b/proxmox-auto-installer/tests/parse-answer.rs
@@ -124,6 +124,7 @@ mod tests {
disk_match_any,
first_boot,
fqdn_from_dhcp,
+ fqdn_from_dhcp_empty_dhcp_domain_setting,
fqdn_from_dhcp_no_dhcp_domain_with_default_domain,
full_fqdn_from_dhcp_with_default_domain,
hashed_root_password,
diff --git a/proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.json b/proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.json
new file mode 100644
index 0000000..5ec6656
--- /dev/null
+++ b/proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.json
@@ -0,0 +1,19 @@
+{
+ "autoreboot": 1,
+ "cidr": "192.168.1.114/24",
+ "country": "at",
+ "dns": "192.168.1.254",
+ "domain": "test.local",
+ "filesys": "ext4",
+ "gateway": "192.168.1.1",
+ "hdsize": 223.57088470458984,
+ "existing_storage_auto_rename": 1,
+ "hostname": "pveauto",
+ "keymap": "de",
+ "mailto": "mail@no.invalid",
+ "mngmt_nic": "eno1",
+ "root_password": { "plain": "12345678" },
+ "target_hd": "/dev/sda",
+ "timezone": "Europe/Vienna",
+ "first_boot": { "enabled": 0 }
+}
diff --git a/proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.toml b/proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.toml
new file mode 100644
index 0000000..a19e342
--- /dev/null
+++ b/proxmox-auto-installer/tests/resources/parse_answer/fqdn_from_dhcp_empty_dhcp_domain_setting.toml
@@ -0,0 +1,17 @@
+[global]
+keyboard = "de"
+country = "at"
+mailto = "mail@no.invalid"
+timezone = "Europe/Vienna"
+root-password = "12345678"
+
+[global.fqdn]
+source = "from-dhcp"
+domain = ""
+
+[network]
+source = "from-dhcp"
+
+[disk-setup]
+filesystem = "ext4"
+disk-list = ["sda"]
--
2.49.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-15 13:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 13:55 [pve-devel] [PATCH installer 0/3] run env, auto: fix dhcp hostname/domain retrieval Christoph Heiss
2025-07-15 13:55 ` [pve-devel] [PATCH installer 1/3] run env: fix dhcp-set hostname containing local domain Christoph Heiss
2025-07-15 13:55 ` Christoph Heiss [this message]
2025-07-15 13:55 ` [pve-devel] [PATCH installer 3/3] install: run `make tidy` Christoph Heiss
2025-07-15 14:32 ` [pve-devel] applied: [PATCH installer 0/3] run env, auto: fix dhcp hostname/domain retrieval Thomas Lamprecht
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=20250715135620.1023136-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.