Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/sysctl Apply patch from PR 43587, mostly from martin an...
details: https://anonhg.NetBSD.org/src/rev/c4adc359ba09
branches: trunk
changeset: 346753:c4adc359ba09
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jul 31 23:30:28 2016 +0000
description:
Apply patch from PR 43587, mostly from martin and kre. When writing a
sysctl variable using ?= fails with EPERM, don't print an error
message.
Ideally setting a sysctl to the same value it already has should also
not fail regardless of permissions, but this would need to be done in
the kernel.
diffstat:
sbin/sysctl/sysctl.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diffs (85 lines):
diff -r f38964bb28e6 -r c4adc359ba09 sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c Sun Jul 31 22:38:04 2016 +0000
+++ b/sbin/sysctl/sysctl.c Sun Jul 31 23:30:28 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.c,v 1.157 2015/12/13 14:24:47 christos Exp $ */
+/* $NetBSD: sysctl.c,v 1.158 2016/07/31 23:30:28 dholland 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.157 2015/12/13 14:24:47 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.158 2016/07/31 23:30:28 dholland Exp $");
#endif
#endif /* not lint */
@@ -128,8 +128,8 @@
static void purge_tree(struct sysctlnode *);
static void print_tree(int *, u_int, struct sysctlnode *, u_int, int, regex_t *,
size_t *);
-static void write_number(int *, u_int, struct sysctlnode *, char *);
-static void write_string(int *, u_int, struct sysctlnode *, char *);
+static void write_number(int *, u_int, struct sysctlnode *, char *, bool);
+static void write_string(int *, u_int, struct sysctlnode *, char *, bool);
static void display_number(const struct sysctlnode *, const char *,
const void *, size_t, int);
static void display_string(const struct sysctlnode *, const char *,
@@ -946,10 +946,10 @@
case CTLTYPE_INT:
case CTLTYPE_BOOL:
case CTLTYPE_QUAD:
- write_number(&name[0], namelen, node, value);
+ write_number(&name[0], namelen, node, value, optional);
break;
case CTLTYPE_STRING:
- write_string(&name[0], namelen, node, value);
+ write_string(&name[0], namelen, node, value, optional);
break;
case CTLTYPE_STRUCT:
/*
@@ -1754,7 +1754,8 @@
* ********************************************************************
*/
static void
-write_number(int *name, u_int namelen, struct sysctlnode *node, char *value)
+write_number(int *name, u_int namelen, struct sysctlnode *node, char *value,
+ bool optional)
{
u_int ii, io;
u_quad_t qi, qo;
@@ -1811,7 +1812,9 @@
rc = prog_sysctl(name, namelen, o, &so, i, si);
if (rc == -1) {
- sysctlerror(0);
+ if (!optional || errno != EPERM) {
+ sysctlerror(0);
+ }
return;
}
@@ -1832,7 +1835,8 @@
}
static void
-write_string(int *name, u_int namelen, struct sysctlnode *node, char *value)
+write_string(int *name, u_int namelen, struct sysctlnode *node, char *value,
+ bool optional)
{
char *i, *o;
size_t si, so;
@@ -1853,7 +1857,10 @@
rc = prog_sysctl(name, namelen, o, &so, i, si);
if (rc == -1) {
- sysctlerror(0);
+ if (!optional || errno != EPERM) {
+ sysctlerror(0);
+ }
+ free(o);
return;
}
Home |
Main Index |
Thread Index |
Old Index