Hi,

I don't know if this is a big issue for you, but when
doing a `sysctl` call with a trailing period ("."),
like `sysctl kern.`, I get an error like this:

sysctl: second level name  in kern. is invalid

On other systems, if I do `sysctl XX.`, I get all the
entries inside XX. We should fix it, and I have a patch.

-Neel

The diff is below:

Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.259
diff -u -p -u -r1.259 sysctl.c
--- sbin/sysctl/sysctl.c        17 May 2023 22:12:51 -0000      1.259
+++ sbin/sysctl/sysctl.c        29 Aug 2023 19:42:56 -0000
@@ -377,6 +377,8 @@ parse(char *string, int flags)

        (void)strlcpy(buf, string, sizeof(buf));
        bufp = buf;
+       if (string[strlen(string) - 1] == '.')
+               buf[strlen(string) - 1] = '\0';
        if ((cp = strchr(string, '=')) != NULL) {
                *strchr(buf, '=') = '\0';
                *cp++ = '\0';

Reply via email to