From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 14 23:49:46 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 50DB1720 for ; Sat, 14 Feb 2015 23:49:46 +0000 (UTC) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 151117A9 for ; Sat, 14 Feb 2015 23:49:46 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 687E5B8056; Sun, 15 Feb 2015 00:49:43 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 533B228494; Sun, 15 Feb 2015 00:49:43 +0100 (CET) Date: Sun, 15 Feb 2015 00:49:43 +0100 From: Jilles Tjoelker To: Perry Hutchison Subject: Re: RFC: make init(8) aware of /rescue/sh Message-ID: <20150214234943.GB1360@stack.nl> References: <54db2f2f.gIXyruGSeJuY3FbJ%perryh@pluto.rain.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54db2f2f.gIXyruGSeJuY3FbJ%perryh@pluto.rain.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2015 23:49:46 -0000 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 > #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