initial commit of file from CVS for e-smith-ibays on Wed 12 Jul 08:56:45 BST 2023
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
use esmith::AccountsDB;
|
||||
|
||||
$OUT = join("\n",
|
||||
map { $_->key }
|
||||
grep { $_->prop('PasswordSet') eq 'yes' }
|
||||
esmith::AccountsDB->open_ro->ibays
|
||||
);
|
||||
}
|
@@ -0,0 +1,198 @@
|
||||
#------------------------------------------------------------
|
||||
# Information bay directories
|
||||
#------------------------------------------------------------
|
||||
|
||||
{
|
||||
use esmith::AccountsDB;
|
||||
my $adb = esmith::AccountsDB->open_ro();
|
||||
$OUT = "";
|
||||
foreach my $ibay ($adb->ibays)
|
||||
{
|
||||
my %properties = $ibay->props;
|
||||
my $key = $ibay->key;
|
||||
#------------------------------------------------------------
|
||||
# Figure out which combination of parameters to use. If
|
||||
# PublicAccess parameter is present, this is e-smith 4.0.
|
||||
# Otherwise, it's e-smith 3.0.
|
||||
#------------------------------------------------------------
|
||||
|
||||
my $allow;
|
||||
my $pass;
|
||||
my $satisfy;
|
||||
|
||||
if ($properties{'PublicAccess'})
|
||||
{
|
||||
if ($properties{'PublicAccess'} eq 'none')
|
||||
{
|
||||
next;
|
||||
}
|
||||
elsif ($properties{'PublicAccess'} eq 'local')
|
||||
{
|
||||
$allow = "ip $localAccess";
|
||||
$pass = 0;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
elsif ($properties{'PublicAccess'} eq 'local-pw')
|
||||
{
|
||||
$allow = "ip $localAccess";
|
||||
$pass = 1;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
elsif ($properties{'PublicAccess'} eq 'global')
|
||||
{
|
||||
$allow = 'all granted';
|
||||
$pass = 0;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
elsif ($properties{'PublicAccess'} eq 'global-pw')
|
||||
{
|
||||
$allow = 'all granted';
|
||||
$pass = 1;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
elsif ($properties{'PublicAccess'} eq 'global-pw-remote')
|
||||
{
|
||||
$allow = "ip $localAccess";
|
||||
$pass = 1;
|
||||
$satisfy = 'Any';
|
||||
}
|
||||
}
|
||||
elsif ($properties {'ReadAccess'} eq 'global')
|
||||
{
|
||||
if ($properties {'UsePassword'} eq 'yes')
|
||||
{
|
||||
$allow = 'all granted';
|
||||
$pass = 1;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
else
|
||||
{
|
||||
$allow = 'all granted';
|
||||
$pass = 0;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($properties {'UsePassword'} eq 'yes')
|
||||
{
|
||||
$allow = "ip $localAccess";
|
||||
$pass = 1;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
else
|
||||
{
|
||||
$allow = "ip $localAccess";
|
||||
$pass = 0;
|
||||
$satisfy = 'All';
|
||||
}
|
||||
}
|
||||
|
||||
my $allowOverride = $properties{'AllowOverride'} || "None";
|
||||
my $dynamicContent = $properties{'CgiBin'} || "disabled";
|
||||
my $followSymLinks = $properties{'FollowSymLinks'} || "disabled";
|
||||
my $indexes = $properties{'Indexes'} || "enabled";
|
||||
my $sslRequireSSL = $properties{'SSLRequireSSL'} || "disabled";
|
||||
# here we force SSL if either a password is asked or DAV is enabled
|
||||
$sslRequireSSL = "enabled" if ($pass == 1);
|
||||
$sslRequireSSL = "enabled" if ( ($properties{'ModDav'}||'disabled') eq 'enabled');
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= "#------------------------------------------------------------\n";
|
||||
$OUT .= "# $key ibay directories ($properties{'Name'})\n";
|
||||
$OUT .= "#------------------------------------------------------------\n";
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= "<Directory /home/e-smith/files/ibays/$key/html>\n";
|
||||
if ($sslRequireSSL eq 'enabled')
|
||||
{
|
||||
$OUT .= " SSLRequireSSL\n";
|
||||
}
|
||||
$OUT .= " Options None\n";
|
||||
$OUT .= " Options +Indexes\n" if ($indexes eq 'enabled');
|
||||
$OUT .= " Options +FollowSymLinks\n" if ($followSymLinks eq 'enabled');
|
||||
if ($dynamicContent eq 'enabled')
|
||||
{
|
||||
$OUT .= " Options +Includes\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= " DirectoryIndex index.shtml index.htm index.html\n";
|
||||
$OUT .= " Options +IncludesNOEXEC\n";
|
||||
$OUT .= " <FilesMatch \"\\.(phar|php|phtml)\$\">\n";
|
||||
$OUT .= " Require all denied\n";
|
||||
$OUT .= " </FilesMatch>\n";
|
||||
}
|
||||
$OUT .= " AllowOverride $allowOverride\n";
|
||||
if ($pass)
|
||||
{
|
||||
$OUT .= " AuthName \"$properties{'Name'}\"\n";
|
||||
$OUT .= " AuthType Basic\n";
|
||||
$OUT .= " AuthBasicProvider external\n";
|
||||
$OUT .= " AuthExternal pwauth\n";
|
||||
$OUT .= " <Require$satisfy>\n";
|
||||
$OUT .= " Require user $key\n";
|
||||
$OUT .= " Require $allow\n";
|
||||
$OUT .= " </Require$satisfy>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= " Require $allow\n";
|
||||
}
|
||||
|
||||
$OUT .= "</Directory>\n";
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= "<Directory /home/e-smith/files/ibays/$key/cgi-bin>\n";
|
||||
if ($sslRequireSSL eq 'enabled')
|
||||
{
|
||||
$OUT .= " SSLRequireSSL\n";
|
||||
}
|
||||
if ($dynamicContent eq 'enabled')
|
||||
{
|
||||
$OUT .= " Options ExecCGI\n";
|
||||
}
|
||||
$OUT .= " AllowOverride None\n";
|
||||
if ($pass)
|
||||
{
|
||||
$OUT .= " AuthName \"$properties{'Name'}\"\n";
|
||||
$OUT .= " AuthType Basic\n";
|
||||
$OUT .= " AuthBasicProvider external\n";
|
||||
$OUT .= " AuthExternal pwauth\n";
|
||||
$OUT .= " <Require$satisfy>\n";
|
||||
$OUT .= " Require user $key\n";
|
||||
$OUT .= " Require $allow\n";
|
||||
$OUT .= " </Require$satisfy>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= " Require $allow\n";
|
||||
}
|
||||
|
||||
$OUT .= "</Directory>\n";
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= "<Directory /home/e-smith/files/ibays/$key/files>\n";
|
||||
if ($sslRequireSSL eq 'enabled')
|
||||
{
|
||||
$OUT .= " SSLRequireSSL\n";
|
||||
}
|
||||
$OUT .= " AllowOverride None\n";
|
||||
if ($pass)
|
||||
{
|
||||
$OUT .= " AuthName \"$properties{'Name'}\"\n";
|
||||
$OUT .= " AuthType Basic\n";
|
||||
$OUT .= " AuthBasicProvider external\n";
|
||||
$OUT .= " AuthExternal pwauth\n";
|
||||
$OUT .= " <Require$satisfy>\n";
|
||||
$OUT .= " Require user $key\n";
|
||||
$OUT .= " Require $allow\n";
|
||||
$OUT .= " </Require$satisfy>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= " Require $allow\n";
|
||||
}
|
||||
$OUT .= "</Directory>\n";
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
{
|
||||
use esmith::AccountsDB;
|
||||
my $accounts = esmith::AccountsDB->open_ro;
|
||||
|
||||
use esmith::DomainsDB;
|
||||
my $domains = esmith::DomainsDB->open_ro;
|
||||
|
||||
$OUT = "";
|
||||
|
||||
my $ibay = $virtualHostContent;
|
||||
my $basedir = "/home/e-smith/files/ibays/$ibay";
|
||||
my $cgiBin = $accounts->get_prop($ibay, "CgiBin") || "";
|
||||
my $ssl_domain = $accounts->get_prop($ibay, "SSLRequireSSL") || "disabled";
|
||||
my $access = $accounts->get_prop($ibay,'PublicAccess') || 'none';
|
||||
my $pass = $access =~ /-pw/;
|
||||
$ssl_domain = "enabled" if $pass;
|
||||
$ssl_domain = "enabled" if (($accounts->get_prop($ibay, 'ModDav')||'disabled') eq 'enabled');
|
||||
|
||||
$OUT .= " DocumentRoot $basedir/html\n";
|
||||
|
||||
if (( $port ne $httpsPort ) && ( $ssl_domain eq 'enabled'))
|
||||
{
|
||||
my $portspec = ($httpsPort eq 443) ? "" : ":$httpsPort";
|
||||
$OUT .= " RewriteEngine on\n";
|
||||
$OUT .= " RewriteRule ^/(.*|\$) https://%{HTTP_HOST}${portspec}/\$1 [R,L]\n";
|
||||
}
|
||||
|
||||
if ($cgiBin)
|
||||
{
|
||||
$OUT .= " ScriptAlias /cgi-bin $basedir/cgi-bin\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .=
|
||||
" # To add cgi-bin ScriptAlias for this i-bay, run:\n"
|
||||
. " # /sbin/e-smith/db accounts setprop $ibay CgiBin "
|
||||
. "enabled\n"
|
||||
. " # /sbin/e-smith/signal-event console-save\n";
|
||||
}
|
||||
$OUT .= " Alias /files $basedir/files\n";
|
||||
|
||||
if (($domains->get_prop($virtualHost, 'SystemPrimaryDomain') || 'no')
|
||||
eq 'yes')
|
||||
{
|
||||
my @ibays = $accounts->ibays;
|
||||
foreach my $ibay (@ibays)
|
||||
{
|
||||
my $key = $ibay->key;
|
||||
next if $key eq $virtualHostContent;
|
||||
my $basedir = "/home/e-smith/files/ibays/$key";
|
||||
my $cgiBin = $ibay->prop("CgiBin") || "";
|
||||
my $name = $ibay->prop("Name") || "";
|
||||
|
||||
$OUT .= "\n";
|
||||
$OUT .= " # $key ibay ($name)\n";
|
||||
$OUT .= "\n";
|
||||
|
||||
my $ssl_bay = $ibay->prop('SSLRequireSSL') || 'disabled';
|
||||
my $access_bay = $ibay->prop('PublicAccess') || 'none';
|
||||
my $pass_bay = $access_bay =~ /-pw/;
|
||||
$ssl_bay = "enabled" if $pass_bay ;
|
||||
$ssl_bay = "enabled" if (($ibay->prop('ModDav')||'disabled') eq 'enabled');
|
||||
|
||||
if (( $port ne $httpsPort ) && ($ssl_bay eq 'enabled')){
|
||||
my $portspec = ($httpsPort eq 443) ? "" : ":$httpsPort";
|
||||
$OUT .= " RewriteEngine on\n";
|
||||
$OUT .= " RewriteRule ^/$key(/.*|\$) https://%{HTTP_HOST}${portspec}/$key\$1 \[L,R\]\n";
|
||||
}
|
||||
if ($cgiBin)
|
||||
{
|
||||
$OUT .= " ScriptAlias /$key/cgi-bin $basedir/cgi-bin\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .=
|
||||
" # To add cgi-bin ScriptAlias for this i-bay, run:\n"
|
||||
. " # /sbin/e-smith/db accounts setprop $key CgiBin "
|
||||
. "enabled\n"
|
||||
. " # /sbin/e-smith/signal-event console-save\n";
|
||||
}
|
||||
|
||||
$OUT .= " Alias /$key/files $basedir/files\n";
|
||||
|
||||
# Make sure this one is last since it's a prefix of the above
|
||||
# aliases. If we put it first, it would get expanded before the
|
||||
# other aliases, creating problems.
|
||||
|
||||
$OUT .= " Alias /$key $basedir/html\n";
|
||||
}
|
||||
$OUT .= " # No ibays in system\n" unless @ibays;
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
{
|
||||
use esmith::AccountsDB;
|
||||
|
||||
$adb = esmith::AccountsDB->open_ro();
|
||||
|
||||
"";
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
{
|
||||
|
||||
my $desc = $adb->get_prop($IBAY_NAME, "Name") || "No description";
|
||||
|
||||
$OUT =<<HERE;
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>Information Bay: $desc</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
|
||||
<H1>Information Bay</H1>
|
||||
|
||||
<P>This information bay has not yet been customized.</P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
HERE
|
||||
}
|
Reference in New Issue
Block a user