Bug 234514 - bsdinstall: Stalled after dhclient
Summary: bsdinstall: Stalled after dhclient
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Jason A. Harmening
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-30 23:37 UTC by Shawn Webb
Modified: 2019-03-06 17:59 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Webb 2018-12-30 23:37:38 UTC
Several HardenedBSD users have reported[1] 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.

[1] https://groups.google.com/a/hardenedbsd.org/d/msg/users/PmTXcc7hp-0/SHMFHJKwCQAJ
Comment 1 Jason A. Harmening freebsd_committer freebsd_triage 2019-01-15 08:28:22 UTC
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.
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-02-06 04:37:22 UTC
A commit references this bug:

Author: jah
Date: Wed Feb  6 04:36:29 UTC 2019
New revision: 343827
URL: https://svnweb.freebsd.org/changeset/base/343827

Log:
  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
  in logopt.

  PR:	234514
  Suggested by:	markj
  Reported by:	Shawn Webb
  Reviewed by:	markj, oshogbo
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D18989

Changes:
  head/lib/libcasper/services/cap_syslog/cap_syslog.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-02-21 06:41:12 UTC
A commit references this bug:

Author: jah
Date: Thu Feb 21 06:40:15 UTC 2019
New revision: 344422
URL: https://svnweb.freebsd.org/changeset/base/344422

Log:
  MFC r343827:

  r342089 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
  in logopt.

  PR:	234514

Changes:
_U  stable/12/
  stable/12/lib/libcasper/services/cap_syslog/cap_syslog.c