Several HardenedBSD users have reported bsdinstall stalling after DHCP grabbing an IP for IPv4 (usr.sbin/bsdinstall/scripts/netconfig_ipv4). I've reproduced this behavior on VirtualBox 6.0 on OSX with FreeBSD 13-CURRENT/amd64 as the guest OS. I tried setting the virtual NIC to the emulated Intel driver (em) and also virtio-net. Both virtual NIC types cause bsdinstall to stall.
It looks like this was caused by r325740 in dhclient.
netconfig_ipv4 captures dhclient's stdout using command substitution for possible logging in case dhclient throws an error. The expectation is that this will terminate as soon as dhclient either fails to get a lease and terminates, or succeeds in getting a lease and daemonizes (which closes stdin/stdout/stderr).
The switch to cap_syslog broke this behavior, because cap_syslog specifies CASPER_SERVICE_STDIO in its service declaration, so the spawned casper service holds dhclient's stdio descriptors opens.
A commit references this bug:
Date: Wed Feb 6 04:36:29 UTC 2019
New revision: 343827
r341692 changed cap_syslog(3) to preserve the stdio descriptors inherited
from its parent so that LOG_PERROR would work. However, this caused
dhclient(8)'s stdio streams to remain open across daemonization, breaking
the ability to capture its foreground output as done in netconfig_ipv4.
Fix this by reverting r341692 and instead passing the parent's stderr
descriptor as an argument to cap_openlog() only when LOG_PERROR is specified
Suggested by: markj
Reported by: Shawn Webb
Reviewed by: markj, oshogbo
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18989