From nobody@FreeBSD.org  Thu May  4 11:48:03 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 668D916A400
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  4 May 2006 11:48:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3299D43D45
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  4 May 2006 11:48:03 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k44Bm25k016527
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 4 May 2006 11:48:02 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k44Bm221016526;
	Thu, 4 May 2006 11:48:02 GMT
	(envelope-from nobody)
Message-Id: <200605041148.k44Bm221016526@www.freebsd.org>
Date: Thu, 4 May 2006 11:48:02 GMT
From: Richard Brooksby <rb@ravenbrook.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: run_rc_command doesn't work for Python scripts
X-Send-Pr-Version: www-2.3

>Number:         96766
>Category:       conf
>Synopsis:       run_rc_command doesn't work for Python scripts
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 04 11:50:16 GMT 2006
>Closed-Date:    Wed Dec 27 11:31:17 GMT 2006
>Last-Modified:  Wed Dec 27 11:31:17 GMT 2006
>Originator:     Richard Brooksby
>Release:        6.0-RELEASE-p6
>Organization:
Ravenbrook Limited <http://www.ravenbrook.com/>
>Environment:
FreeBSD raven.ravenbrook.com 6.0-RELEASE-p6 FreeBSD 6.0-RELEASE-p6 #0: Tue Apr 11 13:52:12 BST 2006     root@coot.verity-networks.com:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
The run_rc_command from /etc/rc.subr is intended to lift out the repetetive
parts of starting and stopping system daemons.  However, it fails to work on
Python scripted daemons which start with the usual #! line:

  #!/usr/bin/env python

Although it will start a daemon, it can't stop, restart, or report its
status.  This gives failures like:

  raven# sh /usr/local/etc/rc.d/py-spamass-milter.sh status
  py_spamass_milter is not running.

even though

  raven# ps -p `cat /var/run/spamd/py-spamass-milter.pid`
    PID  TT  STAT      TIME COMMAND
  75992  ??  Ss     1:55.69 python /usr/local/sbin/py-spamass-milter -p /var/run/spamd/py-spamass-milter.sock

Setting the "interpreter" variable before calling run_rc_command doesn't
help.  I think the run_rc_command function might be assuming that the
interpreter will appear immediately after the #! in the script itself.
This won't just affect Python: there are other systems which use "env"
in the same way.
>How-To-Repeat:
Create a simple daemon in a Python executable script, and a corresponding
file in /usr/local/etc/rc.d, then try to stop or restart the daemon.
>Fix:
The rc_command function does a lot of work to make sure it's not going to
kill the wrong process, but its assumptions about what will come out of
"ps" are wrong, and probably too paranoid?  Perhaps a simpler check would
be fine.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu May 4 13:41:37 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96766 
State-Changed-From-To: open->closed 
State-Changed-By: yar 
State-Changed-When: Wed Dec 27 11:29:04 UTC 2006 
State-Changed-Why:  
PR bin/100287 describes the same problem in more general terms 
as it isn't specific to Python scripts.  Please move the activity 
regarding this issue to PR bin/100287. 


Responsible-Changed-From-To: freebsd-rc->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Wed Dec 27 11:29:04 UTC 2006 
Responsible-Changed-Why:  
So I can see feedback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96766 
>Unformatted:
