conf/98846: Templatize 'jail_rootdir' in /etc/rc.d/jail
skv at FreeBSD.org
skv at FreeBSD.org
Mon Jun 12 11:40:19 UTC 2006
>Number: 98846
>Category: conf
>Synopsis: Templatize 'jail_rootdir' in /etc/rc.d/jail
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Jun 12 11:40:18 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Sergey Skvortsov
>Release: FreeBSD 6.1-STABLE i386
>Organization:
<Organization of PR author (multiple lines)>
>Environment:
<Relevant environment information (multiple lines)>
>Description:
Allow define common template for all jail's rootdir.
>How-To-Repeat:
/etc/rc.conf.d/jail:
jail_rootdir="/data/jails/%%JAIL_IP%%" # TEMPLATE 0
#jail_rootdir="/data/jails/%%JAIL_HOSTNAME%%" # TEMPLATE 1
#jail_rootdir="/data/jails/%%JAIL_ID%%" # TEMPLATE 2
jail_list="host1 host2"
jail_host1_hostname="host1.mydomain.com"
jail_host1_ip="192.168.6.1"
jail_host2_hostname="host2.mydomain.com"
jail_host2_ip="192.168.6.2"
after expanding:
jail_host1_rootdir="/data/jails/192.168.6.1" # TEMPLATE 0
#jail_host1_rootdir="/data/jails/host1.mydomain.com" # TEMPLATE 1
#jail_host1_rootdir="/data/jails/host1" # TEMPLATE 2
>Fix:
Note that this patch is efficient enough, because global template
$jail_rootdir is applied only if relevant $jail_<JID>_rootdir is missed.
--- jail.orig Fri Jun 9 20:04:50 2006
+++ jail Mon Jun 12 15:11:32 2006
@@ -27,12 +27,28 @@
return
fi
+ eval _hostname=\"\$jail_${_j}_hostname\"
+ if [ -z "${_hostname}" ]; then
+ err 3 "$name: No hostname has been defined for ${_j}"
+ fi
+
+ eval _ip=\"\$jail_${_j}_ip\"
+ if [ -z "${_ip}" ]; then
+ err 3 "$name: No IP address has been defined for ${_j}"
+ fi
+
eval _rootdir=\"\$jail_${_j}_rootdir\"
+ if [ -z "${_rootdir}" ]; then
+ if [ -z "${jail_rootdir}" ]; then
+ err 3 "$name: No root directory has been defined for ${_j}"
+ fi
+ _rootdir=$(echo "${jail_rootdir}" |
+ sed -e "s=%%JAIL_ID%%=${_j}=;s=%%JAIL_IP%%=${_ip}=;s=%%JAIL_HOSTNAME%%=${_hostname}=")
+ fi
+
_devdir="${_rootdir}/dev"
_fdescdir="${_devdir}/fd"
_procdir="${_rootdir}/proc"
- eval _hostname=\"\$jail_${_j}_hostname\"
- eval _ip=\"\$jail_${_j}_ip\"
eval _interface=\"\${jail_${_j}_interface:-${jail_interface}}\"
eval _exec=\"\$jail_${_j}_exec\"
eval _exec_start=\"\${jail_${_j}_exec_start:-${jail_exec_start}}\"
@@ -86,16 +102,6 @@
debug "$_j exec start: $_exec_start"
debug "$_j exec stop: $_exec_stop"
debug "$_j flags: $_flags"
-
- if [ -z "${_hostname}" ]; then
- err 3 "$name: No hostname has been defined for ${_j}"
- fi
- if [ -z "${_rootdir}" ]; then
- err 3 "$name: No root directory has been defined for ${_j}"
- fi
- if [ -z "${_ip}" ]; then
- err 3 "$name: No IP address has been defined for ${_j}"
- fi
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list