Package: isc-dhcp-client
Version: 4.2.2.dfsg.1-4
Severity: normal

The following is a quote from 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.  

Unfortunately the last sentence is subtly wrong. To see why we need to
look at /sbin/dhclient-script.

| set_hostname() {
|     local current_hostname
|
|     if [ -n "$new_host_name" ]; then
|         current_hostname=$(hostname)
| 
|         # 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' ] ||
|            [ "$current_hostname" = "$old_host_name" ]; then
|            if [ "$new_host_name" != "$old_host_name" ]; then
|                hostname "$new_host_name"
|            fi
|         fi
|     fi
| }

So old_host_name and new_host_name are controlled by the atta^Wdhcp
server. To reproduce set up a client machine running isc-dhcp-client
named foo and a server running isc-dhcp-server. The server configuration
should contain the following lines.

| host foo {
|       hardware ethernet 11:22:33:44:55:66; # replace with foo's mac address
|       option host-name "foo";
| }

Now machine foo runs dhclient and obtains a lease. It then releases the
lease. Now change the option host-name to "bar". The client machine now
runs dhclient again. In this second run old_host_name matches
current_hostname, so it really updates the system hostname. And this is
where the documentation is wrong.

I suggest extending the last sentence to the following sentence.

| This option is only honored by dhclient-script(8) if the hostname for
| the client machine is not set or the dhcp server has previously sent
| the hostname of the client machine and now sends a different name.

If on the other hand the current behaviour is not desired, I suggest
changing the dhclient-script to remove the || [ "$current_hostname" =
"$old_host_name" ] check to match the description of the documentation.

Thanks

Helmut



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to