line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SPOPS::Secure::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Util.pm,v 1.6 2004/06/02 00:48:24 lachoy Exp $ |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
144
|
|
6
|
3
|
|
|
3
|
|
17
|
use Data::Dumper qw( Dumper ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
183
|
|
7
|
3
|
|
|
3
|
|
17
|
use Log::Log4perl qw( get_logger ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
30
|
|
8
|
3
|
|
|
3
|
|
293
|
use SPOPS::Secure qw( :level :scope ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2467
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $log = get_logger(); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Setup a hashref where w/u => security_level and g points to a |
13
|
|
|
|
|
|
|
# hashref where the key is the group_id value is the security level. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub parse_objects_into_hashref { |
16
|
0
|
|
|
0
|
0
|
|
my ( $class, $security_objects ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my %items = ( SEC_SCOPE_WORLD() => undef, |
19
|
|
|
|
|
|
|
SEC_SCOPE_USER() => undef, |
20
|
|
|
|
|
|
|
SEC_SCOPE_GROUP() => {} ); |
21
|
0
|
0
|
0
|
|
|
|
unless ( ref $security_objects eq 'ARRAY' |
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
and scalar @{ $security_objects } > 0 ) { |
23
|
0
|
|
|
|
|
|
return undef; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
ITEM: |
27
|
0
|
|
|
|
|
|
foreach my $sec ( @{ $security_objects } ) { |
|
0
|
|
|
|
|
|
|
28
|
0
|
0
|
0
|
|
|
|
if ( $sec->{scope} eq SEC_SCOPE_WORLD || $sec->{scope} eq SEC_SCOPE_USER ) { |
|
|
0
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$items{ $sec->{scope} } = $sec->{security_level}; |
30
|
0
|
0
|
|
|
|
|
$log->is_debug && |
31
|
|
|
|
|
|
|
$log->debug( "Assign [$sec->{security_level}] to [$sec->{scope}]" ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( $sec->{scope} eq SEC_SCOPE_GROUP ) { |
34
|
0
|
|
|
|
|
|
$items{ $sec->{scope} }->{ $sec->{scope_id} } = $sec->{security_level}; |
35
|
0
|
0
|
|
|
|
|
$log->is_debug && |
36
|
|
|
|
|
|
|
$log->debug( "Assign [$sec->{security_level}] to ", |
37
|
|
|
|
|
|
|
"[$sec->{scope}][$sec->{scope_id}]" ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
$log->is_info && |
41
|
0
|
0
|
|
|
|
|
$log->info( "All security parsed: ", Dumper( \%items ) );; |
42
|
0
|
|
|
|
|
|
return \%items; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub find_class_and_oid { |
46
|
0
|
|
|
0
|
0
|
|
my ( $class, $item, $p ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# First assume it's a class we're passed in to check |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
0
|
|
|
|
my $obj_class = $p->{class} || $item; |
51
|
0
|
|
0
|
|
|
|
my $oid = $p->{object_id} || $p->{oid} || '0'; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# If this is an object, modify lines accordingly |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
0
|
|
|
|
if ( ref $item and UNIVERSAL::can( $item, 'id' ) ) { |
56
|
0
|
|
0
|
|
|
|
$oid = eval { $item->id } || '0'; |
57
|
0
|
|
|
|
|
|
$obj_class = ref $item; |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
|
return ( $obj_class, $oid ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |