Best way to modify /etc/ppp/ppp.secrets on the fly?

2003-09-27 Thread Brett Glass
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?

--Brett Glass

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Best way to modify /etc/ppp/ppp.secrets on the fly?

2003-09-27 Thread Marc Ramirez
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 12; 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)
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]