Subject: obsoleting sysctl(8)'s -w flag
To: None <tech-userlevel@netbsd.org>
From: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
List: tech-userlevel
Date: 03/04/2002 04:36:12
The patch below changes sysctl(8) to not require the -w flag when setting
a variable. Just "sysctl foo=var" is really enough. Inspired by FreeBSD.
Any objections to commit?
- Hubert
Index: sbin/sysctl/sysctl.8
===================================================================
RCS file: /cvsroot/basesrc/sbin/sysctl/sysctl.8,v
retrieving revision 1.74
diff -u -r1.74 sysctl.8
--- sbin/sysctl/sysctl.8 2002/02/08 01:30:47 1.74
+++ sbin/sysctl/sysctl.8 2002/03/04 03:26:30
@@ -33,7 +33,7 @@
.\"
.\" @(#)sysctl.8 8.1 (Berkeley) 6/6/93
.\"
-.Dd June 6, 1993
+.Dd March 4, 2002
.Dt SYSCTL 8
.Os
.Sh NAME
@@ -41,12 +41,9 @@
.Nd get or set kernel state
.Sh SYNOPSIS
.Nm sysctl
-.Op Fl n
-.Ar name ...
.Nm sysctl
.Op Fl n
-.Fl w
-.Ar name Ns Li = Ns Ar value ...
+.Ar name[=value] ...
.Nm sysctl
.Op Fl n
.Fl a
@@ -88,9 +85,7 @@
.Pp
If just a MIB style name is given,
the corresponding value is retrieved.
-If a value is to be set, the
-.Fl w
-flag must be specified and the MIB name followed
+If a value is to be set, the MIB name must be followed
by an equal sign and the new value to be used.
.Pp
The
@@ -105,10 +100,6 @@
.Ar name
or
.Ar name Ns Li = Ns Ar value .
-The
-.Fl w
-flag is implied by
-.Fl f .
.Pp
The
.Ql proc
@@ -416,7 +407,7 @@
To set the maximum number of processes allowed
in the system to 1000, one would use the following request:
.Bd -literal -offset indent -compact
-sysctl -w kern.maxproc=1000
+sysctl kern.maxproc=1000
.Ed
.Pp
Information about the system clock rate may be obtained with:
@@ -439,11 +430,11 @@
.Pp
To redirect core dumps to the /var/tmp/\*[Lt]username\*[Gt] directory,
.Bd -literal -offset indent -compact
-sysctl -w proc.$$.corename=/var/tmp/%u/%n.core
+sysctl proc.$$.corename=/var/tmp/%u/%n.core
.Ed
Shall be used.
.Bd -literal -offset indent -compact
-sysctl -w proc.curproc.corename=/var/tmp/%u/%n.core
+sysctl proc.curproc.corename=/var/tmp/%u/%n.core
.Ed
changes the value for the sysctl process itself, and will not have the desired
effect.
Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/sysctl/sysctl.c,v
retrieving revision 1.55
diff -u -r1.55 sysctl.c
--- sbin/sysctl/sysctl.c 2002/01/31 20:15:14 1.55
+++ sbin/sysctl/sysctl.c 2002/03/04 03:26:31
@@ -152,7 +152,7 @@
{ 0, 0},
};
-int Aflag, aflag, nflag, wflag;
+int Aflag, aflag, nflag;
/*
* Variables requiring special processing.
@@ -212,7 +212,6 @@
case 'f':
fn = optarg;
- wflag = 1;
break;
case 'n':
@@ -220,7 +219,7 @@
break;
case 'w':
- wflag = 1;
+ /* ignored - keep for backward compatibility */
break;
default:
@@ -305,8 +304,6 @@
bufp = buf;
snprintf(buf, BUFSIZ, "%s", string);
if ((cp = strchr(string, '=')) != NULL) {
- if (!wflag)
- errx(2, "Must specify -w to set variables");
*strchr(buf, '=') = '\0';
*cp++ = '\0';
while (isspace((unsigned char) *cp))
@@ -1158,7 +1155,7 @@
(void)fprintf(stderr,
"Usage:\t%s %s\n\t%s %s\n\t%s %s\n\t%s %s\n\t%s %s\n",
progname, "[-n] variable ...",
- progname, "[-n] -w variable=value ...",
+ progname, "[-n] variable=value ...",
progname, "[-n] -a",
progname, "[-n] -A",
progname, "[-n] -f file");
Index: etc/rc.d/network
===================================================================
RCS file: /cvsroot/basesrc/etc/rc.d/network,v
retrieving revision 1.33
diff -u -r1.33 network
--- etc/rc.d/network 2001/07/22 13:33:59 1.33
+++ etc/rc.d/network 2002/03/04 03:26:31
@@ -119,8 +119,8 @@
#
route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
- sysctl -w net.inet6.ip6.forwarding=0 >/dev/null
- sysctl -w net.inet6.ip6.accept_rtadv=0 >/dev/null
+ sysctl net.inet6.ip6.forwarding=0 >/dev/null
+ sysctl net.inet6.ip6.accept_rtadv=0 >/dev/null
# backward compatibility
#
@@ -139,12 +139,12 @@
case $ip6mode in
router)
echo 'IPv6 mode: router'
- sysctl -w net.inet6.ip6.forwarding=1 >/dev/null
+ sysctl net.inet6.ip6.forwarding=1 >/dev/null
;;
autohost)
echo 'IPv6 mode: autoconfigured host'
- sysctl -w net.inet6.ip6.accept_rtadv=1 >/dev/null
+ sysctl net.inet6.ip6.accept_rtadv=1 >/dev/null
;;
host)
Index: etc/rc.d/securelevel
===================================================================
RCS file: /cvsroot/basesrc/etc/rc.d/securelevel,v
retrieving revision 1.3
diff -u -r1.3 securelevel
--- etc/rc.d/securelevel 2002/03/01 17:58:00 1.3
+++ etc/rc.d/securelevel 2002/03/04 03:26:31
@@ -25,12 +25,12 @@
exit 1
else
echo -n "Setting securelevel: "
- sysctl -w kern.securelevel=$securelevel
+ sysctl kern.securelevel=$securelevel
fi
else
if [ "$osecurelevel" = 0 ]; then
echo -n "Setting securelevel: "
- sysctl -w kern.securelevel=1
+ sysctl kern.securelevel=1
fi
fi
}
Index: etc/rc.d/sysctl
===================================================================
RCS file: /cvsroot/basesrc/etc/rc.d/sysctl,v
retrieving revision 1.9
diff -u -r1.9 sysctl
--- etc/rc.d/sysctl 2000/08/21 23:31:24 1.9
+++ etc/rc.d/sysctl 2002/03/04 03:26:31
@@ -19,7 +19,7 @@
*** WARNING: /etc/rc.conf \$defcorename setting is obsolete. Please
*** set kern.defcorename in /etc/sysctl.conf
__EOF__
- sysctl -w kern.defcorename=$defcorename
+ sysctl kern.defcorename=$defcorename
fi
if [ -n "$nfsiod_flags" ]; then
--
Want to get a clue on IPv6 but don't know where to start? Try this:
* Basics -> http://www.onlamp.com/pub/a/onlamp/2001/05/24/ipv6_tutorial.html
* Setup -> http://www.onlamp.com/pub/a/onlamp/2001/06/01/ipv6_tutorial.html
Of course with your #1 IPv6 ready operating system -> http://www.NetBSD.org/