From dde2146987e3739692a7fbe8af88d3a685597ba6 Mon Sep 17 00:00:00 2001
From: zarzuelo <noreply@pandorafms.org>
Date: Thu, 3 May 2012 14:45:42 +0000
Subject: [PATCH] 2012-05-03  Sergio Martin <sergio.martin@artica.es>

	* win32/windows/pandora_wmi.cc: Added to the windows
	agent inventory module for patches the service pack
	column

	Merged from 4.0.2



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6251 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_agents/ChangeLog                    |  8 ++++++++
 pandora_agents/win32/windows/pandora_wmi.cc | 13 ++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog
index f0d9f66cbc..f179dcb42d 100644
--- a/pandora_agents/ChangeLog
+++ b/pandora_agents/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-03  Sergio Martin <sergio.martin@artica.es>
+
+	* win32/windows/pandora_wmi.cc: Added to the windows
+	agent inventory module for patches the service pack
+	column
+
+	Merged from 4.0.2
+
 2012-04-27 Dario Rodriguez <dario.rodriguez@artica.es>
 
  	* unix/plugins/inventory: Fixed a small error related to inventory plugin
diff --git a/pandora_agents/win32/windows/pandora_wmi.cc b/pandora_agents/win32/windows/pandora_wmi.cc
index 1cadf90557..bae1960605 100644
--- a/pandora_agents/win32/windows/pandora_wmi.cc
+++ b/pandora_agents/win32/windows/pandora_wmi.cc
@@ -1016,7 +1016,7 @@ int
 Pandora_Wmi::getPatchInfo (list<string> &rows) {
     CDhInitialize init;
 	CDispPtr      wmi_svc =  NULL, patch_info = NULL;
-	char         *hot_fix_id  = NULL, *description = NULL, *comments = NULL;
+	char         *hot_fix_id  = NULL, *description = NULL, *comments = NULL, *service_pack = NULL;
 	string        ret = "";
     int          num_objects = 0;
  	try {
@@ -1027,7 +1027,7 @@ Pandora_Wmi::getPatchInfo (list<string> &rows) {
 
         dhCheck (dhGetValue (L"%o", &patch_info, wmi_svc,
 				     L".ExecQuery(%S)",
-				     L"SELECT HotFixID, Description, FixComments FROM Win32_QuickFixEngineering "));
+				     L"SELECT HotFixID, Description, FixComments, ServicePackInEffect FROM Win32_QuickFixEngineering "));
         
 		FOR_EACH (patch_info_item, patch_info, NULL) {
             num_objects++;
@@ -1050,7 +1050,14 @@ Pandora_Wmi::getPatchInfo (list<string> &rows) {
    			if (comments != NULL) {
                ret += comments; 
             }
-            dhFreeString(comments);
+            ret += inventory_field_separator;
+            dhFreeString (comments);		
+			dhGetValue (L"%s", &service_pack, patch_info_item,
+				    L".ServicePackInEffect");
+   			if (service_pack != NULL) {
+               ret += service_pack; 
+            }
+            dhFreeString(service_pack);
             rows.push_back(ret);
             ret.clear();
 		} NEXT_THROW (patch_info_item);