Bug 506384 - Anaconda does not add hostname to /etc/hosts file
Anaconda does not add hostname to /etc/hosts file
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: anaconda (Show other bugs)
11
All Linux
low Severity high
: ---
: ---
Assigned To: Radek Vykydal
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 513462 531364
  Show dependency treegraph
 
Reported: 2009-06-16 22:56 EDT by Rohan Dhruva
Modified: 2016-04-26 09:58 EDT (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-12-22 04:39:31 EST
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 Rohan Dhruva 2009-06-16 22:56:24 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):
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 15:59:56 EDT
As per Bug #491808, anaconda no longer writes to /etc/hosts. Reassigning to setup.
Comment 2 Ondrej Vasik 2009-06-24 16:46:38 EDT
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-24 20:11:10 EDT
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 17:24:36 EDT
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 10:23:03 EDT
This should be fixed in version 12.2 of anaconda.
Comment 6 Nate Straz 2009-10-19 18:07:32 EDT
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 13:05:14 EDT
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 16:57:43 EST
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 16:32:20 EST
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 04:39:31 EST
For the record, the change was reverted in bug #530343 in rawhide/F13 (anaconda-13.8-1).
Comment 11 Rohan Dhruva 2009-12-22 07:59:45 EST
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 02:03:58 EDT
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????

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