Package: isc-dhcp-client<br>Version: 4.1.1-P1-15<br><br>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.<br>
<br>My environment: the dhcp server is sending &#39;option host-name&#39; 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<br>
<br>The code that sets the hostname on lenny is as follows:<br><br>/sbin/dhclient-script from dhcp3-client version 3.1.1-6+lenny4, lines 102 to 107<br>set_hostname() {<br>    local current_hostname=$(hostname)<br>    if [ -z &quot;$current_hostname&quot; -o &quot;$current_hostname&quot; = &quot;(none)&quot; ]; then<br>
        hostname &quot;$new_host_name&quot;<br>    fi<br>}<br><br>The code that sets the hostname on squeeze is as follows:<br><br>/sbin/dhclient-script from isc-dhcp-client version 4.1.1-P1-15, lines 155 to 158<br>        if [ -n &quot;$old_host_name&quot; -a -n &quot;$host_name&quot; -a \<br>
             &quot;$host_name&quot; != &quot;$old_host_name&quot; ]; then<br>            hostname &quot;$new_host_name&quot;<br>        fi  <br><br>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.<br>
<br>I put some print statements around this clause to show the contents of the three variables.  <br><br>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.  <br>
<br>If, after the system has booted, I run &#39;/etc/init.d/networking restart&#39;, 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&#39; name (as shown by running &#39;hostname&#39;) is &quot;(none)&quot;.  $old_host_name seems to be incorrectly populated.<br>
<br>I believe the previous behavior of setting current_hostname=$(hostname) and testing it against &quot;(none)&quot; will cause the system to behave as I expect.  I don&#39;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.<br>
<br>Thank you,<br><br>-ben<br>