Date: Wed, 6 Jan 2010 01:18:20 -0800 From: Rob Farmer <rfarmer@predatorlabs.net> To: Doug Barton <dougb@freebsd.org> Cc: freebsd-rc@freebsd.org Subject: Re: devfs ruleset processing in rc.subr Message-ID: <b025ceb71001060118u94bb380k3fdc985ebf433a56@mail.gmail.com> In-Reply-To: <4B443268.7040905@FreeBSD.org> References: <b025ceb71001051827p10a5becfo3e24b73a2f570f81@mail.gmail.com> <4B443268.7040905@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jan 5, 2010 at 10:49 PM, Doug Barton <dougb@freebsd.org> 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 > >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b025ceb71001060118u94bb380k3fdc985ebf433a56>