line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::USB; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
64037470
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
138
|
|
4
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
227
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1726
|
use FusionInventory::Agent::Tools::Generic; |
|
2
|
|
|
|
|
23
|
|
|
2
|
|
|
|
|
200
|
|
7
|
2
|
|
|
2
|
|
1499
|
use FusionInventory::Agent::Tools::Win32; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
1083
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
11
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{usb}; |
12
|
0
|
|
|
|
|
0
|
return 1; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub doInventory { |
16
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
foreach my $device (_getDevices(logger => $params{logger}, datadir => $params{datadir})) { |
21
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
22
|
|
|
|
|
|
|
section => 'USBDEVICES', |
23
|
|
|
|
|
|
|
entry => $device |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _getDevices { |
29
|
2
|
|
|
2
|
|
562
|
my @devices; |
30
|
|
|
|
|
|
|
my $seen; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
8
|
foreach my $device (_getDevicesFromWMI(@_)) { |
33
|
22
|
50
|
|
|
|
88
|
next if $device->{VENDORID} =~ /^0+$/; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# avoid duplicates |
36
|
22
|
100
|
|
|
|
89
|
next if $seen->{$device->{SERIAL}}++; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# pseudo serial generated by windows |
39
|
12
|
100
|
|
|
|
49
|
delete $device->{SERIAL} if $device->{SERIAL} =~ /&/; |
40
|
|
|
|
|
|
|
|
41
|
12
|
|
|
|
|
66
|
my $vendor = getUSBDeviceVendor(id => lc($device->{VENDORID}), @_); |
42
|
12
|
50
|
|
|
|
50
|
if ($vendor) { |
43
|
12
|
|
|
|
|
30
|
$device->{MANUFACTURER} = $vendor->{name}; |
44
|
|
|
|
|
|
|
|
45
|
12
|
|
|
|
|
43
|
my $entry = $vendor->{devices}->{lc($device->{PRODUCTID})}; |
46
|
12
|
100
|
|
|
|
30
|
if ($entry) { |
47
|
9
|
|
|
|
|
21
|
$device->{CAPTION} = $entry->{name}; |
48
|
9
|
|
|
|
|
20
|
$device->{NAME} = $entry->{name}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
12
|
|
|
|
|
27
|
push @devices, $device; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
28
|
return @devices; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _getDevicesFromWMI { |
59
|
2
|
|
|
2
|
|
3
|
my @devices; |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
12
|
foreach my $object (getWMIObjects( |
62
|
|
|
|
|
|
|
class => 'CIM_LogicalDevice', |
63
|
|
|
|
|
|
|
properties => [ qw/Caption DeviceID Name/ ] |
64
|
|
|
|
|
|
|
)) { |
65
|
517
|
100
|
|
|
|
104835
|
next unless $object->{DeviceID} =~ /^USB\\VID_(\w+)&PID_(\w+)\\(.*)/; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
push @devices, { |
68
|
|
|
|
|
|
|
CAPTION => $object->{Caption}, |
69
|
|
|
|
|
|
|
NAME => $object->{Name}, |
70
|
22
|
|
|
|
|
140
|
VENDORID => $1, |
71
|
|
|
|
|
|
|
PRODUCTID => $2, |
72
|
|
|
|
|
|
|
SERIAL => $3 |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
206
|
return @devices; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |