From 3c13485b5a62fb938e843471e78ebab4fbdf0417 Mon Sep 17 00:00:00 2001 From: ramonn Date: Mon, 13 Feb 2012 17:05:44 +0000 Subject: [PATCH] 2012-02-13 Ramon Novoa * bin/pandora_exec: Quote command line arguments. Thanks to Junichi Satoh. * lib/PandoraFMS/Core.pm: Small fixes to pandora_event. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5578 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 +++++++ pandora_server/bin/pandora_exec | 6 +++++- pandora_server/lib/PandoraFMS/Core.pm | 17 +++++++---------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 7aba26bf5e..b2874d94fa 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2012-02-13 Ramon Novoa + + * bin/pandora_exec: Quote command line arguments. Thanks to Junichi + Satoh. + + * lib/PandoraFMS/Core.pm: Small fixes to pandora_event. + 2012-02-13 Vanessa Gil * util/pandora_manage.pl diff --git a/pandora_server/bin/pandora_exec b/pandora_server/bin/pandora_exec index 6cd4d48d01..669d902a28 100755 --- a/pandora_server/bin/pandora_exec +++ b/pandora_server/bin/pandora_exec @@ -34,7 +34,11 @@ if ($#ARGV < 1) { my @opts = @ARGV; my $timeout = shift(@opts); -my $command = join(' ', @opts); +my $command; +foreach my $arg (@opts) { + $command .= quotemeta ($arg) . ' '; +} +chomp ($command); my $output = ''; my $ReturnCode = 0; diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 68b9d8fa3c..1aa21f709a 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1539,18 +1539,12 @@ Generate an event. =cut ########################################################################## -sub pandora_event ($$$$$$$$$$;$;$;$;$;$) { +sub pandora_event ($$$$$$$$$$;$$$$) { my ($pa_config, $evento, $id_grupo, $id_agente, $severity, - $id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $criticity, $comment, $id_extra) = @_; + $id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $comment, $id_extra) = @_; - logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 15); + logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); - if (!defined ($comment)) { - $comment = ''; - } - if (!defined ($id_extra)) { - $id_extra = ''; - } # Get module tags my $module_tags = ''; if (defined ($id_agentmodule) && $id_agentmodule > 0) { @@ -1559,7 +1553,10 @@ sub pandora_event ($$$$$$$$$$;$;$;$;$;$) { # Set default values for optional parameters $source = 'Pandora' unless defined ($source); - + $comment = '' unless defined ($comment); + $id_extra = '' unless defined ($id_extra); + $user_name = '' unless defined ($user_name); + my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); $id_agentmodule = 0 unless defined ($id_agentmodule);