Author: benj
Date: Tue May 31 11:51:49 2016
New Revision: 1689
URL: http://svn.gna.org/viewcvs/gdtc?rev=1689&view=rev
Log:
Add htpasswd
Modified:
trunk/gdtc/scripts/dtcmanager
Modified: trunk/gdtc/scripts/dtcmanager
URL:
http://svn.gna.org/viewcvs/gdtc/trunk/gdtc/scripts/dtcmanager?rev=1689&r1=1688&r2=1689&view=diff
==============================================================================
--- trunk/gdtc/scripts/dtcmanager (original)
+++ trunk/gdtc/scripts/dtcmanager Tue May 31 11:51:49 2016
@@ -25,6 +25,8 @@
use lib dirname $0;
require 'config.pl';
require 'utils.pl';
+use MIME::Base64;
+
use POSIX qw(locale_h);
use locale;
@@ -100,6 +102,10 @@
$command eq 'planete' )
{
&update_planet ( @args );
+ }
+ elsif ( $command eq 'htpasswd' )
+ {
+ &update_htpasswd ( @args );
}
else
{
@@ -227,6 +233,31 @@
print "\n";
}
+ }
+}
+
+
+
+sub update_htpasswd ()
+{
+ dtc_log ( "Updating htpasswd..." );
+
+ my @results = do_select ( "SELECT * " .
+ " FROM actor " .
+ " WHERE actor.password != '' " .
+ " AND actor.password != 'none' " .
+ " AND actor.password IS NOT NULL " .
+ " AND actor.actor_status IN ( 'employee',
'member' ) " .
+ " ORDER BY actor_id ASC;" );
+ if ( ! @results || ! scalar @results )
+ {
+ fatal ( "Failed to update htpasswd" );
+ }
+
+ foreach my $person ( @results )
+ {
+ printf ( "%s:{SHA}%s", $person -> { 'nickname' },
+ encode_base64 ( pack ('H*', ( $person -> { 'password' } ) ) )
);
}
}
_______________________________________________
Gdtc-commits mailing list
[email protected]
https://mail.gna.org/listinfo/gdtc-commits