Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 176873 - net-misc/networkmanager changes hostname when connecting to wireless networks
Summary: net-misc/networkmanager changes hostname when connecting to wireless networks
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Steev Klimaszewski (RETIRED)
URL:
Whiteboard:
Keywords: InVCS
: 184905 214634 259634 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-03 02:50 UTC by M Cordingley
Modified: 2011-01-27 15:04 UTC (History)
14 users (show)

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


Attachments
make.conf (make.conf,603 bytes, text/plain)
2007-05-03 02:51 UTC, M Cordingley
Details
worldfile (world,453 bytes, text/plain)
2007-05-03 02:52 UTC, M Cordingley
Details
package.keywords (package.keywords,77 bytes, text/plain)
2007-05-03 02:53 UTC, M Cordingley
Details
emerge --info (info,3.00 KB, text/plain)
2007-05-03 02:53 UTC, M Cordingley
Details
This patch fixes the problem for me (networkmanager-hostname.patch,888 bytes, patch)
2007-07-11 16:46 UTC, Daniele Tamino
Details | Diff
fixed read-hostname-patch for net-misc/networkmanager-0.8-r1 (networkmanager-0.8-read-hostname.patch,4.02 KB, patch)
2011-01-27 15:00 UTC, Tanyel A. Nimeu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description M Cordingley 2007-05-03 02:50:44 UTC
NetworkManager will change my system's hostname whenever I use it to successfully connect to a wireless network.  It does not change it when I use NetworkManager to connect to a wired network.  This change of hostname breaks X.  e.g.

Battle for Wesnoth v1.2.4
Started on Wed May  2 22:24:04 2007

started game: 1338004991
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

error display: Could not initialize SDL: No available video device
Could not initialize video. Exiting.

until such time as I manually change my hostname back to what it originally was.  When I do that, the wireless connection continues to function properly.  The wired and wireless connections both use dhcp.

Reproducible: Always

