Summary: | net-misc/networkmanager-0.7.0 alters /etc/hosts and changes hostname | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Daniel Klaffenbach <danielklaffenbach> |
Component: | Current packages | Assignee: | Robert Piasek (RETIRED) <dagger> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | hwoarang, mescalinum, mironov.ivan, pacho, rsalveti, steev, timmy, tobias, wpoely86, zephyrus.271 |
Priority: | High | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
Patch that fixes the bug
patch that reads hostname from /etc/conf.d/hostname if no connection is avaible instead of using localhost.localdomain. |
Description
Daniel Klaffenbach
2009-02-19 20:29:02 UTC
You should not remove the localhost line in /etc/hosts, only add additional ones. localhost lookup to 127.0.0.1 is important for system funnctionality. (In reply to comment #1) > You should not remove the localhost line in /etc/hosts, only add additional > ones. localhost lookup to 127.0.0.1 is important for system funnctionality. I know. I also left localhost in the line. It should read: 127.0.0.1 frodo.home.local frodo localhost But NM keeps changing that. Same issue here. Any idea to solve it? luigi Well it's not a bug, but a design decision. NetworkManager takes total ownership over your networking. If you're not using DHCP you should define system-wide connection with static IP address. That way your IP and hostname will always be preserved. Also you shouldn't add your host alias to 127.0.0.1, but to default IP address. (In reply to comment #4) > Also you shouldn't add your host alias to 127.0.0.1, but to default IP address. But what if there is no default IP address? I only use DHCP. My IP address keeps changing all the time. Assigning an alias for 127.0.0.1 is a pretty normal thing. And the fact that NM touches /etc/hosts (even if it is set to read-only) is not a good thing. There is a patch to let Networkmanager read /etc/hostname from ubuntu: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/276253 That would fix the issue. Created attachment 193285 [details, diff]
Patch that fixes the bug
Hi, I've created a patch that removes all code related to changing the hostname and altering /etc/hosts. Tested and works fine.
Removing the hostname-changing behaviour from NetworkManager is the only correct fix, as it is simply stupid and horribly broken (breaks X sessions, overrides system-configured hostname with meaningless one).
Removing the code is NOT a proper solution. Currently NetworkManager doesn't support native Gentoo configuration, so we're using "default" keyfile plugin. There are two ways to fix the issue: 1) since we're using keyfile plugin, we need to define hostname in keyfile plugin: add 'hostname' in a [keyfile] section in /etc/NetworkManager/nm-system-settings.conf [main] plugins=keyfile [keyfile] hostname=my.persistent.hostname 2) write Gentoo plugin, which will handle gentoo configuration I start working on (2), but it might take a while before I produce something worth commitng to NM base code. Robert: I do not understand why you think removing the code is not correct. It is known that changing the hostname breaks X which is totally unacceptable. Obviously the solution is to simply NOT change the hostname. You on the other hand are trying to ensure it gets "changed" to its original value. Why? Even if it wouldn't break X and probably more apps, why would anybody really want to have the hostname assigned dynamically? Also, the keyfile solution doesn't work. Take a look at the code - if there is no network connection, the hostname will ALWAYS be changed to "localhost.localdomain", no matter the config. This is also broken. Suppose a user boots his laptop with no network connection, so the X session starts up when the hostname was "localhost.localdomain". Then the user plugs the network cable in, and suddely all apps fail to start because the hostname changes to the correct value. (In reply to comment #9) > Robert: > I do not understand why you think removing the code is not correct. It is known > that changing the hostname breaks X which is totally unacceptable. Obviously > the solution is to simply NOT change the hostname. Changing the hostname is intended behaviour according to RFC 2132, section 3.14. Do not claim what it is in any way not correct. If you do not want the hostname to be changed, your DHCP server should not assign a host name. Alternatively, you can choose to ignore the value locally which is what this bug is about. Assigning a hostname via DHCP makes as much sense as assigning an IP address, domain name or NTP server and is what DHCP is there for. (In reply to comment #10) > Do not claim what it is in any way not correct. Read: Do not claim what is and is not correct. The simple idea with localhost.localdomain is, that NM checks for hostname (nm-system-settings). nm-system-settings checks which plugins are enabled and based on that assigns proper hostname based on your distro configuration. If hostname is not defined - it will automatically assign localhost.localdomain. The problem with Gentoo is, that we don't have native plugin which would be able to parse our configs, hence it can't recognise your hostname. It will automatically determinate it, once the connection is established, but that on the other hand breaks X. For now you can try the solution mentioned above. (In reply to comment #8) > 2) write Gentoo plugin, which will handle gentoo configuration > > > I start working on (2), but it might take a while before I produce something > worth commitng to NM base code. Can we help in anyway with that? Ward (In reply to comment #13) > (In reply to comment #8) > > > 2) write Gentoo plugin, which will handle gentoo configuration > > > > > > I start working on (2), but it might take a while before I produce something > > worth commitng to NM base code. > > Can we help in anyway with that? Yeah, how is the state of your current Gentoo plugin? If it's not ready, how can we help with that? This bug is quite annoying. Thanks, Ricardo Hey, (In reply to comment #14) > > Yeah, how is the state of your current Gentoo plugin? If it's not ready, how > can we help with that? > The status is nowhere near complete I'm afraid. I've been busy with other stuff recently, so I didn't have time to work on it. If you want to help you might want to have a look on other plugins (fedora, suse, debian) and write a base we can build on. Your programming stills are far superior comparing to mine (it's an assumption based on your email address :)) Rob Created attachment 203809 [details]
patch that reads hostname from /etc/conf.d/hostname if no connection is avaible instead of using localhost.localdomain.
It's the same thing the ubuntu folks did on theyr Networkmanager.
Comment on attachment 203809 [details]
patch that reads hostname from /etc/conf.d/hostname if no connection is avaible instead of using localhost.localdomain.
An 127.0.0.1 alias to localhost is still in the /etc/hosts. And sry about my C-code, maybe some can parse the /etc/conf.d/hostname claenly and get the hostname out of it. It's exactly the same thing, the ubuntu folks did.
Isn't this a dupe of bug 176873 ? Fixed in 0.8 (altering of /etc/hosts is WONTFIX) *** This bug has been marked as a duplicate of bug 176873 *** |