]> git.proxmox.com Git - pve-installer.git/commitdiff
get fqdn: code/naming style cleanups
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 17 Nov 2023 05:34:33 +0000 (06:34 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 17 Nov 2023 05:34:33 +0000 (06:34 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Proxmox/Install/RunEnv.pm
Proxmox/Sys/Net.pm

index 2d91401dc472429d0ac1cee8a92f8de29b32cd7d..c393f679cb8d5c8bb23da81644451f32e48079f7 100644 (file)
@@ -267,9 +267,9 @@ sub query_installation_environment : prototype() {
        dns => query_dns(),
     };
 
-    # Cannot be put directly in the above hash as it might return undef ..
-    if ( my $hostname = Proxmox::Sys::Net::get_dhcp_hostname()) {
-       $output->{network}->{hostname} = $hostname;
+    # 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;
     }
 
     # FIXME: move whatever makes sense over to Proxmox::Sys::Net:: and keep that as single source,
index 7415bf92f028f1688e9e2ef40d87f7ac6dda0553..ed83fb0f48caf10d124310efec421d2e50b3e405 100644 (file)
@@ -189,16 +189,16 @@ sub get_ip_config {
     }
 }
 
-# Tries to detect the hostname for this system via DHCP, if available.
-# 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.
+# Tries to detect the FQDN hostname for this system via DHCP, if available.
+#
+# 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_hostname : prototype() {
+sub get_dhcp_fqdn : prototype() {
     my $leasefile = '/var/lib/dhcp/dhclient.leases';
     return if ! -f $leasefile;
 
-    open (my $fh, '<', $leasefile) or return;
+    open(my $fh, '<', $leasefile) or return;
 
     my $name = undef;
     while (my $line = <$fh>) {