Module Name: src Committed By: snj Date: Wed Apr 1 21:37:03 UTC 2009
Modified Files: src/sbin/sysctl [netbsd-5]: sysctl.8 sysctl.c Log Message: Pull up following revision(s) (requested by christos in ticket #635): sbin/sysctl/sysctl.8: revision 1.160 sbin/sysctl/sysctl.c: revision 1.129 Don't print an error with sysctl -w name?=value if name does not exist. Should be pulled up to 5.0 To generate a diff of this commit: cvs rdiff -u -r1.158.4.1 -r1.158.4.2 src/sbin/sysctl/sysctl.8 cvs rdiff -u -r1.124 -r1.124.2.1 src/sbin/sysctl/sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/sysctl/sysctl.8 diff -u src/sbin/sysctl/sysctl.8:1.158.4.1 src/sbin/sysctl/sysctl.8:1.158.4.2 --- src/sbin/sysctl/sysctl.8:1.158.4.1 Wed Nov 12 23:40:25 2008 +++ src/sbin/sysctl/sysctl.8 Wed Apr 1 21:37:02 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysctl.8,v 1.158.4.1 2008/11/12 23:40:25 snj Exp $ +.\" $NetBSD: sysctl.8,v 1.158.4.2 2009/04/01 21:37:02 snj Exp $ .\" .\" Copyright (c) 2004 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -54,7 +54,7 @@ .\" .\" @(#)sysctl.8 8.1 (Berkeley) 6/6/93 .\" -.Dd December 4, 2006 +.Dd April 1, 2009 .Dt SYSCTL 8 .Os .Sh NAME @@ -75,7 +75,7 @@ .Fl x .Oc .Fl w -.Ar name Ns Li = Ns Ar value ... +.Ar name Ns Li [?]= Ns Ar value ... .Nm sysctl .Op Fl en .Oo @@ -202,6 +202,10 @@ The MIB style name and value must be separated by .Ql = with no whitespace. +To prevent an error if the MIB style name does not exist (as would be the +case with optional kernel components), one can separate the MIB style name +and the value with +.Ql ?= . Only integral and string values can be set via this method. .It Fl x Makes Index: src/sbin/sysctl/sysctl.c diff -u src/sbin/sysctl/sysctl.c:1.124 src/sbin/sysctl/sysctl.c:1.124.2.1 --- src/sbin/sysctl/sysctl.c:1.124 Sun Jul 20 01:20:23 2008 +++ src/sbin/sysctl/sysctl.c Wed Apr 1 21:37:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.c,v 1.124 2008/07/20 01:20:23 lukem Exp $ */ +/* $NetBSD: sysctl.c,v 1.124.2.1 2009/04/01 21:37:02 snj Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ #if 0 static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: sysctl.c,v 1.124 2008/07/20 01:20:23 lukem Exp $"); +__RCSID("$NetBSD: sysctl.c,v 1.124.2.1 2009/04/01 21:37:02 snj Exp $"); #endif #endif /* not lint */ @@ -788,12 +788,18 @@ u_int namelen, type; char *key, *value, *dot; size_t sz; + bool optional = false; req = 1; key = l; - value = strchr(l, '='); - if (value != NULL) + + if ((value = strchr(l, '=')) != NULL) { + if (value > l && value[-1] == '?') { + value[-1] = '\0'; + optional = true; + } *value++ = '\0'; + } if ((dot = strpbrk(key, "./")) == NULL) sep[0] = '.'; @@ -836,6 +842,8 @@ if (sysctlgetmibinfo(key, &name[0], &namelen, gsname, &sz, &node, SYSCTL_VERSION) == -1) { + if (optional) + return; sysctlparseerror(namelen, l); EXIT(1); }