initial commit of file from CVS for e-smith-ibays on Wed 12 Jul 08:56:45 BST 2023

This commit is contained in:
Brian Read
2023-07-12 08:56:45 +01:00
parent 7ea7fdccf4
commit 1f503a7f0d
33 changed files with 2751 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
{
foreach my $ibay ($DB->get_all_by_prop(type => 'ibay'))
{
# SME9 introduced SSLRequireSSL with enabled/disabled.
# This replaces local customisation, so migrate 'on' to 'enabled'
$ibay->set_prop ('SSLRequireSSL', 'enabled') if (($ibay->prop ('SSLRequireSSL') || '') eq 'on');
# SME10 merge SSL property (setting to redirect to https) with SSLRequireSSL (setting to force SSL in a directory)
# while they have two different purpose, most admin will want to protect one directory with SSL and ease access to their
# client to gently redirect them to https, hence the merge.
my $SSL = $DB->get_prop_and_delete($ibay->key, 'SSL') || 'disabled';
# if SSL is enabled or SSLRequireSSL is enabled we want the new one enabled
# default remains empty for disabled for the moment
$ibay->set_prop('SSLRequireSSL','enabled') if ($SSL eq 'enabled');
}
}

View File

@@ -0,0 +1 @@
12

View File

@@ -0,0 +1,30 @@
#!/usr/bin/perl -w
use strict;
use esmith::AccountsDB;
use esmith::event;
my $accounts = esmith::AccountsDB->open() or
die "Unable to open accounts db: $!";
my ($self, $groupName) = @ARGV;
# Find all "i-bay" entries in the e-smith accounts database and
# if the group matches this one, change it to group "admin".
my @modified_ibays;
foreach my $ibay ( $accounts->ibays ) {
if ( $ibay->prop('Group') eq $groupName ) {
$ibay->set_prop( 'Group', 'admin' );
push @modified_ibays, $ibay->key;
event_signal("ibay-modify-files", $ibay->key) or
die ("Error occurred while updating i-bay.\n");
}
}
my $count = @modified_ibays;
if ( $count > 0 ) {
event_signal("ibay-modify-servers" ) or
die ("Error occurred after updating i-bays.\n");
}

View File

@@ -0,0 +1,49 @@
#!/bin/sh
#----------------------------------------------------------------------
# copyright (C) 1999-2005 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#----------------------------------------------------------------------
#------------------------------------------------------------
# Delete the Unix account and files for the ibay.
#------------------------------------------------------------
event=$1
ibay=$2
if [ -z "$ibay" ]
then
echo ibayName argument missing
exit 1
fi
ldapauth=$(/sbin/e-smith/config getprop ldap Authentication || echo disabled)
x=0 # exit value
/bin/rm -rf /home/e-smith/files/ibays/$ibay
if [ "$ldapauth" != "enabled" ]
then
/usr/sbin/userdel "$ibay" || x=1
/usr/sbin/cpu -C/etc/cpu-system.conf userdel "$ibay"
/usr/sbin/cpu -C/etc/cpu-system.conf groupdel "$ibay"
else
/usr/sbin/cpu userdel "$ibay" || x=1
/usr/sbin/cpu -C/etc/cpu-system.conf groupdel "$ibay" || x=1
fi
exit $x

View File

