Skip to content

Commit

Permalink
collect KB from Win32_QuickFixEngineering
Browse files Browse the repository at this point in the history
On Windows 7, part of the KB are not available in the Uninstall key
from the registry. With this patch, the agent use Win32_QuickFixEngineering
as an alternative source of software.

closes: #706
closes: #1668
closes: #197

Reported-by: David Durieux <d.durieux@siprossii.com>
  • Loading branch information
Gonéri Le Bouder committed May 16, 2012
1 parent 0414f17 commit 0ab900b
Show file tree
Hide file tree
Showing 3 changed files with 7,229 additions and 7,064 deletions.
54 changes: 50 additions & 4 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Softwares.pm
Expand Up @@ -29,7 +29,11 @@ sub doInventory {
my $inventory = $params{inventory};
my $logger = $params{logger};

if (is64bit()) {
my $is64bit = is64bit();

my $kbList = _getKB(is64bit => $is64bit);

if ($is64bit) {

# I don't know why but on Vista 32bit, KEY_WOW64_64 is able to read
# 32bit entries. This is not the case on Win2003 and if I correctly
Expand All @@ -44,7 +48,8 @@ sub doInventory {

foreach my $software (_getSoftwares(
softwares => $softwares64,
is64bit => 1
is64bit => 1,
kbList => $kbList
)) {
_addSoftware(inventory => $inventory, entry => $software);
}
Expand All @@ -64,7 +69,8 @@ sub doInventory {
foreach my $software (_getSoftwares(
softwares => $softwares32,
is64bit => 0,
logger => $logger
logger => $logger,
kbList => $kbList
)) {
_addSoftware(inventory => $inventory, entry => $software);
}
Expand All @@ -85,7 +91,8 @@ sub doInventory {

foreach my $software (_getSoftwares(
softwares => $softwares,
is64bit => 0
is64bit => 0,
kbList => $kbList
)) {
_addSoftware(inventory => $inventory, entry => $software);
}
Expand All @@ -95,6 +102,11 @@ sub doInventory {
is64bit => 0
);
}

foreach (values %$kbList) {
_addSoftware(inventory => $inventory, entry => $_);
}

}

sub _dateFormat {
Expand All @@ -118,6 +130,7 @@ sub _getSoftwares {
my (%params) = @_;

my $softwares = $params{softwares};
my $kbList = $params{kbList};

my @softwares;

Expand Down Expand Up @@ -156,12 +169,45 @@ sub _getSoftwares {
# Workaround for #415
$software->{VERSION} =~ s/[\000-\037].*// if $software->{VERSION};

if ($software->{NAME} =~ /KB(\d{4,10})/i) {
delete($kbList->{$1});
}

push @softwares, $software;
}

return @softwares;
}

sub _getKB {
my (%params) = @_;

my $kbList = {};

foreach my $object (getWmiObjects(
class => 'Win32_QuickFixEngineering',
properties => [ qw/HotFixID Description/ ]
)) {

my $releaseType;
if ($object->{Description} && $object->{Description} =~ /^(Security Update|Hotfix|Update)/) {
$releaseType = $1;
}

next unless $object->{HotFixID} =~ /KB(\d{4,10})/i;
$kbList->{$1} = {
NAME => $object->{HotFixID},
COMMENTS => $object->{Description},
FROM => "WMI",
RELEASE_TYPE => $releaseType,
ARCH => $params{is64bit} ? 'x86_64' : 'i586'
};

}

return $kbList;
}

sub _addSoftware {
my (%params) = @_;

Expand Down
Binary file not shown.

0 comments on commit 0ab900b

Please sign in to comment.