Try harder to get useful values if (a) getent is not available or (b) HOSTNAME env-var

does not exist.

svn path=/trunk/netsurf/; revision=12055
This commit is contained in:
Chris Young 2011-03-15 00:20:18 +00:00
parent 40896dd3d9
commit bdf75f07aa

View File

@ -58,6 +58,13 @@ my %userinfo; # The information about the current user
$gecos =~ s/,.+//g;
$gecos =~ s/"/'/g;
$userinfo{GECOS} = $gecos;
if ( $pwdline eq "" ) { # Try whoami if we don't have getent
my $pwdline = `whoami`;
chomp $pwdline;
$userinfo{USERNAME} = $pwdline;
$userinfo{GECOS} = $pwdline;
}
}
# The current date, in AmigaOS version friendly format (dd.mm.yyyy)
@ -77,6 +84,11 @@ $qroot =~ s/"/\\"/g;
my $hostname = $ENV{HOSTNAME};
if ( $hostname eq "" ) { # Try hostname command if env-var empty
$hostname = `hostname`;
chomp $hostname;
}
$hostname = "unknown-host" unless (defined($hostname) && $hostname ne "");
$hostname =~ s/"/\\"/g;