git: d09b42a876bb - stable/14 - rc: Bail if /dev/null is not a device
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Jun 2026 23:01:12 UTC
The branch stable/14 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=d09b42a876bbd3a03edd8443976d0ad55a864e2e
commit d09b42a876bbd3a03edd8443976d0ad55a864e2e
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-06-05 15:53:29 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-08 23:00:54 +0000
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
(cherry picked from commit b5a96894f67a92f78f0641763eff1e0a46f2e036)
---
libexec/rc/rc | 5 +++++
share/man/man8/rc.8 | 13 +++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/libexec/rc/rc b/libexec/rc/rc
index ae1b24a6f36d..3df98ef8a714 100644
--- a/libexec/rc/rc
+++ b/libexec/rc/rc
@@ -49,6 +49,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 fa736ce50394..beb0e86c6142 100644
--- a/share/man/man8/rc.8
+++ b/share/man/man8/rc.8
@@ -30,8 +30,7 @@
.\"
.\" @(#)rc.8 8.2 (Berkeley) 12/11/93
.\"
-.Dd June 1, 2023
-.Dd September 20, 2024
+.Dd June 4, 2026
.Dt RC 8
.Os
.Sh NAME
@@ -99,6 +98,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