Your message dated Sat, 18 Feb 2012 15:36:11 +0100
with message-id <[email protected]>
and subject line Re: Bug#609851: summary
has caused the Debian Bug report #609851,
regarding incorrect variables used to set hostname in dhclient-script
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
609851: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=609851
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: isc-dhcp-client
Version: 4.1.1-P1-15

The logic to set the hostname on boot when that hostname is supplied via
dhcp is not working.  Looking at the code in dhclient-script, it appears
flawed.  Testing reveals unexpected content in the variables.

My environment: the dhcp server is sending 'option host-name' to send the
hostname to the client.  Examining /var/lib/dhcp/dhclient.eth0.leases shows
that the hostname is present.  The same environment successfully hands out a
hostname when the system is booted with Lenny; it fails when the system is
booted with Squeeze.  Note that I removed /etc/hostname to force it to get
the hostname from dhcp.  The hostname is being handed out by a system
running Debian Etch and dhcp3-server 3.0.4-13+etch2

The code that sets the hostname on lenny is as follows:

/sbin/dhclient-script from dhcp3-client version 3.1.1-6+lenny4, lines 102 to
107
set_hostname() {
    local current_hostname=$(hostname)
    if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then
        hostname "$new_host_name"
    fi
}

The code that sets the hostname on squeeze is as follows:

/sbin/dhclient-script from isc-dhcp-client version 4.1.1-P1-15, lines 155 to
158
        if [ -n "$old_host_name" -a -n "$host_name" -a \
             "$host_name" != "$old_host_name" ]; then
            hostname "$new_host_name"
        fi

The first thing that I believe is a bug is that the if clause tests against
$old_host_name and $host_name, but the hostname is set to $new_host_name.

I put some print statements around this clause to show the contents of the
three variables.

On boot, $old_host_name is empty, $host_name is empty, and $new_host_name
has the hostname given to the machine from dhcp.  Since this if clause tests
that both $old_host_name and $host_name are non-empty, the statement to set
the hostname is not executed.

If, after the system has booted, I run '/etc/init.d/networking restart', the
contents of the variables are $old_host_name = the host name assigned by
dhcp, $host_name is empty, and $new_host_name is the hostname assigned by
dhcp.  Since $host_name is empty, the statement to set the hostname is not
executed.  Note that even though $old_host_name contains the hostname given
out by dhcp, the hosts' name (as shown by running 'hostname') is "(none)".
$old_host_name seems to be incorrectly populated.

I believe the previous behavior of setting current_hostname=$(hostname) and
testing it against "(none)" will cause the system to behave as I expect.  I
don't understand why the previous hostname must have content in order for
the new hostname to be set, and it seems as though testing $host_name
instead of $new_host_name is a typo.

Thank you,

-ben

--- End Message ---
--- Begin Message ---
Version: 4.2.2-2

On Sun, Dec  4, 2011 at 00:00:06 +0100, Helmut Grohne wrote:

> This is a summary for those attempting to squash rc bugs.
> 
> As of 4.2.2-1 /sbin/dhclient-script implements a set_hostname function
> that unconditionally updates the host name if request host-name is set
> in /etc/dhcp/dhclient.conf which is the default. This means that in a
> default setup of dhcp any dhcp server can change the hostname. It is
> known that this break (among other things) X11. It also contradicts the
> documentation (man dhcp-options) "This option is only honored by
> dhclient-script(8) if the hostname for the client machine is not set."
> 
That seems fixed (at least to some extent) in 4.2.2-2:

        if [ -z "$current_hostname" ] ||
           [ "$current_hostname" = '(none)' ] ||
           [ "$current_hostname" = 'localhost' ] ||
           [ "$current_hostname" = "$old_host_name" ]; then
           if [ "$new_host_name" != "$old_host_name" ]; then
               hostname "$new_host_name"
           fi
        fi

I.e. if the current host name doesn't match the previous one from dhcp
then don't change it.

Cheers,
Julien

Attachment: signature.asc
Description: Digital signature


--- End Message ---

Reply via email to