Page MenuHomeFreeBSD

D56828.diff
No OneTemporary

D56828.diff

diff --git a/sbin/init/init.8 b/sbin/init/init.8
--- a/sbin/init/init.8
+++ b/sbin/init/init.8
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 22, 2021
+.Dd May 5, 2026
.Dt INIT 8
.Os
.Sh NAME
@@ -396,6 +396,14 @@
.Pa /etc/rc
script is executed with the standard shell
.Pa /bin/sh .
+.It Va init_rc
+If set to a valid file name in the root file system,
+overrides the default path to
+.Xr rc 8
+.Pq Pa /etc/rc .
+This is useful for testing alternative service managers
+without modifying the default
+.Pa /etc/rc .
.It Va init_path
Specifies the path used to search for the init binary.
More than one binary can be listed in the string,
diff --git a/sbin/init/init.c b/sbin/init/init.c
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1025,11 +1025,23 @@
runcom(void)
{
state_func_t next_transition;
+ char runcom_path[PATH_MAX];
+ const char *rc_script;
- BOOTTRACE("/etc/rc starting...");
- if ((next_transition = run_script(_PATH_RUNCOM)) != NULL)
+ /*
+ * Allow overriding /etc/rc via the init_rc kenv variable.
+ * This is useful for testing alternative service managers
+ * without modifying /etc/rc.
+ */
+ if (kenv(KENV_GET, "init_rc", runcom_path, sizeof(runcom_path)) > 0)
+ rc_script = runcom_path;
+ else
+ rc_script = _PATH_RUNCOM;
+
+ BOOTTRACE("%s starting...", rc_script);
+ if ((next_transition = run_script(rc_script)) != NULL)
return next_transition;
- BOOTTRACE("/etc/rc finished");
+ BOOTTRACE("%s finished", rc_script);
runcom_mode = AUTOBOOT; /* the default */
return (state_func_t) read_ttys;

File Metadata

Mime Type
text/plain
Expires
Tue, Jul 21, 3:16 PM (6 h, 2 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35303396
Default Alt Text
D56828.diff (1 KB)

Event Timeline