Comment 3 for bug 537978

Revision history for this message
Thierry Carrez (ttx) wrote :

Regression was introduced by the fix to:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508804

It could be fixed by fixing the obviously wrong patch, and support two cases:
 * Set hostname if new_host_name provided and hostname is not set
 * Set hostname if new_host_name provided and old_host_name matches the current hostname

Something like

local current_hostname=$(hostname)
if [ -z "$current_hostname" -o "$current_hostname" = "(none)" -o "$current_hostname" = "localhost" -o "$current_hostname" = "$old_host_name" ]; then
  if [ -n "$new_host_name" ]; then
    hostname "$new_host_name"
  fi
fi

However I am not so sure we should support the use case of the debian bug since option host-name should only be "honored by dhclient-script(8) if the hostname for the client machine is not set"...

Bug 482313 would be fixed in the same run (by adding "localhost" to the set of hostnames considered "unset").