svn commit: r244198 - in head: etc/rc.d sbin/sysctl
Jilles Tjoelker
jilles at stack.nl
Mon Dec 17 12:50:06 UTC 2012
On Thu, Dec 13, 2012 at 11:32:48PM +0000, Xin LI wrote:
> Author: delphij
> Date: Thu Dec 13 23:32:47 2012
> New Revision: 244198
> URL: http://svnweb.freebsd.org/changeset/base/244198
> Log:
> Teach sysctl(8) about parsing a file (while I'm there also give it
> capability of parsing both = and : formats).
> Submitted by: hrs (initial version, bugs are mine)
> MFC after: 3 months
> Modified: head/sbin/sysctl/sysctl.c
> ==============================================================================
> --- head/sbin/sysctl/sysctl.c Thu Dec 13 23:19:13 2012 (r244197)
> +++ head/sbin/sysctl/sysctl.c Thu Dec 13 23:32:47 2012 (r244198)
> [snip]
> @@ -194,6 +213,14 @@ parse(const char *string)
> }
> while (isspace(*cp))
> cp++;
> + /* Strip a pair of " or ' if any. */
> + switch (*cp) {
> + case '\"':
> + case '\'':
> + if (cp[strlen(cp) - 1] == *cp)
> + cp[strlen(cp) - 1] = '\0';
> + cp++;
> + }
> newval = cp;
> newsize = strlen(cp);
> }
As I wrote in
http://lists.freebsd.org/pipermail/freebsd-current/2012-December/038241.html
I think this is messy, and requires a confusing change to user code that
called sysctl(8) with strings starting with a quote.
On the positive side this allows setting sysctl values starting with
whitespace, but perhaps the isspace loop above it should be removed as
well so that can be done without adding quotes. It seems inappropriate
for sysctl.conf in particular since that file did not allow the extra
whitespace in the first place.
--
Jilles Tjoelker
More information about the svn-src-all
mailing list