line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache2::AuthzCaps; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
42047
|
use 5.014000; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
760
|
use subs qw/OK DECLINED/; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
854
|
use if $ENV{MOD_PERL}, 'Apache2::Access'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
42
|
use if $ENV{MOD_PERL}, 'Apache2::Const' => qw/OK DECLINED/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
12
|
1
|
|
|
1
|
|
33
|
use if $ENV{MOD_PERL}, 'Apache2::RequestRec'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
13
|
1
|
|
|
1
|
|
32
|
use if $ENV{MOD_PERL}, 'Apache2::RequestUtil'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
14
|
1
|
|
|
1
|
|
1633
|
use YAML::Any qw/LoadFile DumpFile/; |
|
1
|
|
|
|
|
1066
|
|
|
1
|
|
|
|
|
4
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
8315
|
use parent qw/Exporter/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw/setcap hascaps/; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
################################################## |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $rootdir; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub setcap{ |
25
|
3
|
|
|
3
|
1
|
1361
|
my ($user, $cap, $value) = @_; |
26
|
3
|
|
100
|
|
|
5
|
my $config = eval { LoadFile "$rootdir/$user.yml" } // {}; |
|
3
|
|
|
|
|
15
|
|
27
|
3
|
|
100
|
|
|
9071
|
$config->{caps}//={}; |
28
|
3
|
|
|
|
|
6
|
my $caps=$config->{caps}; |
29
|
|
|
|
|
|
|
|
30
|
3
|
100
|
|
|
|
8
|
delete $caps->{$cap} unless $value; |
31
|
3
|
100
|
|
|
|
12
|
$caps->{$cap} = 1 if $value; |
32
|
3
|
|
|
|
|
15
|
DumpFile "$rootdir/$user.yml", $config |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub hascaps{ |
36
|
4
|
|
|
4
|
1
|
20398
|
my ($user, @caps) = @_; |
37
|
4
|
|
|
|
|
19
|
my $config = LoadFile "$rootdir/$user.yml"; |
38
|
4
|
|
|
|
|
19882
|
my $caps = $config->{caps}; |
39
|
4
|
|
|
|
|
13
|
for (@caps) { |
40
|
6
|
100
|
|
|
|
28
|
return 0 unless $caps->{$_} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
1 |
43
|
2
|
|
|
|
|
15
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub handler{ |
46
|
0
|
|
|
0
|
1
|
|
my $r=shift; |
47
|
0
|
|
|
|
|
|
my $user = $r->user; |
48
|
0
|
|
|
|
|
|
local $rootdir = $r->dir_config('AuthzCapsRootdir'); |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ($user) { |
51
|
0
|
|
|
|
|
|
for my $requirement (map { $_->{requirement} } @{$r->requires}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my ($command, @args) = split ' ', $requirement; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
|
return OK if $command eq 'cap' && hascaps $user, @args; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
DECLINED |
59
|
0
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |