Re: RFC: sysctl -f filename

From: Alfred Perlstein <bright_at_mu.org>
Date: Sat, 01 Dec 2012 20:22:46 -0800
Does sysctl(8) really need to learn to parse files?

Can't rc.d/sysctl be modified to do the fixup?

This regex seems to work:
val=`echo $val | sed -e "s_at_ *\"\(.*\)\" *_at_\1_at_" -e "s_at_ *'\(.*\)' *_at_\1_at_"`


-Alfred

On 12/1/12 8:50 AM, Hiroki Sato wrote:
> Hi,
>
>   I would like comments about the attached patch for sysctl(8) to add a
>   new option "-f filename".  It supports reading of a file with
>   key=value lines.
>
>   As you probably know, we already have /etc/sysctl.conf and it is
>   processed by rc.d/sysctl shell script in a line-by-line basis.  The
>   problem I want to fix is a confusing syntax of /etc/sysctl.conf.  The
>   file supports a typical configuration file syntax but problematic in
>   some cases.  For example:
>
>    kern.coredump=1
>
>   works well in /etc/sysctl.conf, but
>
>    kern.coredump="1"
>
>   does not work.  Similarly, it is difficult to use whitespaces and "#"
>   in the value:
>
>    OK: kern.domainname=domain\ name\ with\ spaces
>    NG: kern.domainname="domain name with spaces"
>    NG: kern.domainname=domain\ name\ including\ #\ character
>    NG: kern.domainname=domain\ name\ including\ \#\ character
>
>   The attached patch solves them, and in addition it displays an error
>   message with a line number if there is something wrong in the file
>   like this:
>
>    % cat -n /etc/sysctl.conf
>    ...
>    10  kern.coredump=1
>    11  kern.coredump2=1
>    ...
>
>    % /etc/rc.d/sysctl start
>    sysctl: kern.coredump at line 10: Operation not permitted
>    sysctl: unknown oid 'kern.coredump2' at line 11
>
>    # /etc/rc.d/sysctl start
>    kern.coredump: 1 -> 1
>    sysctl: unknown oid 'kern.coredump2' at line 11
>
>   Any comments are welcome.
>
> -- Hiroki
Received on Sun Dec 02 2012 - 03:22:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:32 UTC