initial commit of file from CVS for smeserver-webshare on Sat Sep 7 21:15:27 AEST 2024
This commit is contained in:
64
root/etc/e-smith/events/actions/webshare-rebuild-htpasswd
Executable file
64
root/etc/e-smith/events/actions/webshare-rebuild-htpasswd
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use esmith::ConfigDB;
|
||||
use Apache::Htpasswd;
|
||||
|
||||
my $db = esmith::ConfigDB->open_ro("WebShare");
|
||||
|
||||
my @WebShare = $db->get_all_by_prop( type => 'WebShare' );
|
||||
my $MultiAccessWebshare = $db->get_prop( "MultiAccess", "WebShareName" ) || "";
|
||||
my %MultiWebshares = split( /,/, $db->get_prop( "MultiAccess", "WebShares" ) || "" );
|
||||
|
||||
foreach my $WebShare (@WebShare) {
|
||||
my $ws = $WebShare->key;
|
||||
my $rec = $db->get("$ws");
|
||||
|
||||
system( "/bin/rm -f /home/e-smith/db/webshare/htpasswd.$ws > /dev/null 2>&1" );
|
||||
system( "/bin/touch", "/home/e-smith/db/webshare/htpasswd.$ws" );
|
||||
|
||||
my %Users = split( /,/, $rec->prop("Users") || "" );
|
||||
|
||||
if ( "%Users" ne "" ) {
|
||||
foreach my $Users ( sort %Users ) {
|
||||
my @user = split( /:/, $Users );
|
||||
my $userName = $user[0];
|
||||
my $password = $user[1];
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Create the MultiAccessWebshare account
|
||||
#------------------------------------------------------------
|
||||
|
||||
if ( ( "$MultiAccessWebshare" eq "$ws" )
|
||||
&& ( "%MultiWebshares" ne "" ) )
|
||||
{
|
||||
my $foo =
|
||||
new Apache::Htpasswd(
|
||||
"/home/e-smith/db/webshare/htpasswd.$MultiAccessWebshare");
|
||||
$foo->htDelete("$userName");
|
||||
$foo->{'USEMD5'} = "MD5";
|
||||
$foo->htpasswd( "$userName", "$password" );
|
||||
|
||||
foreach my $MultiWebshares ( sort %MultiWebshares ) {
|
||||
my $foo1 =
|
||||
new Apache::Htpasswd(
|
||||
"/home/e-smith/db/webshare/htpasswd.$MultiWebshares");
|
||||
$foo1->htDelete("$userName");
|
||||
$foo->{'USEMD5'} = "MD5";
|
||||
$foo1->htpasswd( "$userName", "$password" );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Create the webshare account
|
||||
#------------------------------------------------------------
|
||||
|
||||
my $foo = new Apache::Htpasswd("/home/e-smith/db/webshare/htpasswd.$ws");
|
||||
$foo->htDelete("$userName");
|
||||
$foo->{'USEMD5'} = "MD5";
|
||||
$foo->htpasswd( "$userName", "$password" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(0)
|
Reference in New Issue
Block a user