Red Hat Bugzilla – Bug 506384
Anaconda does not add hostname to /etc/hosts file
Last modified: 2016-04-26 09:58:22 EDT
Description of problem:
I installed Fedora 11 using the i386 DVD. During the install process anaconda asks for the hostname of the system. I changed the default "localhost.localdomain" to "fedora". After rebooting into the installed system, I noticed that the /etc/hosts file still has the "localhost.localdomain" entries only - "fedora", i.e. the hostname I selected, is not added.
This causes a variety of problems, like sudo taking 20s to startup.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Start setup
2. Change the default (localhost.localdomain) hostname to something else
3. In in the installed system, check /etc/hosts
The hosts file is like this -
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Anaconda should have added entries for my selected hostname, thus making the file -
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 fedora
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 fedora
The problem can be easily solved by adding the hostname to the end of both the lines. This also solves the 20s startup delay problem of sudo.
As per Bug #491808, anaconda no longer writes to /etc/hosts. Reassigning to setup.
But... setup just provides default /etc/hosts file, it could be easily edited later (not created/modified in early phases as was done in #491808) by anaconda. Anaconda already edits many files owned by setup without troubles, so I don't see /etc/hosts as something special.
This bugzilla can't be handled by setup (as there is nothing known about hostname at the time of setup installation), only place is anaconda, reassigning back. I know it's some kind of ping-pong game, but I can't do anything with that bugzilla...
We write out the /etc/hosts file before packages are installed so that it can be present and used (with the rest of networking config) when we set up the initrd for things like root-on-iscsi
We should be adding the hostname provided by the user to the 127.0.0.1 and ::1 lines in /etc/hosts. The write() method in class Network in network.py is where this should happen.
This should be fixed in version 12.2 of anaconda.
Adding the hostname to the localhost line breaks things like openais and corosync. This was originally fixed for RHEL5 in 210050 and will be a problem for RHEL6 also.
Yes, this is also breaking libvirt (see https://bugzilla.redhat.com/show_bug.cgi?id=529898). In a properly working setup, the FQDN should not be aliased to 127.0.0.1; it just doesn't make any sense.
This patch should be reverted and something else put in it's place, since it's the wrong solution.
Any clients that get network information from DHCP will have problems if the hostname is automatically added to /etc/hosts. Additionally, "hostname -f" returns "localhost" if only the short hostname is added to /etc/hosts. Adding hostnames to /etc/hosts really does break things.
Seeing the hostname added to localhost on Fedora 12 and that is causing some issues. I'm installing systems via kickstart and using "network --bootproto dhcp" in the kickstart file.
For the record, the change was reverted in bug #530343 in rawhide/F13 (anaconda-13.8-1).
I am sorry but I got lost in the last few comments. How is the issue resolved? What happens if at install, I choose a different hostname and not "localhost"? Will I still experience the same errors as mentioned in the original report (sudo taking time, gdm taking time)?
I have a fedora 12 system, fully patched...
Every time it reboots it adds the system hostname to /etc/hosts for the 127.0.0.1 entry. This in turn screws up sendmail so it can never recieve mail!!!
how was the issue resolves as NOTHING should ever modify the etc/host file????