Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/sysctl PR/44961: Jukka Ruohonen: for sysctl's with buil...
details: https://anonhg.NetBSD.org/src/rev/21fa9ce4faea
branches: trunk
changeset: 778002:21fa9ce4faea
user: christos <christos%NetBSD.org@localhost>
date: Sun Mar 11 23:33:00 2012 +0000
description:
PR/44961: Jukka Ruohonen: for sysctl's with built-in handlers, return OPNOTSUPP
if we don't have handlers instead of using the handler we have and silently
failing on attempts to write a node that cannot be written.
diffstat:
sbin/sysctl/sysctl.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diffs (77 lines):
diff -r f400a2c446b8 -r 21fa9ce4faea sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c Sun Mar 11 23:26:22 2012 +0000
+++ b/sbin/sysctl/sysctl.c Sun Mar 11 23:33:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.c,v 1.140 2012/02/12 20:54:07 christos Exp $ */
+/* $NetBSD: sysctl.c,v 1.141 2012/03/11 23:33:00 christos 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.140 2012/02/12 20:54:07 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.141 2012/03/11 23:33:00 christos Exp $");
#endif
#endif /* not lint */
@@ -122,8 +122,7 @@
/*
* generic routines
*/
-static const struct handlespec *findhandler(const char *, int, regex_t *,
- size_t *);
+static const struct handlespec *findhandler(const char *, regex_t *, size_t *);
static void canonicalize(const char *, char *);
static void purge_tree(struct sysctlnode *);
static void print_tree(int *, u_int, struct sysctlnode *, u_int, int, regex_t *,
@@ -385,7 +384,7 @@
* ********************************************************************
*/
static const struct handlespec *
-findhandler(const char *s, int w, regex_t *re, size_t *lastcompiled)
+findhandler(const char *s, regex_t *re, size_t *lastcompiled)
{
const struct handlespec *p;
size_t i, l;
@@ -406,8 +405,7 @@
}
j = regexec(&re[i], s, 1, &match, 0);
if (j == 0) {
- if (match.rm_so == 0 && match.rm_eo == (int)l &&
- (w ? p[i].ps_w : p[i].ps_p) != NULL)
+ if (match.rm_so == 0 && match.rm_eo == (int)l)
return &p[i];
}
else if (j != REG_NOMATCH) {
@@ -670,8 +668,13 @@
}
canonicalize(gsname, canonname);
- p = findhandler(canonname, 0, re, lastcompiled);
+ p = findhandler(canonname, re, lastcompiled);
if (type != CTLTYPE_NODE && p != NULL) {
+ if (p->ps_p == NULL) {
+ sysctlperror("Cannot print `%s': %s\n", gsname,
+ strerror(EOPNOTSUPP));
+ exit(1);
+ }
(*p->ps_p)(gsname, gdname, NULL, name, namelen, pnode, type,
__UNCONST(p->ps_d));
*sp = *dp = '\0';
@@ -905,8 +908,13 @@
}
canonicalize(gsname, canonname);
- if (type != CTLTYPE_NODE && (w = findhandler(canonname, 1, re,
+ if (type != CTLTYPE_NODE && (w = findhandler(canonname, re,
lastcompiled)) != NULL) {
+ if (w->ps_w == NULL) {
+ sysctlperror("Cannot write `%s': %s\n", gsname,
+ strerror(EOPNOTSUPP));
+ exit(1);
+ }
(*w->ps_w)(gsname, gdname, value, name, namelen, node, type,
__UNCONST(w->ps_d));
gsname[0] = '\0';
Home |
Main Index |
Thread Index |
Old Index