From owner-freebsd-rc@FreeBSD.ORG Wed Jan 6 09:18:34 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5C4E1065765 for ; Wed, 6 Jan 2010 09:18:34 +0000 (UTC) (envelope-from rfarmer@predatorlabs.net) Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com [209.85.221.174]) by mx1.freebsd.org (Postfix) with ESMTP id 6C27D8FC0A for ; Wed, 6 Jan 2010 09:18:34 +0000 (UTC) Received: by qyk4 with SMTP id 4so7151785qyk.7 for ; Wed, 06 Jan 2010 01:18:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.78.17 with SMTP id i17mr1521836qak.359.1262769500233; Wed, 06 Jan 2010 01:18:20 -0800 (PST) X-Originating-IP: [128.95.133.98] In-Reply-To: <4B443268.7040905@FreeBSD.org> References: <4B443268.7040905@FreeBSD.org> Date: Wed, 6 Jan 2010 01:18:20 -0800 Message-ID: From: Rob Farmer To: Doug Barton Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-rc@freebsd.org Subject: Re: devfs ruleset processing in rc.subr X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 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: Wed, 06 Jan 2010 09:18:34 -0000 On Tue, Jan 5, 2010 at 10:49 PM, Doug Barton wrote: > Rob Farmer wrote: >> Hello, >> >> I am trying to fix an issue with the port shells/scponly's rc.d script >> and I think I may have come across a bug in /etc/rc.subr related to >> devfs. >> >> Here's what I'm trying to do: >> >> make_devfs() { >> =A0 =A0 =A0 # $1 is the user name whose home directory needs a minimal >> =A0 =A0 =A0 # devfs created. If ~/dev exists, it will be deleted. >> >> =A0 =A0 =A0 eval DEV=3D"~$1/dev" >> =A0 =A0 =A0 while /sbin/umount "${DEV}" 2>/dev/null; do :; done > > This definitely shouldn't be set up to spin forever like this ... > probably needs to try the umount || err How would you recommend to do this? I have the following, but I have a feeling there must be a simpler way: if /sbin/mount | grep "${DEV}" >/dev/null 2>&1; then /sbin/umount "${DEV}" 2>/dev/null fi > >> =A0 =A0 =A0 /bin/rm -rf "${DEV}" > > Personally I would rather see here: > rmdir $DEV || err 1 "Unable to remove $DEV" Changed. > > Although frankly I'm a little confused as to why you go through all > these gymnastics, although I do admire your thoroughness. :) =A0What are > your goals for all the safety features? I'm not the original author - I'm pretty new to shell scripting so I'm just trying to get it working with the minimum amount of changes so I don't accidentally introduce more mistakes. > >> =A0 =A0 =A0 /bin/mkdir -p "${DEV}" >> =A0 =A0 =A0 devfs_domount "${DEV}" >> =A0 =A0 =A0 if devfs_init_rulesets; then >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 devfs_apply_ruleset "1" "${DEV}" && \ > > # devfs_apply_ruleset ruleset [dir] > # =A0 =A0 =A0 Apply ruleset number $ruleset to the devfs mountpoint $dir. > # =A0 =A0 =A0 The ruleset argument must be a ruleset name as specified > # =A0 =A0 =A0 in a devfs.rules(5) file. > > Take a look at /etc/defaults/devfs.rules if you're interested in how > the symbolic names are assigned. OK - I see now, I was trying to using the rule numbers instead of the symbolic names. It works fine when I do it the way it was designed :) The full script is at http://students.washington.edu/rfarmer/scponly.in if you want to take a look before I submit it. Thanks for your help, Rob Farmer > > > hth, > > Doug > > -- > > =A0 =A0 =A0 =A0Improve the effectiveness of your Internet presence with > =A0 =A0 =A0 =A0a domain name makeover! =A0 =A0http://SupersetSolutions.co= m/ > > =A0 =A0 =A0 =A0Computers are useless. They can only give you answers. > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Pablo Picasso > >