line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache2::AuthzCaps; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
49684
|
use 5.014000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
816
|
use subs qw/OK DECLINED/; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
940
|
no if $] >= 5.017011, warnings => 'experimental::smartmatch'; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.001001'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
75
|
use if $ENV{MOD_PERL}, 'Apache2::Access'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
33
|
use if $ENV{MOD_PERL}, 'Apache2::Const' => qw/OK DECLINED/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
12
|
1
|
|
|
1
|
|
26
|
use if $ENV{MOD_PERL}, 'Apache2::RequestRec'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
13
|
1
|
|
|
1
|
|
687
|
use YAML::Any qw/LoadFile DumpFile/; |
|
1
|
|
|
|
|
823
|
|
|
1
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
8848
|
use parent qw/Exporter/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw/setcap hascaps/; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
################################################## |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $rootdir; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub setcap{ |
24
|
3
|
|
|
3
|
1
|
1402
|
my ($user, $cap, $value) = @_; |
25
|
3
|
|
100
|
|
|
8
|
my $config = eval { LoadFile "$rootdir/$user.yml" } // {}; |
|
3
|
|
|
|
|
17
|
|
26
|
3
|
|
100
|
|
|
9151
|
$config->{caps}//={}; |
27
|
3
|
|
|
|
|
6
|
my $caps=$config->{caps}; |
28
|
|
|
|
|
|
|
|
29
|
3
|
100
|
|
|
|
10
|
delete $caps->{$cap} unless $value; |
30
|
3
|
100
|
|
|
|
9
|
$caps->{$cap} = 1 if $value; |
31
|
3
|
|
|
|
|
16
|
DumpFile "$rootdir/$user.yml", $config |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub hascaps{ |
35
|
4
|
|
|
4
|
1
|
21322
|
my ($user, @caps) = @_; |
36
|
4
|
|
|
|
|
22
|
my $config = LoadFile "$rootdir/$user.yml"; |
37
|
4
|
|
|
|
|
20508
|
my $caps = $config->{caps}; |
38
|
4
|
|
|
|
|
13
|
for (@caps) { |
39
|
6
|
100
|
|
|
|
31
|
return 0 unless $caps->{$_} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
1 |
42
|
2
|
|
|
|
|
14
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub handler{ |
45
|
0
|
|
|
0
|
1
|
|
my $r=shift; |
46
|
0
|
|
|
|
|
|
my $user = $r->user; |
47
|
0
|
|
|
|
|
|
local $rootdir = $r->dir_config('AuthzCapsRootdir'); |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if ($user) { |
50
|
0
|
|
|
|
|
|
LOOP: for my $requirement (map { $_->{requirement} } @{$r->requires}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my ($command, @args) = split ' ', $requirement; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
given ($command){ |
54
|
0
|
|
|
|
|
|
when('cap'){ |
55
|
0
|
0
|
|
|
|
|
return OK if hascaps $user, @args |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
DECLINED |
63
|
0
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |