From: ivan Date: Sun, 6 Aug 2006 23:39:02 +0000 (+0000) Subject: slightly better bootstrapping for htpasswd kludge... hopefully that will go away... X-Git-Tag: BEFORE_FINAL_MASONIZE~53 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=65fc97717e093e8ff35d6f4c0efd04e3af334c8d slightly better bootstrapping for htpasswd kludge... hopefully that will go away in 1.7.1 --- diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm index d325dd6cc..37b3b2f37 100644 --- a/FS/FS/access_user.pm +++ b/FS/FS/access_user.pm @@ -104,6 +104,7 @@ sub insert { sub htpasswd_kludge { my $self = shift; + unshift @_, '-c' unless -e $htpasswd_file; if ( system('htpasswd', '-b', @_, $htpasswd_file, diff --git a/FS/bin/freeside-adduser b/FS/bin/freeside-adduser index 0d8b454bf..3976caece 100644 --- a/FS/bin/freeside-adduser +++ b/FS/bin/freeside-adduser @@ -1,13 +1,13 @@ #!/usr/bin/perl -w use strict; -use vars qw($opt_h $opt_b $opt_c $opt_g); +use vars qw($opt_s $opt_h $opt_b $opt_c $opt_g $opt_n); use Fcntl qw(:flock); use Getopt::Std; my $FREESIDE_CONF = "/usr/local/etc/freeside"; -getopts("bch:g:"); +getopts("s:bch:g:n"); die &usage if $opt_c && ! $opt_h; my $user = shift or die &usage; @@ -27,16 +27,21 @@ if ( $opt_h ) { push @args, '-c' if $opt_c; push @args, $opt_h, $user; push @args, shift if $opt_b; + warn join(', ', 'htpasswd', @args)."\n"; system(@args) == 0 or die "htpasswd failed: $?"; } -#my $secretfile = $opt_s || 'secrets'; -# -#open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets") -# and flock(MAPSECRETS,LOCK_EX) -# or die "can't open $FREESIDE_CONF/mapsecrets: $!"; -#print MAPSECRETS "$user $secretfile\n"; -#close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!"; +if ( $opt_s ) { + open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets") + and flock(MAPSECRETS,LOCK_EX) + or die "can't open $FREESIDE_CONF/mapsecrets: $!"; + print MAPSECRETS "$user $opt_s\n"; + close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!"; +} + +### + +exit if $opt_n; ### @@ -72,7 +77,7 @@ if ( $opt_g ) { ### sub usage { - die "Usage:\n\n freeside-adduser [ -h htpasswd_file [ -c ] [ -b ] ] [ -g groupnum ] username" + die "Usage:\n\n freeside-adduser [ -h htpasswd_file [ -c ] [ -b ] ] [ -g groupnum ] username [ password ]" } =head1 NAME @@ -81,7 +86,7 @@ freeside-adduser - Command line interface to add (freeside) users. =head1 SYNOPSIS - freeside-adduser [ -h htpasswd_file [ -c ] ] -g 1 username + freeside-adduser [ -n ] [ -h htpasswd_file [ -c ] [ -b ] ] [ -g groupnum ] username [ password ] =head1 DESCRIPTION @@ -96,6 +101,12 @@ sales/tech folks) to the web interface, not for adding customer accounts. -g: initial groupnum + Development/multi-DB options: + + -s: alternate secrets file + + -n: no ACL added, for bootstrapping + =head1 SEE ALSO L(1), base Freeside documentation