From owner-freebsd-rc@FreeBSD.ORG Mon Apr 1 19:01:57 2013 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 10010D50; Mon, 1 Apr 2013 19:01:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id E337D9C7; Mon, 1 Apr 2013 19:01:56 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 47BFAB960; Mon, 1 Apr 2013 15:01:56 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Subject: Re: rc.subr: disabling globbing while processing devfs rules Date: Mon, 1 Apr 2013 14:06:50 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <514D6AC5.8010409@FreeBSD.org> In-Reply-To: <514D6AC5.8010409@FreeBSD.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201304011406.50417.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 01 Apr 2013 15:01:56 -0400 (EDT) Cc: freebsd-rc@freebsd.org, Andriy Gapon X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2013 19:01:57 -0000 On Saturday, March 23, 2013 4:41:41 am Andriy Gapon wrote: > > Any objections / concerns for the following change? > > An example. > This rule in devfs.rules: > add path da* mode 660 group operator > and this directory: > /data > result in the following rule being actually installed: > 100 path data group operator mode 660 > > Of course, I could refine the pattern in the rule, but I shouldn't have to do > it, because the pattern is for /dev/ entries, not arbitrary files in the > filesystem namespace. > > commit 7ce5e9ca5c107e2669f18efa472c1ab14999247c > Author: Andriy Gapon > Date: Sat Mar 23 10:29:39 2013 +0200 > > rc.subr: disabling globbing while processing devfs rules in > devfs_rulesets_from_file() > > The rules themselves typically have shell-like patterns and it is incorrect > when they get replaced with matching filesystem entries. > > Shell magic by: jilles > > diff --git a/etc/rc.subr b/etc/rc.subr > index f37ede7..9952c82 100644 > --- a/etc/rc.subr > +++ b/etc/rc.subr > @@ -1301,7 +1301,7 @@ make_symlink() > # > devfs_rulesets_from_file() > { > - local file _err _me > + local file _err _me _opts > file="$1" > _me="devfs_rulesets_from_file" > _err=0 > @@ -1314,6 +1314,11 @@ devfs_rulesets_from_file() > debug "$_me: no such file ($file)" > return 0 > fi > + > + # Disable globbing so that the rule patterns are not expanded > + # by accident with matching filesystem entries. > + _opts=$-; set -f > + > debug "reading rulesets from file ($file)" > { while read line > do > @@ -1360,6 +1365,7 @@ devfs_rulesets_from_file() > break > fi > done } < $file > + case $_opts in *f*) ;; *) set +f ;; esac > return $_err > } Why not use 'local -' instead of the $- magic? That is: devfs_rulesets_from_file() { local file _err _me - ... set -f ... } That would seem to be simpler. -- John Baldwin