The branch stable/15 has been updated by netchild:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f74c4cb8a2eda2c1cc4d3946571e417638447b1a

commit f74c4cb8a2eda2c1cc4d3946571e417638447b1a
Author:     Alexander Leidinger <[email protected]>
AuthorDate: 2026-08-30 09:44:58 +0000
Commit:     Alexander Leidinger <[email protected]>
CommitDate: 2026-09-06 09:58:46 +0000

    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:                  2efbd480f1d3 rc: add service jails framework
    MFC after:              1 week
    MFC to:                 stable/15
    Assisted-by:    Claude Code (Opus 5)
    
    (cherry picked from commit 327dae5081059eb97af0cf319a444b3937ff4db2)
---
 libexec/rc/rc.subr | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index b84d5393bc3f..5bcd104a9cd1 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -1419,7 +1419,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}

Reply via email to