From owner-freebsd-current@FreeBSD.ORG Sun Dec 2 04:26:27 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 230819C8 for ; Sun, 2 Dec 2012 04:26:27 +0000 (UTC) (envelope-from bright@mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 022FF8FC14 for ; Sun, 2 Dec 2012 04:26:26 +0000 (UTC) Received: from Alfreds-MacBook-Pro-6.local (c-67-180-208-218.hsd1.ca.comcast.net [67.180.208.218]) by elvis.mu.org (Postfix) with ESMTPSA id A29CC1A3C1C for ; Sat, 1 Dec 2012 20:26:26 -0800 (PST) Message-ID: <50BAD872.2070107@mu.org> Date: Sat, 01 Dec 2012 20:26:26 -0800 From: Alfred Perlstein User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: freebsd-current@freebsd.org Subject: Re: RFC: sysctl -f filename References: <20121202.015048.1122480556487090170.hrs@allbsd.org> <50BAD796.5050507@mu.org> In-Reply-To: <50BAD796.5050507@mu.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Dec 2012 04:26:27 -0000 On 12/1/12 8:22 PM, Alfred Perlstein wrote: > 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@ *\"\(.*\)\" *@\1@" -e "s@ *'\(.*\)' *@\1@"` Upon catching up with emails and seeing netbsd's code, I want to say I don't feel that strongly about this, although I do wonder how the patch handles trailing whitespace since I wasn't able to test it: example: "kern.foo='bar'...." replace the "...." with spaces. -Alfred > > > -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 > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to > "freebsd-current-unsubscribe@freebsd.org" >