Steps to Reproduce:
0.Open a terminal (so it's still open after the X breakage)
1.Select a wireless network via NetworkManager.
2.Wait for connection to complete.
3.Open a new tab in the terminal to verify the name change.

Actual Results:  
My hostname changed from what I had set, eddard, to something along the lines of dhcp392.

Expected Results:  
Brought up the wireless network while keeping my hostname intact.
Comment 1 M Cordingley 2007-05-03 02:51:36 UTC
Created attachment 118007 [details]
make.conf
Comment 2 M Cordingley 2007-05-03 02:52:21 UTC
Created attachment 118008 [details]
worldfile
Comment 3 M Cordingley 2007-05-03 02:53:02 UTC
Created attachment 118009 [details]
package.keywords
Comment 4 M Cordingley 2007-05-03 02:53:57 UTC
Created attachment 118011 [details]
emerge --info
Comment 5 Steev Klimaszewski (RETIRED) gentoo-dev 2007-05-03 15:35:01 UTC
From the 0.6.5 ebuild...

        elog "Problems with your hostname getting changed?"
        elog ""
        elog "Add the following to /etc/dhcp/dhclient.conf"
        elog 'send host-name "YOURHOSTNAME";'
        elog 'supersede host-name "YOURHOSTNAME";'


Comment 6 Ulrich Dobramysl 2007-05-25 08:41:03 UTC
I have a connected Problem:

I don't use dhcp for my wired interface (eth0) but a static ip when I'm in the office, so dhclient never gets called and the setting in dhclient.conf is not used. The Gentoo backend of NetworkManager from the networkmanager-updatedbackend patch thus makes a reverse dns lookup and sets the hostname to whatever it gets.

At home when I use my wlan interface with dhclient everything works as expected.

IMHO networkmanager should not try to set the hostname. It breaks X and Gnome sessions for users mobile laptop users.
Comment 7 Steev Klimaszewski (RETIRED) gentoo-dev 2007-05-25 14:00:00 UTC
Patches accepted...  proper static IP support is planned for 0.7
Comment 8 Jakub Moc (RETIRED) gentoo-dev 2007-07-11 07:00:09 UTC
*** Bug 184905 has been marked as a duplicate of this bug. ***
Comment 9 Daniele Tamino 2007-07-11 16:46:43 UTC
Created attachment 124584 [details, diff]
This patch fixes the problem for me

Copied from duplicate bug #184905 (sorry, and I did search for it ... 8^):

It's just that in NetworkManagerGentoo.c, the variable sys_data->config is
initialized after being used, or not initialized at all, so reading the
hostname from the config file and putting it into the config hash table fails.
This patch seems to fix it, i.e., the hostname in /etc/conf.d/hostname is loaded and used properly.
Comment 10 Daniele Tamino 2007-07-11 19:48:04 UTC
(In reply to comment #9)
> This patch seems to fix it, i.e., the hostname in /etc/conf.d/hostname is
> loaded and used properly.
Ok, sorry, it doesn't really fix it ... it fixes a null pointer bug though, but the hostname is still set to something else when the device is activated.
I'll use the dhclient.conf workaround in the meantime.
Comment 11 dongxu li 2007-12-28 01:25:16 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > This patch seems to fix it, i.e., the hostname in /etc/conf.d/hostname is
> > loaded and used properly.
> Ok, sorry, it doesn't really fix it ... it fixes a null pointer bug though, but
> the hostname is still set to something else when the device is activated.
> I'll use the dhclient.conf workaround in the meantime.
> 

it still changes hostname for me (0.6.5_p20070823).

it's unpleasant because this hostname change feature (a bug for me though) is enabled by gentoo patch (networkmanager-updatedbackend.patch). I will drop the patch for the time being

hope 0.7 will work it out.

BTW, I never understand dhclient.conf enough to play with hostname tricks, "dhcpcd -h" is easy.

Comment 12 dongxu li 2007-12-28 01:26:54 UTC
can someone reopen this bug?

leaving it "resolved" leaves it out of the default search.

or, we should submit another bug report?
Comment 13 Steev Klimaszewski (RETIRED) gentoo-dev 2007-12-28 01:31:39 UTC
The instructions for dhclient.conf are in the output of emerging NetworkManager - there is an elog entry for how to do it.  If you can't follow those, I really can't help you
Comment 14 Andy Baker 2009-01-05 22:49:54 UTC
(In reply to comment #13)
> The instructions for dhclient.conf are in the output of emerging NetworkManager
> - there is an elog entry for how to do it.  If you can't follow those, I really
> can't help you
> 

I would request that this bug is reopened. The default is not sensible for users with Wifi and the workaround is only that since it involves duplicating the hostname unless the dhclient config file is updated on startup when the hostname init script is run.

I use NetworkManager so that I may connect to various wireless networks, on a laptop, as a normal user and not have to do some funky stuff with sudo. Altering the hostname is not sensible as a default, although it would be appropriate as an option. 
Comment 15 Jouni Rinne 2009-02-14 08:08:54 UTC
(In reply to comment #14) 
> 
> I would request that this bug is reopened. The default is not sensible for
> users with Wifi and the workaround is only that since it involves duplicating
> the hostname unless the dhclient config file is updated on startup when the
> hostname init script is run.
> 

I agree. I had originally set my laptop's hostname in both /etc/conf.d/hostname and /etc/dhcp/dhclient.conf. Later I had the bright idea of changing the hostname, and set the hostname file appropriately, and was dumbfounded when the machine still stubbornly used the old hostname. I had totally forgotten about the dhclient.conf file. It took me several days to figure out what was wrong...

There should be an option to sync the /etc/dhcp/dhclient.conf file with /etc/conf.d/hostname, when the latter is changed.
Comment 16 Ioannis Aslanidis (RETIRED) gentoo-dev 2009-07-10 18:39:46 UTC
This does not work for GSM (Mobile Broadband) networks. I have set 
 * /etc/hosts
 * /etc/dhcp/dhclient.conf
 * /etc/dhcpcd.conf

and it is chaing my hostname and my dnsdomainname to localhost.localdomain using 0.7.1-r6
Comment 17 Skye 2009-08-07 20:19:53 UTC
(In reply to comment #14)
> The default is not sensible for
> users with Wifi and the workaround is only that since it involves duplicating
> the hostname unless the dhclient config file is updated on startup when the
> hostname init script is run.
> 
> I use NetworkManager so that I may connect to various wireless networks, on a
> laptop, as a normal user and not have to do some funky stuff with sudo.
> Altering the hostname is not sensible as a default, although it would be
> appropriate as an option. 
> 

I agree. The default should be a behavior that won't break X.
Comment 18 Federico Ferri (RETIRED) gentoo-dev 2009-11-14 16:13:02 UTC
I have 0.7.1-r6, and the issue is slightly different:

hostname gets changed as soon as /etc/init.d/NetworkManager starts, as in gdm greeter I already see hostname being "localhost.localdomain", while it should be what I set in /etc/conf.d/hostname
Comment 19 Alejandro Diaz Caro 2009-11-27 14:22:27 UTC
(In reply to comment #18)
> I have 0.7.1-r6, and the issue is slightly different:
> 
> hostname gets changed as soon as /etc/init.d/NetworkManager starts, as in gdm
> greeter I already see hostname being "localhost.localdomain", while it should
> be what I set in /etc/conf.d/hostname
> 

Same behaviour here.

katu ~ # cat /etc/dhcp/dhclient.conf
send host-name "katu";
supersede host-name "katu";

katu ~ # cat /etc/hosts
127.0.0.1       katu.imag.fr    localhost.localdomain   localhost
127.0.1.1       katu

katu ~ # cat /etc/conf.d/hostname
# /etc/conf.d/hostname

# Set to the hostname of this machine
HOSTNAME="katu"

However, when I starts the machine
Comment 20 Alejandro Diaz Caro 2009-11-27 14:23:10 UTC
> However, when I starts the machine
I get localhost.localdomain 

Comment 21 Janusz 2010-01-08 22:23:55 UTC
The same here. I'm using networkmanager 0.7.2 for broadband connection, and even though I got:

cat /etc/NetworkManager/nm-system-settings.conf
[main]
plugins=keyfile

[keyfile]
hostname = o0o0o

...after successfull broadband connection I get:

public-gprs107914 ~ #

This results in broken X sesssion!
Comment 22 Nirbheek Chauhan (RETIRED) gentoo-dev 2010-01-25 06:32:25 UTC
A hackish fix for this has been committed to tree with 0.7.999 (p.masked)
Comment 23 Pacho Ramos gentoo-dev 2010-02-22 19:14:55 UTC
*** Bug 214634 has been marked as a duplicate of this bug. ***
Comment 24 Nirbheek Chauhan (RETIRED) gentoo-dev 2010-02-28 06:57:55 UTC
0.8 has been released with the patch, and is in ~arch. Closing FIXED.
Comment 25 Nirbheek Chauhan (RETIRED) gentoo-dev 2010-02-28 06:59:03 UTC
*** Bug 259634 has been marked as a duplicate of this bug. ***
Comment 26 Tanyel A. Nimeu 2011-01-27 15:00:13 UTC
Created attachment 260873 [details, diff]
fixed read-hostname-patch for net-misc/networkmanager-0.8-r1

This is a fixed patch for current stable net-misc/networkmanager-0.8-r1
It uses the correct variable "HOSTNAME" instead of "hostname" read from /etc/conf.d/hostname

Moreover it fixes build errors when compiling without TARGET_GENTOO caused by misplaced #ifdef's.
Comment 27 Tanyel A. Nimeu 2011-01-27 15:04:29 UTC
(In reply to comment #26)
forgot to mention:
I additionally added a file-monitor for /etc/conf.d/hostname, so changes to it get honored immediately