rc.d/hostname dependency on netif backwards?

Jilles Tjoelker jilles at stack.nl
Thu Nov 18 22:47:29 UTC 2010


On Mon, Nov 15, 2010 at 07:27:32PM -0800, Garrett Cooper wrote:
>     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 :).

/bin/hostname is just a wrapper around gethostname()/sethostname(). It
does not use DNS (some versions of GNU hostname do).

You should try to find what is setting the hostname to 2(SERVFAIL). A
cause could be not checking host(1)'s exit status -- it prints any error
message to stdout. Neither /etc/rc.d/hostname nor /sbin/dhclient-script
appear to do anything like that.

-- 
Jilles Tjoelker


More information about the freebsd-rc mailing list