Skip to content

Commit 8a1836c

Browse files
committed
fix: Fix usb devices inventory on linux
Closes #827
1 parent b8eff27 commit 8a1836c

File tree

4 files changed

+187
-7
lines changed

4 files changed

+187
-7
lines changed

Changes

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ inventory:
3636
* Update getProcesses() API to permit filtering and report processes only in the same
3737
namespace to not list containers processes. Refacto inventory module using this API.
3838
* Add support for Trellix/McAfee agent as Antivirus on windows
39+
* fix #827: Fix usb devices inventory on linux which have 0002 as PRODUCTID and are not root hub
3940

4041
remoteinventory:
4142
* Store remote inventory part checksums in dedicated state files and support maintenance

lib/GLPI/Agent/Task/Inventory/Generic/USB.pm

+1-6
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ sub _getDevices {
3737
next unless $device->{PRODUCTID};
3838
next unless $device->{VENDORID};
3939

40-
# ignore the USB Hub
41-
next if
42-
$device->{PRODUCTID} eq "0001" ||
43-
$device->{PRODUCTID} eq "0002" ;
44-
4540
if (defined($device->{SERIAL}) && length($device->{SERIAL}) < 5) {
4641
$device->{SERIAL} = undef;
4742
}
@@ -99,7 +94,7 @@ sub _getDevicesFromLsusb {
9994
if ($iSerial =~ /S\/N:([^: ]+)/) {
10095
$device->{SERIAL} = $1;
10196
} elsif (!empty($iSerial) && $iSerial !~ /:/) {
102-
$device->{SERIAL} = $1;
97+
$device->{SERIAL} = $iSerial;
10398
}
10499
} elsif ($line =~ /^\s*bInterfaceClass\s*(\d+)/i) {
105100
$device->{CLASS} = $1;

resources/generic/lsusb/apc-ups

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
Bus 001 Device 003: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
2+
Device Descriptor:
3+
bLength 18
4+
bDescriptorType 1
5+
bcdUSB 1.10
6+
bDeviceClass 0
7+
bDeviceSubClass 0
8+
bDeviceProtocol 0
9+
bMaxPacketSize0 8
10+
idVendor 0x051d American Power Conversion
11+
idProduct 0x0002 Uninterruptible Power Supply
12+
bcdDevice 0.06
13+
iManufacturer 3 American Power Conversion
14+
iProduct 1 Smart-UPS 1000 RM FW:669.19.I USB FW:11.03
15+
iSerial 2 AS1042245614
16+
bNumConfigurations 1
17+
Configuration Descriptor:
18+
bLength 9
19+
bDescriptorType 2
20+
wTotalLength 0x0022
21+
bNumInterfaces 1
22+
bConfigurationValue 1
23+
iConfiguration 10 1
24+
bmAttributes 0xe0
25+
Self Powered
26+
Remote Wakeup
27+
MaxPower 30mA
28+
Interface Descriptor:
29+
bLength 9
30+
bDescriptorType 4
31+
bInterfaceNumber 0
32+
bAlternateSetting 0
33+
bNumEndpoints 1
34+
bInterfaceClass 3 Human Interface Device
35+
bInterfaceSubClass 0
36+
bInterfaceProtocol 0
37+
iInterface 0
38+
HID Device Descriptor:
39+
bLength 9
40+
bDescriptorType 33
41+
bcdHID 1.10
42+
bCountryCode 33 US
43+
bNumDescriptors 1
44+
bDescriptorType 34 Report
45+
wDescriptorLength 1064
46+
Report Descriptors:
47+
** UNAVAILABLE **
48+
Endpoint Descriptor:
49+
bLength 7
50+
bDescriptorType 5
51+
bEndpointAddress 0x81 EP 1 IN
52+
bmAttributes 3
53+
Transfer Type Interrupt
54+
Synch Type None
55+
Usage Type Data
56+
wMaxPacketSize 0x0006 1x 6 bytes
57+
bInterval 100
58+
can't get debug descriptor: Resource temporarily unavailable
59+
Device Status: 0x0001
60+
Self Powered
61+
62+
Bus 001 Device 003: ID 051d:0003 American Power Conversion UPS
63+
Device Descriptor:
64+
bLength 18
65+
bDescriptorType 1
66+
bcdUSB 2.00
67+
bDeviceClass 0
68+
bDeviceSubClass 0
69+
bDeviceProtocol 0
70+
bMaxPacketSize0 64
71+
idVendor 0x051d American Power Conversion
72+
idProduct 0x0003 UPS
73+
bcdDevice 0.01
74+
iManufacturer 1 American Power Conversion
75+
iProduct 2 Smart-UPS_1500 FW:UPS 03.5 / ID=1018
76+
iSerial 3 AS2032166823
77+
bNumConfigurations 1
78+
Configuration Descriptor:
79+
bLength 9
80+
bDescriptorType 2
81+
wTotalLength 0x0029
82+
bNumInterfaces 1
83+
bConfigurationValue 1
84+
iConfiguration 0
85+
bmAttributes 0xe0
86+
Self Powered
87+
Remote Wakeup
88+
MaxPower 10mA
89+
Interface Descriptor:
90+
bLength 9
91+
bDescriptorType 4
92+
bInterfaceNumber 0
93+
bAlternateSetting 0
94+
bNumEndpoints 2
95+
bInterfaceClass 3 Human Interface Device
96+
bInterfaceSubClass 0
97+
bInterfaceProtocol 0
98+
iInterface 0
99+
HID Device Descriptor:
100+
bLength 9
101+
bDescriptorType 33
102+
bcdHID 1.11
103+
bCountryCode 33 US
104+
bNumDescriptors 1
105+
bDescriptorType 34 Report
106+
wDescriptorLength 451
107+
Report Descriptors:
108+
** UNAVAILABLE **
109+
Endpoint Descriptor:
110+
bLength 7
111+
bDescriptorType 5
112+
bEndpointAddress 0x81 EP 1 IN
113+
bmAttributes 3
114+
Transfer Type Interrupt
115+
Synch Type None
116+
Usage Type Data
117+
wMaxPacketSize 0x0040 1x 64 bytes
118+
bInterval 10
119+
Endpoint Descriptor:
120+
bLength 7
121+
bDescriptorType 5
122+
bEndpointAddress 0x01 EP 1 OUT
123+
bmAttributes 3
124+
Transfer Type Interrupt
125+
Synch Type None
126+
Usage Type Data
127+
wMaxPacketSize 0x0040 1x 64 bytes
128+
bInterval 10
129+
can't get device qualifier: Resource temporarily unavailable
130+
can't get debug descriptor: Resource temporarily unavailable
131+
Device Status: 0x0001
132+
Self Powered
133+

t/tasks/inventory/generic/usb.t

+52-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ my %lsusb_tests = (
6666
SERIAL => '28A1CC69D1D8AE4585EDA53F7CD6CB88',
6767
MANUFACTURER => 'ᄅSymbol Technologies, Inc, 2002'
6868
}
69+
],
70+
'apc-ups' => [
71+
{
72+
NAME => 'Smart-UPS 1000 RM FW:669.19.I USB FW:11.03',
73+
VENDORID => '051d',
74+
PRODUCTID => '0002',
75+
SUBCLASS => '0',
76+
CLASS => '3',
77+
SERIAL => 'AS1042245614',
78+
MANUFACTURER => 'American Power Conversion'
79+
},
80+
{
81+
NAME => 'Smart-UPS_1500 FW:UPS 03.5 / ID=1018',
82+
VENDORID => '051d',
83+
PRODUCTID => '0003',
84+
SUBCLASS => '0',
85+
CLASS => '3',
86+
SERIAL => 'AS2032166823',
87+
MANUFACTURER => 'American Power Conversion'
88+
}
6989
]
7090
);
7191

