mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Allow transfer_xml direct file paths in pluginTools
This commit is contained in:
parent
13b517718f
commit
7275bdd061
@ -792,59 +792,64 @@ sub transfer_xml {
|
|||||||
my $file_name;
|
my $file_name;
|
||||||
my $file_path;
|
my $file_path;
|
||||||
|
|
||||||
if (! (empty ($name))) {
|
if (! -f $xml) {
|
||||||
$file_name = $name . "." . sprintf("%d",getCurrentUTimeMilis(). (rand()*10000)) . ".data";
|
if (! (empty ($name))) {
|
||||||
}
|
$file_name = $name . "." . sprintf("%d",getCurrentUTimeMilis(). (rand()*10000)) . ".data";
|
||||||
else {
|
|
||||||
# Inherit file name
|
|
||||||
($file_name) = $xml =~ /\s+agent_name='(.*?)'\s+.*$/m;
|
|
||||||
if (empty($file_name)){
|
|
||||||
($file_name) = $xml =~ /\s+agent_name="(.*?)"\s+.*$/m;
|
|
||||||
}
|
}
|
||||||
if (empty($file_name)){
|
else {
|
||||||
$file_name = trim(`hostname`);
|
# Inherit file name
|
||||||
|
($file_name) = $xml =~ /\s+agent_name='(.*?)'\s+.*$/m;
|
||||||
|
if (empty($file_name)){
|
||||||
|
($file_name) = $xml =~ /\s+agent_name="(.*?)"\s+.*$/m;
|
||||||
|
}
|
||||||
|
if (empty($file_name)){
|
||||||
|
$file_name = trim(`hostname`);
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_name .= "." . sprintf("%d",time()) . ".data";
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_name .= "." . sprintf("%d",time()) . ".data";
|
logger($conf, "transfer_xml", "Failed to generate file name.") if empty($file_name);
|
||||||
}
|
|
||||||
|
|
||||||
logger($conf, "transfer_xml", "Failed to generate file name.") if empty($file_name);
|
$conf->{temp} = $conf->{tmp} if (empty($conf->{temp}) && defined($conf->{tmp}));
|
||||||
|
$conf->{temp} = $conf->{temporal} if (empty($conf->{temp}) && defined($conf->{temporal}));
|
||||||
|
$conf->{temp} = $conf->{__system}->{tmp} if (empty($conf->{temp}) && defined($conf->{__system})) && (ref($conf->{__system}) eq "HASH");
|
||||||
|
$conf->{temp} = $ENV{'TMP'} if empty($conf->{temp}) && $^O =~ /win/i;
|
||||||
|
$conf->{temp} = '/tmp' if empty($conf->{temp}) && $^O =~ /lin/i;
|
||||||
|
|
||||||
$conf->{temp} = $conf->{tmp} if (empty($conf->{temp}) && defined($conf->{tmp}));
|
|
||||||
$conf->{temp} = $conf->{temporal} if (empty($conf->{temp}) && defined($conf->{temporal}));
|
|
||||||
$conf->{temp} = $conf->{__system}->{tmp} if (empty($conf->{temp}) && defined($conf->{__system})) && (ref($conf->{__system}) eq "HASH");
|
|
||||||
$conf->{temp} = $ENV{'TMP'} if empty($conf->{temp}) && $^O =~ /win/i;
|
|
||||||
$conf->{temp} = '/tmp' if empty($conf->{temp}) && $^O =~ /lin/i;
|
|
||||||
|
|
||||||
$file_path = $conf->{temp} . "/" . $file_name;
|
|
||||||
|
|
||||||
#Creating XML file in temp directory
|
|
||||||
|
|
||||||
if ( -e $file_path ) {
|
|
||||||
sleep (1);
|
|
||||||
$file_name = $name . "." . sprintf("%d",time()) . ".data";
|
|
||||||
$file_path = $conf->{temp} . "/" . $file_name;
|
$file_path = $conf->{temp} . "/" . $file_name;
|
||||||
|
|
||||||
|
#Creating XML file in temp directory
|
||||||
|
|
||||||
|
if ( -e $file_path ) {
|
||||||
|
sleep (1);
|
||||||
|
$file_name = $name . "." . sprintf("%d",time()) . ".data";
|
||||||
|
$file_path = $conf->{temp} . "/" . $file_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $r = open (my $FD, ">>", $file_path);
|
||||||
|
|
||||||
|
if (empty($r)) {
|
||||||
|
print_stderror($conf, "Cannot write to [" . $file_path . "]", $conf->{'debug'});
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $bin_opts = ':raw:encoding(UTF8)';
|
||||||
|
|
||||||
|
if ($^O eq "Windows") {
|
||||||
|
$bin_opts .= ':crlf';
|
||||||
|
}
|
||||||
|
|
||||||
|
binmode($FD, $bin_opts);
|
||||||
|
|
||||||
|
print $FD $xml;
|
||||||
|
|
||||||
|
close ($FD);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$file_path = $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $r = open (my $FD, ">>", $file_path);
|
|
||||||
|
|
||||||
if (empty($r)) {
|
|
||||||
print_stderror($conf, "Cannot write to [" . $file_path . "]", $conf->{'debug'});
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $bin_opts = ':raw:encoding(UTF8)';
|
|
||||||
|
|
||||||
if ($^O eq "Windows") {
|
|
||||||
$bin_opts .= ':crlf';
|
|
||||||
}
|
|
||||||
|
|
||||||
binmode($FD, $bin_opts);
|
|
||||||
|
|
||||||
print $FD $xml;
|
|
||||||
|
|
||||||
close ($FD);
|
|
||||||
|
|
||||||
# Reassign default values if not present
|
# Reassign default values if not present
|
||||||
$conf->{tentacle_client} = "tentacle_client" if empty($conf->{tentacle_client});
|
$conf->{tentacle_client} = "tentacle_client" if empty($conf->{tentacle_client});
|
||||||
$conf->{tentacle_port} = "41121" if empty($conf->{tentacle_port});
|
$conf->{tentacle_port} = "41121" if empty($conf->{tentacle_port});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user