line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package lib::restrict; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1005
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.0.5'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
15
|
use base 'lib'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
890
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
1
|
|
|
1
|
|
9
|
shift; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
2
|
my %uid; |
13
|
|
|
|
|
|
|
my %okd; |
14
|
1
|
|
|
|
|
2
|
my $chk = ''; |
15
|
1
|
50
|
33
|
|
|
21
|
if(defined $_[-1] && (ref $_[-1] eq 'ARRAY' || $_[-1] =~ m/^\d+$/ || ref $_[-1] eq 'CODE')) { |
|
|
|
33
|
|
|
|
|
16
|
0
|
0
|
|
|
|
0
|
if(ref $_[-1]) { |
17
|
0
|
0
|
|
|
|
0
|
if(ref $_[-1] eq 'ARRAY') { |
18
|
0
|
|
|
|
|
0
|
@uid{ grep { m/^\d+$/ } @{$_[-1]} } = (); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
0
|
|
|
|
|
0
|
$chk = $_[-1]; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
|
|
|
|
0
|
$uid{ $_[-1] } = $_[-1]; |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
0
|
pop @_; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
3
|
for (@_) { |
31
|
1
|
|
|
|
|
2
|
my $path = $_; # we'll be modifying it, so break the alias, is there an echo in here :) |
32
|
1
|
|
|
|
|
2
|
eval { |
33
|
1
|
|
|
|
|
14
|
$path = lib::_nativize($path); |
34
|
|
|
|
|
|
|
}; # we eval since older lib.pm's don't have this |
35
|
|
|
|
|
|
|
|
36
|
1
|
50
|
33
|
|
|
16
|
if(!-d $path && ref $ENV{'lib::restrict-!-d_ok_in'} eq 'ARRAY') { |
37
|
0
|
|
|
|
|
0
|
my $ok = 0; |
38
|
0
|
|
|
|
|
0
|
require File::Spec; |
39
|
0
|
|
|
|
|
0
|
require File::Basename; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
0
|
my $absolute = File::Spec->file_name_is_absolute($path) ? $path : File::Spec->rel2abs( $path ); |
42
|
0
|
|
|
|
|
0
|
my $pathless = File::Basename::dirname($absolute); |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
0
|
if(File::Spec->file_name_is_absolute($absolute)) { |
45
|
0
|
|
|
|
|
0
|
for my $base (@{ $ENV{'lib::restrict-!-d_ok_in'} }) { |
|
0
|
|
|
|
|
0
|
|
46
|
0
|
0
|
|
|
|
0
|
$base = File::Spec->rel2abs($base) if !File::Spec->file_name_is_absolute($base); |
47
|
0
|
|
|
|
|
0
|
my $grow = ''; # IE '/' |
48
|
0
|
|
|
|
|
0
|
for my $part (File::Spec->splitdir($base)) { |
49
|
0
|
|
|
|
|
0
|
$grow = File::Spec->catdir($grow, $part); |
50
|
0
|
0
|
|
|
|
0
|
$ok = 1 if $pathless eq $grow; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
0
|
$okd{ $_ } = 1; |
54
|
0
|
0
|
|
|
|
0
|
next if $ok; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
33
|
|
|
12
|
if( (keys %uid && !exists $uid{ _get_owner($path) }) || (ref $chk eq 'CODE' && !$chk->($_)) ) { |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
59
|
0
|
0
|
|
|
|
0
|
if( !$ENV{'lib::restrict-quiet'} ) { |
60
|
0
|
|
|
|
|
0
|
require Carp; |
61
|
0
|
|
|
|
|
0
|
Carp::carp('Parameter to use lib::restrict is not allowed'); |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
0
|
@_ = grep { !m/^$path$/ } @_; |
|
0
|
|
|
|
|
0
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
7
|
lib->import(@_); # SUPER instead ?? |
68
|
1
|
|
|
|
|
73
|
@lib::restrict::ORIG_INC = @lib::ORIG_INC; |
69
|
|
|
|
|
|
|
|
70
|
1
|
50
|
|
|
|
4
|
if(keys %uid) { |
71
|
0
|
0
|
|
|
|
0
|
@INC = grep { exists $uid{_get_owner($_)} || exists $okd{ $_ } } @INC; # uninit value ?? |
|
0
|
|
|
|
|
0
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
11
|
return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _get_owner { |
78
|
0
|
|
|
0
|
|
|
my $own = (stat shift)[4]; |
79
|
0
|
0
|
|
|
|
|
return defined $own ? $own : ''; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |