From tataz@tataz.chchile.org  Mon Sep 17 13:32:44 2007
Return-Path: <tataz@tataz.chchile.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 18A1E16A468
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Sep 2007 13:32:44 +0000 (UTC)
	(envelope-from tataz@tataz.chchile.org)
Received: from postfix1-g20.free.fr (postfix1-g20.free.fr [212.27.60.42])
	by mx1.freebsd.org (Postfix) with ESMTP id A052E13C468
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Sep 2007 13:32:43 +0000 (UTC)
	(envelope-from tataz@tataz.chchile.org)
Received: from smtp5-g19.free.fr (smtp5-g19.free.fr [212.27.42.35])
	by postfix1-g20.free.fr (Postfix) with ESMTP id 7E6C719E05B9
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Sep 2007 14:57:38 +0200 (CEST)
Received: from smtp5-g19.free.fr (localhost.localdomain [127.0.0.1])
	by smtp5-g19.free.fr (Postfix) with ESMTP id CCEDE52B83
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Sep 2007 14:57:36 +0200 (CEST)
Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98])
	by smtp5-g19.free.fr (Postfix) with ESMTP id C5BC552B79
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Sep 2007 14:57:35 +0200 (CEST)
Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25])
	by tatooine.tataz.chchile.org (Postfix) with ESMTP id A1B9C9BF12;
	Mon, 17 Sep 2007 12:56:13 +0000 (UTC)
Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000)
	id 9B2C6405D; Mon, 17 Sep 2007 14:56:13 +0200 (CEST)
Message-Id: <20070917125613.9B2C6405D@obiwan.tataz.chchile.org>
Date: Mon, 17 Sep 2007 14:56:13 +0200 (CEST)
From: Jeremie Le Hen <jeremie@le-hen.org>
Reply-To: Jeremie Le Hen <jeremie@le-hen.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Jeremie Le Hen <jeremie@le-hen.org>
Subject: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         116416
>Category:       conf
>Synopsis:       [patch] [request] per-jail rc.conf(5) style configuration file in /etc/jail/
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-jail
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 17 13:40:01 GMT 2007
>Closed-Date:    Wed Jul 10 15:14:24 UTC 2013
>Last-Modified:  Wed Jul 10 15:20:00 UTC 2013
>Originator:     Jeremie Le Hen <jeremie@le-hen.org>
>Release:        FreeBSD 6.2-PRERELEASE i386
>Organization:
>Environment:
FreeBSD 7.0-CURRENT

>Description:
This patch changes etc/rc.d/jail: for a given jail $j, it will look for
/etc/jail/$j.  If it exists, it will mostly source it, except that the
file only has to contain the parameter name "param" instead of "jail_$j_param".
The main benefit of this patch is that adding or removing a jail is far
more easily scriptable than it is currently.

For instance, let's say your current rc.conf(5) contains:
% jail_enable="YES"
% jail_list="test"
% jail_test_rootdir="/jail/test"
% jail_test_hostname="test.my.domain"
% jail_test_ip="10.11.12.13"

You can remove the last three lines and put the following in /etc/jail/test:
% rootdir="/jail/test"
% hostname="test.my.domain"
% ip="10.11.12.13"

The patch is very little intrusive and works well.  I've not yet documented
it because I don't know where to insert it, but I would be glad to do it.
Please contact me if you have any idea about this.

--- etc_jail.diff begins here ---
Index: jail
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/jail,v
retrieving revision 1.37
diff -u -p -u -r1.37 jail
--- jail	24 May 2007 06:01:06 -0000	1.37
+++ jail	17 Sep 2007 12:22:01 -0000
@@ -27,6 +27,14 @@ init_variables()
 		return
 	fi
 
+	if [ -f "/etc/jail/$_j" ]; then
+		eval `awk -v j="$_j" \
+		    '/^[[:blank:]]*[a-zA-Z_][a-zA-Z0-9_]*=/ {
+			    sub(/^[[:blank:]]+/, "")
+			    print sprintf("jail_%s_%s", j, $0)
+		    }' "/etc/jail/$_j"`
+	fi
+
 	eval _rootdir=\"\$jail_${_j}_rootdir\"
 	_devdir="${_rootdir}/dev"
 	_fdescdir="${_devdir}/fd"
--- etc_jail.diff ends here ---


>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:

From: Jeremie Le Hen <jeremie@le-hen.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Jeremie Le Hen <jeremie@le-hen.org>
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
Date: Mon, 17 Sep 2007 17:22:29 +0200 (CEST)

 >Submitter-Id:	current-users
 >Originator:	Jeremie Le Hen <jeremie@le-hen.org>
 >Confidential:	no 
 >Synopsis:	Re: conf/116416: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
 >Severity:	non-critical
 >Priority:	low
 >Category:	conf
 >Class:		change-request
 >Release:	FreeBSD 7.0-CURRENT
 >Environment:
 FreeBSD 7.0-CURRENT
 
 >Description:
 This patch improves the previous one in that if $jail_list is empty,
 the rc.d script will deduce it from the content of /etc/jail/.
 This is even more easier to add/remove jail inside a script.
 
 >Fix:
 
 --- etc_jail.diff begins here ---
 Index: jail
 ===================================================================
 RCS file: /home/ncvs/src/etc/rc.d/jail,v
 retrieving revision 1.37
 diff -u -p -u -r1.37 jail
 --- jail	24 May 2007 06:01:06 -0000	1.37
 +++ jail	17 Sep 2007 15:14:34 -0000
 @@ -14,6 +14,8 @@ name="jail"
  rcvar=`set_rcvar`
  start_cmd="jail_start"
  stop_cmd="jail_stop"
 +start_precmd="jail_prestart"
 +jails_confdir="/etc/jail"
  
  # init_variables _j
  #	Initialize the various jail variables for jail _j.
 @@ -27,6 +29,14 @@ init_variables()
  		return
  	fi
  
 +	if [ -f "$jails_confdir/$_j" ]; then
 +		eval `awk -v j="$_j" \
 +		    '/^[[:blank:]]*[a-zA-Z_][a-zA-Z0-9_]*=/ {
 +			    sub(/^[[:blank:]]+/, "")
 +			    print sprintf("jail_%s_%s", j, $0)
 +		    }' "$jails_confdir/$_j"`
 +	fi
 +
  	eval _rootdir=\"\$jail_${_j}_rootdir\"
  	_devdir="${_rootdir}/dev"
  	_fdescdir="${_devdir}/fd"
 @@ -267,6 +277,17 @@ jail_mount_fstab()
  	mount -a -F "${_fstab}"
  }
  
 +# jail_prestart
 +#	If jail_list is empty, compute it from $jails_confdir.
 +jail_prestart()
 +{
 +	[ -z "$jail_list" ] || return 0
 +	[ -d "$jails_confdir" ] || return 0
 +
 +	jail_list=`ls "$jails_confdir"`
 +	return 0
 +}
 +
  jail_start()
  {
  	echo -n 'Configuring jails:'
 --- etc_jail.diff ends here ---
 
 
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: remko 
Responsible-Changed-When: Fri Sep 21 06:17:10 UTC 2007 
Responsible-Changed-Why:  
Over to the RC team for evaluation 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116416 
Responsible-Changed-From-To: freebsd-rc->mtm 
Responsible-Changed-By: mtm 
Responsible-Changed-When: Wed Oct 10 19:06:41 UTC 2007 
Responsible-Changed-Why:  
I'll take care of this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116416 

From: Mike Makonnen <mtm@FreeBSD.Org>
To: bug-followup@FreeBSD.org, jeremie@le-hen.org
Cc: freebsd-rc@FreeBSD.Org
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
Date: Wed, 10 Oct 2007 22:40:00 +0300

 Hi,
 
 I like this patch, especially the second revision. I think people who
 run a very large number of jails will appreciate it. However, I'd like
 to see a few changes made:
 
 1. Rename /etc/jail to /etc/jail.d
 2. The jails_confdir knob should be sourced from /etc/defaults/rc.conf
    so the sysadmin can change it if necessary.
 3. Instead of simply populating jail_list from the directory if it's
    empty I'd like to see it cascade through the following logic:
 	If jail_enable=no
 		do nothing (current behaviour)
 	else if jail_enable=yes
 		process jails defined in jail_list (current behaviour)
 	else if jail_enable=auto
 		if jail_list is NOT empty
 			process ONLY the jails listed in it
 		else
 			automatically populate jail_list from /etc/jail.d/
 
    This will give maximum flexibility and choice to the sysadmin.
    Your patch is essentially the same, however I would like to see the
    behaviour controlled by the jail_enable knob than have the script
    determine for itselft what it's going to do. For example, your patch,
    as it currently stands, would break a setup where the sysadmin had
    enabled jails but intentionally left jail_list empty in order *not* to
    start any jails.
 
 Cheers.
 -- 
 Mike Makonnen         | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
 mmakonnen @ gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
 mtm @ FreeBSD.Org     | FreeBSD - http://www.freebsd.org

From: Jeremie Le Hen <jeremie@le-hen.org>
To: Mike Makonnen <mtm@FreeBSD.Org>
Cc: bug-followup@FreeBSD.org, jeremie@le-hen.org, freebsd-rc@FreeBSD.Org
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration
	file in /etc/jail/
Date: Sat, 13 Oct 2007 23:58:24 +0200

 --XOIedfhf+7KOe/yw
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi Mike,
 
 Thanks for taking care of this.
 
 On Wed, Oct 10, 2007 at 10:40:00PM +0300, Mike Makonnen wrote:
 > I like this patch, especially the second revision. I think people who
 > run a very large number of jails will appreciate it. However, I'd like
 > to see a few changes made:
 > 
 > 1. Rename /etc/jail to /etc/jail.d
 > 2. The jails_confdir knob should be sourced from /etc/defaults/rc.conf
 >    so the sysadmin can change it if necessary.
 > 3. Instead of simply populating jail_list from the directory if it's
 >    empty I'd like to see it cascade through the following logic:
 > 	If jail_enable=no
 > 		do nothing (current behaviour)
 > 	else if jail_enable=yes
 > 		process jails defined in jail_list (current behaviour)
 > 	else if jail_enable=auto
 > 		if jail_list is NOT empty
 > 			process ONLY the jails listed in it
 > 		else
 > 			automatically populate jail_list from /etc/jail.d/
 > 
 >    This will give maximum flexibility and choice to the sysadmin.
 >    Your patch is essentially the same, however I would like to see the
 >    behaviour controlled by the jail_enable knob than have the script
 >    determine for itselft what it's going to do. For example, your patch,
 >    as it currently stands, would break a setup where the sysadmin had
 >    enabled jails but intentionally left jail_list empty in order *not* to
 >    start any jails.
 
 I've included all your requests in the attached patch.  If this is not
 the valid way to attach a file to a PR followup, please let me know.
 
 I will be able to document this tomorrow.  $jail_confdir should
 certainly be documented in rc.conf(5), but I'm not sure where to explain
 the content of /etc/jail.d/.
 
 Regards,
 -- 
 Jeremie Le Hen
 < jeremie at le-hen dot org >< ttz at chchile dot org >
 
 --XOIedfhf+7KOe/yw
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="rc.d_jail.patch"
 
 Index: defaults/rc.conf
 ===================================================================
 RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
 retrieving revision 1.296
 diff -u -p -u -p -r1.296 rc.conf
 --- defaults/rc.conf	20 Sep 2006 19:48:31 -0000	1.296
 +++ defaults/rc.conf	13 Oct 2007 09:21:20 -0000
 @@ -536,6 +536,7 @@ newsyslog_flags="-CN"	# Newsyslog flags 
  ### Jail Configuration #######################################
  ##############################################################
  jail_enable="NO"	# Set to NO to disable starting of any jails
 +jails_confdir="/etc/jail.d"  # Where per-jail configuration files are looked up
  jail_list=""		# Space separated list of names of jails
  jail_set_hostname_allow="YES" # Allow root user in a jail to change its hostname
  jail_socket_unixiproute_only="YES" # Route only TCP/IP within a jail
 Index: rc.d/jail
 ===================================================================
 RCS file: /home/ncvs/src/etc/rc.d/jail,v
 retrieving revision 1.37
 diff -u -p -u -p -r1.37 jail
 --- rc.d/jail	24 May 2007 06:01:06 -0000	1.37
 +++ rc.d/jail	13 Oct 2007 21:45:32 -0000
 @@ -27,6 +27,16 @@ init_variables()
  		return
  	fi
  
 +	if [ -f "${jails_confdir}/${_j}" ]; then
 +		eval [ \"\$jail_${_j}_ip\" ] && \
 +		    warn "${_j} is already defined in rc.conf(5) - overriding"
 +		eval `awk -v j="${_j}" \
 +		    '/^[[:blank:]]*[a-zA-Z_][a-zA-Z0-9_]*=/ {
 +			    sub(/^[[:blank:]]+/, "")
 +			    print sprintf("jail_%s_%s", j, $0)
 +		    }' "${jails_confdir}/${_j}"`
 +	fi
 +
  	eval _rootdir=\"\$jail_${_j}_rootdir\"
  	_devdir="${_rootdir}/dev"
  	_fdescdir="${_devdir}/fd"
 @@ -267,6 +277,17 @@ jail_mount_fstab()
  	mount -a -F "${_fstab}"
  }
  
 +jail_auto()
 +{
 +	if [ -z "${jail_list}" ]; then
 +		[ -d "${jails_confdir}" ] || \
 +		    err 3 "${jails_confdir} doesn't exist"
 +
 +		jail_list=`ls "${jails_confdir}"`
 +	fi
 +	jail_start
 +}
 +
  jail_start()
  {
  	echo -n 'Configuring jails:'
 @@ -416,4 +437,11 @@ fi
  if [ -n "$*" ]; then
  	jail_list="$*"
  fi
 +# XXX Unfortunately we do not support anything else than yes or no for now.
 +case "${jail_enable}" in
 +[Aa][Uu][Tt][Oo])
 +	jail_enable="YES"
 +	start_cmd="jail_auto"
 +	;;
 +esac
  run_rc_command "${cmd}"
 
 --XOIedfhf+7KOe/yw--

From: Dirk Engling <erdgeist@erdgeist.org>
To: Mike Makonnen <mtm@FreeBSD.Org>
Cc: bug-followup@FreeBSD.org, jeremie@le-hen.org, freebsd-rc@FreeBSD.Org
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration
 file in /etc/jail/
Date: Sun, 14 Oct 2007 00:27:03 +0200 (CEST)

 On Wed, 10 Oct 2007, Mike Makonnen wrote:
 
 > I like this patch, especially the second revision. I think people who
 > run a very large number of jails will appreciate it. However, I'd like
 > to see a few changes made:
 
 Hi, before you reinvent the wheel, I'd like you to take a look at my 
 ezjail[1] project. I've done much of the work more than two years ago and 
 would call the results stable and in wide use.
 
 I'd be too happy to just use /etc/jail.d as config directory for jails, as 
 I do today with /usr/local/etc/ezjail. However, if you write config files 
 the right way, there is no need to throw awk on them, just source them.
 
 Usign an rcorder style scheme on config files allows starting jails in a 
 predefined order.
 
 Allowing some pre-start commands to mount root dirs or attach certain 
 disc based memory images would be helpful, too.
 
 I'd hate to see diverging developments on jail configs so please do not 
 rush into some sub-optimal decisions.
 
 Regards
 
    erdgeist
 
 [1] http://erdgeist.org/arts/software/ezjail/

From: Jeremie Le Hen <jeremie@le-hen.org>
To: Dirk Engling <erdgeist@erdgeist.org>
Cc: Mike Makonnen <mtm@FreeBSD.Org>, bug-followup@FreeBSD.org,
	jeremie@le-hen.org, freebsd-rc@FreeBSD.Org
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration
	file in /etc/jail/
Date: Sun, 14 Oct 2007 08:36:19 +0200

 --vOmOzSkFvhd7u8Ms
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Dirk,
 
 Thank you for your enlightened review.
 
 On Sun, Oct 14, 2007 at 12:27:03AM +0200, Dirk Engling wrote:
 > 
 >  On Wed, 10 Oct 2007, Mike Makonnen wrote:
 > 
 > > I like this patch, especially the second revision. I think people who
 > > run a very large number of jails will appreciate it. However, I'd like
 > > to see a few changes made:
 > 
 >  Hi, before you reinvent the wheel, I'd like you to take a look at my 
 >  ezjail[1] project. I've done much of the work more than two years ago and 
 >  would call the results stable and in wide use.
 >
 >  I'd be too happy to just use /etc/jail.d as config directory for jails, as I 
 >  do today with /usr/local/etc/ezjail. However, if you write config files the 
 >  right way, there is no need to throw awk on them, just source them.
 
 Certainly we would all benefit from your experience with ezjail.  As for
 files in /etc/jail.d, I personally prefer the way I did it.  IMO it is
 repetitions that /etc/jail.d/myjail contains:
 % jail_myjail_ip=...
 % jail_myjail_hostname=...
 % jail_myjail_rootdir=...
 
 The awk script is not a great deal and just translates "ip=..." to
 "jail_<jname>_ip=...":
 % ip=...
 % hostname=...
 % rootdir=...
 
 Both ways have benefits and I would like to read some FreeBSD
 developper's opinion on this subject.  I will change my patch
 accordingly, if needed.
 
 >  Usign an rcorder style scheme on config files allows starting jails in a 
 >  predefined order.
 
 It is undoubtly necessary to be able to define jail starting order even
 in the "auto" case.  I've made that change.
 
 >  Allowing some pre-start commands to mount root dirs or attach certain disc 
 >  based memory images would be helpful, too.
 
 I completly agree.  I've already come up to this conclusion for some
 time.  I will submit another PR, unless Mike asks me to achieve this in
 the same patch.
 
 Regards,
 -- 
 Jeremie Le Hen
 < jeremie at le-hen dot org >< ttz at chchile dot org >
 
 --vOmOzSkFvhd7u8Ms
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="rc.d_jail.patch"
 
 Index: defaults/rc.conf
 ===================================================================
 RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
 retrieving revision 1.296
 diff -u -p -u -p -r1.296 rc.conf
 --- defaults/rc.conf	20 Sep 2006 19:48:31 -0000	1.296
 +++ defaults/rc.conf	13 Oct 2007 21:47:29 -0000
 @@ -536,6 +536,7 @@ newsyslog_flags="-CN"	# Newsyslog flags 
  ### Jail Configuration #######################################
  ##############################################################
  jail_enable="NO"	# Set to NO to disable starting of any jails
 +jail_confdir="/etc/jail.d"  # Where per-jail configuration files are looked up
  jail_list=""		# Space separated list of names of jails
  jail_set_hostname_allow="YES" # Allow root user in a jail to change its hostname
  jail_socket_unixiproute_only="YES" # Route only TCP/IP within a jail
 Index: rc.d/jail
 ===================================================================
 RCS file: /home/ncvs/src/etc/rc.d/jail,v
 retrieving revision 1.37
 diff -u -p -u -p -r1.37 jail
 --- rc.d/jail	24 May 2007 06:01:06 -0000	1.37
 +++ rc.d/jail	14 Oct 2007 06:08:50 -0000
 @@ -27,6 +27,16 @@ init_variables()
  		return
  	fi
  
 +	if [ -f "${jail_confdir}/${_j}" ]; then
 +		eval [ \"\$jail_${_j}_ip\" ] && \
 +		    warn "${_j} is already defined in rc.conf(5) - overriding"
 +		eval `awk -v j="${_j}" \
 +		    '/^[[:blank:]]*[a-zA-Z_][a-zA-Z0-9_]*=/ {
 +			    sub(/^[[:blank:]]+/, "")
 +			    print sprintf("jail_%s_%s", j, $0)
 +		    }' "${jail_confdir}/${_j}"`
 +	fi
 +
  	eval _rootdir=\"\$jail_${_j}_rootdir\"
  	_devdir="${_rootdir}/dev"
  	_fdescdir="${_devdir}/fd"
 @@ -267,6 +277,17 @@ jail_mount_fstab()
  	mount -a -F "${_fstab}"
  }
  
 +jail_auto()
 +{
 +	if [ -z "${jail_list}" ]; then
 +		[ -d "${jail_confdir}" ] || \
 +		    err 3 "${jail_confdir} doesn't exist"
 +
 +		jail_list=`cd "${jail_confdir}"; rcorder *`
 +	fi
 +	jail_start
 +}
 +
  jail_start()
  {
  	echo -n 'Configuring jails:'
 @@ -416,4 +437,11 @@ fi
  if [ -n "$*" ]; then
  	jail_list="$*"
  fi
 +# XXX Unfortunately we do not support anything else than yes or no for now.
 +case "${jail_enable}" in
 +[Aa][Uu][Tt][Oo])
 +	jail_enable="YES"
 +	start_cmd="jail_auto"
 +	;;
 +esac
  run_rc_command "${cmd}"
 
 --vOmOzSkFvhd7u8Ms--

From: "Mike Telahun Makonnen" <mtm@FreeBSD.Org>
To: "Jeremie Le Hen" <jeremie@le-hen.org>
Cc: "Dirk Engling" <erdgeist@erdgeist.org>, bug-followup@freebsd.org, 
	freebsd-rc@freebsd.org
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
Date: Tue, 16 Oct 2007 11:16:31 +0300

 Thanks guys.
 I'm currently away from my keyboard and won't be able to look at this
 issue for a couple more days.
 
 Cheers.
 Mike.

From: Jeremie Le Hen <jeremie@le-hen.org>
To: Mike Telahun Makonnen <mtm@FreeBSD.Org>
Cc: Jeremie Le Hen <jeremie@le-hen.org>,
	Dirk Engling <erdgeist@erdgeist.org>, bug-followup@freebsd.org,
	freebsd-rc@freebsd.org
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration
	file in /etc/jail/
Date: Thu, 18 Oct 2007 10:11:39 +0200

 --5I6of5zJg18YgZEa
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Mike,
 
 On Tue, Oct 16, 2007 at 11:16:31AM +0300, Mike Telahun Makonnen wrote:
 > Thanks guys.
 > I'm currently away from my keyboard and won't be able to look at this
 > issue for a couple more days.
 
 I've attached the rc.conf(5) changes to this e-mail.  Please, feel free
 to reword some parts of it since I am not a native english speaker.
 
 Best regards,
 -- 
 Jeremie Le Hen
 < jeremie at le-hen dot org >< ttz at chchile dot org >
 
 --5I6of5zJg18YgZEa
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="rc.conf.5-jail_confdir.patch"
 
 Index: rc.conf.5
 ===================================================================
 RCS file: /home/ncvs/src/share/man/man5/rc.conf.5,v
 retrieving revision 1.330
 diff -u -p -u -r1.330 rc.conf.5
 --- rc.conf.5	15 Oct 2007 20:00:20 -0000	1.330
 +++ rc.conf.5	18 Oct 2007 08:10:10 -0000
 @@ -3192,15 +3192,36 @@ should use the lowest frequency availabl
  .Dq Li HIGH
  indicates that the highest frequency (less power savings) should be used.
  .It Va jail_enable
 -.Pq Vt bool
 +.Pq Vt str
  If set to
  .Dq Li NO ,
  any configured jails will not be started.
 +If set to
 +.Dq Li YES ,
 +jails listed in
 +.Va jail_list
 +will be started.
 +If set to
 +.Dq Li AUTO ,
 +an empty
 +.Va jail_list
 +will be populated from the
 +.Va jail_confdir
 +directory.
  .It Va jail_list
  .Pq Vt str
  A space separated list of names for jails.
  This is purely a configuration aid to help identify and
  configure multiple jails.
 +If
 +.Va jail_list
 +is empty and
 +.Va jail_enable
 +is set to
 +.Dq Li AUTO ,
 +it will be populated from the content of the
 +.Va jail_confdir
 +directory.
  The names specified in this list will be used to
  identify settings common to an instance of a jail.
  Assuming that the jail in question was named
 @@ -3212,6 +3233,28 @@ jail_vjail_ip="192.168.1.100"
  jail_vjail_rootdir="/var/jails/vjail/root"
  .Ed
  .Pp
 +.It Va jail_confdir
 +.Pq Vt str
 +Set to
 +.Dq Pa /etc/jail.d
 +by default.
 +This directory contains per-jail configuration files.
 +Each file must have the same name as the jail it configures.
 +Variables in these files must not be prefixed with
 +.Dq jail_ Ns Ao Ar jname Ac Ns _
 +and override their counterparts from
 +.Nm .
 +In order to configure the above
 +.Li vjail ,
 +you have to fill
 +.Pa /etc/jail.d/vjail
 +with:
 +.Bd -literal
 +hostname="jail.example.com"
 +ip="192.168.1.100"
 +rootdir="/var/jails/vjail/root"
 +.Ed
 +.Pp
  .It Va jail_flags
  .Pq Vt str
  Unset by default.
 
 --5I6of5zJg18YgZEa--

From: Jeremie Le Hen <jeremie@le-hen.org>
To: bug-followup@FreeBSD.org
Cc: Jeremie Le Hen <jeremie@le-hen.org>
Subject: Re: conf/116416: [patch] [request] per-jail rc.conf(5) style
	configuration file in /etc/jail.d/
Date: Mon, 4 Aug 2008 17:27:47 +0200

 --/9DWx/yDrRhgMJTb
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi,
 
 There hasn't been much activity in this PR for a couple of month. :-)
 
 Here is an all-in-one patch.  I think it would be more attractive to
 commit therefrom.
 
 As a reminder for those reading only the e-mails, this patch creates a
 new configuration directory /etc/jail.d where per-jail configuration
 parameters can be stored.
 
 The parameter "jail_enable" can now be set to "AUTO" to populate
 "jail_list" automaticaly using rcorder(8) on files in /etc/jail.d/ .
 This is especially useful for automatic creation and deletion of jails.
 
 For example, instead of having the following in /etc/rc.conf:
 % jail_enable=YES
 % jail_list="ns mx"
 % 
 % jail_ns_rootdir=/jail/ns
 % jail_ns_hostname=ns.example.com
 % jail_ns_ip=192.168.1.53
 % 
 % jail_mx_rootdir=/jail/mx
 % jail_mx_hostname=mx.example.com
 % jail_mx_ip=192.168.1.25
 
 
 You could use in /etc/rc.conf:
 % jail_enable=AUTO
 
 In /etc/jail.d/ns:
 % # PROVIDE: ns
 % roodir=/jail/ns
 % hostname=ns.example.com
 % ip=192.168.1.53
 
 And in /etc/jail.d/mx:
 % # PROVIDE: mx
 % # REQUIRE: ns
 % rootdir=/jail/mx
 % hostname=mx.example.com
 % ip=192.168.1.25
 
 -- 
 Jeremie Le Hen
 < jeremie at le-hen dot org >< ttz at chchile dot org >
 
 --/9DWx/yDrRhgMJTb
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="fbsd8-jail.d.diff"
 
 Index: etc/defaults/rc.conf
 ===================================================================
 RCS file: /mnt/octobre/space/freebsd-cvs/src/etc/defaults/rc.conf,v
 retrieving revision 1.338
 diff -u -p -r1.338 rc.conf
 --- etc/defaults/rc.conf	1 Aug 2008 05:15:54 -0000	1.338
 +++ etc/defaults/rc.conf	4 Aug 2008 14:34:30 -0000
 @@ -592,6 +592,7 @@ mixer_enable="YES"	# Run the sound mixer
  ### Jail Configuration #######################################
  ##############################################################
  jail_enable="NO"	# Set to NO to disable starting of any jails
 +jail_confdir="/etc/jail.d"  # Where per-jail configuration files are looked up
  jail_list=""		# Space separated list of names of jails
  jail_set_hostname_allow="YES" # Allow root user in a jail to change its hostname
  jail_socket_unixiproute_only="YES" # Route only TCP/IP within a jail
 Index: etc/rc.d/jail
 ===================================================================
 RCS file: /mnt/octobre/space/freebsd-cvs/src/etc/rc.d/jail,v
 retrieving revision 1.38
 diff -u -p -r1.38 jail
 --- etc/rc.d/jail	13 Jan 2008 14:27:53 -0000	1.38
 +++ etc/rc.d/jail	4 Aug 2008 14:34:30 -0000
 @@ -33,6 +33,16 @@ init_variables()
  		return
  	fi
  
 +	if [ -f "${jail_confdir}/${_j}" ]; then
 +		eval [ \"\$jail_${_j}_ip\" ] && \
 +		    warn "${_j} is already defined in rc.conf(5) - overriding"
 +		eval `awk -v j="${_j}" \
 +		    '/^[[:blank:]]*[a-zA-Z_][a-zA-Z0-9_]*=/ {
 +			    sub(/^[[:blank:]]+/, "")
 +			    print sprintf("jail_%s_%s", j, $0)
 +		    }' "${jail_confdir}/${_j}"`
 +	fi
 +
  	eval _rootdir=\"\$jail_${_j}_rootdir\"
  	_devdir="${_rootdir}/dev"
  	_fdescdir="${_devdir}/fd"
 @@ -273,6 +283,17 @@ jail_mount_fstab()
  	mount -a -F "${_fstab}"
  }
  
 +jail_auto()
 +{
 +	if [ -z "${jail_list}" ]; then
 +		[ -d "${jail_confdir}" ] || \
 +		    err 3 "${jail_confdir} doesn't exist"
 +
 +		jail_list=`cd "${jail_confdir}"; rcorder *`
 +	fi
 +	jail_start
 +}
 +
  jail_start()
  {
  	echo -n 'Configuring jails:'
 @@ -422,4 +443,11 @@ fi
  if [ -n "$*" ]; then
  	jail_list="$*"
  fi
 +# XXX Unfortunately we do not support anything else than yes or no for now.
 +case "${jail_enable}" in
 +[Aa][Uu][Tt][Oo])
 +	jail_enable="YES"
 +	start_cmd="jail_auto"
 +	;;
 +esac
  run_rc_command "${cmd}"
 Index: share/man/man5/rc.conf.5
 ===================================================================
 RCS file: /mnt/octobre/space/freebsd-cvs/src/share/man/man5/rc.conf.5,v
 retrieving revision 1.343
 diff -u -p -r1.343 rc.conf.5
 --- share/man/man5/rc.conf.5	21 Jun 2008 13:53:35 -0000	1.343
 +++ share/man/man5/rc.conf.5	4 Aug 2008 14:39:04 -0000
 @@ -3293,15 +3293,37 @@ should use the lowest frequency availabl
  .Dq Li HIGH
  indicates that the highest frequency (less power savings) should be used.
  .It Va jail_enable
 -.Pq Vt bool
 +.Pq Vt str
  If set to
  .Dq Li NO ,
  any configured jails will not be started.
 +If set to
 +.Dq Li YES ,
 +jails listed in
 +.Va jail_list
 +will be started.
 +If set to
 +.Dq Li AUTO ,
 +an empty
 +.Va jail_list
 +will be populated from the
 +.Va jail_confdir
 +directory using
 +.Xr rcorder 8 .
  .It Va jail_list
  .Pq Vt str
  A space separated list of names for jails.
  This is purely a configuration aid to help identify and
  configure multiple jails.
 +If
 +.Va jail_list
 +is empty and
 +.Va jail_enable
 +is set to
 +.Dq Li AUTO ,
 +it will be populated from the content of the
 +.Va jail_confdir
 +directory.
  The names specified in this list will be used to
  identify settings common to an instance of a jail.
  Assuming that the jail in question was named
 @@ -3313,6 +3335,28 @@ jail_vjail_ip="192.168.1.100"
  jail_vjail_rootdir="/var/jails/vjail/root"
  .Ed
  .Pp
 +.It Va jail_confdir
 +.Pq Vt str
 +Set to
 +.Dq Pa /etc/jail.d
 +by default.
 +This directory contains per-jail configuration files.
 +Each file must have the same name as the jail it configures.
 +Variables in these files must not be prefixed with
 +.Dq jail_ Ns Ao Ar jname Ac Ns _
 +and override their counterparts from
 +.Nm .
 +In order to configure the above
 +.Li vjail ,
 +you have to fill
 +.Pa /etc/jail.d/vjail
 +with:
 +.Bd -literal
 +hostname="jail.example.com"
 +ip="192.168.1.100"
 +rootdir="/var/jails/vjail/root"
 +.Ed
 +.Pp
  .It Va jail_flags
  .Pq Vt str
  Unset by default.
 
 --/9DWx/yDrRhgMJTb--
State-Changed-From-To: open->open 
State-Changed-By: linimon 
State-Changed-When: Wed Jul 3 00:50:32 UTC 2013 
State-Changed-Why:  
commit bit has been taken in for safekeeping. 

To submitter: is this aging PR still relevant? 


Responsible-Changed-From-To: mtm->freebsd-jail 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jul 3 00:50:32 UTC 2013 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=116416 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Wed Jul 10 15:14:03 UTC 2013 
State-Changed-Why:  
obsoleted by subsequent events. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116416 

From: Mark Linimon <linimon@lonesome.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/116416: [patch] [request] per-jail rc.conf(5) style
 configuration file in /etc/jail/
Date: Wed, 10 Jul 2013 10:14:52 -0500

 ----- Forwarded message from Jeremie Le Hen <jlh@FreeBSD.org> -----
 
 Date: Tue, 9 Jul 2013 10:47:45 +0200
 From: Jeremie Le Hen <jlh@FreeBSD.org>
 To: linimon@FreeBSD.org
 Cc: jeremie@le-hen.org, mtm@FreeBSD.org, freebsd-jail@FreeBSD.org
 Subject: Re: conf/116416: [patch] [request] per-jail rc.conf(5) style configuration file in /etc/jail/
 User-Agent: Mutt/1.5.21 (2010-09-15)
 
 > To submitter: is this aging PR still relevant?
 
 Thanks for bringing it up.  No it is clearly not relevant any more as we
 now have jail.conf(5) that can (mostly) replace rc.conf(5) jail
 parameters.
 
 -- 
 Jeremie Le Hen
 
 Scientists say the world is made up of Protons, Neutrons and Electrons.
 They forgot to mention Morons.
 
 ----- End forwarded message -----
>Unformatted:
