Bug 506384

Summary: Anaconda does not add hostname to /etc/hosts file
Product: [Fedora] Fedora Reporter: Rohan Dhruva <rohandhruva>
Component: anacondaAssignee: Radek Vykydal <rvykydal>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: 11CC: amcnabb, anthony, clalance, jdorff, nstraz, ovasik, pknirsch, rmaximo, vanmeeuwen+fedora
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-12-22 09:39:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 513462, 531364    

Description Rohan Dhruva 2009-06-17 02:56:24 UTC
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):
11.5.0.59-1.fc11

How reproducible:
Always

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
  
Actual results:
The hosts file is like this -
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 

Expected results:
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

Additional info:
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.

Comment 1 Andy Lindeberg 2009-06-24 19:59:56 UTC
As per Bug #491808, anaconda no longer writes to /etc/hosts. Reassigning to setup.

Comment 2 Ondrej Vasik 2009-06-24 20:46:38 UTC
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...

Comment 3 Jeremy Katz 2009-06-25 00:11:10 UTC
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

Comment 4 David Cantrell 2009-06-30 21:24:36 UTC
Radek,

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.

Comment 5 Radek Vykydal 2009-07-07 14:23:03 UTC
This should be fixed in version 12.2 of anaconda.

Comment 6 Nate Straz 2009-10-19 22:07:32 UTC
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.

Comment 7 Chris Lalancette 2009-10-20 17:05:14 UTC
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.

Chris Lalancette

Comment 8 Andrew McNabb 2009-11-13 21:57:43 UTC
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.

Comment 9 Jimmy Dorff 2009-12-21 21:32:20 UTC
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.

Comment 10 Radek Vykydal 2009-12-22 09:39:31 UTC
For the record, the change was reverted in bug #530343 in rawhide/F13 (anaconda-13.8-1).

Comment 11 Rohan Dhruva 2009-12-22 12:59:45 UTC
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)?

Comment 12 Anthony Thyssen 2010-09-01 06:03:58 UTC
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????