diff options
-rw-r--r-- | etc/defaults/rc.conf | 2 | ||||
-rw-r--r-- | etc/rc.d/jail | 37 |
2 files changed, 25 insertions, 14 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index dd60fe3..c1b9b7c 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -455,8 +455,6 @@ 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 jail_sysvipc_allow="NO" # Allow SystemV IPC use from within a jail -jail_stop_jailer="NO" # Only stop jailer. Requires jail_*_exec be set - # to use sysutils/jailer port to start the jail. # # To use rc's built-in jail infrastructure create entries for diff --git a/etc/rc.d/jail b/etc/rc.d/jail index 019e148..6de0071 100644 --- a/etc/rc.d/jail +++ b/etc/rc.d/jail @@ -124,25 +124,37 @@ jail_start() mount -t procfs proc "${jail_procdir}" fi fi - jail 1>${jail_rootdir}/var/log/console.log 2>&1 \ - ${jail_rootdir} ${jail_hostname} ${jail_ip} ${jail_exec} + _tmp_jail=/tmp/jail.$$ + jail -i ${jail_rootdir} ${jail_hostname} \ + ${jail_ip} ${jail_exec} > ${_tmp_jail} 2>&1 [ "$?" -eq 0 ] && echo -n " $jail_hostname" + _jail_id=$(head -1 ${_tmp_jail}) + tail +2 ${_tmp_jail} >${jail_rootdir}/var/log/console.log + rm -f ${_tmp_jail} + echo ${_jail_id} > /var/run/jail_${_jail}.id done echo '.' } jail_stop() { - echo 'Stopping all jails.' - if checkyesno jail_stop_jailer; then - rc_pid=$(ps aux | grep "jailer" | awk '$8 ~ /.*J/ {print $2};') - else - rc_pid=$(ps aux | awk '$8 ~ /.*J/ {print $2};') - fi - if [ -n "${rc_pid}" ]; then - kill -TERM $rc_pid - wait_for_pids $rc_pid - fi + echo 'Stopping jails.' + for _jail in ${jail_list} + do + if [ -f /var/run/jail_${_jail}.id ]; then + _jail_id=$(cat /var/run/jail_${_jail}.id) + if [ ! -z ${_jail_id} ]; then + killall -j ${_jail_id} -TERM > /dev/null 2>&1 + fi + rm /var/run/jail_${_jail}.id + else + echo "cannot stop jail ${_jail}. no jail id saved in /var/run" + jail_list=$(echo ${jail_list} | \ + tr ' ' '\n' | \ + grep -v "^${_jail}$" | \ + tr '\n' ' ') + fi + done for _jail in ${jail_list} do init_variables $_jail @@ -165,5 +177,6 @@ jail_stop() } +[ -n "$2" ] && jail_list="$2" load_rc_config $name run_rc_command "$1" |