Package: isc-dhcp-client
Version: 4.2.2-1
Followup-For: Bug #643771

Hello,

According to the Debian reference, the host name (as set by /etc/hostname) 
should be non-fqdn, i.e. a simple host name without domain name.

DHCP may contain pretty random host/domain names, and changing the host name on 
the machine might trigger a denial of service as services (including X) can't 
connect or spawn new processes anymore when a new DHCP packet arrives and the 
host name is changed while those services are already running.

Attached you find a simple patch that strips the domain name part of 
$new_host_name in /etc/dhclient-script to bring it in line with the Debian 
reference and user expectations. I'm not going to elaborate on the benefits and 
drawbacks of using the DHCP host name field; there are probably valid reasons 
either way and I'm not qualified enough to discuss or acknowledge all possible 
network configurations.


Regards,

  Wouter

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.39-2-686-pae (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=nl_BE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages isc-dhcp-client depends on:
ii  debianutils      4.0.4     
ii  iproute          20110629-1
ii  isc-dhcp-common  4.2.2-1   
ii  libc6            2.13-21   

isc-dhcp-client recommends no packages.

Versions of packages isc-dhcp-client suggests:
pn  avahi-autoipd  <none>
pn  resolvconf     <none>

-- no debconf information
--- /sbin/dhclient-script	2011-09-27 09:58:38.000000000 +0300
+++ ./dhclient-script	2011-10-10 14:06:58.289195825 +0300
@@ -86,16 +86,18 @@
 # set host name
 set_hostname() {
     local current_hostname
+    local new_host_name_no_fqdn
 
     if [ -n "$new_host_name" ]; then
         current_hostname=$(hostname)
+        new_host_name_no_fqdn="${new_host_name%%.*}"
 
         # current host name is empty, '(none)' or 'localhost' or differs from new one from DHCP
         if [ -z "$current_hostname" ] ||
            [ "$current_hostname" = '(none)' ] ||
            [ "$current_hostname" = 'localhost' ] ||
-           [ "$new_host_name" != "$current_hostname" ]; then
-            hostname "$new_host_name"
+           [ "$new_host_name_no_fqdn" != "$current_hostname" ]; then
+            hostname "$new_host_name_no_fqdn"
         fi
     fi
 }

Reply via email to