Date: Sun, 15 Feb 2015 00:49:43 +0100 From: Jilles Tjoelker <jilles@stack.nl> To: Perry Hutchison <perryh@pluto.rain.com> Cc: freebsd-hackers@freebsd.org Subject: Re: RFC: make init(8) aware of /rescue/sh Message-ID: <20150214234943.GB1360@stack.nl> In-Reply-To: <54db2f2f.gIXyruGSeJuY3FbJ%perryh@pluto.rain.com> References: <54db2f2f.gIXyruGSeJuY3FbJ%perryh@pluto.rain.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150214234943.GB1360>