summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/jail
diff options
context:
space:
mode:
authorflz <flz@FreeBSD.org>2006-04-08 12:15:36 +0000
committerflz <flz@FreeBSD.org>2006-04-08 12:15:36 +0000
commit04498a993a54742b6f15cf278d3443b6cf425f7f (patch)
tree8ee12c4f7de73720768f2ccd66d16e7639f450fc /etc/rc.d/jail
parent721f0cd723063a28d3c5cdc66000001230d799cd (diff)
downloadFreeBSD-src-04498a993a54742b6f15cf278d3443b6cf425f7f.zip
FreeBSD-src-04498a993a54742b6f15cf278d3443b6cf425f7f.tar.gz
- Add following global jail options, used if no jail-specific options are
set: * jail_mount_enable * jail_devfs_ruleset * jail_devfs_enable * jail_fdescfs_enable * jail_procfs_enable * jail_fstab * jail_flags - Add a jail_interface / jail_<jid>_interface option. An ip alias will be created (jail_<jid>_ip) on jail_interface or jail_<jid>_interface if set. This is not a mandatory option. - Document all missing jail_* options in rc.conf(5). Approved by: cperciva (mentor) MFC after: 2 weeks
Diffstat (limited to 'etc/rc.d/jail')
-rw-r--r--etc/rc.d/jail26
1 files changed, 17 insertions, 9 deletions
diff --git a/etc/rc.d/jail b/etc/rc.d/jail
index b4b051f..0edf078 100644
--- a/etc/rc.d/jail
+++ b/etc/rc.d/jail
@@ -33,9 +33,10 @@ init_variables()
jail_procdir="${jail_rootdir}/proc"
eval jail_hostname=\"\$jail_${_j}_hostname\"
eval jail_ip=\"\$jail_${_j}_ip\"
+ eval jail_interface=\"\${jail_${_j}_interface:-${jail_interface}}\"
eval jail_exec=\"\$jail_${_j}_exec\"
- eval jail_exec_start=\"\$jail_${_j}_exec_start\"
- eval jail_exec_stop=\"\$jail_${_j}_exec_stop\"
+ eval jail_exec_start=\"\${jail_${_j}_exec_start:-${jail_exec_start}}\"
+ eval jail_exec_stop=\"\${jail_${_j}_exec_stop:-${jail_exec_stop}}\"
if [ -n "${jail_exec}" ]; then
# simple/backward-compatible execution
jail_exec_start="${jail_exec}"
@@ -51,20 +52,20 @@ init_variables()
fi
# The default jail ruleset will be used by rc.subr if none is specified.
- eval jail_ruleset=\"\$jail_${_j}_devfs_ruleset\"
- eval jail_devfs=\"\$jail_${_j}_devfs_enable\"
+ eval jail_ruleset=\"\${jail_${_j}_devfs_ruleset:-${jail_devfs_ruleset}}\"
+ eval jail_devfs=\"\${jail_${_j}_devfs_enable:-${jail_devfs_enable}}\"
[ -z "${jail_devfs}" ] && jail_devfs="NO"
- eval jail_fdescfs=\"\$jail_${_j}_fdescfs_enable\"
+ eval jail_fdescfs=\"\${jail_${_j}_fdescfs_enable:-${jail_fdescfs_enable}}\"
[ -z "${jail_fdescfs}" ] && jail_fdescfs="NO"
- eval jail_procfs=\"\$jail_${_j}_procfs_enable\"
+ eval jail_procfs=\"\${jail_${_j}_procfs_enable:-${jail_procfs_enable}}\"
[ -z "${jail_procfs}" ] && jail_procfs="NO"
- eval jail_mount=\"\$jail_${_j}_mount_enable\"
+ eval jail_mount=\"\${jail_${_j}_mount_enable:-${jail_mount_enable}}\"
[ -z "${jail_mount}" ] && jail_mount="NO"
# "/etc/fstab.${_j}" will be used for {,u}mount(8) if none is specified.
- eval jail_fstab=\"\$jail_${_j}_fstab\"
+ eval jail_fstab=\"\${jail_${_j}_fstab:-${jail_fstab}}\"
[ -z "${jail_fstab}" ] && jail_fstab="/etc/fstab.${_j}"
- eval jail_flags=\"\$jail_${_j}_flags\"
+ eval jail_flags=\"\${jail_${_j}_flags:-${jail_flags}}\"
[ -z "${jail_flags}" ] && jail_flags="-l -U root"
# Debugging aid
@@ -75,6 +76,7 @@ init_variables()
debug "$_j mount enable: $jail_mount"
debug "$_j hostname: $jail_hostname"
debug "$_j ip: $jail_ip"
+ debug "$_j interface: $jail_interface"
debug "$_j root: $jail_rootdir"
debug "$_j devdir: $jail_devdir"
debug "$_j fdescdir: $jail_fdescdir"
@@ -162,6 +164,9 @@ jail_start()
echo -n " [${jail_hostname} already running (/var/run/jail_${_jail}.id exists)]"
continue;
fi
+ if [ -n ${jail_interface} ]; then
+ ifconfig ${jail_interface} alias ${jail_ip} netmask 255.255.255.255
+ fi
if checkyesno jail_mount; then
info "Mounting fstab for jail ${_jail} (${jail_fstab})"
if [ ! -f "${jail_fstab}" ]; then
@@ -234,6 +239,9 @@ jail_stop()
jail_umount_fs
echo -n " $jail_hostname"
fi
+ if [ -n ${jail_interface} ]; then
+ ifconfig ${jail_interface} -alias ${jail_ip}
+ fi
rm /var/run/jail_${_jail}.id
else
echo "cannot stop jail ${_jail}. No jail id in /var/run"
OpenPOWER on IntegriCloud