@@ -0,0 +1,232 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 1999-2005 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#----------------------------------------------------------------------
package esmith;
use strict;
use Errno;
use File::Find;
use esmith::util;
use esmith::templates;
use esmith::AccountsDB;
use esmith::ConfigDB;
my $conf = esmith::ConfigDB->open_ro
or die "Could not open Config DB";
my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled';
my $x = 0; # exit value
$ENV{'PATH'} = "/bin";
my $event = $ARGV [0];
my $ibayName = $ARGV [1];
die "ibayName argument missing" unless defined ($ibayName);
my $accountdb = esmith::AccountsDB->open_ro();
my $ibay = $accountdb->get($ibayName) or
die "Couldn't find $ibayName record in accounts db\n";
die "Account $ibayName is not an ibay account; modify ibay event failed.\n"
unless ($ibay->prop('type') eq 'ibay');
if ($event eq 'ibay-create')
{
#------------------------------------------------------------
# Check the Unix account.
#------------------------------------------------------------
# Create the ibay's unique group first
if ($ldapauth ne 'enabled')
{
system(
"/usr/sbin/groupadd",
"-g",
$ibay->prop("Gid"),
$ibayName
) == 0 or ( $x = 255, warn "Failed to create (unix) group $ibayName.\n" );
system(
"/usr/sbin/useradd",
"-u",
$ibay->prop("Uid"),
"-g",
$ibay->prop("Gid"),
"-c",
$ibay->prop("Name"),
"-d",
"/home/e-smith/files/ibays/$ibayName/files",
"-G",
"shared,"
. $ibay->prop("Group"),
"-M",
"-s",
"/bin/false",
"$ibayName"
) == 0 or ( $x = 255, warn "Failed to create (unix) account $ibayName.\n" );
}
system(
"/usr/sbin/cpu", "-C/etc/cpu-system.conf", "groupadd",
"-g",
$ibay->prop("Gid"),
$ibayName
) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) group $ibayName.\n" );
system(
"/usr/sbin/cpu", "-C/etc/cpu-system.conf", "useradd",
"-u",
$ibay->prop("Uid"),
"-g",
$ibay->prop("Gid"),
"-c",
$ibay->prop("Name"),
"-d",
"/home/e-smith/files/ibays/$ibayName/files",
"-G",
"shared,"
. $ibay->prop("Group"),
"-s",
"/bin/false",
"$ibayName"
) == 0 or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to create (ldap) account $ibayName.\n" );
#------------------------------------------------------------
# Create the ibay files and set the password.
#------------------------------------------------------------
system("/bin/cp", "-Rp", "/etc/e-smith/skel/ibay",
"/home/e-smith/files/ibays/$ibayName") == 0
or ( $x = 255, warn "Error copying ibay skeletal files" );
processTemplate( {
TEMPLATE_PATH=>"/home/e-smith/files/ibays/html/index.html",
OUTPUT_FILENAME=>"/home/e-smith/files/ibays/$ibayName/html/index.html",
MORE_DATA=>{IBAY_NAME=>$ibayName},
} );
if ($ldapauth ne 'enabled')
{
system("/usr/bin/passwd", "-l", $ibayName) == 0
or ( $x = 255, warn "Error locking (unix) account $ibayName" );
}
system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "usermod", "-L", $ibayName) == 0
or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Error locking (ldap) account $ibayName" );
}
elsif ($event eq 'ibay-modify' and $ibayName ne 'Primary')
{
#------------------------------------------------------------
# Modify ibay description in /etc/passwd using "usermod"
#------------------------------------------------------------
if ($ldapauth ne 'enabled')
{
system("/usr/sbin/usermod", "-c", $ibay->prop("Name"),
"-G", "shared," . $ibay->prop("Group"), "$ibayName") == 0
or ( $x = 255, warn "Failed to modify (unix) account $ibayName.\n" );
}
system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "usermod", "-c", $ibay->prop("Name"),
"-G", "shared," . $ibay->prop("Group"), "$ibayName") == 0
or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify (ldap) account $ibayName.\n" );
}
#------------------------------------------------------------
# Fix permissions on ibay files.
#------------------------------------------------------------
#--------------------------------------------------
# main directory is writeable only by root
#--------------------------------------------------
chdir "/home/e-smith/files/ibays/$ibayName"
or ( $x = 255, warn "Could not chdir to /home/e-smith/files/ibays/$ibayName" );
esmith::util::chownFile("root", "root", ".");
chmod 0755, ".";
#--------------------------------------------------
# fix ownership of subdirectories
#--------------------------------------------------
#--------------------------------------------------
# Set the group as www if it was admin, since
# while set as admin, the web server no longer has
# access to the ibay HTML directory, and web pages.
#--------------------------------------------------
my %properties = $ibay->props;
$::group = ($properties{'Group'} eq "admin") ? "www" : $properties {'Group'};
# Make sensible defaults
$::owner = undef;
$::fileperm = 0600;
$::dirperm = 0550;
if ($properties {'UserAccess'} eq 'wr-admin-rd-group')
{
$::owner = "admin";
$::fileperm = 0640;
$::dirperm = 02750;
}
elsif ($properties {'UserAccess'} eq 'wr-group-rd-group')
{
$::fileperm = 0660;
$::dirperm = 02770;
}
elsif ($properties {'UserAccess'} eq 'wr-group-rd-everyone')
{
$::fileperm = 0664;
$::dirperm = 02775;
}
else
{
warn("Value of UserAccess bad or unset");
}
sub process
{
if (-l)
{
$File::Find::prune = 1;
}
else
{
esmith::util::chownFile($::owner, $::group, $_);
if (-d)
{
chmod $::dirperm, $_;
}
elsif (-f)
{
# Preserve execute permissions on files
my $experm = (stat($_))[2] & 0111;
$experm |= $::fileperm;
chmod $experm, $_;
}
}
}
find(\&process, glob("*"));
exit ($x);

View File

