From nobody@FreeBSD.org  Sun May  4 12:23:02 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 05F0E730
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 May 2014 12:23:02 +0000 (UTC)
Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(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 DA94F1FEB
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 May 2014 12:23:01 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s44CN1FW009306
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 4 May 2014 12:23:01 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s44CN1Y4009299;
	Sun, 4 May 2014 12:23:01 GMT
	(envelope-from nobody)
Message-Id: <201405041223.s44CN1Y4009299@cgiserv.freebsd.org>
Date: Sun, 4 May 2014 12:23:01 GMT
From: Joe Barbish <joeb1@a1poweruser.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: major logic error in /etc/rc.d/jail script for release 10.0
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         189354
>Category:       conf
>Synopsis:       major logic error in /etc/rc.d/jail script for release 10.0
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 04 12:30:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Sat May 10 17:10:00 UTC 2014
>Originator:     Joe Barbish
>Release:        10.0-RELEASE i386
>Organization:
none
>Environment:
>Description:
In freebsd-10.0 the /etc/rc.d/jail script has been changed to convert jails defined in /etc/rc.conf to the jail(8) format and then start a jail using those jail(8) definitions. The /etc/rc.d/jail script logic is incomplete and inaccurate in what and how the on the fly conversion is done. The show-stopper problem is the fstab statement in the /etc/rc.conf file is not being converted to the jail.conf format. On inspection of the /etc/rc.d/jail script shows there is no logic to convert the fstab statement at all. Only the 3 most basic jail definition statements are converted and a bunch of other un-necessary statements are inserted into the jail(8) format file which is written in /var/run/jailname instead of /etc/jail.conf like the man page states is the correct location. In addition the /var/run/jailname jail(8) format file contains these un-necessary statements.
    exec.clean; 
    exec.system_user = "root"; 
    exec.jail_user = "root";
    allow.set_hostname = 0; 
    allow.sysvipc = 0;

In effect this show-stopper forces the 10.0 user to immediately manually convert to jail.conf method or restore the 10.0 system back to a previous release of his system thus negating the intended purpose and results of the auto conversion. I am sure this is NOT the original intended purpose.

>How-To-Repeat:

>Fix:
Logic has to be added to the /etc/rc.d/jail script to convert all possible rc.conf jail statements as shown in /etc/default/rc.conf to the jail(8) format and remove the un-necessary statements it now inserts. An alterative would be to restore the 9.2 /etc/rc.d/jail script to 10.0 thus allowing both rc.conf and jail.conf jails to function.

>Release-Note:
>Audit-Trail:

From: "joeb1" <joeb1@a1poweruser.com>
To: <bug-followup@FreeBSD.org>,
	<joeb1@a1poweruser.com>
Cc:  
Subject: Re: conf/189354: major logic error in /etc/rc.d/jail script for release 10.0
Date: Sat, 10 May 2014 13:05:11 -0400

 After continued research into this problem I have found that this statement
 is at the cause of the problem.
 jail_legacy_rc_dir0_flags="-n legacy_rc_dir0 -l -U root"
 
 I comment that [flags=] statement out and everything works as expected.
 My previous diagnosis was incorrect.
 
 
>Unformatted:
 >cat /etc/rc.conf
 
 jail_enable="YES"        # legacy rc.d method
 
 jail_list="legacy_rc_dir0"
 jail_legacy_rc_dir0_hostname="legacy_rc_dir0"
 jail_legacy_rc_dir0_rootdir="/usr/jail/legacy_rc_dir0"
 jail_legacy_rc_dir0_fstab="/usr/local/etc/jail.rcconf.fstab/legacy_rc_dir0"
 jail_legacy_rc_dir0_ip="10.10.0.50"
 jail_legacy_rc_dir0_interface="xl0"
 jail_legacy_rc_dir0_flags="-n legacy_rc_dir0 -l -U root"
 jail_legacy_rc_dir0_mount_enable="YES"
 jail_legacy_rc_dir0_devfs_enable="YES"
 jail_legacy_rc_dir0_exec_start="/bin/sh /etc/rc"
 jail_legacy_rc_dir0_exec_stop="/bin/sh /etc/rc.shutdown"
 
 
 /var/run >ls
 jail.legacy_rc_dir0.conf   
 
 
 /var/run >cat jail.legacy_rc_dir0.conf
 # Generated by rc.d/jail at 2014-05-03 16:59:32
 
 legacy_rc_dir0 {
     host.hostname = "legacy_rc_dir0";
     path = "/usr/jail/legacy_rc_dir0";
     interface = "xl0";
     ip4.addr += "xl0|10.10.0.50/32";
     exec.clean;
     exec.system_user = "root";
     exec.jail_user = "root";
     exec.start += "/bin/sh /etc/rc";
     exec.stop = "/bin/sh /etc/rc.shutdown";
     exec.consolelog = "/var/log/jail_legacy_rc_dir0_console.log";
     mount.devfs;
     allow.mount;
     allow.set_hostname = 0;
     allow.sysvipc = 0;
 } 
 
