Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Dec 2012 07:52:49 -0800
From:      Alfred Perlstein <bright@mu.org>
To:        Ian Lepore <freebsd@damnhippie.dyndns.org>
Cc:        "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, Andrey Zonov <zont@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, Xin LI <delphij@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>
Subject:   Re: svn commit: r244198 - in head: etc/rc.d sbin/sysctl
Message-ID:  <05CC5BAD-B968-4A7A-8097-A3344D970D63@mu.org>
In-Reply-To: <1355931456.1198.203.camel@revolution.hippie.lan>
References:  <201212132332.qBDNWmK4037503@svn.freebsd.org> <50D1D720.80206@FreeBSD.org> <1355931456.1198.203.camel@revolution.hippie.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
Wouldn't this obfuscate any errors in files?

Sent from my iPhone

On Dec 19, 2012, at 7:37 AM, Ian Lepore <freebsd@damnhippie.dyndns.org> wrot=
e:

> On Wed, 2012-12-19 at 19:02 +0400, Andrey Zonov wrote:
>> On 12/14/12 3:32 AM, Xin LI wrote:
>>> Author: delphij
>>> Date: Thu Dec 13 23:32:47 2012
>>> New Revision: 244198
>>> URL: http://svnweb.freebsd.org/changeset/base/244198
>>>=20
>>> Log:
>>>  Teach sysctl(8) about parsing a file (while I'm there also give it
>>>  capability of parsing both =3D and : formats).
>>>=20
>>>  Submitted by:    hrs (initial version, bugs are mine)
>>>  MFC after:    3 months
>>>=20
>>> Modified:
>>>  head/etc/rc.d/sysctl
>>>  head/sbin/sysctl/sysctl.8
>>>  head/sbin/sysctl/sysctl.c
>>>=20
>>> Modified: head/etc/rc.d/sysctl
>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
>>> --- head/etc/rc.d/sysctl    Thu Dec 13 23:19:13 2012    (r244197)
>>> +++ head/etc/rc.d/sysctl    Thu Dec 13 23:32:47 2012    (r244198)
>>> @@ -8,51 +8,27 @@
>>> . /etc/rc.subr
>>>=20
>>> name=3D"sysctl"
>>> +command=3D"/sbin/sysctl"
>>> stop_cmd=3D":"
>>> start_cmd=3D"sysctl_start"
>>> reload_cmd=3D"sysctl_start"
>>> lastload_cmd=3D"sysctl_start last"
>>> extra_commands=3D"reload lastload"
>>>=20
>>> -#
>>> -# Read in a file containing sysctl settings and set things accordingly.=

>>> -#
>>> -parse_file()
>>> -{
>>> -    if [ -f $1 ]; then
>>> -        while read var comments
>>> -        do
>>> -            case ${var} in
>>> -            \#*|'')
>>> -                ;;
>>> -            *)
>>> -                mib=3D${var%=3D*}
>>> -                val=3D${var#*=3D}
>>> -
>>> -                if current_value=3D`${SYSCTL} -n ${mib} 2>/dev/null`; t=
hen
>>> -                    case ${current_value} in
>>> -                    ${val})
>>> -                        ;;
>>> -                    *)
>>> -                        if ! sysctl "${var}" >/dev/null 2>&1; then
>>> -                            warn "unable to set ${var}"
>>> -                        fi
>>> -                        ;;
>>> -                    esac
>>> -                elif [ "$2" =3D "last" ]; then
>>> -                    warn "sysctl ${mib} does not exist."
>>> -                fi
>>> -                ;;
>>> -            esac
>>> -        done < $1
>>> -    fi
>>> -}
>>> -
>>> sysctl_start()
>>> {
>>> -
>>> -    parse_file /etc/sysctl.conf $1
>>> -    parse_file /etc/sysctl.conf.local $1
>>> +    case $1 in
>>> +    last)
>>> +        command_args=3D"-i -f"
>>> +    ;;
>>> +    *)
>>> +        command_args=3D"-f"
>>> +    ;;
>>> +    esac
>>> +
>>> +    for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do
>>> +        [ -r ${_f} ] && ${command} ${command_args} ${_f} > /dev/null
>>> +    done
>>> }
>>>=20
>>> load_rc_config $name
>>=20
>> Hi,
>>=20
>> I'd really like to see something like the patch bellow in the tree.  I
>> found it very useful with cfengine configuration (as like as cron.d).
>>=20
>> What do think?
>>=20
>> diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl
>> index 36f1414..014e4c5 100755
>> --- a/etc/rc.d/sysctl
>> +++ b/etc/rc.d/sysctl
>> @@ -26,7 +26,7 @@ sysctl_start()
>>        ;;
>>        esac
>>=20
>> -       for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do
>> +       for _f in `ls /etc/sysctl.d/* 2> /dev/null` /etc/sysctl.conf
>> /etc/sysctl.conf.local; do
>>                [ -r ${_f} ] && ${command} ${command_args} ${_f} > /dev/nu=
ll
>>        done
>> }
>=20
> Instead of running sysctl a bunch of times, how about something
> conceptually similar to
>=20
>   cat /etc/sysctl.d/* /etc/sysctl.conf | sysctl -f -
>=20
> Along with this (untested) patch to make sysctl understand "-f -".
>=20
> Hmmm, is /dev/stdin available as early as sysctl.conf runs?  If not, the
> attached patch isn't going to work.
>=20
> -- Ian
>=20
> diff -r cc5bd6d80aa1 sbin/sysctl/sysctl.c --- sbin/sysctl/sysctl.c	Sun=
 Aug 19 11:01:08 2012 -0600 +++ sbin/sysctl/sysctl.c	Wed Dec 19 08:31:14=
 2012 -0700 @@ -112,7 +112,10 @@ main(int argc, char **argv) eflag =3D 1; br=
eak; case 'f': - conffile =3D optarg; +	 if (strcmp(optarg, "-") =3D=3D 0) +=
	 conffile =3D "/dev/stdin"; + else +	 conffile =3D optarg; break=
; case 'h': hflag =3D 1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?05CC5BAD-B968-4A7A-8097-A3344D970D63>