#------------------------------------------------------------ # 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 .= < Options Includes Indexes FollowSymLinks AllowOverride None order deny,allow deny from all allow from $localAccess PerlHeaderParserHandler My::Package Satisfy all 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 .= " \n"; $OUT .= " order deny,allow\n"; $OUT .= " deny from all\n"; $OUT .= " allow from env=allow_$file\n"; $OUT .= " \n"; } $OUT .= "\n"; }