From mokr@amber.mokr.ru  Sat Oct 19 14:53:03 2002
Return-Path: <mokr@amber.mokr.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id BAB8637B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 19 Oct 2002 14:53:03 -0700 (PDT)
Received: from guardian.sch.ru (TCH-MSU.ATM6-0.181.M9-R1.msu.net [212.16.0.250])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 56DAF43E91
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 19 Oct 2002 14:52:57 -0700 (PDT)
	(envelope-from mokr@amber.mokr.ru)
Received: from amber.mokr.ru ([172.16.0.6])
	by guardian.sch.ru (8.12.6/8.12.6/20021009101427) with ESMTP id g9JLqteA045028
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Oct 2002 01:52:55 +0400 (MSD)
	(envelope-from mokr@amber.mokr.ru)
Received: from amber.mokr.ru (localhost [127.0.0.1])
	by amber.mokr.ru (8.12.6/8.12.6/020822) with ESMTP id g9JLqNCA000900
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Oct 2002 01:52:54 +0400 (MSD)
	(envelope-from mokr@amber.mokr.ru)
Received: (from mokr@localhost)
	by amber.mokr.ru (8.12.6/8.12.6/Submit) id g9JLqMQj000899;
	Sun, 20 Oct 2002 01:52:22 +0400 (MSD)
Message-Id: <200210192152.g9JLqMQj000899@amber.mokr.ru>
Date: Sun, 20 Oct 2002 01:52:22 +0400 (MSD)
From: Sergey Mokryshev <mokr@mokr.net>
Reply-To: Sergey Mokryshev <mokr@mokr.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: /etc/rc.d/sysctl script works incorrectly in case of non-existent  MIB
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         44282
>Category:       conf
>Synopsis:       /etc/rc.d/sysctl script works incorrectly in case of non-existent  MIB
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mtm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 19 15:00:03 PDT 2002
>Closed-Date:    Sat Jul 12 19:10:11 PDT 2003
>Last-Modified:  Sat Jul 12 19:10:11 PDT 2003
>Originator:     Sergey Mokryshev
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Tersys
>Environment:
System: FreeBSD amber.mokr.net 5.0-CURRENT FreeBSD 5.0-CURRENT #12: Sun Oct 20 00:40:36 MSD 2002 su@amber.mokr.net:/.1/a/obj/.1/a/src/sys/AMBER_UP i386


>Description:
	/sbin/sysctl does not return anything printable upon request 
	(sysctl -n ${mib}) of a non-existent variable, just an error-code.
	The code in 'elif' clause in /etc/rc.d/sysctl

        elif [ "$1" -eq "last" ]; then
          warn "sysctl ${mib} does not exits."
        fi

	is probably wrong


>How-To-Repeat:
	
	Put a non-existent variable in /etc/sysctl.conf 
	and reboot. There will be message like (taken from /var/log/console.log)

	Oct 20 00:22:44 amber kernel: [: : bad number

>Fix:

--- /tmp/sysctl.orig	Sun Oct 20 01:08:03 2002
+++ sysctl	Sun Oct 20 01:23:04 2002
@@ -49,7 +49,7 @@
 						sysctl ${var}
 						;;
 					esac
-				elif [ "$1" -eq "last" ]; then
+				elif [ "$?" -ne "0" ]; then
 					warn "sysctl ${mib} does not exits."
 				fi
 				;;
>Release-Note:
>Audit-Trail:

From: Bill Fenner <fenner@research.att.com>
To: freebsd-gnats-submit@FreeBSD.org, mokr@mokr.net
Cc:  
Subject: Re: conf/44282: /etc/rc.d/sysctl script works incorrectly in case of 
 non-existent  MIB
Date: Fri, 25 Oct 2002 17:24:19 -0700

 This appears to be an attempt to preserve /etc/rc.sysctl's
 original functionality, which was to run twice -- the early
 run would not complain about illegal sysctl variables, presumably to
 allow sysctl.conf to contain variables that were in modules that would
 be loaded later.
 
 If one runs "/etc/rc.d/sysctl lastload", you get the right behavior --
 however, there doesn't seem to be any provision to ever run
 "/etc/rc.d/sysctl lastload".  I don't know enough about the rc.d system
 to know how to fix it -- perhaps an /etc/rc.d/sysctllast which runs
 /etc/rc.d/sysctl lastload?
 
 Alternately, if we are going to abandon the multiple sysctl.conf loads,
 the elif should just be turned into an else, the additional test of $?
 is not necessary.
 
   Bill
Responsible-Changed-From-To: freebsd-bugs->mtm 
Responsible-Changed-By: kris 
Responsible-Changed-When: Sat Jul 12 16:49:37 PDT 2003 
Responsible-Changed-Why:  
Assign to rcng maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=44282 
State-Changed-From-To: open->closed 
State-Changed-By: mtm 
State-Changed-When: Sat Jul 12 19:04:07 PDT 2003 
State-Changed-Why:  
Bill is right, the script is supposed to be run twice, and the warning 
is shown only if called with the last argument. As for the problem 
of not being called twice in the boot sequence, that's already 
fixed. 

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