From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 13 13:20:05 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 952BB16A420 for ; Mon, 13 Feb 2006 13:20:05 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 821C943D55 for ; Mon, 13 Feb 2006 13:20:04 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k1DDK40i080483 for ; Mon, 13 Feb 2006 13:20:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k1DDK44O080482; Mon, 13 Feb 2006 13:20:04 GMT (envelope-from gnats) Resent-Date: Mon, 13 Feb 2006 13:20:04 GMT Resent-Message-Id: <200602131320.k1DDK44O080482@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Anders Nordby Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CFAC016A420 for ; Mon, 13 Feb 2006 13:16:27 +0000 (GMT) (envelope-from anders@totem.fix.no) Received: from totem.fix.no (totem.fix.no [80.91.36.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5696343D55 for ; Mon, 13 Feb 2006 13:16:27 +0000 (GMT) (envelope-from anders@totem.fix.no) Received: by totem.fix.no (Postfix, from userid 1000) id 3D5438DB14E; Mon, 13 Feb 2006 14:16:21 +0100 (CET) Message-Id: <20060213131621.3D5438DB14E@totem.fix.no> Date: Mon, 13 Feb 2006 14:16:21 +0100 (CET) From: Anders Nordby To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: conf/93287: Make rc.subr jail-aware X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Anders Nordby List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Feb 2006 13:20:05 -0000 >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@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: