Package: network-manager
Version: 0.9.2.0-1
Severity: important
Tags: patch
NetworkManager keeps changing my hostname when I connect to a wireless
network. I'm a bit puzzled why NetworkManager gives a higher priority
to the name that a dhcp server on a random wireless network returns
than the hostname configured by the user in /etc/hostname. In my
opinion NetworkManager shouldn't overrule configuration done by the
user and in Debian the hostname is already set by
/etc/init.d/hostname.sh. It causes a lot of trouble, from annoying
change of your shell prompts to errors because your hostname isn't
resolvable.
The attached patch changes the order of preference, so that an already
set hostname takes precedence over a hostname from DHCP.
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (150, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.1.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages network-manager depends on:
ii adduser 3.113
ii dbus 1.4.16-1
ii isc-dhcp-client 4.1.1-P1-17
ii libc6 2.13-21
ii libdbus-1-3 1.4.16-1
ii libdbus-glib-1-2 0.98-1
ii libgcrypt11 1.5.0-3
ii libglib2.0-0 2.30.2-4
ii libgnutls26 2.12.14-3
ii libgudev-1.0-0 175-2
ii libnl1 1.1-7
ii libnm-glib4 0.9.2.0-1
ii libnm-util2 0.9.2.0-1
ii libpolkit-gobject-1-0 0.102-2
ii libuuid1 2.19.1-5
ii lsb-base 3.2-28
ii udev 175-2
ii wpasupplicant 0.7.3-5
Versions of packages network-manager recommends:
ii dnsmasq-base 2.59-2
ii iptables 1.4.12-1
ii modemmanager 0.5-1
ii policykit-1 0.102-2
ii ppp 2.4.5-5
Versions of packages network-manager suggests:
ii avahi-autoipd 0.6.30-5
-- Configuration Files:
/etc/NetworkManager/nm-system-settings.conf changed [not included]
(Only contents is the MAC address of the wired interface)
-- no debconf information
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -307,8 +307,8 @@
/* Hostname precedence order:
*
* 1) a configured hostname (from settings)
- * 2) automatic hostname from the default device's config (DHCP, VPN, etc)
- * 3) the original hostname when NM started
+ * 2) the original hostname when NM started
+ * 3) automatic hostname from the default device's config (DHCP, VPN, etc)
* 4) reverse-DNS of the best device's IPv4 address
*
*/
@@ -321,6 +321,13 @@
return;
}
+ /* Try using the hostname from when NM started up.
+ */
+ if (policy->orig_hostname) {
+ _set_hostname (policy, policy->orig_hostname, "from system startup");
+ return;
+ }
+
/* Try automatically determined hostname from the best device's IP config */
if (!best4)
best4 = get_best_ip4_device (policy->manager, &best_req4);
@@ -375,14 +382,6 @@
}
}
- /* If no automatically-configured hostname, try using the hostname from
- * when NM started up.
- */
- if (policy->orig_hostname) {
- _set_hostname (policy, policy->orig_hostname, "from system startup");
- return;
- }
-
/* No configured hostname, no automatically determined hostname, and no
* bootup hostname. Start reverse DNS of the current IPv4 or IPv6 address.
*/