Subject: misc/18119: rc.d script doesn't do anything with bogus argument
To: None <gnats-bugs@gnats.netbsd.org>
From: None <reed@reedmedia.net>
List: netbsd-bugs
Date: 08/30/2002 07:27:06
>Number:         18119
>Category:       misc
>Synopsis:       rc_usage isn't printed with wrong rc.d command
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 30 07:28:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.5.3
>Organization:
http://bsd.reedmedia.net/
>Environment:
	
	
System: NetBSD rainier.reedmedia.net 1.5.3 NetBSD 1.5.3 (JCR-1.5-20020723) #0: Tue Jul 23 15:18:22 PDT 2002 reed@rainier.reedmedia.net:/usr/src/sys/arch/i386/compile/JCR-1.5-20020723 i386
Architecture: i386
Machine: i386
>Description:
Manually use /etc/rc.d/ script from command line
with some bogus command and it will do nothing.
(And the rcvar is not yes.)
So you aren't sure if it worked or not.
>How-To-Repeat:
rainier:~$ /etc/rc.d/ntpd junk here
rainier:~
>Fix:
This patch makes it so it always checks each argument.

Then only does checkyesno ${rcvar} for "start".
Then it checks for $_rc_fast_run to guess if interactive or not.

NOTE: this changes the functionality of an rc.d script because 
all commands can be used even if not set to YES; for example:

 $ /etc/rc.d/sendmail restart
 sendmail not running? (check /var/run/sendmail.pid).
 sendmail is not configured to start.

I think that is okay behavior. But if not, then could check for rcvar
is yes for each item (other than "rcvar").

--- /usr/src/etc/rc.subr	Sun Oct  1 18:02:49 2000
+++ /etc/rc.subr	Fri Aug 30 07:23:25 2002
@@ -302,15 +302,6 @@
 	eval _group=\$${name}_group
 	eval _groups=\$${name}_groups
 
-					# if ${rcvar} is set and we're not
-					# running `rcvar', then check it
-					#
-	if [ -n "${rcvar}" -a "$_arg" != "rcvar" ]; then
-		if ! checkyesno ${rcvar}; then
-			return 0
-		fi
-	fi
-
 	eval $_pidcmd			# determine the pid if necessary
 
 	for _elem in $_keywords; do
@@ -352,6 +343,15 @@
 			fi
 
 			if [ ! -x $command ]; then
+				return 0
+			fi
+
+			# only start if rcvar is yes
+			if ! checkyesno ${rcvar}; then
+				# guess if interactive
+				if [ -z "${_rc_fast_run}" ]; then
+					echo "${name} is not configured to start."
+				fi
 				return 0
 			fi
 
>Release-Note:
>Audit-Trail:
>Unformatted: