From clsung@going04.iis.sinica.edu.tw  Tue May  9 09:59:02 2006
Return-Path: <clsung@going04.iis.sinica.edu.tw>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id BAC8D16A403
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  9 May 2006 09:59:02 +0000 (UTC)
	(envelope-from clsung@going04.iis.sinica.edu.tw)
Received: from going04.iis.sinica.edu.tw (going04.iis.sinica.edu.tw [140.109.19.154])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 67F8D43D49
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  9 May 2006 09:59:02 +0000 (GMT)
	(envelope-from clsung@going04.iis.sinica.edu.tw)
Received: by going04.iis.sinica.edu.tw (Postfix, from userid 1002)
	id 12AEE28471; Tue,  9 May 2006 17:59:08 +0800 (CST)
Message-Id: <20060509095908.12AEE28471@going04.iis.sinica.edu.tw>
Date: Tue,  9 May 2006 17:59:08 +0800 (CST)
From: Cheng-Lung Sung <clsung@freebsd.org>
Reply-To: Cheng-Lung Sung <clsung@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] rc.d/jail start ignore failed jail but still put jid under /var/run 
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         97024
>Category:       conf
>Synopsis:       [patch] rc.d/jail start ignore failed jail but still put jid under /var/run
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    matteo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 09 10:00:39 GMT 2006
>Closed-Date:    Fri May 26 14:05:13 GMT 2006
>Last-Modified:  Fri May 26 14:05:13 GMT 2006
>Originator:     Cheng-Lung Sung
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
FreeBSD @ Taiwan
>Environment:
System: FreeBSD going04.iis.sinica.edu.tw 6.1-STABLE FreeBSD 6.1-STABLE #9: Mon May 8 09:53:48 CST 2006 root@going04.iis.sinica.edu.tw:/usr/obj/usr/src/sys/GOING04 i386

>Description:

	'rc.d/jail start' echoes successful jail's name, however it
	still put failing jail's id to /var/run/. It should be able
	to tell user what's going on instead of just ignoring it.
>How-To-Repeat:

	establish two jail, choose one and remove /bin, then try to 
	start two jail via rc.d/jail start, you should only one jail's
	name was echoed, but rc.d/jail stop can stop these two jail.

>Fix:


--- rc.d/jail.orig	Tue May  9 17:20:29 2006
+++ rc.d/jail	Tue May  9 17:42:02 2006
@@ -210,11 +210,16 @@
 		_tmp_jail=${_tmp_dir}/jail.$$
 		eval jail ${jail_flags} -i ${jail_rootdir} ${jail_hostname} \
 			${jail_ip} ${jail_exec_start} > ${_tmp_jail} 2>&1
-		[ "$?" -eq 0 ] && echo -n " $jail_hostname"
-		_jail_id=$(head -1 ${_tmp_jail})
-		tail +2 ${_tmp_jail} >${jail_rootdir}/var/log/console.log
+		if [ "$?" -eq 0 ] ; then
+			echo -n " $jail_hostname"
+			_jail_id=$(head -1 ${_tmp_jail})
+			tail +2 ${_tmp_jail} >${jail_rootdir}/var/log/console.log
+			echo ${_jail_id} > /var/run/jail_${_jail}.id
+		else 
+			echo " cannot start jail ${_jail}. message: "
+			tail +2 ${_tmp_jail}
+		fi
 		rm -f ${_tmp_jail}
-		echo ${_jail_id} > /var/run/jail_${_jail}.id
 	done
 	rmdir ${_tmp_dir}
 	echo '.'
@@ -244,7 +249,7 @@
 			fi
 			rm /var/run/jail_${_jail}.id
 		else
-			echo "cannot stop jail ${_jail}. No jail id in /var/run"
+			echo " cannot stop jail ${_jail}. No jail id in /var/run"
 		fi
 	done
 	echo '.'

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->matteo 
Responsible-Changed-By: matteo 
Responsible-Changed-When: Tue May 9 16:31:28 UTC 2006 
Responsible-Changed-Why:  
Take ownership 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97024 
State-Changed-From-To: open->patched 
State-Changed-By: matteo 
State-Changed-When: Tue May 9 20:47:51 UTC 2006 
State-Changed-Why:  
Patch committed to HEAD with minor changes 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97024 
State-Changed-From-To: patched->closed 
State-Changed-By: matteo 
State-Changed-When: Fri May 26 14:04:50 UTC 2006 
State-Changed-Why:  
fixed and MFC'ed 


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