conf/93287: Make rc.subr jail-aware
Anders Nordby
anders at FreeBSD.org
Mon Feb 13 05:20:05 PST 2006
>Number: 93287
>Category: conf
>Synopsis: Make rc.subr jail-aware
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Feb 13 13:20:03 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Anders Nordby
>Release: FreeBSD 6.0-RELEASE i386
>Organization:
-
>Environment:
System: FreeBSD totem.fix.no 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Mon Nov 21 01:52:03 UTC 2005 root at master.fupp.net:/usr/obj/usr/src/sys/MASTER i386
>Description:
Starting and stopping of daemons without pid files in rc.subr is broken
when using jails. Trying to start a daemon in main OS (jid=0) fails if it
is already running a jail, and trying to stop it makes daemons with the
same process name die in all the jails.
>How-To-Repeat:
Install ports/net-mgmt/nrpe and/or any other port that uses rc.subr/rc_NG
for stopping and starting daemons that has no pid file. Start and stop
the daemon in jails and outside jail, running them at the same time.
>Fix:
Make rc.subr check that the process it looks for runs in the same jid. Patch
applies to 6.0-RELEASE and -CURRENT. Let me know if the patch should be
improved.
It would be a possibility to just check if jid=0. Inside the jail jid is
also 0 for all processes there, but that means we have to rely on that.
--- rc.subr.orig Thu Nov 3 09:12:06 2005
+++ rc.subr Mon Jan 9 13:40:17 2006
@@ -52,6 +52,7 @@
CMD_OSTYPE="${SYSCTL_N} kern.ostype"
OSTYPE=`${CMD_OSTYPE}`
ID="/usr/bin/id"
+JID=`ps -p $$ -o jid | tail -1 | tr -d ' '`
IDCMD="if [ -x $ID ]; then $ID -un; fi"
case ${OSTYPE} in
@@ -271,14 +272,16 @@
fi
_proccheck='
- ps 2>/dev/null -o "pid,command" '"$_psargs"' |
- while read _npid '"$_fp_args"'; do
+ ps 2>/dev/null -o "pid,jid,command" '"$_psargs"' |
+ while read _npid _jid '"$_fp_args"'; do
case "$_npid" in
PID)
continue;;
esac; '"$_fp_match"'
- echo -n "$_pref$_npid";
- _pref=" "
+ if [ "$JID" -eq "$_jid" ];
+ then echo -n "$_pref$_npid";
+ _pref=" ";
+ fi
;;
esac
done'
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list