mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
rc.subr: svcj - run a service's own restart and status methods in its jail
A script that defines non-default restart_cmd or status_cmd should
execute them in the service jail. Where there is no jail to enter,
restart starts the service instead of failing.
Fixes: 2efbd480f1 rc: add service jails framework
MFC after: 1 week
MFC to: stable/15
Assisted-by: Claude Code (Opus 5)
This commit is contained in:
1 file changed
+17
-1
+17
-1
@@ -1429,7 +1429,23 @@ run_rc_command()
|
||||
_run_rc_doit "$_cmd $rc_extra_args" || _return=1
|
||||
fi
|
||||
;;
|
||||
restart|status) ;; # no special case needed for svcj or handled somewhere else
|
||||
restart)
|
||||
if [ "${_rc_svcj}" = jailing ]; then
|
||||
_run_rc_doit "$_cmd $rc_extra_args" || _return=1
|
||||
elif /usr/sbin/jls -j svcj-${name} jid >/dev/null 2>&1; then
|
||||
$SERVICE -E _rc_svcj=jailing -j svcj-${name} ${rc_service##*/} ${_rc_prefix}restart $rc_extra_args || _return=1
|
||||
else
|
||||
# nothing to restart, so start it
|
||||
( run_rc_command ${_rc_prefix}start $rc_extra_args ) || _return=1
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
if [ "${_rc_svcj}" != jailing ]; then
|
||||
$SERVICE -E _rc_svcj=jailing -j svcj-${name} ${rc_service##*/} ${_rc_prefix}status $rc_extra_args || _return=1
|
||||
else
|
||||
_run_rc_doit "$_cmd $rc_extra_args" || _return=1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
eval _rc_svcj_extra_cmd=\$${name}_${rc_arg}_svcj_enable
|
||||
: ${_rc_svcj_extra_cmd:=NO}
|
||||
|
||||
Reference in new issue
Block a user