sbin/sysctl: Always honor skip in sysctl_all

Fix broken CTLFLAG_SKIP when present on the first child of the requested
node.

We don't need to ignore skip for the first node because in sysctl_all()
we've implicitly visited the first node already when oid is specified.
The first call to show_var() in here is after we have iterated to the
next node. When the command line specifically requests a non-node sysctl
we go straight into show_var() without calling sysctl_all().

Reported by:	jhb
Reviewed by:	jhb
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D27674
This commit is contained in:
Ryan Moeller 2020-12-23 12:42:38 -05:00
parent 0ec2ce0d32
commit a5ec1dd453

View File

@ -1227,7 +1227,6 @@ sysctl_all(int *oid, int len)
int name1[22], name2[22];
int i, j;
size_t l1, l2;
bool honor_skip = false;
name1[0] = CTL_SYSCTL;
name1[1] = (oid != NULL || Nflag || dflag || tflag) ?
@ -1258,12 +1257,11 @@ sysctl_all(int *oid, int len)
if (memcmp(name2, oid, len * sizeof(int)) != 0)
return (0);
i = show_var(name2, l2, honor_skip);
i = show_var(name2, l2, true);
if (!i && !bflag)
putchar('\n');
memcpy(name1 + 2, name2, l2 * sizeof(int));
l1 = 2 + l2;
honor_skip = true;
}
}