Bug 605338

Summary: nm doesn't restore entry in /etc/hosts
Product: [Fedora] Fedora Reporter: Fabrice Bellet <fabrice>
Component: NetworkManagerAssignee: Dan Williams <dcbw>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: dcbw
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: NetworkManager-0.8.1-4.git20100817.fc13 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-06-27 18:28:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Description Flags
drop the short old hostname from local mapping none

Description Fabrice Bellet 2010-06-17 16:46:59 UTC
I noticed the following problem with NetworkManager-0.8.1-0.1.git20100510.fc13.x86_64 :

I start nm with hostname = localhost.localdomain, and with /etc/hosts containing " localhost.localdomain localhost", I connect to a network, nm changes the entry like that " <fqdn> localhost.localdomain localhost". When I disconnect from this network, nm doesn't remove <fqdn> from /etc/hosts.

nm_policy_get_etc_hosts() is called with hostname="localhost.localdomain", the statement (found_localhost && found_host) is evaluated to true, so the function returns without building a new /etc/hosts file.

Comment 1 Dan Williams 2010-06-28 19:46:29 UTC
I've reworked the code significantly for another issue (bgo #619931) in master but that's not going to hit 0.8.1.  I guess we can try to fix that in 0.8.1 separately.

Comment 2 Fedora Update System 2010-08-17 17:10:54 UTC
NetworkManager-0.8.1-4.git20100817.fc12 has been submitted as an update for Fedora 12.

Comment 3 Fedora Update System 2010-08-17 17:12:39 UTC
NetworkManager-0.8.1-4.git20100817.fc13 has been submitted as an update for Fedora 13.

Comment 4 Fedora Update System 2010-08-17 17:14:31 UTC
NetworkManager-0.8.1-4.git20100817.fc14 has been submitted as an update for Fedora 14.

Comment 5 Fedora Update System 2010-08-19 20:33:03 UTC
NetworkManager-0.8.1-5.git20100818.fc14 has been submitted as an update for Fedora 14.

Comment 6 Fedora Update System 2010-08-20 02:14:11 UTC
NetworkManager-0.8.1-4.git20100817.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update NetworkManager'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/NetworkManager-0.8.1-4.git20100817.fc13

Comment 7 Fedora Update System 2010-08-23 22:05:35 UTC
NetworkManager-0.8.1-4.git20100817.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2010-08-24 01:20:41 UTC
NetworkManager-0.8.1-5.git20100818.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2010-09-01 01:26:25 UTC
NetworkManager-0.8.1-6.git20100831.fc13 has been submitted as an update for Fedora 13.

Comment 10 Fedora Update System 2010-09-01 01:43:25 UTC
NetworkManager-0.8.1-6.git20100831.fc12 has been submitted as an update for Fedora 12.

Comment 11 Fedora Update System 2010-09-26 04:35:02 UTC
NetworkManager-0.8.1-6.git20100831.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 12 Fabrice Bellet 2010-12-17 14:46:17 UTC
I reopen this bug, as it appears that there's still a problem in the sense that /etc/hosts is not restored when the wired interface is unplugged, and when the hostname is restored back to localhost.localdomain.

/etc/hosts remains unchanged :

# Do not remove the following line, or various programs
# that require network functionality will fail.	bonobo.example.com	bonobo	# Added by NetworkManager	localhost.localdomain	localhost
::1	bonobo.example.com	bonobo	localhost6.localdomain6	localhost6

Comment 13 Dan Williams 2010-12-19 18:17:03 UTC
Note that we've removed all code touching /etc/hosts from NM upstream.  I believe the issue you're experiencing here was already fixed by:


Which all should be present in NetworkManager-0.8.1-9.git20100831.fc12 and later.  What version do you have installed?

Comment 14 Fabrice Bellet 2010-12-20 09:04:38 UTC
Hi Dan,

yes, I'm running this version with the three patches included. I see two issues in the current code:

 - the short hostname added to the loopback entry with patch bbf3f12d7b2c79c49d87d41e6cf7b65ac7782071 should be removed when hostname comes back to localhost.localdomain, with a mechanism just like old_hostname. Else, it becomes part of the variable custom6, and remains in the loopback entry.

 - with the /etc/hosts from comment #12, when nm_policy_get_etc_hosts() is called with hostname="localhost.localdomain" and old_hostname="bonobo.example.com", all conditions found_localhost4, found_host4, found_localhost6, found_host6, host4_before, host6_before, no_stale are set to true, and /etc/hosts is not modified. I think that when evaluating the ::1 line, the found_localhost6 should be set conditionally if this line doesn't contain the old_hostname to be removed, ditto for found_localhost4

patch follows.

Comment 15 Fabrice Bellet 2010-12-20 09:07:33 UTC
Created attachment 469702 [details]
drop the short old hostname from local mapping

this patch passes the ./test-policy-hosts tests

Comment 16 Bug Zapper 2011-06-02 10:27:22 UTC
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '13'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 

Comment 17 Bug Zapper 2011-06-27 18:28:27 UTC
Fedora 13 changed to end-of-life (EOL) status on 2011-06-25. Fedora 13 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.