Date: Mon, 15 Nov 2010 19:27:32 -0800 From: Garrett Cooper <yanegomi@gmail.com> To: rc@freebsd.org Subject: rc.d/hostname dependency on netif backwards? Message-ID: <AANLkTikaT0fhNn79pJn5fUM-MSvz_%2BJviRvTma9eq1t4@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
It looks like existing code for rc.d/hostname might be backwards:
%/etc/rc.d/hostname restart
+ /sbin/sysctl -n security.jail.jailed
+ [ 0 -eq 1 ]
+ /bin/hostname -s
+ hostname_s=2(SERVFAIL)
+ [ -n 2(SERVFAIL) ]
+ return
+ _return=0
+ [ 0 -ne 0 ]
+ return 0
+ _run_rc_postcmd
+ [ -n ]
+ return 0
+ return 0
%sysctl -a | grep hostname
kern.hostname: 2(SERVFAIL)
security.jail.set_hostname_allowed: 1
Why is it trying to resolve a hostname (hostname -s) before the
network's up? I could understand if this was a statically defined
hostname, but all of my hostnames are derived from pxebooting ala
dhcpd / named, not a static value :).
I have a lame patch attached (it hasn't worked so far with 7.x
from boot, but it works after the network's up and happy, etc; it
might work with CURRENT with the network state wait change), but I'm
wondering who sets hostname (etc/rc.d/hostname?) s.t. the SERVFAIL
check can be removed.
Thanks!
-Garrett
[-- Attachment #2 --]
Index: etc/rc.d/hostname
===================================================================
--- etc/rc.d/hostname (revision 215157)
+++ etc/rc.d/hostname (working copy)
@@ -39,6 +39,8 @@
hostname_start()
{
+ local hostname_s
+
# If we are not inside a jail, set the host name if it is not already set.
# If we are inside a jail, set the host name even if it is already set,
# but first check if it is permitted.
@@ -47,7 +49,8 @@
if [ `$SYSCTL_N security.jail.set_hostname_allowed` -eq 0 ]; then
return
fi
- elif [ -n "`/bin/hostname -s`" ]; then
+ elif hostname_s=`/bin/hostname -s` && [ -n "$hostname_s" ] && \
+ ! expr "$hostname_s" : '2(SERVFAIL)' 2>/dev/null; then
return
else
# If we're not in a jail and rc.conf doesn't specify a
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikaT0fhNn79pJn5fUM-MSvz_%2BJviRvTma9eq1t4>
