Date: Sat, 27 Sep 2003 13:41:09 -0400 From: Marc Ramirez <marc.ramirez@bluecirclesoft.com> To: Brett Glass <brett@lariat.org> Cc: questions@freebsd.org Subject: Re: Best way to modify /etc/ppp/ppp.secrets on the fly? Message-ID: <20030927174109.GA67893@www.bluecirclesoft.com> In-Reply-To: <4.3.2.7.2.20030927103435.02caf820@localhost> References: <4.3.2.7.2.20030927103435.02caf820@localhost>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 27, 2003 at 10:36:59AM -0600, Brett Glass wrote: > I need to write a program or script that modifies > /etc/ppp/ppp.secrets on the fly to add, change, and remove > passwords. One thing I do NOT want is for replacement of the file to > interfere with a login that's occurring at the same time. What's the > best way to slip a new version of the file in without messing up an > instance of userland PPP that might check it at just the wrong > moment? This is the way I do things like this; note that this does not do any locking on the file (man 1 lockf). #!/bin/sh -e REALNAME=/etc/ppp/secrets TEMPNAME=/etc/ppp/secrets.$$ trap "echo Error occurred 1>&2; rm -f $TEMPNAME" EXIT INT cp $REALNAME $TEMPNAME # do your stuff to $TEMPNAME trap "" INT # don't interrupt the FS ops unlink $REALNAME ln $TEMPNAME $REALNAME unlink $TEMPNAME trap EXIT INT -- Marc Ramirez Blue Circle Software Corporation 513-688-1070 (main) 513-382-1270 (direct) http://www.bluecirclesoft.com http://www.mrami.com (personal)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030927174109.GA67893>