line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2008 by Mark Overmeer. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 1.05. |
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package HTTP::Server::Directory::UserDirs; |
9
|
1
|
|
|
1
|
|
5
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.11'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use base 'HTTP::Server::Directory'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
93
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use Log::Report 'httpd-multiplex', syntax => 'SHORT'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init($) |
18
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
0
|
|
|
|
my $subdirs = $args->{user_subdirs} || 'public_html'; |
21
|
0
|
0
|
|
|
|
|
my %allow = map { ($_ => 1) } @{$args->{allow_users} || []}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
my %deny = map { ($_ => 1) } @{$args->{deny_users} || []}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
23
|
0
|
|
0
|
|
|
|
$args->{location} ||= $self->userdirRewrite($subdirs, \%allow, \%deny); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$self->SUPER::init($args); |
26
|
0
|
|
|
|
|
|
$self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#----------------- |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#----------------- |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub userdirRewrite($$$) |
34
|
0
|
|
|
0
|
0
|
|
{ my ($self, $udsub, $allow, $deny) = @_; |
35
|
0
|
|
|
|
|
|
my %homes; # cache |
36
|
0
|
|
|
0
|
|
|
sub { my ($user, $pathinfo) = $_[0] =~ m!^/\~([^/]*)(.*)!; |
37
|
0
|
0
|
0
|
|
|
|
return if keys %$allow && !$allow->{$user}; |
38
|
0
|
0
|
0
|
|
|
|
return if keys %$deny && $deny->{$user}; |
39
|
0
|
0
|
0
|
|
|
|
return if exists $homes{$user} && !defined $homes{$user}; |
40
|
0
|
|
0
|
|
|
|
my $d = $homes{$user} ||= (getpwnam $user)[7]; |
41
|
0
|
0
|
|
|
|
|
$d ? "$d/$udsub$pathinfo" : undef; |
42
|
0
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |