From eugen@grosbein.pp.ru  Fri Apr 15 18:12:43 2011
Return-Path: <eugen@grosbein.pp.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C08C0106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Apr 2011 18:12:43 +0000 (UTC)
	(envelope-from eugen@grosbein.pp.ru)
Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [62.231.161.221])
	by mx1.freebsd.org (Postfix) with ESMTP id 2FF0C8FC1C
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Apr 2011 18:12:42 +0000 (UTC)
Received: from grosbein.pp.ru (188-123-32-240.rdtc.ru [188.123.32.240] (may be forged))
	by eg.sd.rdtc.ru (8.14.4/8.14.4) with ESMTP id p3FICe15016751;
	Sat, 16 Apr 2011 01:12:40 +0700 (NOVST)
	(envelope-from eugen@grosbein.pp.ru)
Received: from grosbein.pp.ru (localhost [127.0.0.1])
	by grosbein.pp.ru (8.14.4/8.14.4) with ESMTP id p3FIBOns002960;
	Sat, 16 Apr 2011 01:11:24 +0700 (NOVST)
	(envelope-from eugen@grosbein.pp.ru)
Received: (from eugen@localhost)
	by grosbein.pp.ru (8.14.4/8.14.4/Submit) id p3FIBOgd002959;
	Sat, 16 Apr 2011 01:11:24 +0700 (NOVST)
	(envelope-from eugen)
Message-Id: <201104151811.p3FIBOgd002959@grosbein.pp.ru>
Date: Sat, 16 Apr 2011 01:11:24 +0700 (NOVST)
From: Eugene Grosbein <eugen@grosbein.pp.ru>
Reply-To: Eugene Grosbein <eugen@grosbein.pp.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: dougb@freebsd.org
Subject: rcNG may start disabled service
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         156427
>Category:       conf
>Synopsis:       rc.d may start disabled service
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 15 18:20:08 UTC 2011
>Closed-Date:    Fri Apr 22 23:46:42 UTC 2011
>Last-Modified:  Fri Apr 22 23:46:42 UTC 2011
>Originator:     Eugene Grosbein
>Release:        FreeBSD 8.2-STABLE i386
>Organization:
RDTC JSC
>Environment:
System: FreeBSD grosbein.pp.ru 8.2-STABLE FreeBSD 8.2-STABLE #21: Sat Apr 9 16:26:00 NOVST 2011 root@grosbein.pp.ru:/usr/local/obj/usr/local/src/sys/DADV i386

>Description:

	For some services I prefer using service_enable="NO" in /etc/rc.conf
	and start them by other means when needed using "forcestart" feature.

	SVN r206686 and MFC r207797 broke this: now rc.subr at boot time
	starts disabled service if it is already started by other means
	($rc_pid is not empty).

	So, the service sometimes get started twice that's not good for me.

>How-To-Repeat:

	1. Disable any installed service using servicename="NO" in /etc/rc.conf
	2. Run it at boot time by another script (I need service be started
	   or not depending on results of some local tests).
	3. See it's started twice.

>Fix:

	Mentioned change occured to make 'stop' work even if ${name}_enable
	is not set. The code should check whether it's started to 'stop'.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: dougb 
State-Changed-When: Fri Apr 15 19:34:05 UTC 2011 
State-Changed-Why:  

Can you please give some examples of services that exhibit this problem? 
Also, can you provide the local code that you are using to start them? 


Thanks, 

Doug 


Responsible-Changed-From-To: freebsd-bugs->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Fri Apr 15 19:34:05 UTC 2011 
Responsible-Changed-Why:  

I committed the original change. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156427 
State-Changed-From-To: feedback->analyzed 
State-Changed-By: dougb 
State-Changed-When: Sat Apr 16 01:05:51 UTC 2011 
State-Changed-Why:  

I was able to reproduce the error, please try the following patch: 


Index: rc.subr 
=================================================================== 
--- rc.subr	(revision 220684) 
+++ rc.subr	(working copy) 
@@ -651,7 +651,8 @@ 
#	checkyesno ${rcvar} 
# and return if that failed 
# 
-		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a -z "${rc_pid}" ]; then 
+		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != "stop" ] || 
+		    [ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then 
if ! checkyesno ${rcvar}; then 
if [ -n "${rc_quiet}" ]; then 
return 0 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156427 

From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: bug-followup@FreeBSD.ORG
Cc:  
Subject: Re: misc/156427: rc.d may start disabled service
Date: Sun, 17 Apr 2011 16:29:36 +0700

 On 16.04.2011 08:07, dougb@FreeBSD.org wrote:
 > Synopsis: rc.d may start disabled service
 > 
 > State-Changed-From-To: feedback->analyzed
 > State-Changed-By: dougb
 > State-Changed-When: Sat Apr 16 01:05:51 UTC 2011
 > State-Changed-Why: 
 > 
 > I was able to reproduce the error, please try the following patch:
 > 
 > 
 > Index: rc.subr
 > ===================================================================
 > --- rc.subr	(revision 220684)
 > +++ rc.subr	(working copy)
 > @@ -651,7 +651,8 @@
 >  					#	checkyesno ${rcvar}
 >  					# and return if that failed
 >  					#
 > -		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a -z "${rc_pid}" ]; then
 > +		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != "stop" ] ||
 > +		    [ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
 >  			if ! checkyesno ${rcvar}; then
 >  				if [ -n "${rc_quiet}" ]; then
 >  					return 0
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=156427
 > 
 > 
 
 I've just tested it and it really helps, thanks!
 Please commit.
State-Changed-From-To: analyzed->patched 
State-Changed-By: dougb 
State-Changed-When: Sun Apr 17 22:35:54 UTC 2011 
State-Changed-Why:  

Originator confirms that the patch worked. I've committed it to HEAD, 
will MFC after it's had a chance to settle in. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156427 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/156427: commit references a PR
Date: Sun, 17 Apr 2011 22:31:49 +0000 (UTC)

 Author: dougb
 Date: Sun Apr 17 22:31:36 2011
 New Revision: 220760
 URL: http://svn.freebsd.org/changeset/base/220760
 
 Log:
   The change in r206686 to allow the stop argument to work for a service
   that is running even though not _enable'd had an annoying side effect.
   If the service was already started at boot time by another means when
   the related script came around again in rcorder it would start again,
   regardless of _enable, because there was a valid pid. [1]
   
   So, split the test into 2 parts, one for (!rcvar && !stop), and one
   for (stop && !valid_pid). This preserves the behavior from r206686
   while preventing the undesired side effect.
   
   PR:		conf/156427 [1]
   Submitted by:	Eugene Grosbein <eugen@grosbein.pp.ru> [1]
 
 Modified:
   head/etc/rc.subr
 
 Modified: head/etc/rc.subr
 ==============================================================================
 --- head/etc/rc.subr	Sun Apr 17 22:26:07 2011	(r220759)
 +++ head/etc/rc.subr	Sun Apr 17 22:31:36 2011	(r220760)
 @@ -651,7 +651,8 @@ run_rc_command()
  					#	checkyesno ${rcvar}
  					# and return if that failed
  					#
 -		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a -z "${rc_pid}" ]; then
 +		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != "stop" ] ||
 +		    [ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
  			if ! checkyesno ${rcvar}; then
  				if [ -n "${rc_quiet}" ]; then
  					return 0
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: dougb 
State-Changed-When: Fri Apr 22 23:46:11 UTC 2011 
State-Changed-Why:  

The change has now been MFC'ed to RELENG_[78]. 

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