Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 345401 - net-misc/networkmanager-0.8.2 breaks /etc/hosts
Summary: net-misc/networkmanager-0.8.2 breaks /etc/hosts
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal
Assignee: Robert Piasek (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-14 13:44 UTC by Marc Schiffbauer
Modified: 2012-04-16 09:13 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
backport 39eed50e470d6f41222e40ce0276b898e8c84dc4 to 0.8.2 (networkmanager-0.8.2-etchosts.patch,120.90 KB, patch)
2011-01-15 10:25 UTC, dynamotwain
Details | Diff
update ebuild to apply new patch. (networkmanager-0.8.2-r2-to-r3.patch,356 bytes, patch)
2011-01-15 10:25 UTC, dynamotwain
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Schiffbauer gentoo-dev 2010-11-14 13:44:45 UTC
Since version 0.8.2 net-misc/networkmanager modifies my /etc/hosts file and adds invalid lines to it which will break things because the system cannot determine its domainname anymore.

The line added by nm lacks the domain name which is provided by the DHCP server:

192.168.1.91    bart    # Added by NetworkManager

This line must look like the following in order to be valid:
192.168.1.91 bart.mydomain.net bart

But thats not all:
When NM removes that line when the interface goes down it will add two other bogus lines like that:
127.0.0.1       bart    localhost.localdomain   localhost
::1     bart    localhost6.localdomain6 localhost6

These two lines are invalid as well.

I first noticed that misbehavior because after boot my system welcomes me with "bart.unknown_domain" at the login prompt.
Comment 1 Marc Schiffbauer gentoo-dev 2010-11-14 13:45:21 UTC
bart ~ # emerge --info
Portage 2.2.0_alpha4 (default/linux/amd64/10.0/desktop, gcc-4.4.5, glibc-2.12.1-r3, 2.6.36-gentoo-r1 x86_64)
=================================================================
System uname: Linux-2.6.36-gentoo-r1-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T7300_@_2.00GHz-with-gentoo-2.0.1
Timestamp of tree: Sun, 14 Nov 2010 11:15:02 +0000
distcc 3.1 x86_64-pc-linux-gnu [enabled]
ccache version 2.4 [enabled]                                                                                                                                                            
app-shells/bash:     4.1_p9                                                                                                                                                             
dev-java/java-config: 2.1.11-r2                                                                                                                                                         
dev-lang/python:     2.6.6-r1, 3.1.2-r4                                                                                                                                                 
dev-util/ccache:     2.4-r8                                                                                                                                                             
dev-util/cmake:      2.8.1-r2                                                                                                                                                           
sys-apps/baselayout: 2.0.1-r1                                                                                                                                                           
sys-apps/openrc:     0.6.3                                                                                                                                                              
sys-apps/sandbox:    2.3-r1                                                                                                                                                             
sys-devel/autoconf:  2.13, 2.68                                                                                                                                                         
sys-devel/automake:  1.8.5-r4, 1.9.6-r3, 1.10.3, 1.11.1                                                                                                                                 
sys-devel/binutils:  2.20.1-r1                                                                                                                                                          
sys-devel/gcc:       4.4.5                                                                                                                                                              
sys-devel/gcc-config: 1.4.1                                                                                                                                                             
sys-devel/libtool:   2.4                                                                                                                                                                
sys-devel/make:      3.82                                                                                                                                                               
virtual/os-headers:  2.6.35 (sys-kernel/linux-headers)                                                                                                                                  
Repositories: gentoo vmware kde-sunset roslin enlightenment sunrise qting-edge kde stormfront mschiff-local mschiff                                                                     
ACCEPT_KEYWORDS="amd64 ~amd64"                                                                                                                                                          
ACCEPT_LICENSE="* -@EULA Q3AEULA PUEL dlj-1.1 skype-eula googleearth AdobeFlash-10 AdobeFlash-10.1"                                                                                     
CBUILD="x86_64-pc-linux-gnu"                                                                                                                                                            
CFLAGS="-march=core2 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/tomoyo/conf /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/eselect/postgresql /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo"
CXXFLAGS="-march=core2 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --load-average=3.0"
FEATURES="assume-digests binpkg-logs ccache distcc distlocks fixlafiles fixpackages metadata-transfer news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="de"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/vmware /var/lib/layman/kde-sunset /var/lib/layman/roslin /var/lib/layman/enlightenment /var/lib/layman/sunrise /var/lib/layman/qting-edge /var/lib/layman/kde /var/lib/layman/stormfront /usr/local/portage/local /home/mschiff/docs/Privat/SCM/gentoo/mentoring-mschiff/overlay"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X a52 aac aalib acl acpi adns akonadi alsa amd64 ao audiofile bacula-clientonly bacula-console bash-completion berkdb bluetooth branding bzip2 cairo caps cdda cddb cdr chm cli consolekit cracklib crypt css cups curl cxx dbus device-mapper dhclient disk-partition djvu dri dts dvd dvdr ebook emboss encode exif fam ffmpeg firefox flac fortran gdbm gif gimp glibc-omitfp gnome google-gadgets gpm gtk hal iconv id3tag ieee1394 ipod jpeg jpeg2k kde kipi l7filter lame laptop lcms ldap libnotify lm_sensors logrotate loop-aes lzma lzo mad mikmod mjpeg mmap mmx mmxext mng modules mp3 mp4 mpeg mudflap multilib musicbrainz mysql ncurses networkmanager nls nptl nptlonly nsplugin ntp ogg openexr opengl openmp pam pango pcmcia pcre pdf perl phonon png policykit postgres ppds pppd python qt3support qt4 readline rss samba sdl semantic-desktop session smapi smp sndfile spell sse sse2 ssl ssse3 startup-notification svg sysfs tcpd threads thumbnail tiff truetype unicode usb utempter vcd vim-syntax vnc vorbis webkit wifi x264 xattr xcb xcomposite xinerama xml xorg xscreensaver xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CAMERAS="canon" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse synaptics evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de" PHP_TARGETS="php5-2" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

bart ~ # 
Comment 2 hubertstar 2010-11-27 06:35:03 UTC
change /etc/hosts by yourself, then:

chattr +i /etc/hosts

now nm can't modify this file.

Comment 3 Robert Piasek (RETIRED) gentoo-dev 2010-12-14 09:51:06 UTC
NetworkManager modifies your hosts file based on information from dhcp server.

If you DHCP server provides only host name (without domain name), it will be written to your hosts file.
I suggest either fix DHCP configuration to publish domain name, or disable hostname publishing.

With 0.8.2, it's also parsing default gentoo configuration files (/etc/conf.d/net as well as /etc/conf.d/hostname). For more information how to set up your hostname, please follow:
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=8


Please let me know if that fixes your problem.

Alternatively, you can completely disable Gentoo plugin support, by editing:
/etc/NetworkManager/nm-system-settings.conf
and removing ifnet from plugin list.
Comment 4 Marc Schiffbauer gentoo-dev 2010-12-14 23:41:09 UTC
(In reply to comment #3)
> NetworkManager modifies your hosts file based on information from dhcp server.
> 
> If you DHCP server provides only host name (without domain name), it will be
> written to your hosts file.
> I suggest either fix DHCP configuration to publish domain name, or disable
> hostname publishing.

As I wrote first, my DHCP *does* provide a domain name. I just proved that using wireshark a minute ago (Option 15).
(http://www.networksorcery.com/enp/protocol/bootp/option015.htm)

> 
> With 0.8.2, it's also parsing default gentoo configuration files
> (/etc/conf.d/net as well as /etc/conf.d/hostname). For more information how to
> set up your hostname, please follow:
> http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=8

/etc/conf.d/hostname: is set to the correct normal hostname (no domain)
/etc/conf.d/net only contains comments


> 
> 
> Please let me know if that fixes your problem.

It does not, the hosts file is edited in a wrong way.

IMO if a domain cannot be determined (either by misconfigured dhcp or if non is set elsewhere) it should be set to something like "localdomain".


> 
> Alternatively, you can completely disable Gentoo plugin support, by editing:
> /etc/NetworkManager/nm-system-settings.conf
> and removing ifnet from plugin list.
> 

That would be the option if it would stay buggy. But generally I like the fact that it can do set the correct name in /etc/hosts
Comment 5 Mu Qiao (RETIRED) gentoo-dev 2010-12-15 01:28:15 UTC
(In reply to comment #0)
> Since version 0.8.2 net-misc/networkmanager modifies my /etc/hosts file and
> adds invalid lines to it which will break things because the system cannot
> determine its domainname anymore.
> 
> The line added by nm lacks the domain name which is provided by the DHCP
> server:
> 
> 192.168.1.91    bart    # Added by NetworkManager
> 
> This line must look like the following in order to be valid:
> 192.168.1.91 bart.mydomain.net bart
> 
> But thats not all:
> When NM removes that line when the interface goes down it will add two other
> bogus lines like that:
> 127.0.0.1       bart    localhost.localdomain   localhost
> ::1     bart    localhost6.localdomain6 localhost6
> 
> These two lines are invalid as well.
> 

It seems to be an upstream bug.
This one https://bugzilla.redhat.com/show_bug.cgi?id=648725 is probably corresponding to your problem.
Comment 6 dynamotwain 2011-01-15 10:23:54 UTC
This has been fixed upstream with the following GIT commit: http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=39eed50e470d6f41222e40ce0276b898e8c84dc4
Comment 7 dynamotwain 2011-01-15 10:25:19 UTC
Created attachment 259913 [details, diff]
backport 39eed50e470d6f41222e40ce0276b898e8c84dc4 to 0.8.2
Comment 8 dynamotwain 2011-01-15 10:25:57 UTC
Created attachment 259914 [details, diff]
update ebuild to apply new patch.
Comment 9 Mehmet Giritli 2011-03-09 21:36:45 UTC
(In reply to comment #3)
> NetworkManager modifies your hosts file based on information from dhcp server.

I configure my network manually, there is no dhcp server and NM still tries to manage my hosts file...What about that patch in the previous comment(s)? Is this going to be included into the portage? It solves my problem entirely...
Comment 10 Leho Kraav (:macmaN @lkraav) 2011-04-24 15:07:22 UTC
i have a static ip configured for eth0. i have applied the patch, but NetworkManager did not stop fricking with my /etc/hosts until i rewrote it from:

xxx.yyy.zzz.www    host.domain.com host

to:

xxx.yyy.zzz.www    host host.domain.com



otherwise i would get /etc/hosts like this with every NM restart:

127.0.0.1          host localhost.localdomain localhost
::1                host localhost6.localdomain localhost6

192.168.1.2        host.domain.com host

and things would obviously start breaking.

i'm still not understanding exactly what the "right way" is.
Comment 11 Leho Kraav (:macmaN @lkraav) 2011-04-27 07:45:26 UTC
i have since learned that arrangement is a bad idea. /etc/hosts format is to have canonical hostname first, otherwise gentoo has trouble figuring out your domain name. anyway, i've become annoyed enough with networkmanager to just uninstall it.
Comment 12 Pacho Ramos gentoo-dev 2012-04-06 15:15:31 UTC
Is this still valid with current latest stable versions?
Comment 13 Marc Schiffbauer gentoo-dev 2012-04-16 08:52:46 UTC
I just checked with NM 0.9.4.0 (disconnect / reconnect using DHCP) and it seems my /etc/hosts is not being scrambled anymore.

Though I do not have the time for excessive tests right now it *seems* to me that this is not a problem anymore.

AFAICS /etc/hosts is not changed by NM in *any* way anymore.

So I assume this bug can be closed.
Comment 14 Alexandre Rostovtsev (RETIRED) gentoo-dev 2012-04-16 09:13:38 UTC
(In reply to comment #13)
> So I assume this bug can be closed.

Closing then.