RFC: make init(8) aware of /rescue/sh
Jilles Tjoelker
jilles at stack.nl
Sat Feb 14 23:49:46 UTC 2015
On Wed, Feb 11, 2015 at 02:30:07AM -0800, Perry Hutchison wrote:
> 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);
> }
It is already possible to type "/rescue/sh" at the prompt (the Makefile
always compiles with -DDEBUGSHELL). This must be done manually but also
covers the case where /bin/sh exists but rtld or shared libraries are
missing or broken.
I'm not really sure this is worth the extra code.
--
Jilles Tjoelker
More information about the freebsd-hackers
mailing list