From b7d4b96e542cbdfadb9cc46ba861f4c3496f4e17 Mon Sep 17 00:00:00 2001
From: Ramon Novoa <rnovoa@artica.es>
Date: Thu, 19 Nov 2009 00:44:30 +0000
Subject: [PATCH] 2009-11-19  Ramon Novoa  <rnovoa@artica.es>

	* Check for empty module/agent when processing
          module data.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2116 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/ChangeLog              | 5 +++++
 pandora_server/lib/PandoraFMS/Core.pm | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index c445b547bb..442d11b0eb 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-19  Ramon Novoa  <rnovoa@artica.es>
+
+	* lib/PandoraFMS/Core.pm: Check for empty module/agent when processing
+	  module data.
+
 2009-11-13  Ramon Novoa  <rnovoa@artica.es>
 
 	* conf/pandora_server.conf: Updated configuration tokens.
diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm
index 432adab594..3c98add008 100644
--- a/pandora_server/lib/PandoraFMS/Core.pm
+++ b/pandora_server/lib/PandoraFMS/Core.pm
@@ -528,7 +528,7 @@ sub pandora_process_module ($$$$$$$$$) {
 	logger($pa_config, "Processing module '" . $module->{'nombre'} . "' for agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 10);
 
 	# Get module type
-	if (! defined ($module_type)) {
+	if (! defined ($module_type) || $module_type eq '') {
 		$module_type = get_db_value ($dbh, 'SELECT nombre FROM ttipo_modulo WHERE id_tipo = ?', $module->{'id_tipo_modulo'});
 		if (! defined ($module_type)) {
 			logger($pa_config, "Invalid module type ID " . $module->{'id_tipo_modulo'} . " module '" . $module->{'nombre'} . "' agent " . (defined ($agent) ? "'" . $agent->{'nombre'} . "'" : 'ID ' . $module->{'id_agente'}) . ".", 10);
@@ -538,7 +538,7 @@ sub pandora_process_module ($$$$$$$$$) {
 	}
 
 	# Get agent information
-	if (! defined ($agent)) {
+	if (! defined ($agent) || $agent eq '') {
 		$agent = get_db_single_row ($dbh, 'SELECT * FROM tagente WHERE id_agente = ?', $module->{'id_agente'});
 		if (! defined ($agent)) {
 			logger($pa_config, "Agent ID " . $module->{'id_agente'} . " not found while processing module '" . $module->{'nombre'} . "'.", 3);