Subject: bin/25115: sysctl -f is broken
To: None <>
From: Christian Biere <>
List: netbsd-bugs
Date: 04/09/2004 18:31:49
>Number:         25115
>Category:       bin
>Synopsis:       sysctl -f is broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 09 16:32:00 UTC 2004
>Originator:     Christian Biere
>Release:        NetBSD 2.0B
System: NetBSD cyclonus 2.0B NetBSD 2.0B (STARSCREAM) #0: Mon Apr 5 04:06:21 CEST 2004 bin@cyclonus:/usr/obj/sys/arch/i386/compile/STARSCREAM i386
Architecture: i386
Machine: i386

$ { echo 'net.inet.tcp.cwm=1 '; echo 'blah=1';} | /sbin/sysctl -f /dev/stdin
1 : not a number

First of at all, the error message is simply bad. Which line please? What
setting? Next, why the hell is 1 not a number? Well because sysctl thinks
a number must not be followed by a space. See, the actual message is
'"1 ": not a number'. It's much easier to see what's "wrong" this way, right?
After all, this is still write_number() in sysctl.c is still wrong and
incompatible with previous versions (this was added in rev. 1.75). Why does
it care about spaces? That's BS. Since fparseln() is used it's possible
to add comments with # to each line but because of this bug there must not
be any spaces between the value and the hash. So this works:

	net.inet.tcp.cwm=1# blah

While this doesn't:

	net.inet.tcp.cwm=1	# blah

As you see above, it *quits* after the line containing an "error". Again
incompatible with previous versions. E.g., I sometimes switch between a
GENERIC and a modified kernel without IPv6 support. My /etc/sysctl.conf
contains a few settings regarding IPv6 and I always had warnings in my
boot logs regarding those. Fortunately, these are the last lines in my
sysctl.conf. Otherwise, important settings might not have been processed.


Fix write_number() i.e., allow spaces after values and do NOT quit after
lines with errors. Maybe introduce a command-line parameter to switch
between strict and relaxed mode.