initial commit of file from CVS for smeserver-webshare on Sat Sep 7 21:15:27 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 21:15:27 +10:00
parent 609e015cb7
commit e4661a6aa1
90 changed files with 5344 additions and 2 deletions

View 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)