public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH installer] run env: do not store emtpy hostname
@ 2023-11-16 19:59 Stoiko Ivanov
  2023-11-17  5:37 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Stoiko Ivanov @ 2023-11-16 19:59 UTC (permalink / raw)
  To: pve-devel

without this patch the hostname ends up as the empty string in
run-env-info.json, which results in a parse-error in the TUI code
(an empty string is not None, but still too short as hostname)

Minimally tested on a VM.

Fixes: bda1cdf699a3fcfc1cf3cfa446b1493689fc8eb8
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 Proxmox/Install/RunEnv.pm | 4 +++-
 Proxmox/Sys/Net.pm        | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Proxmox/Install/RunEnv.pm b/Proxmox/Install/RunEnv.pm
index 5f68d82..2d91401 100644
--- a/Proxmox/Install/RunEnv.pm
+++ b/Proxmox/Install/RunEnv.pm
@@ -268,7 +268,9 @@ sub query_installation_environment : prototype() {
     };
 
     # Cannot be put directly in the above hash as it might return undef ..
-    $output->{network}->{hostname} = Proxmox::Sys::Net::get_dhcp_hostname();
+    if ( my $hostname = Proxmox::Sys::Net::get_dhcp_hostname()) {
+	$output->{network}->{hostname} = $hostname;
+    }
 
     # FIXME: move whatever makes sense over to Proxmox::Sys::Net:: and keep that as single source,
     # it can then use some different structure just fine (after adapting the GTK GUI to that) but
diff --git a/Proxmox/Sys/Net.pm b/Proxmox/Sys/Net.pm
index 35d2abd..7415bf9 100644
--- a/Proxmox/Sys/Net.pm
+++ b/Proxmox/Sys/Net.pm
@@ -211,7 +211,7 @@ sub get_dhcp_hostname : prototype() {
     }
 
     close($fh);
-    return $1 if defined($name) && $name =~ m/^([^\.]+)(?:\.(?:\S+))?$/;
+    return $name if defined($name) && $name =~ m/^([^\.]+)(?:\.(?:\S+))?$/;
 }
 
 1;
-- 
2.39.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH installer] run env: do not store emtpy hostname
  2023-11-16 19:59 [pve-devel] [PATCH installer] run env: do not store emtpy hostname Stoiko Ivanov
@ 2023-11-17  5:37 ` Thomas Lamprecht
  2023-11-17 10:11   ` Christoph Heiss
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lamprecht @ 2023-11-17  5:37 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stoiko Ivanov

Am 16/11/2023 um 20:59 schrieb Stoiko Ivanov:
> without this patch the hostname ends up as the empty string in
> run-env-info.json, which results in a parse-error in the TUI code
> (an empty string is not None, but still too short as hostname)
> 
> Minimally tested on a VM.
> 
> Fixes: bda1cdf699a3fcfc1cf3cfa446b1493689fc8eb8
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  Proxmox/Install/RunEnv.pm | 4 +++-
>  Proxmox/Sys/Net.pm        | 2 +-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
>

applied, with some code/naming (style) clean up done in a follow-up, thanks!

E.g., the method is now named get_dhcp_fqdn, as it doesn't parses out the
first part (sometimes also just named hostname) anymore, but rather passes
along the full FQDN, be it just the local part or a full host.domain one.

@christoph: please give this another sanity check.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] applied: [PATCH installer] run env: do not store emtpy hostname
  2023-11-17  5:37 ` [pve-devel] applied: " Thomas Lamprecht
@ 2023-11-17 10:11   ` Christoph Heiss
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Heiss @ 2023-11-17 10:11 UTC (permalink / raw)
  To: Thomas Lamprecht; +Cc: Proxmox VE development discussion, Stoiko Ivanov


On Fri, Nov 17, 2023 at 06:37:08AM +0100, Thomas Lamprecht wrote:
>
> Am 16/11/2023 um 20:59 schrieb Stoiko Ivanov:
> > without this patch the hostname ends up as the empty string in
> > run-env-info.json, which results in a parse-error in the TUI code
> > (an empty string is not None, but still too short as hostname)
> >
> > Minimally tested on a VM.
> >
> > Fixes: bda1cdf699a3fcfc1cf3cfa446b1493689fc8eb8
> > Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> > ---
> >  Proxmox/Install/RunEnv.pm | 4 +++-
> >  Proxmox/Sys/Net.pm        | 2 +-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> >
>
> applied, with some code/naming (style) clean up done in a follow-up, thanks!
>
> E.g., the method is now named get_dhcp_fqdn, as it doesn't parses out the
> first part (sometimes also just named hostname) anymore, but rather passes
> along the full FQDN, be it just the local part or a full host.domain one.
>
> @christoph: please give this another sanity check.

One thing - and why this only took the actual hostname in the first
place - was that if the DHCP `host-name` is indeed fully-qualified and
`domain-name` is set too (which is allowed by the spec), we end up with
a duplicate domain name. E.g. if the DHCP server sends

  `host-name` => "foo.bar"     `domain-name` => "bar"

would show up in the network setup screen in both UIs as "foo.bar.bar"
as the hostname/FQDN. (Tested this case just now FWIW)

Not breaking, but I'll send a follow-up patch to strip out the
domain-name from the FQDN hostname as needed.

Other than that; LGTM.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-17 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16 19:59 [pve-devel] [PATCH installer] run env: do not store emtpy hostname Stoiko Ivanov
2023-11-17  5:37 ` [pve-devel] applied: " Thomas Lamprecht
2023-11-17 10:11   ` Christoph Heiss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal