diff options
author | hrs <hrs@FreeBSD.org> | 2013-10-21 08:49:46 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2013-10-21 08:49:46 +0000 |
commit | 101264b729f3abbf30c2a44a669b20a693c6d80f (patch) | |
tree | 0dde5d2e0d5cb0f7702cdfb4eb155fef6be9edfe /etc/rc.d/jail | |
parent | 9b3dfbc2507b9298fdb6550a8ea699a898717234 (diff) | |
download | FreeBSD-src-101264b729f3abbf30c2a44a669b20a693c6d80f.zip FreeBSD-src-101264b729f3abbf30c2a44a669b20a693c6d80f.tar.gz |
- Fix jail_parallel_start="YES".
- Fix ip[46].addr when interface parameter is not defined.
Spotted by: rpaulo
Diffstat (limited to 'etc/rc.d/jail')
-rwxr-xr-x | etc/rc.d/jail | 86 |
1 files changed, 60 insertions, 26 deletions
diff --git a/etc/rc.d/jail b/etc/rc.d/jail index e2ee380..fb91aaf 100755 --- a/etc/rc.d/jail +++ b/etc/rc.d/jail @@ -132,7 +132,9 @@ parse_options() # _confwarn=1 if [ -r "$jail_conf" -o -r "$_jconf" ]; then - warn "$_conf is created and used for jail $_j." + if ! checkyesno jail_parallel_start; then + warn "$_conf is created and used for jail $_j." + fi fi /usr/bin/install -m 0644 -o root -g wheel /dev/null $_conf || return 1 @@ -367,10 +369,10 @@ jail_handle_ips_option() # Append address to list of addresses for the jail command. case $_type in inet) - echo " ip4.addr += \"${_iface}|${_addr}${_mask}\";" + echo " ip4.addr += \"${_iface:+${_iface}|}${_addr}${_mask}\";" ;; inet6) - echo " ip6.addr += \"${_iface}|${_addr}${_mask}\";" + echo " ip6.addr += \"${_iface:+${_iface}|}${_addr}${_mask}\";" need_dad_wait=1 ;; esac @@ -418,7 +420,7 @@ jail_status() jail_start() { - local _j _jid _jn + local _j _jid _jn _jl if [ $# = 0 ]; then return @@ -446,30 +448,62 @@ jail_start() return ;; esac - for _j in $@; do - _j=$(echo $_j | tr /. _) - parse_options $_j || continue - - eval rc_flags=\${jail_${_j}_flags:-$jail_flags} - eval command=\${jail_${_j}_program:-$jail_program} - if checkyesno jail_parallel_start; then - command_args="-i -f $_conf -c $_j &" - else + if checkyesno jail_parallel_start; then + # + # Start jails in parallel and then check jail id when + # jail_parallel_start is YES. + # + _jl= + for _j in $@; do + _j=$(echo $_j | tr /. _) + parse_options $_j || continue + + _jl="$_jl $_j" + eval rc_flags=\${jail_${_j}_flags:-$jail_flags} + eval command=\${jail_${_j}_program:-$jail_program} command_args="-i -f $_conf -c $_j" - fi - _tmp=`mktemp -t jail` || exit 3 - if $command $rc_flags $command_args \ - >> $_tmp 2>&1 </dev/null; then + $command $rc_flags $command_args \ + >/dev/null 2>&1 </dev/null & + done + sleep 1 + for _j in $_jl; do echo -n " ${_hostname:-${_j}}" - _jid=$($jail_jls -n -j $_j | tr " " "\n" | grep ^jid=) - echo "${_jid#jid=}" > /var/run/jail_${_j}.id - else - rm -f /var/run/jail_${_j}.id - echo " cannot start jail \"${_hostname:-${_j}}\": " - cat $_tmp - fi - rm -f $_tmp - done + if _jid=$($jail_jls -n -j $_j | tr " " "\n" | \ + grep ^jid=); then + echo "${_jid#jid=}" > /var/run/jail_${_j}.id + else + rm -f /var/run/jail_${_j}.id + echo " cannot start jail " \ + "\"${_hostname:-${_j}}\": " + fi + done + else + # + # Start jails one-by-one when jail_parallel_start is NO. + # + for _j in $@; do + _j=$(echo $_j | tr /. _) + parse_options $_j || continue + + eval rc_flags=\${jail_${_j}_flags:-$jail_flags} + eval command=\${jail_${_j}_program:-$jail_program} + command_args="-i -f $_conf -c $_j" + _tmp=`mktemp -t jail` || exit 3 + if $command $rc_flags $command_args \ + >> $_tmp 2>&1 </dev/null; then + echo -n " ${_hostname:-${_j}}" + _jid=$($jail_jls -n -j $_j | \ + tr " " "\n" | grep ^jid=) + echo "${_jid#jid=}" > /var/run/jail_${_j}.id + else + rm -f /var/run/jail_${_j}.id + echo " cannot start jail " \ + "\"${_hostname:-${_j}}\": " + cat $_tmp + fi + rm -f $_tmp + done + fi echo '.' } |