Comment 0 for bug 537978

Revision history for this message
Valentijn Sessink (valentijn) wrote :

Until recently (up to and including Karmic), there was a "set_hostname()" function in /sbin/dhclient-script, that said:
set_hostname() {
    local current_hostname=$(hostname)
    if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then
        hostname "$new_host_name"
    fi
}

Up to 9.04, this would work when there was no /etc/hostname. With 9.10 (Karmic), this changed: a missing /etc/hostname sets the hostname to "localhost" and the dhclient-script will no longer set the hostname: this bug is reported as bug #482313 and #523188 - see #482313 for the fix we have been using for years.

Now with Lucid, the whole thing goes wrong, as the set_hostname() function is missing. There's only:
    BOUND|RENEW|REBIND|REBOOT)
        if [ -n "$old_host_name" -a -n "$host_name" -a \
             "$host_name" != "$old_host_name" ]; then
            hostname "$new_host_name"
        fi

This is plain wrong for two reasons:
1) as far as I can see, the $host_name variable does not exist at all; there's only an "old_host_name" and a "new_host_name", but "host_name" does not exist - which means the test will never be true.
2) if the test would be true at all, it would still only change the hostname if there is a change in the *dhcp-server supplied hostname*, i.e. if the hostname used to be "foo" and suddenly, the dhcp-server sends a hostname "bar", then the hostname will change.

This is also against the dhclient documentation, see "man dhcp-options":
option host-name string;
          This option specifies the name of the client. The name may or may
          not be qualified with the local domain name (it is preferable to use
          the domain-name option to specify the domain name). See RFC 1035
          for character set restrictions. This option is only honored by
          dhclient-script(8) if the hostname for the client machine is not
          set.

This is no longer true: under Lucid, the hostname will not be set at all, no matter what you try to do.