]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network/dhclient-script: set FQDN
authorIan Dall <ian@beware.dropbear.id.au>
Mon, 23 Jan 2012 09:46:10 +0000 (10:46 +0100)
committerHarald Hoyer <harald@redhat.com>
Mon, 23 Jan 2012 09:47:38 +0000 (10:47 +0100)
When booting with nfsroot, dracut doesn't necessarily set the initial
hostname correctly.

According to dhcp-options(5), the name may or may not be qualified with
the local domain. It goes on to say "it is preferable to use the
domain-name option to specify the domain name".

So dhclient-script needs to be able to handle the cases: a) where
host-name is fully qualified and domain name is also specified; b)
where hostname is fully qualified and the domain is not separately
specified; c) where host-name is "short" and domain-name is also
specified; and d) do its best where host-name is short but domain-name
is not specified.

The dhclient-script in initramfs does not handle case "c", apparently
the preferred situation properly, setting hostname to "short".

https://bugzilla.redhat.com/show_bug.cgi?id=756347

modules.d/40network/dhclient-script

index 2c26838f2f0ad9448126238be1bb9e9e35a307df..e8bd8b224e1323e152669e0832ca073f90e64c95 100755 (executable)
@@ -41,7 +41,9 @@ setup_interface() {
         done
     fi >> /tmp/net.$netif.resolv.conf
 
-    [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+    # Note: hostname can be fqdn OR short hostname, so chop off any
+    # trailing domain name and explicity add any domain if set.
+    [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
 }
 
 PATH=/usr/sbin:/usr/bin:/sbin:/bin