@@ -0,0 +1,64 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 1999-2003 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
package esmith;
use strict;
use Errno;
use esmith::util;
use esmith::AccountsDB;
# Populate pre-defined Primary i-bay
# Start with top level owner/permissions
my $files = "/home/e-smith/files";
my $perms = 0755;
my $owner = 'root';
my $group = 'root';
foreach (qw(Primary Primary/cgi-bin Primary/html Primary/files))
{
my $dir = "$files/ibays/$_";
unless (-d "$dir")
{
mkdir ($dir, $perms) or warn "Could not create dir $dir: $!";
chmod ($perms, $dir) or warn "Could not chmod dir $dir: $!";
esmith::util::chownFile($owner, $group, $dir);
}
# Switch to subdir owner/permissions
$perms = 02750;
$owner = 'admin';
$group = 'shared';
}
# Create a starter website index page if necessary
if( !grep /\.\w+$/, </home/e-smith/files/ibays/Primary/html/index.*> )
{
system("/bin/cp", "-p",
"/etc/e-smith/skel/e-smith/files/primary/html/index.htm",
"/home/e-smith/files/ibays/Primary/html/index.htm");
chmod 0640, "/home/e-smith/files/ibays/Primary/html/index.htm";
esmith::util::chownFile('admin', 'shared',
"/home/e-smith/files/ibays/Primary/html/index.htm");
}
exit (0);

View File

