add code lost inventory server pandora_enterprise#12188
This commit is contained in:
parent
c7a746ea41
commit
b45c967919
|
@ -183,15 +183,22 @@ sub data_consumer ($$) {
|
||||||
|
|
||||||
# No code to run
|
# No code to run
|
||||||
return if ($module->{'interpreter'} eq '');
|
return if ($module->{'interpreter'} eq '');
|
||||||
|
|
||||||
# Save script in a temporary file
|
my $command;
|
||||||
my ($fh, $temp_file) = tempfile();
|
my ($fh, $temp_file) = tempfile();
|
||||||
$fh->print (decode_base64($module->{'code'}));
|
|
||||||
close ($fh);
|
|
||||||
set_file_permissions($pa_config, $temp_file, "0777");
|
|
||||||
|
|
||||||
# Run the script
|
if ($module->{'script_mode'} == '1') {
|
||||||
my $command = $module->{'interpreter'} . ' ' . $temp_file . ' "' . $module->{'target'} . '"';
|
my $script_file = $module->{'script_path'};
|
||||||
|
$command = $module->{'interpreter'} . ' ' . $script_file;
|
||||||
|
} else {
|
||||||
|
# Save script in a temporary file
|
||||||
|
$fh->print (decode_base64($module->{'code'}));
|
||||||
|
close ($fh);
|
||||||
|
set_file_permissions($pa_config, $temp_file, "0777");
|
||||||
|
|
||||||
|
# Run the script
|
||||||
|
$command = $module->{'interpreter'} . ' ' . $temp_file . ' "' . $module->{'target'} . '"';
|
||||||
|
}
|
||||||
|
|
||||||
# Try to read the custom fields to use them as arguments into the command
|
# Try to read the custom fields to use them as arguments into the command
|
||||||
if (defined($module->{'custom_fields'}) && $module->{'custom_fields'} ne '') {
|
if (defined($module->{'custom_fields'}) && $module->{'custom_fields'} ne '') {
|
||||||
|
@ -206,7 +213,11 @@ sub data_consumer ($$) {
|
||||||
|
|
||||||
if (!defined ($decoded_cfields)) {
|
if (!defined ($decoded_cfields)) {
|
||||||
logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed because the custom fields can't be read", 6);
|
logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed because the custom fields can't be read", 6);
|
||||||
unlink ($temp_file);
|
|
||||||
|
if ($module->{'script_mode'} == '2') {
|
||||||
|
unlink ($temp_file);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,11 +248,18 @@ sub data_consumer ($$) {
|
||||||
# Check for errors
|
# Check for errors
|
||||||
if ($? != 0) {
|
if ($? != 0) {
|
||||||
logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed with error level $?", 6);
|
logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed with error level $?", 6);
|
||||||
unlink ($temp_file);
|
|
||||||
|
if ($module->{'script_mode'} == '2') {
|
||||||
|
unlink ($temp_file);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink ($temp_file);
|
if ($module->{'script_mode'} == '2') {
|
||||||
|
unlink ($temp_file);
|
||||||
|
}
|
||||||
|
|
||||||
my $utimestamp = time ();
|
my $utimestamp = time ();
|
||||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
||||||
eval {
|
eval {
|
||||||
|
|
Loading…
Reference in New Issue