From rick@wzoeterwoude.net  Fri Jun  9 03:03:51 2006
Return-Path: <rick@wzoeterwoude.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A665916A41B
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  9 Jun 2006 03:03:51 +0000 (UTC)
	(envelope-from rick@wzoeterwoude.net)
Received: from smtp-vbr12.xs4all.nl (smtp-vbr12.xs4all.nl [194.109.24.32])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7F1BB43D8D
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  9 Jun 2006 03:03:49 +0000 (GMT)
	(envelope-from rick@wzoeterwoude.net)
Received: from traffie.wzoeterwoude.net (rvdzwet.xs4all.nl [213.84.99.45])
	by smtp-vbr12.xs4all.nl (8.13.6/8.13.6) with ESMTP id k5933f0S038174
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 9 Jun 2006 05:03:49 +0200 (CEST)
	(envelope-from rick@wzoeterwoude.net)
Received: (qmail 98306 invoked by uid 98); 9 Jun 2006 03:03:38 -0000
Received: from 192.168.0.19 by traffie.wzoeterwoude.net (envelope-from <rick@wzoeterwoude.net>, uid 82) with qmail-scanner-1.25 
 (spamassassin: 3.1.1.  
 Clear:RC:1(192.168.0.19):. 
 Processed in 0.537998 secs); 09 Jun 2006 03:03:38 -0000
Received: from unknown (HELO ?192.168.0.19?) (rick@192.168.0.19)
  by traffie.wzoeterwoude.net with SMTP; 9 Jun 2006 03:03:35 -0000
Message-Id: <4488E509.4020606@wzoeterwoude.net>
Date: Fri, 09 Jun 2006 05:03:37 +0200
From: Rick van der Zwet <rick@wzoeterwoude.net>
Reply-To: Rick van der Zwet <rick@wzoeterwoude.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: rick@wzoeterwoude.net
Subject: [Patch] /etc/rc.subr restart_postcmd is failing start_postcmd executed
 instead

>Number:         98734
>Category:       conf
>Synopsis:       [patch] /etc/rc.subr restart_postcmd is failing start_postcmd executed instead
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 09 03:10:24 GMT 2006
>Closed-Date:    Fri Aug 17 12:03:00 GMT 2007
>Last-Modified:  Fri Aug 17 12:10:03 GMT 2007
>Originator:     Rick van der Zwet
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
Stichting Wireless Leiden
>Environment:
System: FreeBSD freezone-mobile 6.1-STABLE FreeBSD 6.1-STABLE #8: Wed 
Jun 7 00:37:44 CEST 2006 
root@freezone-mobile:/usr/obj/usr/src/sys/SONY_VAIO i386


	
>Description:
     instead of excecuting restart_postcmd it issues start_postcmd again
>How-To-Repeat:
create foe.sh
. /etc/rc.subr
name='foe'
foe_enable="yes"
rcvar=`set_rcvar`
start_postcmd="echo 'foo'"
restart_postcmd="echo 'bar'"
run_rc_command "$1"

execute  sh foe.sh restart, output will be
foo
foo
>Fix:

	

--- rc.subr.diff begins here ---
--- rc.subr.orig	Fri Jun  9 04:50:16 2006
+++ rc.subr	Fri Jun  9 04:50:36 2006
@@ -776,7 +776,7 @@

  			# run stop in a subshell to keep variables for start
  			( run_rc_command ${_rc_prefix}stop $rc_extra_args )
-			run_rc_command ${_rc_prefix}start $rc_extra_args
+			( run_rc_command ${_rc_prefix}start $rc_extra_args )

  			if [ -n "$_postcmd" ]; then
  				eval $_postcmd $rc_extra_args
--- rc.subr.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Jun 9 03:14:21 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98734 
State-Changed-From-To: open->analyzed 
State-Changed-By: yar 
State-Changed-When: Wed Dec 27 11:02:22 UTC 2006 
State-Changed-Why:  
I've fixed this issue in my p4 branch where I hack rc.d. 
I will merge it to the project's main source tree RSN 
along with my other fixes to the processing of precmd 
and postcmd by rc.subr. 

Thank you for spotting this bug! 


Responsible-Changed-From-To: freebsd-rc->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Wed Dec 27 11:02:22 UTC 2006 
Responsible-Changed-Why:  
I've fixed this issue in my p4 branch where I hack rc.d. 
I will merge it to the project's main source tree RSN 
along with my other fixes to the processing of precmd 
and postcmd by rc.subr. 

Thank you for spotting this bug! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/98734: commit references a PR
Date: Wed, 27 Dec 2006 13:15:52 +0000 (UTC)

 yar         2006-12-27 13:15:34 UTC
 
   FreeBSD src repository
 
   Modified files:
     etc                  rc.subr 
   Log:
   MFp4:
   
   Implement the checks for required_* objects as two functions, one
   to be run before precmd and the other after it.  They get the current
   rc command as an argument so they can choose what requirement tests
   to perform.  As of now, only "start" needs such tests.
   
   Implement a new requirement variable, required_modules.  It can
   list kernel modules that need to be loaded after start_precmd
   indicated success.  Each name in the list can be just "file", or
   "file:module", or "file~regex".  This will allow us to remove a lot
   of duplicated code from rc.d scripts.
   
   Perform the checks not only for the default start method, but for
   any method.  This allows for more flexibility and fixes a few rc.d
   scripts (namely newsyslog, pf, sendmail) that rely on a required_*
   variable while providing a non-default start method.
   
   To be able to call the new check_required* functions naturally,
   remove lots of crufty duplicated code pieces from run_rc_command
   and replace each of them by a call to the helper function providing
   a single corrected instance of the respective code snippet.  Now
   run_rc_command isn't as scary as it used to be, and it even appears
   to have quite a nice logic that was obscured by the old crufty code.
   
   In the default handler for restart, run start from a subshell to
   protect global varibles, e.g., _postcmd, from modification by the
   start handler.  This enables using restart_postcmd. [x]
   
   PR:             conf/98734 [x]
   Submitted by:   Rick van der Zwet <rick@wzoeterwoude.net> [x]
   Reviewed by:    freebsd-rc (silence for an older version)
   MFC after:      1 month
   
   Revision  Changes    Path
   1.72      +198 -146  src/etc/rc.subr
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: yar 
State-Changed-When: Wed Dec 27 13:25:02 UTC 2006 
State-Changed-Why:  
Fixed in CURRENT, MFC is due.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98734 
State-Changed-From-To: patched->closed 
State-Changed-By: yar 
State-Changed-When: Fri Aug 17 12:02:16 UTC 2007 
State-Changed-Why:  
The fix has been merged to 6-STABLE.  Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/98734: commit references a PR
Date: Fri, 17 Aug 2007 12:00:42 +0000 (UTC)

 yar         2007-08-17 12:00:33 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     etc                  rc.subr 
     share/man/man8       rc.subr.8 
   Log:
   MFC:
   
           src/etc/rc.subr                 1.72
           src/share/man/man8/rc.subr.8    1.17
   
   Eliminate a number of inconsistencies in handling pre- and post-commands
   as well as required_* conditions.  Introduce required_modules.
   
   PR:     conf/98734
   
   Revision   Changes    Path
   1.34.2.22  +198 -146  src/etc/rc.subr
   1.6.8.8    +32 -4     src/share/man/man8/rc.subr.8
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