@@ -0,0 +1,286 @@
<!-- vim: ft=xml ts=4 sw=8 noet:
-->
<lexicon lang="en-us" params="getExtraParams()">
<entry>
<base>FORM_TITLE</base>
<trans>
Create, modify, or remove i-bays
</trans>
</entry>
<entry>
<base>FIRSTPAGE_DESC</base>
<trans>
<![CDATA[
<p>
<a class="button-like" href="ibays?page=0&page_stack=&Next=Next&wherenext=CreateModify">Add i-bay</a>
</p>
<p>
You can remove any information bay or reset its password by
clicking on the corresponding command
next to the information bay. If the information bay shows up
in red, that means that the password has not
yet been changed from the default, and should be changed
soon.
</p>
]]>
</trans>
</entry>
<entry>
<base>ADD_TITLE</base>
<trans>
Create or modify an i-bay
</trans>
</entry>
<entry>
<base>NAME_FIELD_DESC</base>
<trans>
The information bay name should contain only lower-case
letters, numbers, periods, hyphens and underscores, and
should start with a lower-case letter. For example
"johnson", "intra", and "cust3.prj12" are all valid
names, but "3associates", "John Smith" and
"Bus!Partner" are not. The name is limited to
{$maxLength} characters.
</trans>
</entry>
<entry>
<base>NAME_LABEL</base>
<trans>
Information bay name
</trans>
</entry>
<entry>
<base>USER_ACCESS</base>
<trans>
User access via file sharing or user ftp
</trans>
</entry>
<entry>
<base>PUBLIC_ACCESS</base>
<trans>
Public access via web or anonymous ftp
</trans>
</entry>
<entry>
<base>PUBLIC_ACCESS_DESCRIPTION</base>
<trans>
The public access mode "password required outside local
network" is not supported by the FTP server component. If
you select this mode, the FTP server will require a
password both inside and outside the local network for this
i-bay.
</trans>
</entry>
<entry>
<base>ALLOW_DYNAMIC_CONTENT</base>
<trans>
Execution of dynamic content (CGI, PHP, SSI)
</trans>
</entry>
<entry>
<base>HTTPS_Only</base>
<trans>
Force secure connections
</trans>
</entry>
<entry>
<base>REMOVE_TITLE</base>
<trans>
Remove information bay
</trans>
</entry>
<entry>
<base>REMOVE_DESC</base>
<trans>
<![CDATA[
<p>
You are about to remove the information bay "{$name}"
({$description}).
</p>
<p>
All files belonging to this information bay will be deleted.
</p>
<p>
Are you sure you wish to remove this information bay?
</p>
]]>
</trans>
</entry>
<entry>
<base>ERROR_WHILE_CREATING_IBAY</base>
<trans>
An error occurred while creating the i-bay.
</trans>
</entry>
<entry>
<base>SUCCESSFULLY_CREATED_IBAY</base>
<trans>
Successfully created i-bay.
</trans>
</entry>
<entry>
<base>NO_IBAYS</base>
<trans>
There are no i-bays currently configured.
</trans>
</entry>
<entry>
<base>CANT_FIND_IBAY</base>
<trans>
Can't find account for {$name} (does it exist?)
</trans>
</entry>
<entry>
<base>CANT_CREATE_IBAY</base>
<trans>
Can't create new account for {$name} (does it already exist?)
</trans>
</entry>
<entry>
<base>ERROR_WHILE_MODIFYING_IBAY</base>
<trans>
An error occurred while modifying the i-bay.
</trans>
</entry>
<entry>
<base>SUCCESSFULLY_MODIFIED_IBAY</base>
<trans>
Successfully modified i-bay.
</trans>
</entry>
<entry>
<base>VIRTUAL_HOST_MESSAGE</base>
<trans>
The following virtual domains were using this information
bay as their content and will be changed to the primary web
site (you can change them to something else afterward).
</trans>
</entry>
<entry>
<base>SUCCESSFULLY_DELETED_IBAY</base>
<trans>
Successfully deleted i-bay.
</trans>
</entry>
<entry>
<base>ERROR_WHILE_DELETING_IBAY</base>
<trans>
An error occurred while deleting the i-bay.
</trans>
</entry>
<entry>
<base>PASSWORD_DESC</base>
<trans>
You are about to change the password for the i-bay {$name}.
</trans>
</entry>
<entry>
<base>IBAY_PASSWD_VALIDATION_ERROR</base>
<trans>
The password may contain only letters and numbers.
</trans>
</entry>
<entry>
<base>IBAY_PASSWD_VERIFY_ERROR</base>
<trans>
The passwords do not match.
</trans>
</entry>
<entry>
<base>SUCCESSFULLY_RESET_PASSWORD</base>
<trans>
Successfully reset password.
</trans>
</entry>
<entry>
<base>ERROR_WHILE_RESETTING_PASSWORD</base>
<trans>
Error while resetting password.
</trans>
</entry>
<entry>
<base>VHOST_MESSAGE</base>
<trans>
<![CDATA[
<P>The following virtual domains were using this information bay
as their content and will be changed to the primary web site
(you can change them to something else afterward):</P>
<ul>{$vhostList}</ul>
]]>
</trans>
</entry>
<entry>
<base>Information bays</base>
<trans>Information bays</trans>
</entry>
<entry>
<base>WGRG</base>
<trans>Write = group, Read = group</trans>
</entry>
<entry>
<base>WGRE</base>
<trans>Write = group, Read = everyone</trans>
</entry>
<entry>
<base>WARG</base>
<trans>Write = admin, Read = group</trans>
</entry>
<entry>
<base>NONE</base>
<trans>No access</trans>
</entry>
<entry>
<base>LOCAL_NETWORK_NO_PASSWORD</base>
<trans>Local network (no password required)</trans>
</entry>
<entry>
<base>LOCAL_NETWORK_PASSWORD</base>
<trans>Local network (password required)</trans>
</entry>
<entry>
<base>ENTIRE_INTERNET_NO_PASSWORD</base>
<trans>Entire Internet (no password required)</trans>
</entry>
<entry>
<base>ENTIRE_INTERNET_PASSWORD</base>
<trans>Entire Internet (password required)</trans>
</entry>
<entry>
<base>ENTIRE_INTERNET_PASSWORD_REMOTE</base>
<trans>Entire Internet (password required outside local network)</trans>
</entry>
<entry>
<base>INVALID_IBAY_DESCRIPTION</base>
<trans>Error: unexpected or missing characters in i-bay description</trans>
</entry>
<entry>
<base>ACCT_NAME_HAS_INVALID_CHARS</base>
<trans>The i-bay name "{$acctName}" contains invalid characters.
I-bay names must start with a lower case letter and contain
only lower case letters, numbers, and hyphens.
</trans>
</entry>
<entry>
<base>MAX_IBAY_NAME_LENGTH_ERROR</base>
<trans>
The i-bay name "{$name}" is too long. The maximum is
{$maxIbayNameLength} characters.
</trans>
</entry>
<entry>
<base>ACCT_CLASHES_WITH_PSEUDONYM</base>
<trans>
<![CDATA[
The account "{$acctName}" clashes with pseudonym
details for {$acctType} account "{$acct}".
<p>{$acctName} is a pseudonym for {$acct}.</p>
]]>
</trans>
</entry>
<entry>
<base>ACCOUNT_EXISTS</base>
<trans>
The account "{$acctName}" is an existing {$acctType} account.
</trans>
</entry>
</lexicon>

View File

View File

View File

View File

View File

View File

@@ -0,0 +1,9 @@
{
use esmith::AccountsDB;
$OUT = join("\n",
map { $_->key }
grep { $_->prop('PasswordSet') eq 'yes' }
esmith::AccountsDB->open_ro->ibays
);
}

View File

@@ -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";
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,7 @@
{
use esmith::AccountsDB;
$adb = esmith::AccountsDB->open_ro();
"";
}

