slightly better bootstrapping for htpasswd kludge... hopefully that will go away...
authorivan <ivan>
Sun, 6 Aug 2006 23:39:02 +0000 (23:39 +0000)
committerivan <ivan>
Sun, 6 Aug 2006 23:39:02 +0000 (23:39 +0000)
FS/FS/access_user.pm
FS/bin/freeside-adduser

index d325dd6..37b3b2f 100644 (file)
@@ -104,6 +104,7 @@ sub insert {
 
 sub htpasswd_kludge {
   my $self = shift;
+  unshift @_, '-c' unless -e $htpasswd_file;
   if ( 
        system('htpasswd', '-b', @_,
                           $htpasswd_file,
index 0d8b454..3976cae 100644 (file)
@@ -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<htpasswd>(1), base Freeside documentation