conf/89945: rc script in /usr should be run in subshell

NIIMI Satoshi sa2c at sa2c.net
Sun Dec 4 20:10:08 GMT 2005


>Number:         89945
>Category:       conf
>Synopsis:       rc script in /usr should be run in subshell
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 04 20:10:06 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     NIIMI Satoshi
>Release:        FreeBSD 6.0-RELEASE i386
>Organization:
>Environment:
System: FreeBSD freebsd7.localdomain 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Mon Dec  5 00:32:37 JST 2005     root at freebsd7.localdomain:/usr/obj/usr/src/sys/GENERIC  i386

	
>Description:
/usr/*/rc.d/*.sh should be run in subshell instead of in current shell.
	
>How-To-Repeat:
After "pkg_add -r portupgrade", sshd won't start on boot.
	
>Fix:

	

--- rc.subr.diff begins here ---
Index: rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.44
diff -u -r1.44 rc.subr
--- rc.subr	2 Dec 2005 20:06:07 -0000	1.44
+++ rc.subr	4 Dec 2005 19:57:49 -0000
@@ -832,6 +832,9 @@
 	eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd
 
 	case "$_file" in
+	/usr/*)				# user scripts
+		run_in_subshell
+		;;
 	*.sh)				# run in current shell
 		set $_arg; . $_file
 		;;
@@ -839,19 +842,24 @@
 		warn "Ignoring scratch file $_file"
 		;;
 	*)				# run in subshell
-		if [ -x $_file ]; then
-			if [ -n "$rc_fast_and_loose" ]; then
-				set $_arg; . $_file
-			else
-				( trap "echo Script $_file interrupted; kill -QUIT $$" 3
-				  trap "echo Script $_file interrupted; exit 1" 2
-				  set $_arg; . $_file )
-			fi
-		fi
+		run_in_subshell
 		;;
 	esac
 }
 
+run_in_subshell()
+{
+	if [ -x $_file ]; then
+		if [ -n "$rc_fast_and_loose" ]; then
+			set $_arg; . $_file
+		else
+			( trap "echo Script $_file interrupted; kill -QUIT $$" 3
+			  trap "echo Script $_file interrupted; exit 1" 2
+			  set $_arg; . $_file )
+		fi
+	fi
+}
+
 #
 # load_rc_config
 #	Source in the configuration file for a given command.
--- rc.subr.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list