X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-adduser;h=530481377df7ca66f793a82136ff09fba1839b8e;hb=2922b22de0c028e066f8859d32ebea5bf67ccf63;hp=8f9d4a33f7ff79906e40e9c33f134b35f243f605;hpb=0815da7f25324df1040ba64c84ace44e49d7387c;p=freeside.git diff --git a/FS/bin/freeside-adduser b/FS/bin/freeside-adduser index 8f9d4a33f..530481377 100644 --- a/FS/bin/freeside-adduser +++ b/FS/bin/freeside-adduser @@ -5,7 +5,7 @@ use vars qw($opt_s $opt_g $opt_n); use Fcntl qw(:flock); use Getopt::Std; -my $FREESIDE_CONF = "/usr/local/etc/freeside"; +my $FREESIDE_CONF = "%%%FREESIDE_CONF%%%"; getopts("s:g:n"); my $user = shift or die &usage; @@ -22,11 +22,22 @@ if ( $opt_s ) { # close MAPSECRETS; #} - open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets") + #insert new entry before a wildcard... + open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets") and flock(MAPSECRETS,LOCK_EX) or die "can't open $FREESIDE_CONF/mapsecrets: $!"; - print MAPSECRETS "$user $opt_s\n"; + open(NEW,">$FREESIDE_CONF/mapsecrets.new") + or die "can't open $FREESIDE_CONF/mapsecrets.new: $!"; + while() { + if ( /^\*\s/ ) { + print NEW "$user $opt_s\n"; + } + print NEW $_; + } close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!"; + close NEW or die "can't close $FREESIDE_CONF/mapsecrets.new: $!"; + rename("$FREESIDE_CONF/mapsecrets.new", "$FREESIDE_CONF/mapsecrets") + or die "can't move mapsecrets.new into place: $!"; } @@ -97,7 +108,7 @@ B. =head1 NOTE -No explicit htpasswd options are available in 1.7 - passwordsa are now +No explicit htpasswd options are available in 1.7 - passwords are now maintained automatically. =head1 SEE ALSO