You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.4 KiB
76 lines
2.4 KiB
#------------------------------------------------------------
|
|
# e-smith-user panel
|
|
#------------------------------------------------------------
|
|
{
|
|
use esmith::AccountsDB;
|
|
my $a = esmith::AccountsDB->open_ro;
|
|
|
|
my %panelshash;
|
|
opendir (DIR, "/etc/e-smith/web/panels/user/cgi-bin")
|
|
|| die "Can't open /etc/e-smith/web/panels/user/cgi-bin directory.\n";
|
|
|
|
my @files = sort (grep (!/(^\.\.?$)|(^pleasewait$)|(^userpanel-[a-z][\-\_a-z0-9]*)/, readdir(DIR)));
|
|
|
|
closedir (DIR);
|
|
|
|
# TODO: globalPanels
|
|
# my $globalpanels = db_get_prop(\%accounts, 'globalUP', 'AdminPanels');
|
|
# $globalpanels = '' if ( ! defined ($globalpanels) );
|
|
# my @globalpanels = split (/,/, $globalpanels, -1);
|
|
|
|
foreach $file (@files){
|
|
next if ($globalpanels && grep (/^$file$/, @globalpanels));
|
|
foreach my $user ($a->users){
|
|
my $key = $user->key;
|
|
push @{$panelshash{$file}}, $key
|
|
if ((grep {$file eq $_} split(/[;,]/, ($user->prop('AdminPanels') || '')))
|
|
&& (!grep {$key eq $_} @{$panelshash{$file}}));
|
|
}
|
|
foreach my $group ($a->groups){
|
|
foreach my $member (split(/[;,]/,($group->prop('Members') || ''))){
|
|
push @{$panelshash{$file}}, $member
|
|
if ((grep {$file eq $_} split(/[;,]/, ($group->prop('AdminPanels') || '')))
|
|
&& (!grep {$member eq $_} @{$panelshash{$file}}));
|
|
}
|
|
}
|
|
}
|
|
|
|
$OUT .= <<HERE;
|
|
|
|
<Directory \"/etc/e-smith/web/panels/user/html\" >
|
|
Options Includes Indexes FollowSymLinks
|
|
AllowOverride None
|
|
order deny,allow
|
|
deny from all
|
|
allow from $localAccess
|
|
PerlHeaderParserHandler My::Package
|
|
Satisfy all
|
|
</Directory>
|
|
|
|
<Directory \"/etc/e-smith/web/panels/user/cgi-bin\" >
|
|
Options Includes Indexes FollowSymLinks
|
|
AllowOverride None
|
|
order deny,allow
|
|
deny from all
|
|
allow from $localAccess
|
|
PerlHeaderParserHandler My::Package
|
|
Satisfy all
|
|
|
|
HERE
|
|
|
|
foreach my $file (@files){
|
|
next unless ( defined ($panelshash{$file}) );
|
|
foreach my $u (@{$panelshash{$file}}){
|
|
$OUT .= " SetEnvIf Auth-User \"$u\" allow_$file\n";
|
|
}
|
|
$OUT .= "\n";
|
|
$OUT .= " <Files $file>\n";
|
|
$OUT .= " order deny,allow\n";
|
|
$OUT .= " deny from all\n";
|
|
$OUT .= " allow from env=allow_$file\n";
|
|
$OUT .= " </Files>\n";
|
|
}
|
|
|
|
$OUT .= "</Directory>\n";
|
|
}
|
|
|
|
|