Skip to content

Commit

Permalink
fix: Proxy plugin should store json in place of datas file
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Nov 9, 2023
1 parent 90007c9 commit df3c74c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/GLPI/Agent/HTTP/Server/Proxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -445,19 +445,20 @@ sub _handle_proxy_request {

if ($local_store && $action ne "contact") {
my $file = $local_store;
my $json = ($message->get("deviceid") || $agentid).".json";
$file =~ s|/*$||;
$file .= "/$agentid.data";
$self->debug("Saving datas from $remoteid in $file");
$file .= "/$json";
$self->debug("Saving $json from $remoteid in $local_store");
my $DATA;
unless (open($DATA, '>', $file)) {
$self->error("Can't store datas from $remoteid");
return $self->proxy_error(500, "Proxy failed to store datas");
$self->error("Can't store $json from $remoteid");
return $self->proxy_error(500, "Proxy failed to store json");
}
binmode($DATA);
print $DATA $content;
close($DATA);
unless (-s $file == length($content)) {
$self->error("Failed to store datas from $remoteid");
$self->error("Failed to store $json from $remoteid");
return $self->proxy_error(500, "Proxy storing failure");
}
}
Expand Down
2 changes: 1 addition & 1 deletion t/agent/http/server/proxy.t
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ SKIP: {
chmod 400, $local_store;
_request();
subtest "only only_local_store but can't store" => sub {
check_error(500, "Proxy failed to store datas");
check_error(500, "Proxy failed to store json");
};
chmod 755, $local_store;
}
Expand Down

0 comments on commit df3c74c

Please sign in to comment.