diff --git a/Changes b/Changes index 12e7b419f2..542b8bfc1c 100644 --- a/Changes +++ b/Changes @@ -5,13 +5,22 @@ General: * failure encoding with UTF8 content when using Fusion protocol (#1663) * wrong CSS path (#1580) * missing test suite dependency (#1575) +* improve CPU details (#1597) +* --no-category process support (#1630) +* replace IS64BIT software property with more general ARCH property (#1581) +* sync EDID parsing code with mandriva +* more EDID manufacturer codes +* various UTF8 encoding fixes Windows: * various encoding issues (#1550) -* network addresses collecting failure +* network addresses collecting failure (#1549) +* inventory all the KB on Win Vista/7 (#1668, #197, #706) +* Store the XML file with the local codepage (#272) Virtualization: * wrong character in Xen machine ID (#1562) +* additional disk emulation types for qemu and kvm support (#1630) BSD: * multiple network addresses per interface support (#1565) @@ -21,13 +30,17 @@ Solaris: * solaris container zone bug (#1586) * sparc T3-1 CPU support (#1583) * solaris 8/9/10 swap bug (#1577) -* sparc arch mismatch (#1573) Linux: * bad name for physical volumes (#1587) * missing volume group ID (#1585) * wrong volume group ID (#1584) * duplicate volume groups (#1582) +* fix Lsilogic raid controller support (#1630) +* get device name from udev file content, not file name (#1630) +* get more disk informations from smartctl (#1630) +* sparc arch mismatch (#1573) +* read EDID data directly from /sys when available 2.2.0 Sat, 07 Apr 2012 18:57:49 +0200 diff --git a/lib/FusionInventory/Agent.pm b/lib/FusionInventory/Agent.pm index f9f4e14b13..fca62943d4 100644 --- a/lib/FusionInventory/Agent.pm +++ b/lib/FusionInventory/Agent.pm @@ -22,7 +22,7 @@ use FusionInventory::Agent::Tools; use FusionInventory::Agent::Tools::Hostname; use FusionInventory::Agent::XML::Query::Prolog; -our $VERSION = '2.2.0'; +our $VERSION = '2.2.1'; our $VERSION_STRING = "FusionInventory unified agent for UNIX, Linux and MacOSX ($VERSION)"; our $AGENT_STRING = diff --git a/lib/FusionInventory/Agent/HTTP/Client/OCS.pm b/lib/FusionInventory/Agent/HTTP/Client/OCS.pm index a65822b4fa..9e1679feba 100644 --- a/lib/FusionInventory/Agent/HTTP/Client/OCS.pm +++ b/lib/FusionInventory/Agent/HTTP/Client/OCS.pm @@ -8,6 +8,7 @@ use English qw(-no_match_vars); use HTTP::Request; use UNIVERSAL::require; use URI; +use Encode; use FusionInventory::Agent::Tools; use FusionInventory::Agent::XML::Response; @@ -61,7 +62,7 @@ sub send { ## no critic (ProhibitBuiltinHomonyms) my $request_content = $message->getContent(); $logger->debug2($log_prefix . "sending message:\n $request_content"); - $request_content = $self->_compress($request_content); + $request_content = $self->_compress(encode('UTF-8', $request_content)); if (!$request_content) { $logger->error($log_prefix . 'inflating problem'); return; diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm index d649b58cc0..e4d34f8747 100644 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/CPU.pm @@ -47,11 +47,12 @@ sub _getCpus{ my (%params) = @_; my $logger = $params{logger}; - + my $sysctl = $params{sysctl}; # Get more informations from sysctl my $sysctl = getFileHandle ( logger => $logger, - command => 'sysctl -a machdep.cpu' + command => 'sysctl -a machdep.cpu', + file => $sysctl ); # System profiler informations diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/User.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/User.pm index 5beaaabd61..88242ae15b 100644 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/User.pm +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Win32/User.pm @@ -15,6 +15,9 @@ use Win32::TieRegistry ( qw/KEY_READ/ ); +Win32::OLE->Option(CP => Win32::OLE::CP_UTF8); + + use FusionInventory::Agent::Tools::Win32; my $seen; @@ -52,6 +55,9 @@ sub doInventory { DOMAIN => $domain->Get() }; + utf8::upgrade($user->{LOGIN}); + utf8::upgrade($user->{DOMAIN}); + next if $seen->{$user->{LOGIN}}++; $inventory->addEntry( diff --git a/lib/FusionInventory/Agent/Tools/Win32.pm b/lib/FusionInventory/Agent/Tools/Win32.pm index 16cd92a0d2..92bfda7942 100644 --- a/lib/FusionInventory/Agent/Tools/Win32.pm +++ b/lib/FusionInventory/Agent/Tools/Win32.pm @@ -18,6 +18,7 @@ use Win32::TieRegistry ( qw/KEY_READ/ ); +use utf8; use File::Temp (); use File::Temp qw(:seekable); use Win32::Job; @@ -66,7 +67,9 @@ sub encodeFromRegistry { ## no critic (ExplicitReturnUndef) return undef unless $string; - return encode("UTF-8", decode(getLocalCodepage(), $string)); + return $string if Encode::is_utf8($string); + + return decode(getLocalCodepage(), $string); } sub getWmiObjects { @@ -84,7 +87,17 @@ sub getWmiObjects { )) { my $object; foreach my $property (@{$params{properties}}) { - $object->{$property} = $instance->{$property}; + if (!ref($instance->{$property}) && $instance->{$property}) { + # cast the Win32::OLE object in string + $object->{$property} = sprintf("%s", $instance->{$property}); + + # because of the Win32::OLE->Option(CP => Win32::OLE::CP_UTF8); + # we know it's UTF8, let's flag the string according because + # Win32::OLE don't do it + utf8::upgrade($object->{$property}); + } else { + $object->{$property} = $instance->{$property}; + } } push @objects, $object; } diff --git a/lib/FusionInventory/Agent/XML/Query.pm b/lib/FusionInventory/Agent/XML/Query.pm index 0768f2e6df..5769992a5c 100644 --- a/lib/FusionInventory/Agent/XML/Query.pm +++ b/lib/FusionInventory/Agent/XML/Query.pm @@ -24,6 +24,7 @@ sub getContent { my ($self) = @_; my $tpp = XML::TreePP->new(indent => 2); + return $tpp->write({ REQUEST => $self->{h} }); } diff --git a/t/inventory/macos/cpu.t b/t/inventory/macos/cpu.t index 831c58dbc7..5dd918b6f4 100644 --- a/t/inventory/macos/cpu.t +++ b/t/inventory/macos/cpu.t @@ -25,7 +25,8 @@ my %tests = ( plan tests => scalar keys %tests; foreach my $test (keys %tests) { - my $file = "resources/macos/sysctl/$test"; - my @cpus = FusionInventory::Agent::Task::Inventory::Input::MacOS::Memory::_getCpus(file => $file); + my $sysctl = "resources/macos/sysctl/$test"; + my $file = "resources/macos/system_profiler/$test"; + my @cpus = FusionInventory::Agent::Task::Inventory::Input::MacOS::CPU::_getCpus(file => $file,sysctl => $sysctl); is_deeply(\@cpus, $tests{$test}, $test); } diff --git a/t/inventory/windows/softwares.t b/t/inventory/windows/softwares.t index fa3ebb942d..a4c99e21c6 100644 --- a/t/inventory/windows/softwares.t +++ b/t/inventory/windows/softwares.t @@ -7081,75 +7081,75 @@ my %tests = ( }, wmi => { xp => { - '981852' => { - 'FROM' => 'WMI', - 'NAME' => 'KB981852', - 'COMMENTS' => 'Security Update for Windows XP (KB981852)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + '981852' => { + FROM => 'WMI', + NAME => 'KB981852', + COMMENTS => 'Security Update for Windows XP (KB981852)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '981349' => { - 'FROM' => 'WMI', - 'NAME' => 'KB981349', - 'COMMENTS' => 'Security Update for Windows XP (KB981349)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB981349', + COMMENTS => 'Security Update for Windows XP (KB981349)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '981322' => { - 'FROM' => 'WMI', - 'NAME' => 'KB981322', - 'COMMENTS' => 'Security Update for Windows XP (KB981322)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB981322', + COMMENTS => 'Security Update for Windows XP (KB981322)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '980232' => { - 'FROM' => 'WMI', - 'NAME' => 'KB980232', - 'COMMENTS' => 'Security Update for Windows XP (KB980232)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB980232', + COMMENTS => 'Security Update for Windows XP (KB980232)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '980436' => { - 'FROM' => 'WMI', - 'NAME' => 'KB980436', - 'COMMENTS' => 'Security Update for Windows XP (KB980436)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB980436', + COMMENTS => 'Security Update for Windows XP (KB980436)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '982132' => { - 'FROM' => 'WMI', - 'NAME' => 'KB982132', - 'COMMENTS' => 'Security Update for Windows XP (KB982132)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB982132', + COMMENTS => 'Security Update for Windows XP (KB982132)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '980195' => { - 'FROM' => 'WMI', - 'NAME' => 'KB980195', - 'COMMENTS' => 'Security Update for Windows XP (KB980195)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB980195', + COMMENTS => 'Security Update for Windows XP (KB980195)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '981997' => { - 'FROM' => 'WMI', - 'NAME' => 'KB981997', - 'COMMENTS' => 'Security Update for Windows XP (KB981997)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB981997', + COMMENTS => 'Security Update for Windows XP (KB981997)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '982214' => { - 'FROM' => 'WMI', - 'NAME' => 'KB982214', - 'COMMENTS' => 'Security Update for Windows XP (KB982214)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB982214', + COMMENTS => 'Security Update for Windows XP (KB982214)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' }, '982665' => { - 'FROM' => 'WMI', - 'NAME' => 'KB982665', - 'COMMENTS' => 'Security Update for Windows XP (KB982665)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB982665', + COMMENTS => 'Security Update for Windows XP (KB982665)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' } } } @@ -7214,11 +7214,11 @@ is_deeply( $kbList, { '981349' => { - 'FROM' => 'WMI', - 'NAME' => 'KB981349', - 'COMMENTS' => 'Security Update for Windows XP (KB981349)', - 'ARCH' => 'i586', - 'RELEASE_TYPE' => 'Security Update' + FROM => 'WMI', + NAME => 'KB981349', + COMMENTS => 'Security Update for Windows XP (KB981349)', + ARCH => 'i586', + RELEASE_TYPE => 'Security Update' } }, "duplicated KB found in the KB stack are deleted" diff --git a/t/xml/query/inventory.t b/t/xml/query/inventory.t index cbb6fbfb6a..09b466940c 100755 --- a/t/xml/query/inventory.t +++ b/t/xml/query/inventory.t @@ -3,59 +3,86 @@ use strict; use warnings; +use Config; use Test::More; use Test::Exception; use XML::TreePP; use FusionInventory::Agent::XML::Query::Inventory; +use FusionInventory::Agent::Task::Inventory::Inventory; -plan tests => 5; +plan tests => 6; -my $inventory; +my $query; throws_ok { - $inventory = FusionInventory::Agent::XML::Query::Inventory->new(); + $query = FusionInventory::Agent::XML::Query::Inventory->new(); } qr/^no content/, 'no content'; +my $inventory = FusionInventory::Agent::Task::Inventory::Inventory->new(); throws_ok { - $inventory = FusionInventory::Agent::XML::Query::Inventory->new( - content => { - HARDWARE => { - ARCHNAME => 'x86_64-linux-thread-multi', - VMSYSTEM => 'Physical' - }, - }, + $query = FusionInventory::Agent::XML::Query::Inventory->new( + content => $inventory->getContent() ); } qr/^no deviceid/, 'no device id'; lives_ok { - $inventory = FusionInventory::Agent::XML::Query::Inventory->new( + $query = FusionInventory::Agent::XML::Query::Inventory->new( deviceid => 'foo', - content => { - HARDWARE => { - ARCHNAME => 'x86_64-linux-thread-multi', - VMSYSTEM => 'Physical' - }, - }, + content => $inventory->getContent() ); } 'everything OK'; -isa_ok($inventory, 'FusionInventory::Agent::XML::Query::Inventory'); +isa_ok($query, 'FusionInventory::Agent::XML::Query::Inventory'); my $tpp = XML::TreePP->new(); is_deeply( - scalar $tpp->parse($inventory->getContent()), + scalar $tpp->parse($query->getContent()), + { + REQUEST => { + DEVICEID => 'foo', + QUERY => 'INVENTORY', + CONTENT => { + HARDWARE => { + ARCHNAME => $Config{archname}, + VMSYSTEM => 'Physical' + }, + VERSIONCLIENT => $FusionInventory::Agent::AGENT_STRING, + }, + } + }, + 'empty inventory, expected content' +); + +$inventory->addEntry( + section => 'SOFTWARES', + entry => { + NAME => '<&>', + } +); + +$query = FusionInventory::Agent::XML::Query::Inventory->new( + deviceid => 'foo', + content => $inventory->getContent() +); + +is_deeply( + scalar $tpp->parse($query->getContent()), { REQUEST => { DEVICEID => 'foo', QUERY => 'INVENTORY', CONTENT => { HARDWARE => { - ARCHNAME => 'x86_64-linux-thread-multi', + ARCHNAME => $Config{archname}, VMSYSTEM => 'Physical' }, + VERSIONCLIENT => $FusionInventory::Agent::AGENT_STRING, + SOFTWARES => { + NAME => '<&>' + } }, } }, - 'expected content' + 'additional content with prohibited characters, expected content' );