From nobody@FreeBSD.org  Sun Jan  6 23:02:27 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 705AF7E0
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  6 Jan 2013 23:02:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 5C7321C2E
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  6 Jan 2013 23:02:27 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r06N2RXT094381
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 6 Jan 2013 23:02:27 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r06N2Rmi094380;
	Sun, 6 Jan 2013 23:02:27 GMT
	(envelope-from nobody)
Message-Id: <201301062302.r06N2Rmi094380@red.freebsd.org>
Date: Sun, 6 Jan 2013 23:02:27 GMT
From: Yuriy Taraday <yorik.sar@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: rc.subr poorly handles recursive run_rc_command invocations
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         175079
>Category:       conf
>Synopsis:       [rc.subr] [patch] rc.subr poorly handles recursive run_rc_command invocations
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 06 23:10:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Mon Jan 07 03:26:01 UTC 2013
>Originator:     Yuriy Taraday
>Release:        8.3-RELEASE-p5
>Organization:
>Environment:
reeBSD greater 8.3-RELEASE-p5 FreeBSD 8.3-RELEASE-p5 #1: Wed Dec 12 15:30:21 GST 2012     root@greater:/usr/obj/usr/src/sys/MYCONF  amd64
>Description:
When custom precmd or cmd calls run_rc_command, postcmd and/or cmd are most likely to be missed.
For example, when squid stop_cmd calls "run_rc_command poll", _postcmd variable is overwritten and my postcmd was never called.
>How-To-Repeat:
Add your custom stop_postcmd for squid in /etc/rc.conf.d/squid. It will never be called.
>Fix:
Proposed patch makes these variables local to function so that they are not overwritten in caller's namespace.

Patch attached with submission follows:

*** /usr/src/etc/rc.subr	2012-03-03 10:15:13.000000000 +0400
--- /etc/rc.subr	2013-01-07 02:48:43.000000000 +0400
*************** run_rc_command()
*** 717,722 ****
--- 717,723 ----
  					# if there's a custom ${XXX_cmd},
  					# run that instead of the default
  					#
+ 		local _cmd _precmd _postcmd
  		eval _cmd=\$${rc_arg}_cmd \
  		     _precmd=\$${rc_arg}_precmd \
  		     _postcmd=\$${rc_arg}_postcmd


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Jan 7 03:25:40 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

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