From anton@belle.rnoc.urc.ac.ru  Tue Oct 10 22:00:23 2000
Return-Path: <anton@belle.rnoc.urc.ac.ru>
Received: from belle.rnoc.urc.ac.ru (belle.rnoc.urc.ac.ru [193.233.85.10])
	by hub.freebsd.org (Postfix) with ESMTP id 1A2BA37B66D
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 10 Oct 2000 22:00:06 -0700 (PDT)
Received: (from anton@localhost)
	by belle.rnoc.urc.ac.ru (8.11.0/8.9.3) id e9B4xJG82752;
	Wed, 11 Oct 2000 10:59:19 +0600 (YEKST)
	(envelope-from anton)
Message-Id: <200010110459.e9B4xJG82752@belle.rnoc.urc.ac.ru>
Date: Wed, 11 Oct 2000 10:59:19 +0600 (YEKST)
From: anton@urc.ac.ru
Sender: anton@belle.rnoc.urc.ac.ru
Reply-To: anton@urc.ac.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: Fix for diskless startup bug in /etc/rc
X-Send-Pr-Version: 3.2

>Number:         21904
>Category:       misc
>Synopsis:       [MFC] [PATCH] Fix for diskless startup bug in /etc/rc
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 10 22:10:01 PDT 2000
>Closed-Date:    Fri Dec 15 23:04:02 PST 2000
>Last-Modified:  Fri Dec 15 23:05:55 PST 2000
>Originator:     Anton Voronin
>Release:        FreeBSD 4.1-STABLE i386
>Organization:
Southern Ural State University, Chelyabinsk, Russia
>Environment:

	i386 workstations boot FreeBSD 4.1-STABLE remotely from the server with
	the same OS using rc.diskless* scripts. / and /usr are monted from
	the server (actually the server's / and /usr), /etc and /var are
	mounted by rc.diskless2. /tmp and swap are mounted from local disks.

>Description:

	/etc/rc checks $1 against "autoboot" after it runs /etc/rc.diskless1.
	But as the latter uses "set" command, it clears the command line, and
	so /etc/rc fails to check for autoboot mode, so it doesn't run fsck,
	and so fails to mount local filesystems (/tmp in my case).

>How-To-Repeat:

	Ensure you have /etc/rc.diskless* on the file server, boot
	FreeBSD 4.1-STABLE remotely from this server, and specify some
	locally mounted filesystems in /etc/fstab (ensure you have "1" in
	the 6th column for these filesystems. Then do a "dirty" reboot
	of the remote-booting machine (with reset button), and watch the
	booting process: instead of running fsck it prints "Skipping disk
	checks...", and then fails to mount local filesystems because they
	are still not clean.

>Fix:

--- rc.old	Fri Sep  8 12:16:20 2000
+++ rc	Wed Oct 11 10:34:09 2000
@@ -20,6 +20,7 @@
 trap : 2
 trap : 3	# shouldn't be needed
 
+bootmode=$1
 HOME=/
 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
 export HOME PATH
@@ -57,7 +58,7 @@
 
 swapon -a
 
-case $1 in
+case ${bootmode} in
 autoboot)
 	echo Automatic boot in progress...
 	fsck -p


>Release-Note:
>Audit-Trail:

From: Doug Barton <DougB@gorean.org>
To: anton@urc.ac.ru
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: misc/21904: Fix for diskless startup bug in /etc/rc
Date: Tue, 10 Oct 2000 22:31:04 -0700

 anton@urc.ac.ru wrote:
 
 > 
 > --- rc.old      Fri Sep  8 12:16:20 2000
 > +++ rc  Wed Oct 11 10:34:09 2000
 > @@ -20,6 +20,7 @@
 >  trap : 2
 >  trap : 3       # shouldn't be needed
 > 
 > +bootmode=$1
 >  HOME=/
 >  PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
 >  export HOME PATH
 > @@ -57,7 +58,7 @@
 > 
 >  swapon -a
 > 
 > -case $1 in
 > +case ${bootmode} in
 >  autoboot)
 >         echo Automatic boot in progress...
 >         fsck -p
 
 	The patch seems reasonable. For style reasons I'd add a newline after
 the assignment line, otherwise it seems fine. Good detective work.
 
 Doug
 
Responsible-Changed-From-To: freebsd-bugs->dougb 
Responsible-Changed-By: dirk 
Responsible-Changed-When: Thu Nov 9 03:49:34 PST 2000 
Responsible-Changed-Why:  
Doug seems to be interested in this and became a committer meanwhile. 8-) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21904 
State-Changed-From-To: open->analyzed 
State-Changed-By: dougb 
State-Changed-When: Mon Nov 20 20:26:01 PST 2000 
State-Changed-Why:  

I've committed this to -current, will MFC after a 
respectable time period for feedback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21904 
State-Changed-From-To: analyzed->closed 
State-Changed-By: dougb 
State-Changed-When: Fri Dec 15 23:04:02 PST 2000 
State-Changed-Why:  

The patch has been committed to -current and RELENG_4. In my opinion it's 
not appropriate for RELENG_3, but I have no objections if another 
committer wants to take it on. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21904 
>Unformatted:
