From nobody@FreeBSD.org  Sat May 13 05:48:14 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9D78816A402
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 13 May 2006 05:48:14 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4F51B43D45
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 13 May 2006 05:48:14 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k4D5mEik096776
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 13 May 2006 05:48:14 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k4D5mEUq096775;
	Sat, 13 May 2006 05:48:14 GMT
	(envelope-from nobody)
Message-Id: <200605130548.k4D5mEUq096775@www.freebsd.org>
Date: Sat, 13 May 2006 05:48:14 GMT
From: Aaron Gifford <agifford@infowest.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /etc/rc.d/jail script tests for empty variable using faulty method
X-Send-Pr-Version: www-2.3

>Number:         97192
>Category:       conf
>Synopsis:       [patch] /etc/rc.d/jail script tests for empty variable using faulty method
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 13 05:50:18 GMT 2006
>Closed-Date:    Sat May 27 10:53:57 GMT 2006
>Last-Modified:  Sat May 27 10:53:57 GMT 2006
>Originator:     Aaron Gifford
>Release:        6.1-RELEASE
>Organization:
>Environment:
FreeBSD host.name 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Fri May 12 15:21:07 MDT 2006
>Description:
The RC script /etc/rc.d/jail does the following test:

  if [ -n ${jail_interface} ]; then

The '[' test operator will ALWAYS evaluate the above as true,
even when the variable jail_interface is empty.

This bug is a showstopper if you upgrade from FreeBSD 5.x to 6.1-RELEASE
and expect existing configured jails to work correclty.  Some may, but
those which depend on the jail system NOT automatically adding an alias
IP will fail to launch.


Sorry if this has already been reported.  The www.freebsd.org bugs web page does NOT have a form to search existing bug reports to see if any similar submissions have already been made.
>How-To-Repeat:
Attempt to configure a jail using rc.conf in such a way that
you desire an empty jail_interface variable.  Starting/stopping
the jail will fail due to the RC script bug.
>Fix:
Solution: Add double quotes around the variable in the test.

############### PATCH:
--- jail.orig   Fri May 12 17:27:40 2006
+++ jail        Fri May 12 17:27:47 2006
@@ -164,7 +164,7 @@
                        echo -n " [${jail_hostname} already running (/var/run/jail_${_jail}.id exists)]"
                        continue;
                fi
-               if [ -n ${jail_interface} ]; then
+               if [ -n "${jail_interface}" ]; then
                        ifconfig ${jail_interface} alias ${jail_ip} netmask 255.255.255.255
                fi
                if checkyesno jail_mount; then
@@ -239,7 +239,7 @@
                                jail_umount_fs
                                echo -n " $jail_hostname"
                        fi
-                       if [ -n ${jail_interface} ]; then
+                       if [ -n "${jail_interface}" ]; then
                                ifconfig ${jail_interface} -alias ${jail_ip}
                        fi
                        rm /var/run/jail_${_jail}.id

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: matteo 
State-Changed-When: Sat May 27 10:52:53 UTC 2006 
State-Changed-Why:  
This has been fixed (by flz@ IIRC). Thanks 

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