Changeset View
Changeset View
Standalone View
Standalone View
sbin/sysctl/sysctl.c
Show First 20 Lines • Show All 1,190 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
sysctl_all(int *oid, int len) | sysctl_all(int *oid, int len) | ||||
{ | { | ||||
int name1[22], name2[22]; | int name1[22], name2[22]; | ||||
int i, j; | int i, j; | ||||
size_t l1, l2; | size_t l1, l2; | ||||
name1[0] = 0; | name1[0] = CTL_SYSCTL; | ||||
name1[1] = 2; | name1[1] = (oid || Nflag || dflag) ? CTL_SYSCTL_ALLNEXT : | ||||
freqlabs: Maybe tflag too? | |||||
jhbUnsubmitted Done Inline ActionsSo the oid thing here might have an unusual effect. Specifically, suppose I have the following nodes: foo (CTLFLAG_SKIP) I think your change might make it so that 'sysctl foo' would still do foo.bar.baz whereas I what we want is that 'sysctl foo' would ignore the SKIP flag on 'foo' but still honor it for any descendants. (It should also be oid != NULL). jhb: So the `oid` thing here might have an unusual effect. Specifically, suppose I have the… | |||||
CTL_SYSCTL_NEXT; | |||||
l1 = 2; | l1 = 2; | ||||
if (len) { | if (len) { | ||||
memcpy(name1+2, oid, len * sizeof(int)); | memcpy(name1 + 2, oid, len * sizeof(int)); | ||||
l1 += len; | l1 += len; | ||||
} else { | } else { | ||||
name1[2] = 1; | name1[2] = CTL_KERN; | ||||
l1++; | l1++; | ||||
} | } | ||||
for (;;) { | for (;;) { | ||||
l2 = sizeof(name2); | l2 = sizeof(name2); | ||||
j = sysctl(name1, l1, name2, &l2, 0, 0); | j = sysctl(name1, l1, name2, &l2, 0, 0); | ||||
if (j < 0) { | if (j < 0) { | ||||
if (errno == ENOENT) | if (errno == ENOENT) | ||||
return (0); | return (0); | ||||
Show All 21 Lines |
Maybe tflag too?