View File

@@ -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
}

View File

View File

@@ -0,0 +1,145 @@
#!/usr/bin/perl -wT
# vim: ft=xml ts=4 sw=4 et:
#----------------------------------------------------------------------
# heading : Collaboration
# description : Information bays
# navigation : 2000 2500
#
# Copyright (c) 2001 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from e-smith, inc.
# Please visit our web site www.e-smith.com for details.
#----------------------------------------------------------------------
use strict;
use esmith::FormMagick::Panel::ibays;
my $fm = esmith::FormMagick::Panel::ibays->new();
$fm->display();
=pod
=head1 NAME
ibays -- add/remove/manage ibays
=head2 DESCRIPTION
This screen allows the administrator to manage information bays.
=begin testing
use esmith::FormMagick::Tester;
use esmith::TestUtils;
use esmith::TestUtils;
use esmith::ConfigDB;
use esmith::AccountsDB;
my $panel = $Original_File;
my $ua = esmith::FormMagick::Tester->new();
my $c = esmith::ConfigDB->open();
my $a = esmith::AccountsDB->open();
is (mode($panel), '4750', "Check permissions on script");
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
is ($ua->{status}, 200, "200 OK");
#like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
ok ($ua->set_language("en"), "Set language to English");
ok ($ua->get_panel($panel), "Get panel");
is ($ua->{status}, 200, "200 OK");
like($ua->{content}, qr/Information bays/, "Saw translated form title");
ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING IBAY");
ok ($ua->follow("Click here"), "Follow 'create ibay' link");
is ($ua->{status}, 200, "200 OK");
like($ua->{content}, qr/Create a new information bay/, "Saw page title");
like($ua->{content}, qr/Brief description/, "Saw description field");
like($ua->{content}, qr/Group/, "Saw group field");
like($ua->{content}, qr/User access via file/, "Saw user access field");
like($ua->{content}, qr/Public access via/, "Saw Public access field");
like($ua->{content}, qr/Add/, "Saw add button");
SKIP: {
skip 10, "Unsafe!" unless destruction_ok();
ok ($ua->follow("Click here"), "ACTUALLY ADDING A NETWORK");
$ua->field();
$ua->click("Add");
like($ua->{content}, qr/Successfully added ibay/, "Saw success message");
ok ($ua->follow("Remove"), "REMOVING NETWORK");
like($ua->{content}, qr/Are you sure/, "Saw confirmation message");
$ua->click("Remove");
like($ua->{content}, qr/Successfully deleted/, "Saw success message");
}
=cut
__DATA__
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl" footer="/etc/e-smith/web/common/foot.tmpl">
<page name="First" pre-event="print_status_message()">
<description>FIRSTPAGE_DESC</description>
<subroutine src="print_ibay_table()" />
</page>
<page name="CreateModify" pre-event="turn_off_buttons()" post-event="handle_ibays()">
<title>ADD_TITLE</title>
<subroutine src="print_ibay_name_field()" />
<field type="text" id="description" validation="validate_description">
<label>DESCRIPTION</label>
</field>
<field type="select" id="group" options="group_list()">
<label>GROUP</label>
</field>
<field type="select" id="userAccess" options="userAccess_list()">
<label>USER_ACCESS</label>
</field>
<field type="select" id="publicAccess" options="publicAccess_list()" value="none">
<label>PUBLIC_ACCESS</label>
</field>
<field type="select" id="CgiBin" options="'disabled' => 'DISABLED', 'enabled' => 'ENABLED'">
<label>ALLOW_DYNAMIC_CONTENT</label>
</field>
<field type="select" id="SSLRequireSSL" options="'disabled' => 'DISABLED', 'enabled' => 'ENABLED'">
<label>HTTPS_Only</label>
</field>
<subroutine src="print_save_or_add_button()" />
</page>
<page name="Remove" pre-event="turn_off_buttons()" post-event="remove_ibay()">
<title>REMOVE_TITLE</title>
<description>REMOVE_DESC</description>
<subroutine src="print_vhost_message()" />
<subroutine src="print_button('REMOVE')" />
</page>
<page name="Password" pre-event="turn_off_buttons()" post-event="reset_password()">
<title>PASSWORD_RESET</title>
<description>PASSWORD_DESC</description>
<field type="password" id="newPass" validation="nonblank, check_password">
<label>PASSWORD_NEW</label>
</field>
<field type="password" id="newPassVerify" validation="verifyPasswords">
<label>PASSWORD_VERIFY_NEW</label>
</field>
<subroutine src="print_button('SAVE')"/>
</page>
</form>

View File

View File

View File