aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2026-06-05 15:53:29 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2026-06-05 15:53:29 +0000
commitb5a96894f67a92f78f0641763eff1e0a46f2e036 (patch)
tree981f090a2abc8c33cdd4f5c02551acae5b7bf0e0
parentddf6fad0295aa92af5eed2a4b2fa0bd02f47d94d (diff)
rc: Bail if /dev/null is not a device
On startup, check that /dev/null exists and is a character device. Otherwise, one of two things will happen: either /dev is a writable directory and we will immediately create /dev/null as a regular file and dump garbage into it, or it does not and we will spit out a stream of error messages about failing to create /dev/null. PR: 295782 MFC after: 1 week Reviewed by: jhb, emaste Differential Revision: https://reviews.freebsd.org/D57447
-rw-r--r--libexec/rc/rc5
-rw-r--r--share/man/man8/rc.812
2 files changed, 16 insertions, 1 deletions
diff --git a/libexec/rc/rc b/libexec/rc/rc
index db3c3e20ab44..75eef606b7fe 100644
--- a/libexec/rc/rc
+++ b/libexec/rc/rc
@@ -46,6 +46,11 @@ HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export HOME PATH
+if ! [ -c /dev/null ]; then
+ echo "/dev is not populated" >&2
+ exit 1
+fi
+
if [ "$1" = autoboot ]; then
autoboot=yes
_boot="faststart"
diff --git a/share/man/man8/rc.8 b/share/man/man8/rc.8
index a68878f0a10a..bfdd65b52f4a 100644
--- a/share/man/man8/rc.8
+++ b/share/man/man8/rc.8
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 20, 2024
+.Dd June 4, 2026
.Dt RC 8
.Os
.Sh NAME
@@ -97,6 +97,16 @@ command provides a scripting interface to modify system config files.
.Ss Operation of Nm
.Bl -enum
.It
+Verify that
+.Pa /dev/null
+exists and is a character device.
+If that is not the case,
+.Nm
+prints an error message and terminates.
+This is normally caused by forgetting to enable
+.Xr devfs 5
+in a jail's configuration.
+.It
If autobooting, set
.Va autoboot Ns = Ns Li yes
and enable a flag