Codebase list fusioninventory-agent / debian/2.2.3-4
Import Debian changes 2.2.3-4 fusioninventory-agent (2.2.3-4) unstable; urgency=low * fix the postrm script, thanks Adam D. Barratt, (closes: #679299) * Import bug fixes from upstream * Disable t/components/server.t, the test is too fragile. it needs to be able to bind port 8080. Gonéri Le Bouder authored 11 years ago Guillaume Bougard committed 5 years ago
4 changed file(s) with 700 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
0 fusioninventory-agent (2.2.3-4) unstable; urgency=low
1
2 * fix the postrm script, thanks Adam D. Barratt,
3 (closes: #679299)
4 * Import bug fixes from upstream
5 * Disable t/components/server.t, the test is too fragile. it needs to be
6 able to bind port 8080.
7
8 -- Gonéri Le Bouder <goneri@rulezlan.org> Sat, 03 Nov 2012 13:34:31 +0100
9
010 fusioninventory-agent (2.2.3-3) unstable; urgency=low
111
212 * Add a post{inst,rm} scripts to prepeare and clean up
77 # This package is being removed, but its configuration has not yet
88 # been purged.
99 :
10
11 # Remove diversion
12 : dpkg-divert --package foo --remove --rename \
13 : --divert /usr/bin/other.real /usr/bin/other
1410
1511 # ldconfig is NOT needed during removal of a library, only during
1612 # installation
3733 ucf --purge /etc/fusioninventory/agent.conf
3834 fi
3935 if which ucfr >/dev/null; then
40 ucfr --purge foo /etc/fusioninventory/agent.conf
36 ucfr --purge fusioninventory-agent /etc/fusioninventory/agent.conf
4137 fi
4238
4339 ;;
0 diff --git a/lib/FusionInventory/Agent.pm b/lib/FusionInventory/Agent.pm
1 index 03bf240..f2a8482 100644
2 --- a/lib/FusionInventory/Agent.pm
3 +++ b/lib/FusionInventory/Agent.pm
4 @@ -22,7 +22,7 @@ use FusionInventory::Agent::Tools;
5 use FusionInventory::Agent::Tools::Hostname;
6 use FusionInventory::Agent::XML::Query::Prolog;
7
8 -our $VERSION = '2.2.3';
9 +our $VERSION = '2.2.3debian';
10 our $VERSION_STRING =
11 "FusionInventory unified agent for UNIX, Linux and MacOSX ($VERSION)";
12 our $AGENT_STRING =
13 @@ -143,8 +143,17 @@ sub init {
14 $logger->error("Can't load Proc::Daemon. Is the module installed?");
15 exit 1;
16 }
17 +
18 + my $cwd = getcwd();
19 Proc::Daemon::Init();
20 $logger->debug("Daemon started");
21 +
22 +
23 + # If we use relative path, we must stay in the current directory
24 + if (substr( $params{libdir}, 0, 1 ) ne '/') {
25 + chdir($cwd);
26 + }
27 +
28 if ($self->_isAlreadyRunning()) {
29 $logger->debug("An agent is already runnnig, exiting...");
30 exit 1;
31 @@ -520,6 +529,6 @@ Get all available tasks found on the system, as a list of module / version
32 pairs:
33
34 %tasks = (
35 - 'FusionInventory::Agent::Task::Foo' => x,
36 - 'FusionInventory::Agent::Task::Bar' => y,
37 + 'Foo' => x,
38 + 'Bar' => y,
39 );
40 diff --git a/lib/FusionInventory/Agent/Config.pm b/lib/FusionInventory/Agent/Config.pm
41 index f4a910b..f1345da 100644
42 --- a/lib/FusionInventory/Agent/Config.pm
43 +++ b/lib/FusionInventory/Agent/Config.pm
44 @@ -15,6 +15,8 @@ my $default = {
45 'backend-collect-timeout' => 30,
46 'httpd-port' => 62354,
47 'timeout' => 180,
48 + 'no-task' => [],
49 + 'no-category' => []
50 };
51
52 my $deprecated = {
53 @@ -50,31 +52,31 @@ my $deprecated = {
54 },
55 'no-inventory' => {
56 message => 'use --no-task inventory option instead',
57 - new => { 'no-task' => 'inventory' }
58 + new => { 'no-task' => '+inventory' }
59 },
60 'no-wakeonlan' => {
61 message => 'use --no-task wakeonlan option instead',
62 - new => { 'no-task' => 'wakeonlan' }
63 + new => { 'no-task' => '+wakeonlan' }
64 },
65 'no-netdiscovery' => {
66 message => 'use --no-task netdiscovery option instead',
67 - new => { 'no-task' => 'netdiscovery' }
68 + new => { 'no-task' => '+netdiscovery' }
69 },
70 'no-snmpquery' => {
71 message => 'use --no-task snmpquery option instead',
72 - new => { 'no-task' => 'snmpquery' }
73 + new => { 'no-task' => '+snmpquery' }
74 },
75 'no-ocsdeploy' => {
76 message => 'use --no-task ocsdeploy option instead',
77 - new => { 'no-task' => 'ocsdeploy' }
78 + new => { 'no-task' => '+ocsdeploy' }
79 },
80 'no-printer' => {
81 message => 'use --no-category printer option instead',
82 - new => { 'no-category' => 'printer' }
83 + new => { 'no-category' => '+printer' }
84 },
85 'no-software' => {
86 message => 'use --no-category software option instead',
87 - new => { 'no-category' => 'software' }
88 + new => { 'no-category' => '+software' }
89 },
90 };
91
92 @@ -215,19 +217,25 @@ sub _checkContent {
93 # transfer the value to the new option, if possible
94 if ($handler->{new}) {
95 if (ref $handler->{new} eq 'HASH') {
96 - # list of new options with new values
97 + # old boolean option replaced by new non-boolean options
98 foreach my $key (keys %{$handler->{new}}) {
99 - $self->{$key} = $self->{$key} ?
100 - $self->{$key} . ',' . $handler->{new}->{$key} :
101 - $handler->{new}->{$key};
102 + my $value = $handler->{new}->{$key};
103 + if ($value =~ /^\+(\S+)/) {
104 + # multiple values: add it to exiting one
105 + $self->{$key} = $self->{$key} ?
106 + $self->{$key} . ',' . $1 : $1;
107 + } else {
108 + # unique value: replace exiting value
109 + $self->{$key} = $value;
110 + }
111 }
112 } elsif (ref $handler->{new} eq 'ARRAY') {
113 - # list of new options, with same value
114 + # old boolean option replaced by new boolean options
115 foreach my $new (@{$handler->{new}}) {
116 $self->{$new} = $self->{$old};
117 }
118 } else {
119 - # new option, with same value
120 + # old non-boolean option replaced by new option
121 $self->{$handler->{new}} = $self->{$old};
122 }
123 }
124 @@ -244,10 +252,8 @@ sub _checkContent {
125 # multi-values options
126 $self->{logger} = [ split(/,/, $self->{logger}) ] if $self->{logger};
127 $self->{server} = [ split(/,/, $self->{server}) ] if $self->{server};
128 - $self->{'no-task'} = [ split(/,/, $self->{'no-task'}) ]
129 - if $self->{'no-task'};
130 - $self->{'no-category'} = [ split(/,/, $self->{'no-category'}) ]
131 - if $self->{'no-category'};
132 + $self->{'no-task'} = [ split(/,/, $self->{'no-task'}) ];
133 + $self->{'no-category'} = [ split(/,/, $self->{'no-category'}) ];
134
135 # files location
136 $self->{'ca-cert-file'} =
137 diff --git a/lib/FusionInventory/Agent/Logger/File.pm b/lib/FusionInventory/Agent/Logger/File.pm
138 index f0b8cb7..1102245 100644
139 --- a/lib/FusionInventory/Agent/Logger/File.pm
140 +++ b/lib/FusionInventory/Agent/Logger/File.pm
141 @@ -36,23 +36,30 @@ sub addMessage {
142 }
143
144 my $handle;
145 - if (open $handle, '>>', $self->{logfile}) {
146 + if (!open $handle, '>>', $self->{logfile}) {
147 + die "can't open $self->{logfile}: $ERRNO";
148 + }
149
150 - # get an exclusive lock on log file
151 - flock($handle, LOCK_EX)
152 - or die "can't get an exclusive lock on $self->{logfile}: $ERRNO";
153 + my $locked;
154 + my $retryTill = time + 60;
155
156 - print {$handle}
157 - "[". localtime() ."]" .
158 - "[$level]" .
159 - " $message\n";
160 + while ($retryTill > time && !$locked) {
161 + # get an exclusive lock on log file
162 + $locked = 1 if flock($handle, LOCK_EX|LOCK_NB);
163 + }
164
165 - # closing handle release the lock automatically
166 - close $handle;
167 - } else {
168 - die "can't open $self->{logfile}: $ERRNO";
169 + if (!$locked) {
170 + die "can't get an exclusive lock on $self->{logfile}: $ERRNO";
171 }
172
173 + print {$handle}
174 + "[". localtime() ."]" .
175 + "[$level]" .
176 + " $message\n";
177 +
178 + # closing handle release the lock automatically
179 + close $handle;
180 +
181 }
182
183 1;
184 diff --git a/lib/FusionInventory/Agent/Storage.pm b/lib/FusionInventory/Agent/Storage.pm
185 index b38df9f..63b140c 100644
186 --- a/lib/FusionInventory/Agent/Storage.pm
187 +++ b/lib/FusionInventory/Agent/Storage.pm
188 @@ -15,13 +15,14 @@ sub new {
189 my ($class, %params) = @_;
190
191 die "no directory parameter" unless $params{directory};
192 -
193 if (!-d $params{directory}) {
194 - mkpath($params{directory}, {error => \my $err});
195 - if (@$err) {
196 - my (undef, $message) = %{$err->[0]};
197 - die "Can't create $params{directory}: $message";
198 - }
199 + # {error => \my $err} is not supported on RHEL 5,
200 + # we let mkpath call die() itself
201 + # http://forge.fusioninventory.org/issues/1817
202 + eval {
203 + mkpath($params{directory});
204 + };
205 + die "Can't create $params{directory}: $EVAL_ERROR" if $EVAL_ERROR;
206 }
207
208 if (! -w $params{directory}) {
209 diff --git a/lib/FusionInventory/Agent/Target.pm b/lib/FusionInventory/Agent/Target.pm
210 index 710df8d..db61331 100644
211 --- a/lib/FusionInventory/Agent/Target.pm
212 +++ b/lib/FusionInventory/Agent/Target.pm
213 @@ -122,7 +122,7 @@ sub _computeNextRunDate {
214
215 my $ret;
216 if ($self->{initialDelay}) {
217 - $ret = time + $self->{initialDelay};
218 + $ret = time + ($self->{initialDelay} / 2) + int rand($self->{initialDelay} / 2);
219 $self->{initialDelay} = undef;
220 } else {
221 $ret =
222 diff --git a/lib/FusionInventory/Agent/Task/Inventory.pm b/lib/FusionInventory/Agent/Task/Inventory.pm
223 index 13dc0b0..2cd774a 100644
224 --- a/lib/FusionInventory/Agent/Task/Inventory.pm
225 +++ b/lib/FusionInventory/Agent/Task/Inventory.pm
226 @@ -61,10 +61,11 @@ sub run {
227 }
228
229 if (not $ENV{PATH}) {
230 - # set a minimal PATH if none is set (#1129)
231 - $ENV{PATH} = '/sbin:/usr/sbin:/bin:/usr/bin';
232 + # set a minimal PATH if none is set (#1129, #1747)
233 + $ENV{PATH} =
234 + '/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin';
235 $self->{logger}->debug(
236 - "PATH is not set, using /sbin:/usr/sbin:/bin:/usr/bin as default"
237 + "PATH is not set, using $ENV{PATH} as default"
238 );
239 }
240
241 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm
242 index 57ed095..c0ccc71 100644
243 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm
244 +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm
245 @@ -6,27 +6,12 @@ use warnings;
246 use English qw(-no_match_vars);
247 use UNIVERSAL::require;
248
249 -use FusionInventory::Agent::Tools;
250 +use FusionInventory::Agent::Tools::Generic;
251
252 sub isEnabled {
253
254 - if ($OSNAME eq 'MSWin32') {
255 - # don't run dmidecode on Win2003
256 - # http://forge.fusioninventory.org/issues/379
257 - Win32->require();
258 - my @osver = Win32::GetOSVersion();
259 - return if
260 - $osver[4] == 2 &&
261 - $osver[1] == 5 &&
262 - $osver[2] == 2;
263 - }
264 -
265 - return unless canRun('dmidecode');
266 -
267 - my $count = getLinesCount(
268 - command => "dmidecode"
269 - );
270 - return $count > 10;
271 + return unless getDmidecodeInfos();
272 +
273 }
274
275 sub doInventory {}
276 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Screen.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Screen.pm
277 index 0991f88..7846745 100644
278 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Screen.pm
279 +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Screen.pm
280 @@ -30,22 +30,15 @@ sub doInventory {
281 foreach my $screen (_getScreens($logger)) {
282
283 if ($screen->{edid}) {
284 - my $edid = parseEdid($screen->{edid});
285 - if (my $err = checkParsedEdid($edid)) {
286 - $logger->debug("check failed: bad edid: $err");
287 - } else {
288 - $screen->{CAPTION} =
289 - $edid->{monitor_name};
290 - $screen->{DESCRIPTION} =
291 - $edid->{week} . "/" . $edid->{year};
292 - $screen->{MANUFACTURER} =
293 - getManufacturerFromCode($edid->{manufacturer_name});
294 - $screen->{SERIAL} = $edid->{serial_number2}->[0];
295 - }
296 - $screen->{BASE64} = encode_base64($screen->{edid});
297 + my $info = _getEdidInfo($screen->{edid}, $logger);
298 + $screen->{CAPTION} = $info->{CAPTION};
299 + $screen->{DESCRIPTION} = $info->{DESCRIPTION};
300 + $screen->{MANUFACTURER} = $info->{MANUFACTURER};
301 + $screen->{SERIAL} = $info->{SERIAL};
302
303 + $screen->{BASE64} = encode_base64($screen->{edid});
304 + delete $screen->{edid};
305 }
306 - delete $screen->{edid};
307
308 $inventory->addEntry(
309 section => 'MONITORS',
310 @@ -54,6 +47,61 @@ sub doInventory {
311 }
312 }
313
314 +sub _getEdidInfo {
315 + my ($raw_edid, $logger) = @_;
316 +
317 + my $edid = parseEdid($raw_edid);
318 + if (my $error = checkParsedEdid($edid)) {
319 + $logger->debug("bad edid: $error");
320 + return;
321 + }
322 +
323 + my $info = {
324 + CAPTION => $edid->{monitor_name},
325 + DESCRIPTION => $edid->{week} . "/" . $edid->{year},
326 + MANUFACTURER => getManufacturerFromCode($edid->{manufacturer_name}) ||
327 + $edid->{manufacturer_name}
328 + };
329 +
330 + # they are two different serial numbers in EDID
331 + # - a mandatory 4 bytes numeric value
332 + # - an optional 13 bytes ASCII value
333 + # we use the ASCII value if present, the numeric value as an hex string
334 + # unless for a few list of known exceptions deserving specific handling
335 + # References:
336 + # http://forge.fusioninventory.org/issues/1607
337 + # http://forge.fusioninventory.org/issues/1614
338 + if (
339 + $edid->{EISA_ID} &&
340 + $edid->{EISA_ID} =~ /^ACR(0018|0020|0024|00A8|7883|ad49|adaf)$/
341 + ) {
342 + $info->{SERIAL} =
343 + substr($edid->{serial_number2}->[0], 0, 8) .
344 + sprintf("%08x", $edid->{serial_number}) .
345 + substr($edid->{serial_number2}->[0], 8, 4) ;
346 + } elsif (
347 + $edid->{EISA_ID} &&
348 + $edid->{EISA_ID} eq 'GSM4b21'
349 + ) {
350 + # split serial in two parts
351 + my ($high, $low) = $edid->{serial_number} =~ /(\d+) (\d\d\d)$/x;
352 +
353 + # translate the first part using a custom alphabet
354 + my @alphabet = split(//, "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ");
355 + my $base = scalar @alphabet;
356 +
357 + $info->{SERIAL} =
358 + $alphabet[$high / $base] . $alphabet[$high % $base] .
359 + $low;
360 + } else {
361 + $info->{SERIAL} = $edid->{serial_number2} ?
362 + $edid->{serial_number2}->[0] :
363 + sprintf("%08x", $edid->{serial_number});
364 + }
365 +
366 + return $info;
367 +}
368 +
369 sub _getScreensFromWindows {
370 my ($logger) = @_;
371
372 @@ -117,25 +165,23 @@ sub _getScreensFromUnix {
373
374 my @screens;
375
376 - if (-d '/sys') {
377 + if (-d '/sys/devices') {
378 my $wanted = sub {
379 - return unless $File::Find::name =~ m{/edid$};
380 - open my $handle, '<', $File::Find::name;
381 - my $edid = <$handle>;
382 - close $handle;
383 -
384 + return unless $_ eq 'edid';
385 + return unless -s $File::Find::name;
386 + my $edid = getAllLines(file => $File::Find::name);
387 push @screens, { edid => $edid } if $edid;
388 };
389
390 no warnings 'File::Find';
391 - File::Find::find($wanted, '/sys');
392 + File::Find::find($wanted, '/sys/devices');
393
394 return @screens if @screens;
395 }
396
397 my $edid =
398 - getFirstLine(command => 'monitor-get-edid-using-vbe') ||
399 - getFirstLine(command => 'monitor-get-edid');
400 + getAllLines(command => 'monitor-get-edid-using-vbe') ||
401 + getAllLines(command => 'monitor-get-edid');
402 push @screens, { edid => $edid };
403
404 return @screens if @screens;
405 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/LVM.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/LVM.pm
406 index d4bf1a8..d775a80 100644
407 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/LVM.pm
408 +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/LVM.pm
409 @@ -71,6 +71,11 @@ sub _getPhysicalVolumes {
410 while (my $line = <$handle>) {
411 my @infos = split(/\s+/, $line);
412
413 + my $pe_size;
414 + if ($infos[7] && $infos[7]>0) {
415 + $pe_size = int($infos[4] / $infos[7]);
416 + }
417 +
418 push @volumes, {
419 DEVICE => $infos[1],
420 FORMAT => $infos[2],
421 @@ -79,7 +84,7 @@ sub _getPhysicalVolumes {
422 FREE => int($infos[5]||0),
423 PV_UUID => $infos[6],
424 PV_PE_COUNT => $infos[7],
425 - PE_SIZE => int($infos[4] / $infos[7]),
426 + PE_SIZE => $pe_size,
427 VG_UUID => $infos[8]
428 };
429 }
430 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages.pm
431 index 1b01862..bd1bb68 100644
432 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages.pm
433 +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages.pm
434 @@ -37,7 +37,8 @@ sub doInventory {
435 }
436 }
437
438 - # fallback on sysfs if udev didn't worked
439 + # fallback on sysfs if /dev/.udev is not available. That's the
440 + # case on any up to date Linux system
441 if (!@devices) {
442 @devices = getDevicesFromProc(logger => $logger);
443 }
444 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Qemu.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Qemu.pm
445 index 6c333ff..e0052c3 100644
446 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Qemu.pm
447 +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Qemu.pm
448 @@ -28,7 +28,7 @@ sub doInventory {
449 )) {
450 # match only if an qemu instance
451 next unless
452 - $process->{CMD} =~ /(qemu|kvm|qemu-kvm) .* -([fhsv]d[a-d]|cdrom)/x;
453 + $process->{CMD} =~ /(qemu|kvm|qemu-kvm) .* -([fhsv]d[a-z]|cdrom|drive)/x;
454
455 my $name;
456 my $mem = 0;
457 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Vmsystem.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Vmsystem.pm
458 index 9f5bd60..8416eb4 100644
459 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Vmsystem.pm
460 +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Vmsystem.pm
461 @@ -191,8 +191,8 @@ sub _getStatus {
462 logger => $logger
463 );
464 while (my $line = <$handle>) {
465 - my ( $varID, $varValue ) = split( ":", $line );
466 - $result = "Virtuozzo" if ( $varID eq 'envID' && $varValue > 0 );
467 + my ($key, $value) = split(/:/, $line);
468 + $result = "Virtuozzo" if $key eq 'envID' && $value > 0;
469 }
470 }
471 return $result if $result;
472 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Bios.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Bios.pm
473 index b664c67..cfb11d0 100644
474 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Bios.pm
475 +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Bios.pm
476 @@ -31,7 +31,7 @@ sub doInventory {
477 foreach my $object (getWmiObjects(
478 class => 'Win32_Bios',
479 properties => [ qw/
480 - SerialNumber Version Manufacturer SMBIOSBIOSVersion BIOSVersion
481 + SerialNumber Version Manufacturer SMBIOSBIOSVersion BIOSVersion ReleaseDate
482 / ]
483 )) {
484 $bios->{BIOSSERIAL} = $object->{SerialNumber};
485 @@ -40,6 +40,7 @@ sub doInventory {
486 $bios->{BVERSION} = $object->{SMBIOSBIOSVersion} ||
487 $object->{BIOSVersion} ||
488 $object->{Version};
489 + $bios->{BDATE} = $object->{ReleaseDate};
490 }
491
492 foreach my $object (getWmiObjects(
493 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm b/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm
494 index 17479c9..abaca7e 100644
495 --- a/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm
496 +++ b/lib/FusionInventory/Agent/Task/Inventory/Inventory.pm
497 @@ -354,6 +354,9 @@ sub computeChecksum {
498 $self->{last_state_content} = XML::TreePP->new()->parsefile(
499 $self->{last_state_file}
500 );
501 + };
502 + if (ref($self->{last_state_content}) ne 'HASH') {
503 + $self->{last_state_file} = {};
504 }
505 } else {
506 $logger->debug(
507 diff --git a/lib/FusionInventory/Agent/Task/WakeOnLan.pm b/lib/FusionInventory/Agent/Task/WakeOnLan.pm
508 index fc35b51..106b1b1 100644
509 --- a/lib/FusionInventory/Agent/Task/WakeOnLan.pm
510 +++ b/lib/FusionInventory/Agent/Task/WakeOnLan.pm
511 @@ -9,6 +9,7 @@ use constant PF_PACKET => 17;
512 use constant SOCK_PACKET => 10;
513
514 use English qw(-no_match_vars);
515 +use List::Util qw(first);
516 use Socket;
517
518 use FusionInventory::Agent::Tools;
519 @@ -85,6 +86,8 @@ sub run {
520 # degraded WOL by UDP
521 eval {
522 socket(SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('udp'));
523 + setsockopt(SOCKET, SOL_SOCKET, SO_BROADCAST, 1)
524 + or warn "Can't do setsockopt: $ERRNO\n";
525 my $magic_packet =
526 chr(0xFF) x 6 .
527 (pack('H12', $target) x 16);
528 diff --git a/lib/FusionInventory/Agent/Tools.pm b/lib/FusionInventory/Agent/Tools.pm
529 index c507bc3..97e19e6 100644
530 --- a/lib/FusionInventory/Agent/Tools.pm
531 +++ b/lib/FusionInventory/Agent/Tools.pm
532 @@ -357,7 +357,8 @@ sub hex2char {
533 return undef unless $value;
534 return $value unless $value =~ /^0x/;
535
536 - $value =~ s/^0x//;
537 + $value =~ s/^0x//; # drop hex prefix
538 + $value =~ s/00$//; # drop trailing null-character
539 $value =~ s/(\w{2})/chr(hex($1))/eg;
540
541 return $value;
542 @@ -571,8 +572,9 @@ of line removed.
543
544 =head2 getAllLines(%params)
545
546 -Returns all the lines of given command output or given file content, with end
547 -of line removed.
548 +Returns all the lines of given command output or given file content, as a list
549 +of strings with end of line removed in list context, as a single string
550 +otherwise.
551
552 =over
553
554 diff --git a/lib/FusionInventory/Agent/Tools/Generic.pm b/lib/FusionInventory/Agent/Tools/Generic.pm
555 index 840e68c..37532af 100644
556 --- a/lib/FusionInventory/Agent/Tools/Generic.pm
557 +++ b/lib/FusionInventory/Agent/Tools/Generic.pm
558 @@ -24,8 +24,18 @@ sub getDmidecodeInfos {
559 @_
560 );
561
562 - my $handle = getFileHandle(%params);
563 + if ($OSNAME eq 'MSWin32') {
564 + # don't run dmidecode on Win2003
565 + # http://forge.fusioninventory.org/issues/379
566 + Win32->require();
567 + my @osver = Win32::GetOSVersion();
568 + return if
569 + $osver[4] == 2 &&
570 + $osver[1] == 5 &&
571 + $osver[2] == 2;
572 + }
573
574 + my $handle = getFileHandle(%params);
575 my ($info, $block, $type);
576
577 while (my $line = <$handle>) {
578 @@ -59,6 +69,9 @@ sub getDmidecodeInfos {
579 }
580 close $handle;
581
582 + # do not return anything if dmidecode output is obviously truncated
583 + return if keys %$info < 2;
584 +
585 return $info;
586 }
587
588 diff --git a/lib/FusionInventory/Agent/Tools/Linux.pm b/lib/FusionInventory/Agent/Tools/Linux.pm
589 index 228d81a..ed1626e 100644
590 --- a/lib/FusionInventory/Agent/Tools/Linux.pm
591 +++ b/lib/FusionInventory/Agent/Tools/Linux.pm
592 @@ -41,7 +41,7 @@ sub getDevicesFromUdev {
593 }
594
595 foreach my $device (@devices) {
596 - next if $device->{TYPE} eq 'cd';
597 + next if $device->{TYPE} && $device->{TYPE} eq 'cd';
598 $device->{DISKSIZE} = getDeviceCapacity(device => '/dev/' . $device->{NAME})
599 }
600
601 @@ -297,28 +297,61 @@ sub getInterfacesFromIfconfig {
602 next;
603 }
604
605 - if ($line =~ /^(\S+)/) {
606 + if ($line =~ /^([\w\d.]+)/) {
607 # new interface
608 +
609 $interface = {
610 STATUS => 'Down',
611 DESCRIPTION => $1
612 }
613 +
614 + }
615 + if ($line =~ /
616 + inet \s ($ip_address_pattern) \s+
617 + netmask \s ($ip_address_pattern) \s+
618 + broadcast \s $ip_address_pattern
619 + /x) {
620 + $interface->{IPADDRESS} = $1;
621 + $interface->{IPMASK} = $2;
622 + }
623 +
624 + if ($line =~ /
625 + ether \s ($mac_address_pattern)
626 + .+
627 + \( ([^)]+) \)
628 + /x) {
629 + $interface->{MACADDR} = $1;
630 + $interface->{TYPE} = $2;
631 + }
632 +
633 + if ($line =~ /inet6 \s (\S+)/x) {
634 + $interface->{IPADDRESS6} = $1;
635 }
636 +
637 if ($line =~ /inet addr:($ip_address_pattern)/i) {
638 $interface->{IPADDRESS} = $1;
639 }
640 +
641 if ($line =~ /Mask:($ip_address_pattern)/) {
642 $interface->{IPMASK} = $1;
643 }
644 +
645 if ($line =~ /inet6 addr: (\S+)/i) {
646 $interface->{IPADDRESS6} = $1;
647 }
648 +
649 if ($line =~ /hwadd?r\s+($mac_address_pattern)/i) {
650 $interface->{MACADDR} = $1;
651 }
652 +
653 if ($line =~ /^\s+UP\s/) {
654 $interface->{STATUS} = 'Up';
655 }
656 +
657 + if ($line =~ /flags=.*[<,]UP[>,]/) {
658 + $interface->{STATUS} = 'Up';
659 + }
660 +
661 if ($line =~ /link encap:(\S+)/i) {
662 $interface->{TYPE} = $1;
663 }
664 @@ -411,7 +444,8 @@ This module provides some generic functions for Linux.
665
666 =head2 getDevicesFromUdev(%params)
667
668 -Returns a list of devices, by parsing udev database.
669 +Returns a list of devices, by parsing /dev/.udev directory.
670 +This directory is not exported anymore with recent udev.
671
672 Availables parameters:
673
674 diff --git a/lib/FusionInventory/Agent/Tools/Screen.pm b/lib/FusionInventory/Agent/Tools/Screen.pm
675 index 25111b8..16bb9a7 100644
676 --- a/lib/FusionInventory/Agent/Tools/Screen.pm
677 +++ b/lib/FusionInventory/Agent/Tools/Screen.pm
678 @@ -450,7 +450,7 @@ sub parseEdid {
679 while (length($v) >= 18) {
680 (my $pixel_clock, my $vv, $v) = unpack("v a16 a*", $v);
681 last if !$pixel_clock;
682 - my $h = build_detailed_timing($pixel_clock, $vv);
683 + my $h = _build_detailed_timing($pixel_clock, $vv);
684 push @{$edid{detailed_timings}}, $h
685 if $h->{horizontal_active} > 1 && $h->{vertical_active} > 1;
686 }
687
2121 [ ! -f MYMETA.yml ] || rm MYMETA.yml
2222 [ ! -f MYMETA.json ] || rm MYMETA.json
2323 [ ! -f t/inventory/generic/lspci/controllers.t ] || rm t/inventory/generic/lspci/controllers.t
24 [ ! -f t/components/server.t ] || rm t/components/server.t
2425 ifeq ($(BACKPORT),yes)
2526 [ ! -f t/components/client/ocs/response.t ] || rm t/components/client/ocs/response.t
2627 [ ! -f t/components/client/connection.t ] || rm t/components/client/connection.t