From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 0C52C1FF16B for ; Tue, 15 Jul 2025 15:56:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 72E2A3E48C; Tue, 15 Jul 2025 15:57:03 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 15 Jul 2025 15:55:39 +0200 Message-ID: <20250715135620.1023136-2-c.heiss@proxmox.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250715135620.1023136-1-c.heiss@proxmox.com> References: <20250715135620.1023136-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [runenv.pm, net.pm, rfc-editor.org, proxmox.com] Subject: [pve-devel] [PATCH installer 1/3] run env: fix dhcp-set hostname containing local domain X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" According to RFC 2132 section 3.14 [0], the hostname _can_ also include the local domain name. Strip the suffix it before storing it into the runtime environment. Reported on the community forum [1]. [0] https://www.rfc-editor.org/rfc/rfc2132#section-3.14 [1] https://forum.proxmox.com/threads/auto-install-fetching-fqdn-through-dhcp-does-not-set-search-domain-correctly.168369/ Fixes: bda1cdf ("run env: retrieve and store hostname from DHCP lease if available") Signed-off-by: Christoph Heiss --- Proxmox/Install/RunEnv.pm | 7 ++++++- Proxmox/Sys/Net.pm | 12 ++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Proxmox/Install/RunEnv.pm b/Proxmox/Install/RunEnv.pm index cdd7992..ce89346 100644 --- a/Proxmox/Install/RunEnv.pm +++ b/Proxmox/Install/RunEnv.pm @@ -292,7 +292,12 @@ sub query_installation_environment : prototype() { }; # avoid serializing out null or an empty string, that can trip up the UIs - if (my $fqdn = Proxmox::Sys::Net::get_dhcp_fqdn()) { + if (my $fqdn = Proxmox::Sys::Net::get_dhcp_hostname()) { + if (defined($output->{network}->{dns}->{domain})) { + # strip domain name suffix, if possible + $fqdn =~ s/\.$output->{network}->{dns}->{domain}//; + } + $output->{network}->{hostname} = $fqdn; } diff --git a/Proxmox/Sys/Net.pm b/Proxmox/Sys/Net.pm index 38aab0e..6fe99ec 100644 --- a/Proxmox/Sys/Net.pm +++ b/Proxmox/Sys/Net.pm @@ -204,12 +204,16 @@ sub udevadm_netdev_details { return $result; } -# Tries to detect the FQDN hostname for this system via DHCP, if available. +# Tries to detect the hostname for this system given via DHCP, if available. +# The hostname _might_ also include the local domain name, depending on the +# concrete DHCP server implementation. +# +# DHCP servers can set option 12 to inform the client about it's hostname [0]. +# dhclient dumps all options set by the DHCP server it in lease file, so just +# read it from there. # -# DHCP server can set option 12 to inform the client about it's hostname [0]. dhclient dumps all -# options set by the DHCP server it in lease file, so just read it from there. # [0] RFC 2132, section 3.14 -sub get_dhcp_fqdn : prototype() { +sub get_dhcp_hostname : prototype() { my $leasefile = '/var/lib/dhcp/dhclient.leases'; return if !-f $leasefile; -- 2.49.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel