From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 11 10:31:45 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A8830F62 for ; Wed, 11 Feb 2015 10:31:45 +0000 (UTC) Received: from agora.rdrop.com (agora.rdrop.com [IPv6:2607:f678:1010::34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 86BE1B14 for ; Wed, 11 Feb 2015 10:31:45 +0000 (UTC) Received: from agora.rdrop.com (66@localhost [127.0.0.1]) by agora.rdrop.com (8.13.1/8.12.7) with ESMTP id t1BAUPqY064086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 11 Feb 2015 02:30:25 -0800 (PST) (envelope-from perryh@pluto.rain.com) Received: (from uucp@localhost) by agora.rdrop.com (8.13.1/8.14.2/Submit) with UUCP id t1BAUPLI064085 for freebsd-hackers@freebsd.org; Wed, 11 Feb 2015 02:30:25 -0800 (PST) (envelope-from perryh@pluto.rain.com) Received: from fbsd81 by pluto.rain.com (4.1/SMI-4.1-pluto-M2060407) id AA03444; Wed, 11 Feb 15 02:29:02 PST Date: Wed, 11 Feb 2015 02:30:07 -0800 From: perryh@pluto.rain.com (Perry Hutchison) To: freebsd-hackers@freebsd.org Subject: RFC: make init(8) aware of /rescue/sh Message-Id: <54db2f2f.gIXyruGSeJuY3FbJ%perryh@pluto.rain.com> User-Agent: nail 11.25 7/29/05 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: Wed, 11 Feb 2015 10:31:45 -0000 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); }