@@ -108,6 +128,15 @@ my %usb_tests = (
108128
MANUFACTURER => 'Broadcom Corp.',
109129
CAPTION => re('^BCM5880 Secure Applications Processor')
110130
},
131+
{
132+
NAME => re('^Duosense Transparent Electromagnetic Digitizer'),
133+
VENDORID => '1b96',
134+
SUBCLASS => '0',
135+
CLASS => '0',
136+
PRODUCTID => '0001',
137+
MANUFACTURER => 'N-Trig',
138+
CAPTION => re('^Duosense Transparent Electromagnetic Digitizer')
139+
},
111140
{
112141
NAME => re('^PocketMouse Pro'),
113142
VENDORID => '047d',
@@ -127,7 +156,29 @@ my %usb_tests = (
127156
SERIAL => '28A1CC69D1D8AE4585EDA53F7CD6CB88',
128157
CAPTION => re('^Bar Code Scanner')
129158
}
130-
]
159+
],
160+
'apc-ups' => [
161+
{
162+
NAME => re('Uninterruptible Power Supply'),
163+
VENDORID => '051d',
164+
PRODUCTID => '0002',
165+
SUBCLASS => '0',
166+
CLASS => '3',
167+
SERIAL => 'AS1042245614',
168+
MANUFACTURER => re('American Power Conversion'),
169+
CAPTION => re('^Uninterruptible Power Supply')
170+
},
171+
{
172+
NAME => re('UPS'),
173+
VENDORID => '051d',
174+
PRODUCTID => '0003',
175+
SUBCLASS => '0',
176+
CLASS => '3',
177+
SERIAL => 'AS2032166823',
178+
MANUFACTURER => re('American Power Conversion'),
179+
CAPTION => re('^UPS')
180+
}
181+
]
131182
);
132183

133184
plan tests =>

0 commit comments

Comments
 (0)