From fe31a954b2c8e9461b435ff18ab786a5b23e9118 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Mon, 14 Mar 2022 22:36:17 +0100 Subject: [PATCH] marsadm: try to correct dottet hostname when possible --- userspace/marsadm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/userspace/marsadm b/userspace/marsadm index 2a556f35..be7eba80 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -239,7 +239,9 @@ sub get_checked_utsname { $hostname = <$fh>; close($fh); chomp $hostname; - } else { + } + # Some distros like OpenSUSE allow differences between /etc/hostname and other sources + if (!$hostname || $hostname =~ m/\./) { $etc_hostname = "/bin/hostname"; unless (-x $etc_hostname) { $etc_hostname = "/usr/bin/hostname"; @@ -259,6 +261,14 @@ sub get_checked_utsname { unless ($uname) { die "CRITICAL RISK: cannot determine network node name via 'uname -n'\n"; } + if ($uname ne $hostname) { + # try to shorten only the hostname + my $oldname = $hostname; + if ($hostname =~ s/\..*$//) { + warn "WARNING: I am now shortening the FQDN-like hostname '$oldname' from $etc_hostname down to '$hostname', but you are running a RISK.\n"; + warn "WARNING: Please read mars-user-manual.pdf about the SERIOUS RISKS from FQDN-like hostnames\n"; + } + } if ($uname ne $hostname) { die "CRITICAL RISK: the utsname from 'uname -n' is '$uname', DIFFERING from $etc_hostname '$hostname'\n"; }