Commit 162c2794 authored by Robert Ricci's avatar Robert Ricci

Change the way we handle the localhost alias - it's unqualified in

the hosts files that we put on free nodes. For reserved nodes, we
start a new hosts file from scrath, and qualify localhost with
the domain found from the hostname command.
parent 4e627d29
......@@ -991,19 +991,31 @@ sub dohostnames ()
my $TM;
#
# Start with fresh copy, since the hosts files is potentially updated
# after the node boots via the update command.
#
if (system($CP, "-f", TMHOSTS, HOSTSFILE) != 0) {
printf STDERR "Could not copy default %s into place: $!\n", HOSTSFILE;
return 1;
}
# Note, we no longer start with the 'prototype' file here, because we have
# to make up a localhost line that's properly qualified.
#
$TM = OPENTMCC(TMCCCMD_HOSTS);
open(HOSTS, ">>" . HOSTSFILE)
open(HOSTS, ">" . HOSTSFILE)
or die("Could not open $HOSTSFILE: $!");
my $localaliases = "loghost";
#
# Find out our domain name, so that we can qualify the localhost entry
#
my $hostname = `hostname`;
if ($hostname =~ /[^.]+\.(.+)/) {
$localaliases .= " localhost.$1";
}
#
# First, write a localhost line into the hosts file - we have to know the
# domain to use here
#
print HOSTS os_etchosts_line("localhost", "127.0.0.1", $localaliases), "\n";
#
# Now convert each hostname into hosts file representation and write
# it to the hosts file. Note that ALIASES is for backwards compat.
......
......@@ -7,5 +7,5 @@
# not be consulted at all; see /etc/host.conf for the resolution order.
#
#
127.0.0.1 localhost localhost.emulab.net loghost
127.0.0.1 localhost loghost
......@@ -991,19 +991,31 @@ sub dohostnames ()
my $TM;
#
# Start with fresh copy, since the hosts files is potentially updated
# after the node boots via the update command.
#
if (system($CP, "-f", TMHOSTS, HOSTSFILE) != 0) {
printf STDERR "Could not copy default %s into place: $!\n", HOSTSFILE;
return 1;
}
# Note, we no longer start with the 'prototype' file here, because we have
# to make up a localhost line that's properly qualified.
#
$TM = OPENTMCC(TMCCCMD_HOSTS);
open(HOSTS, ">>" . HOSTSFILE)
open(HOSTS, ">" . HOSTSFILE)
or die("Could not open $HOSTSFILE: $!");
my $localaliases = "loghost";
#
# Find out our domain name, so that we can qualify the localhost entry
#
my $hostname = `hostname`;
if ($hostname =~ /[^.]+\.(.+)/) {
$localaliases .= " localhost.$1";
}
#
# First, write a localhost line into the hosts file - we have to know the
# domain to use here
#
print HOSTS os_etchosts_line("localhost", "127.0.0.1", $localaliases), "\n";
#
# Now convert each hostname into hosts file representation and write
# it to the hosts file. Note that ALIASES is for backwards compat.
......
#
# Hosts Database.
#
127.0.0.1 localhost localhost.emulab.net loghost
127.0.0.1 localhost loghost
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment