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