NetBSD Problem Report #43390
From www@NetBSD.org Sun May 30 15:48:30 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id F323463B8DB
for <gnats-bugs@gnats.NetBSD.org>; Sun, 30 May 2010 15:48:29 +0000 (UTC)
Message-Id: <20100530154829.9409863B8CF@www.NetBSD.org>
Date: Sun, 30 May 2010 15:48:29 +0000 (UTC)
From: idleroux@fastmail.fm
Reply-To: idleroux@fastmail.fm
To: gnats-bugs@NetBSD.org
Subject: shutdown does not remove /etc/nologin when called with -r, -h or -p
X-Send-Pr-Version: www-1.0
>Number: 43390
>Category: bin
>Synopsis: shutdown does not remove /etc/nologin when called with -r, -h or -p
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun May 30 15:50:00 +0000 2010
>Closed-Date: Wed Jun 09 04:55:48 +0000 2010
>Last-Modified: Wed Jun 09 05:05:02 +0000 2010
>Originator: Ian D. Leroux
>Release: amd64 5.0.2-RELEASE
>Organization:
>Environment:
NetBSD spip.homeunix.net 5.0.2 NetBSD 5.0.2 (GENERIC) #0: Sat Feb 6 13:44:19 UTC 2010 builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-2-RELEASE/amd64/201002061851Z-obj/home/builds/ab/netbsd-5-0-2-RELEASE/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
Synopsis:
If shutdown(8) is called with any of the -r, -h, or -p options on a system where / is marked read-only in /etc/fstab but is currently writable, then non-root logins are disabled at the next boot.
Explanation:
Provided the root file system is currently writable, shutdown(8) creates the file /etc/nologin to prevent inadvertant logins just before the system goes down. Normally this file is removed just before shutdown(8) exits in the finish() function. However, if shutdown(8) is called with any of the flags -r, -h, or -p it execs reboot(8), poweroff(8), or halt(8); the finish() function is never called, and /etc/nologin is never removed. This prevents login as a non-root user at the next boot.
This behaviour is noticeable if / is marked ro in /etc/fstab; otherwise /etc/rc.d/mountcritlocal independently removes /etc/nologin at boot time, if possible.
Thanks to Robert Elz for helping me understand the cause of the problem.
>How-To-Repeat:
# Mark / as readonly in /etc/fstab, thus preventing the
# /etc/rc.d/mountcritlocal script from removing /etc/nologin during boot.
mount -u -w /
shutdown -r now
# attempt to login as a normal user
>Fix:
The following patch /usr/src/sbin/shutdown/shutdown.c corrects the problem
--- shutdown.c.orig 2010-05-30 08:03:19.000000000 -0400
+++ shutdown.c 2010-05-30 08:11:26.000000000 -0400
@@ -395,6 +395,7 @@
*arg++ = bootstr;
*arg++ = 0;
#ifndef DEBUG
+ (void)unlink(_PATH_NOLOGIN);
(void)execve(path, __UNCONST(args), NULL);
serrno = errno;
syslog(LOG_ERR, "Can't exec `%s' (%m)", path);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: riz@NetBSD.org
State-Changed-When: Wed, 09 Jun 2010 04:55:48 +0000
State-Changed-Why:
Patch applied, thanks!
From: Jeff Rizzo <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/43390 CVS commit: src/sbin/shutdown
Date: Wed, 9 Jun 2010 04:51:53 +0000
Module Name: src
Committed By: riz
Date: Wed Jun 9 04:51:53 UTC 2010
Modified Files:
src/sbin/shutdown: shutdown.c
Log Message:
Remove _PATH_NOLOGIN before reboot, as well as before exit(), to prevent
a root file system which has been marked read-only in fstab from continuing
to prevent logins after reboot. From Ian D. Leroux in PR#43390.
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/shutdown/shutdown.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.