Package: isc-dhcp-client
Version: 4.1.1-P1-15+squeeze2
Severity: normal
Tags: patch

The logic in Debian's dhclient-script as when to set hostname to the DHCP 
supplied new_host_name seems completly broken. It uses an now unset variable 
``host_name''; since that will always be empty, the test always fails and the 
hostname ist never set.

The idea behind the test in the upstream original dhclient-script seems to be
-- if the current hostname is different from what the last invocation of DHCP 
gave, it was probably set by the user, so leave it alone.
-- otherwise, if the hostname obtained by DHCP this time is the same as it was 
last time, there's no need to change is, so leave it alone.
-- else, set the hostname to what DHCP supplied.

The attached patch implements this logic (or so I hope).

-- System Information:
Debian Release: 6.0.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.38.2.wap (SMP w/1 CPU core)
Locale: LANG=de_DE@euro, LC_CTYPE=de_DE@euro (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/dash

Versions of packages isc-dhcp-client depends on:
ii  debianutils         3.4                  Miscellaneous utilities specific t
ii  iproute             20100519-3           networking and traffic control too
ii  isc-dhcp-common     4.1.1-P1-15+squeeze2 common files used by all the isc-d
ii  libc6               2.11.2-10            Embedded GNU C Library: Shared lib

isc-dhcp-client recommends no packages.

Versions of packages isc-dhcp-client suggests:
pn  avahi-autoipd                 <none>     (no description available)
pn  resolvconf                    <none>     (no description available)

-- no debconf information
Index: files/usr/local/sbin/dhclient-script/DHCPC
===================================================================
--- files/usr/local/sbin/dhclient-script/DHCPC	(revision 2131)
+++ files/usr/local/sbin/dhclient-script/DHCPC	(revision 2132)
@@ -152,8 +152,16 @@
         ;;
     BOUND|RENEW|REBIND|REBOOT)
 
-	if [ -n "$old_host_name" -a -n "$host_name" -a \
-     	     "$host_name" != "$old_host_name" ]; then
+	host_name=$(hostname)
+	# Linux uses '(none)' for an unassigned hostname
+	# Debian /etc/init.d/hostname.sh sets it to 'localhost'
+	# Treat both as unassigned, e.g. empty
+	if [ "$host_name" = "(none)" -o "$host_name" = "localhost" ]; then
+		host_name=""
+	fi
+	# set the hostname only if the current one is either empty
+	#  or is the one DHCP gave us last time and now it has changed.
+	if [ -z "$host_name" -o \( "$host_name" = "$old_host_name" -a "$new_host_name" != "$old_host_name" \) ]; then
     	    hostname "$new_host_name"
 	fi
 

Reply via email to