line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::Registry; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
68220026
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
90
|
|
4
|
2
|
|
|
2
|
|
23
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
129
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
32
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
83
|
|
|
2
|
|
|
|
|
31
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
2138
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
506
|
|
9
|
2
|
|
|
2
|
|
1465
|
use FusionInventory::Agent::Tools::Win32; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1182
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my @hives = qw/ |
13
|
|
|
|
|
|
|
HKEY_CLASSES_ROOT |
14
|
|
|
|
|
|
|
HKEY_CURRENT_USER |
15
|
|
|
|
|
|
|
HKEY_LOCAL_MACHINE |
16
|
|
|
|
|
|
|
HKEY_USERS |
17
|
|
|
|
|
|
|
HKEY_CURRENT_CONFIG |
18
|
|
|
|
|
|
|
HKEY_DYN_DATA |
19
|
|
|
|
|
|
|
/; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub isEnabled { |
22
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
0
|
|
|
|
return $params{registry} && @{$params{registry}}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _getRegistryData { |
28
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my @data; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my @registrys = ref($params{registry}->{PARAM}) eq 'ARRAY' ? |
33
|
0
|
|
|
|
|
|
@{$params{registry}->{PARAM}} : |
34
|
0
|
0
|
|
|
|
|
($params{registry}->{PARAM}); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
foreach my $option (@registrys) { |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $name = $option->{NAME}; |
39
|
0
|
|
|
|
|
|
my $regkey = $option->{REGKEY}; |
40
|
0
|
|
|
|
|
|
my $regtree = $option->{REGTREE}; |
41
|
0
|
|
|
|
|
|
my $content = $option->{content}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# This should never append, err wait... |
44
|
0
|
0
|
|
|
|
|
next unless $content; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$regkey =~ s{\\}{/}g; |
47
|
|
|
|
|
|
|
my $value = getRegistryValue( |
48
|
|
|
|
|
|
|
path => $hives[$regtree]."/".$regkey."/".$content, |
49
|
|
|
|
|
|
|
logger => $params{logger} |
50
|
0
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if (ref($value) eq "HASH") { |
53
|
0
|
|
|
|
|
|
foreach ( keys %$value ) { |
54
|
0
|
|
0
|
|
|
|
my $n = encodeFromRegistry($_) || ''; |
55
|
0
|
|
0
|
|
|
|
my $v = encodeFromRegistry($value->{$_}) || ''; |
56
|
0
|
|
|
|
|
|
push @data, { section => 'REGISTRY', entry => { |
57
|
|
|
|
|
|
|
NAME => $name, |
58
|
|
|
|
|
|
|
REGVALUE => "$n=$v" |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} else { |
63
|
0
|
|
|
|
|
|
push @data, {section => 'REGISTRY', entry => { |
64
|
|
|
|
|
|
|
NAME => $name, |
65
|
|
|
|
|
|
|
REGVALUE => encodeFromRegistry($value) |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return @data; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub doInventory { |
76
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
return unless $params{registry}->{NAME} eq 'REGISTRY'; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
foreach my $data (_getRegistryData( |
81
|
|
|
|
|
|
|
registry => $params{registry}, |
82
|
|
|
|
|
|
|
logger => $params{logger})) |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
|
|
|
$params{inventory}->addEntry(%$data); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |