15.12.2025 16:00, alf пишет:
> Hello,
> 
> I noticed that some of our machines spit the following while booting:
> 
> sysctl: top level name  in  is invalid
> 
> which can be caused by a sysctl.conf like this:
> 
> $ cat sysctl.conf
> #kern.splassert=2             # 2=Enable with verbose error messages
> kern.nosuidcoredump=2         # 2=Put suid coredumps in /var/crash
>                               # bla bla
> #kern.watchdog.period=32      # >0=Enable hardware watchdog(4) timer if 
> available
> 
> The '#bla bla' line is causing the error.
> 
> The following patch fixes it for me.

Thanks, this should indeed work and your fix reads correct to me.

> 
> 
> Alf
> 
> (originally sent to florian@ roughly a week ago but he appears to be busy)

Unless explicitly communicated, there's no point in mailing developers
(who last touched a file) directly.

> 
> Index: sbin/sysctl/sysctl.c
> ===================================================================
> RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
> retrieving revision 1.268
> diff -u -p -r1.268 sysctl.c
> --- sbin/sysctl/sysctl.c      6 Aug 2025 16:50:53 -0000       1.268
> +++ sbin/sysctl/sysctl.c      2 Dec 2025 09:42:15 -0000
> @@ -295,7 +295,7 @@ main(int argc, char *argv[])
>  
>               while (getline(&line, &sz, fp) != -1) {
>                       lp = line + strspn(line, " \t");
> -                     line[strcspn(line, " \t\n#")] = '\0';
> +                     lp[strcspn(lp, " \t\n#")] = '\0';
>  
>                       if (lp[0] != '\0')
>                               parse(line, 1);
> 
> 

I wrote new regress bits that run 'sysctl -f' against a few unique
one-line configs;  your diff fix the spc-com test (your case) just
like the spc one (whitespace-only line) without breaking any other.

To tes, extract the tarball in /usr/src/regress/sbin/, 'cd sysctl'
and compare 'make REGRESS_FAIL_EARLY=no' with(out) SYSCTL=... set.


Feedback? OK?  For Alf's fix and/or new regress?

Index: sysctl.c
===================================================================
RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
diff -u -p -r1.268 sysctl.c
--- sysctl.c    6 Aug 2025 16:50:53 -0000       1.268
+++ sysctl.c    27 Dec 2025 17:11:08 -0000
@@ -295,7 +295,7 @@ main(int argc, char *argv[])
 
                while (getline(&line, &sz, fp) != -1) {
                        lp = line + strspn(line, " \t");
-                       line[strcspn(line, " \t\n#")] = '\0';
+                       lp[strcspn(lp, " \t\n#")] = '\0';
 
                        if (lp[0] != '\0')
                                parse(line, 1);

Attachment: sysctl.tgz
Description: application/compressed-tar

Reply via email to