mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
2010-07-08 Ramon Novoa <rnovoa@artica.es>
* pandora_exec: Do not verify the command to allow pipes and complex commands. * pandora_agent: Quote the command passed to pandora_exec. Fixed the module cron. Modules without a module cron would not run. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2980 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
4cedaaabd1
commit
3a234628f9
@ -1,3 +1,11 @@
|
|||||||
|
2010-07-08 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* pandora_exec: Do not verify the command to allow pipes and complex
|
||||||
|
commands.
|
||||||
|
|
||||||
|
* pandora_agent: Quote the command passed to pandora_exec. Fixed
|
||||||
|
the module cron. Modules without a module cron would not run.
|
||||||
|
|
||||||
2010-07-05 Junichi Satoh <junichi@rworks.jp>
|
2010-07-05 Junichi Satoh <junichi@rworks.jp>
|
||||||
|
|
||||||
* pandora_agent_installer: Fixed typo and directory permission
|
* pandora_agent_installer: Fixed typo and directory permission
|
||||||
|
@ -761,7 +761,8 @@ sub module_exec ($) {
|
|||||||
if ($module->{'timeout'} == 0) {
|
if ($module->{'timeout'} == 0) {
|
||||||
@data = `$module->{'params'} 2> /dev/null`;
|
@data = `$module->{'params'} 2> /dev/null`;
|
||||||
} else {
|
} else {
|
||||||
@data = `$Conf{'pandora_exec'} $module->{'timeout'} $module->{'params'} 2> /dev/null`;
|
my $cmd = quotemeta ($module->{'params'});
|
||||||
|
@data = `$Conf{'pandora_exec'} $module->{'timeout'} $cmd 2> /dev/null`;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Something went wrong or no data
|
# Something went wrong or no data
|
||||||
@ -945,7 +946,7 @@ sub check_module_cron ($) {
|
|||||||
my $module = shift;
|
my $module = shift;
|
||||||
|
|
||||||
# No cron string defined
|
# No cron string defined
|
||||||
return 0 unless ($module->{'cron'} ne '');
|
return 1 unless ($module->{'cron'} ne '');
|
||||||
|
|
||||||
# Check if the module was already executed
|
# Check if the module was already executed
|
||||||
return 0 unless (time() > $module->{'cron_utimestamp'});
|
return 0 unless (time() > $module->{'cron_utimestamp'});
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# execution times out or the command does not exist nothing is printed
|
# execution times out or the command does not exist nothing is printed
|
||||||
# to stdout. This is part of Pandora FMS Plugin server, do not delete!.
|
# to stdout. This is part of Pandora FMS Plugin server, do not delete!.
|
||||||
#
|
#
|
||||||
# Usage: pandora_exec <timeout in seconds> <command> [arguments]
|
# Usage: pandora_exec <timeout in seconds> <command>
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Copyright (c) 2008 Ramon Novoa, rnovoa@gmail.com
|
# Copyright (c) 2008 Ramon Novoa, rnovoa@gmail.com
|
||||||
# (c) 2008 Artica Soluciones Tecnologicas S.L
|
# (c) 2008 Artica Soluciones Tecnologicas S.L
|
||||||
@ -34,23 +34,16 @@ if ($#ARGV < 1) {
|
|||||||
|
|
||||||
my @opts = @ARGV;
|
my @opts = @ARGV;
|
||||||
my $timeout = shift(@opts);
|
my $timeout = shift(@opts);
|
||||||
my $command = quotemeta(shift(@opts));
|
my $command = join(' ', @opts);
|
||||||
my $arguments = join(' ', @opts);
|
|
||||||
my $output = '';
|
my $output = '';
|
||||||
my $ReturnCode = 0;
|
my $ReturnCode = 0;
|
||||||
|
|
||||||
|
|
||||||
# Check that the command exists
|
|
||||||
if (system("$command >/dev/null 2>&1") == 32512) {
|
|
||||||
exit 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Execute the command
|
# Execute the command
|
||||||
eval {
|
eval {
|
||||||
local $SIG{ALRM} = sub { die "alarm\n" };
|
local $SIG{ALRM} = sub { die "alarm\n" };
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
|
|
||||||
$output = `$command $arguments`;
|
$output = `$command`;
|
||||||
$ReturnCode = ($? >> 8) & 0xff;
|
$ReturnCode = ($? >> 8) & 0xff;
|
||||||
alarm 0;
|
alarm 0;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user