Bug 461933 - Anaconda sets hostname to localhost.localdomain
Anaconda sets hostname to localhost.localdomain
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: NetworkManager (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Dan Williams
Fedora Extras Quality Assurance
: Reopened
: 468445 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-11 10:37 EDT by Orion Poplawski
Modified: 2008-12-21 18:43 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-10-21 14:44:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Orion Poplawski 2008-09-11 10:37:39 EDT
Description of problem:

I do pxeboot/ks installs with fixed addresses handed out by dhcp.  In the past, the hostname of the installed system has be set properly.  Now it is set to "localhost.localdomain".

Version-Release number of selected component (if applicable):
11.4.1.3

Some log snippets:

14:01:43 INFO    : moving (1) to step preinstallconfig
14:01:43 DEBUG   : isys.py:mount()- going to mount /selinux on /mnt/sysimage/selinux with options defaults
14:01:43 WARNING : no dev package, going to bind mount /dev
14:01:43 DEBUG   : isys.py:mount()- going to mount /dev on /mnt/sysimage/dev with options defaults,bind
14:01:43 INFO    : self.hostname = localhost.localdomain
14:01:43 INFO    : moving (1) to step installpackages

....

18:16:30 INFO    : Writing main configuration
18:16:47 INFO    : self.hostname = localhost.localdomain
18:16:57 INFO    : moving (1) to step firstboot
Comment 1 David Cantrell 2008-09-19 00:50:02 EDT
This is fixed in the git repo and will be in the next build of anaconda.
Comment 2 Orion Poplawski 2008-09-26 17:38:02 EDT
Still there with 11.4.1.40:

12:13:53 INFO    : moving (1) to step preinstallconfig
12:13:53 DEBUG   : isys.py:mount()- going to mount /selinux on /mnt/sysimage/selinux with options defaults
12:13:53 WARNING : no dev package, going to bind mount /dev
12:13:53 DEBUG   : isys.py:mount()- going to mount /dev on /mnt/sysimage/dev with options defaults,bind
12:13:53 INFO    : self.hostname = localhost.localdomain
12:13:53 INFO    : moving (1) to step installpackages

15:08:49 INFO    : Writing main configuration
15:08:53 INFO    : self.hostname = localhost.localdomain
15:08:57 INFO    : moving (1) to step firstboot

Probably another side affect of moving to NM as NM doesn't set the hostname.
Comment 3 David Cantrell 2008-10-06 23:28:29 EDT
Tested with latest rawhide and this appears to be working now.  So long as you are doing a network-based install, the network connection will come up early and anaconda can figure out your hostname by either asking NetworkManager or trying a DNS lookup on your address.
Comment 4 Orion Poplawski 2008-10-16 18:21:17 EDT
Doesn't work with 11.4.1.49:

08:34:29 DEBUG   : isys.py:mount()- going to mount /dev on /mnt/sysimage/dev with options defaults,bind
08:34:29 INFO    : self.hostname = localhost.localdomain
08:34:29 INFO    : moving (1) to step installpackages
08:34:29 INFO    : Preparing to install packages
09:12:40 WARNING : /usr/lib/anaconda/iw/progress_gui.py:55: GtkWarning: gtk_progress_set_percentage: assertion `percentage >= 0 && percentage <= 1.0' failed
  self.progress.set_fraction(pct)

09:13:06 INFO    : moving (1) to step postinstallconfig
09:13:06 INFO    : moving (1) to step writeconfig
09:13:06 INFO    : Writing main configuration
09:13:10 INFO    : self.hostname = localhost.localdomain
09:13:12 INFO    : moving (1) to step firstboot

NM (which happens all before the above - this is PXE boot/netowrk ks):

<29>Oct 16 08:22:40 NetworkManager: <info>  Setting system hostname to 'test' (from DHCP)
<28>Oct 16 08:22:40 NetworkManager: <WARN>  update_etc_hosts(): update_etc_hosts: couldn'tread /etc/hosts: (4) Failed to open file '/etc/hosts': No such file or directory
<28>Oct 16 08:22:40 NetworkManager: <WARN>  update_etc_hosts(): update_etc_hosts: couldn'tupdate /etc/hosts: (4) Failed to open file '/etc/hosts': No such file or directory
<29>Oct 16 08:22:40 NetworkManager: <info>  Setting system hostname to 'localhost.localdomain' (error updating /etc/hosts)
Comment 5 David Cantrell 2008-10-20 18:23:31 EDT
This looks like a bug in update_etc_hosts() in src/NetworkManagerPolicy.c in NetworkManager.  The call to g_file_set_contents() fails, which causes set_system_hostname() to revert back to localhost.localdomain.

Not sure why g_file_set_contents() is failing.  Reading update_etc_hosts() in NetworkManager, it looks like that function will create /etc/hosts if it doesn't exist, which is what we want.
Comment 6 Dan Williams 2008-10-21 08:54:34 EDT
Any chance we could get the warning message that NM prints out when the g_set_file_contents() call fails?  That'll tell us what's probably going wrong.
Comment 7 Orion Poplawski 2008-10-21 11:57:53 EDT
The problem is that you are not clearing error from the previous g_file_get_contents call that fails.  You probably want:

--- NetworkManager-0.7.0/src/NetworkManagerPolicy.c.error       2008-10-11 12:05:54.000000000 -0600
+++ NetworkManager-0.7.0/src/NetworkManagerPolicy.c     2008-10-21 09:53:53.000000000 -0600
@@ -266,6 +266,7 @@
                nm_warning ("%s: couldn't read " SYSCONFDIR "/hosts: (%d) %s",
                            __func__, error ? error->code : 0,
                            (error && error->message) ? error->message : "(unknown)");
+               g_error_free (error);
        } else {
                lines = g_strsplit_set (contents, "\n\r", 0);
                g_free (contents);
@@ -316,6 +317,7 @@
                nm_warning ("%s: couldn't update " SYSCONFDIR "/hosts: (%d) %s",
                            __func__, error ? error->code : 0,
                            (error && error->message) ? error->message : "(unknown)");
+               g_error_free (error);
        } else
                success = TRUE;

Don't know if you also need to set error to NULL or if g_error_free does that for you.

If run under --no-daemon you see the Glib error:

NetworkManager: <info>  Setting system hostname to 'test' (from DHCP)
NetworkManager: <WARN>  update_etc_hosts(): update_etc_hosts: couldn't read /etc/hosts: (4) Failed to open file '/etc/hosts': No such file or directory
(NetworkManager:3539): GLib-CRITICAL **: g_file_set_contents: assertion `error == NULL || *error == NULL' failed
NetworkManager: <WARN>  update_etc_hosts(): update_etc_hosts: couldn't update /etc/hosts: (4) Failed to open file '/etc/hosts': No such file or directory
NetworkManager: <info>  Setting system hostname to 'localhost.localdomain' (error updating/etc/hosts)
Comment 8 Dan Williams 2008-10-21 13:59:47 EDT
good catch, there probably isn't an /etc/hosts, thus the g_file_get_contents() call fails, and the fact that the error doesn't get reset causes the g_file_set_contents() to fail.

Fixed upstream in svn r4201.
Comment 10 David Cantrell 2008-10-24 22:18:10 EDT
*** Bug 468445 has been marked as a duplicate of this bug. ***
Comment 11 Fedora Update System 2008-11-23 18:04:49 EST
NetworkManager-0.7.0-0.12.svn4326.fc9,NetworkManager-vpnc-0.7.0-0.11.svn4326.fc9,NetworkManager-openvpn-0.7.0-16.svn4326.fc9,NetworkManager-pptp-0.7.0-0.12.svn4326.fc9 has been submitted as an update for Fedora 9.
http://admin.fedoraproject.org/updates/NetworkManager-0.7.0-0.12.svn4326.fc9,NetworkManager-vpnc-0.7.0-0.11.svn4326.fc9,NetworkManager-openvpn-0.7.0-16.svn4326.fc9,NetworkManager-pptp-0.7.0-0.12.svn4326.fc9
Comment 12 Fedora Update System 2008-11-23 18:07:49 EST
NetworkManager-0.7.0-0.12.svn4326.fc8,NetworkManager-vpnc-0.7.0-0.11.svn4326.fc8,NetworkManager-openvpn-0.7.0-16.svn4326.fc8,NetworkManager-pptp-0.7.0-0.12.svn4326.fc8 has been submitted as an update for Fedora 8.
http://admin.fedoraproject.org/updates/NetworkManager-0.7.0-0.12.svn4326.fc8,NetworkManager-vpnc-0.7.0-0.11.svn4326.fc8,NetworkManager-openvpn-0.7.0-16.svn4326.fc8,NetworkManager-pptp-0.7.0-0.12.svn4326.fc8
Comment 13 Fedora Update System 2008-12-21 18:37:22 EST
NetworkManager-0.7.0-0.12.svn4326.fc9, NetworkManager-vpnc-0.7.0-0.11.svn4326.fc9, NetworkManager-openvpn-0.7.0-16.svn4326.fc9, NetworkManager-pptp-0.7.0-0.12.svn4326.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 14 Fedora Update System 2008-12-21 18:43:02 EST
NetworkManager-0.7.0-0.12.svn4326.fc8, NetworkManager-vpnc-0.7.0-0.11.svn4326.fc8, NetworkManager-openvpn-0.7.0-16.svn4326.fc8, NetworkManager-pptp-0.7.0-0.12.svn4326.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.