RFC: make init(8) aware of /rescue/sh

Perry Hutchison perryh at pluto.rain.com
Wed Feb 11 10:31:45 UTC 2015


Seems to me it might be desirable for init(8) to fall back
to /rescue/sh for single-user mode if neither the default
(kenv:init_shell) nor /bin/sh is usable.  Thoughts?

(Patch generated against stable/8, but will likely apply to
HEAD also -- not much has changed in init.)

--- init.c-orig
+++ init.c
@@ -79,6 +79,9 @@
 #include <login_cap.h>
 #endif
 
+/* Ideally this value should come from the RESCUE side of paths.h */
+#define	_PATH_R_BSHELL	"/rescue/sh"
+
 #include "pathnames.h"
 
 /*
@@ -706,7 +709,8 @@
 
 		/*
 		 * Fire off a shell.
-		 * If the default one doesn't work, try the Bourne shell.
+		 * If the default one doesn't work, try the Bourne shell;
+		 * if that doesn't work either, try the rescue shell.
 		 */
 
 		char name[] = "-sh";
@@ -717,6 +721,8 @@
 		emergency("can't exec %s for single user: %m", shell);
 		execv(_PATH_BSHELL, argv);
 		emergency("can't exec %s for single user: %m", _PATH_BSHELL);
+		execv(_PATH_R_BSHELL, argv);
+		emergency("can't exec %s for single user: %m", _PATH_R_BSHELL);
 		sleep(STALL_TIMEOUT);
 		_exit(1);
 	}


More information about the freebsd-hackers mailing list