* [pve-devel] [PATCH installer] run env: strip out domain name from hostname
@ 2023-11-17 10:55 Christoph Heiss
0 siblings, 0 replies; only message in thread
From: Christoph Heiss @ 2023-11-17 10:55 UTC (permalink / raw)
To: pve-devel
The FQDN (retrieved via the DHCP `host-name` option) might contain the
domain name too, as allowed by RFC 2132.
E.g. if the DHCP server sends
`host-name` => "foo.bar" `domain-name` => "bar"
that would show up in the network setup screen in both UIs as
"foo.bar.bar" as hostname/FQDN.
Fixes: a805423 ("run env: do not store emtpy hostname")
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Tested this with various possible settings for the `host-name` DHCP
option, also including e.g. if `host-name` is set to "" in the lease
(which should never happen but you never know what shoddy DHCP
implementations are out there).
Proxmox/Install/RunEnv.pm | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Proxmox/Install/RunEnv.pm b/Proxmox/Install/RunEnv.pm
index c393f67..214a001 100644
--- a/Proxmox/Install/RunEnv.pm
+++ b/Proxmox/Install/RunEnv.pm
@@ -258,18 +258,24 @@ sub query_installation_environment : prototype() {
my $output = {};
my $routes = query_routes();
+ my $dns = query_dns();
log_info("query block devices");
$output->{disks} = Proxmox::Sys::Block::get_cached_disks();
$output->{network} = {
interfaces => query_netdevs(),
routes => $routes,
- dns => query_dns(),
+ dns => $dns,
};
# avoid serializing out null or an empty string, that can trip up the UIs
if (my $fqdn = Proxmox::Sys::Net::get_dhcp_fqdn()) {
- $output->{network}->{hostname} = $fqdn;
+ # strip out the domain name if contained in the FQDN
+ if (defined($dns->{domain}) && $fqdn =~ m/^(.*)\.$dns->{domain}$/) {
+ $output->{network}->{hostname} = $1;
+ } else {
+ $output->{network}->{hostname} = $fqdn;
+ }
}
# FIXME: move whatever makes sense over to Proxmox::Sys::Net:: and keep that as single source,
--
2.42.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-17 10:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-17 10:55 [pve-devel] [PATCH installer] run env: strip out domain name from hostname Christoph Heiss
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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal