Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Sep 2007 14:56:13 +0200 (CEST)
From:      Jeremie Le Hen <jeremie@le-hen.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Jeremie Le Hen <jeremie@le-hen.org>
Subject:   conf/116416: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
Message-ID:  <20070917125613.9B2C6405D@obiwan.tataz.chchile.org>
Resent-Message-ID: <200709171340.l8HDe1Va061760@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         116416
>Category:       conf
>Synopsis:       [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 17 13:40:01 GMT 2007
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070917125613.9B2C6405D>