Skip to content

Commit

Permalink
fix: Avoid perl syntax error when running Powershell script from Depl…
Browse files Browse the repository at this point in the history
…oy task on windows
  • Loading branch information
g-bougard committed Aug 27, 2024
1 parent f3c91fa commit a7a3c21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ netdiscovery/netinventory:
* Skip Konica printers firmware with "Registered" set as version
* Enhanced Hikvision devices support

deploy:
* Avoid perl syntax error when running Powershell script from Deploy task on windows

packaging:
* Update Windows MSI packing building process to use:
- libxml2 2.13.3
Expand Down
16 changes: 11 additions & 5 deletions lib/GLPI/Agent/Task/Deploy/ActionProcessor/Action/Cmd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,25 @@ sub _runOnWindows {

$fd->seek(0, SEEK_SET);

my $buf;
while(my $line = readline($fd)) {
my $buf = '';
while (my $line = readline($fd)) {
$buf .= $line;
}
close $fd;
$self->debug2("Run: ".$buf);

if (empty($buf)) {
$self->debug2("Run: Got no output");
} else {
$self->debug2("Run: ".$buf);
}

my $errMsg = '';
if ($exitcode eq '293') {
if ($exitcode && $exitcode eq '293') {
$errMsg = "timeout";
}

return ($buf, $errMsg, $exitcode);
# Report ERROR_NOT_SUPPORTED (50) on not defined exitcode
return ($buf, $errMsg, $exitcode // 50);
}


Expand Down

3 comments on commit a7a3c21

@mostafa0017
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of this part:

    if (empty($buf)) {
        $self->debug2("Run: Got no output");
    } else {
        $self->debug2("Run: ".$buf);
    }

Is causing deployment issues of a PowerShell script on v1.11-gitd23ad9fb

Error	Actions:PS Test, processing failure
Running	Actions:PS Test: Undefined subroutine &GLPI::Agent::Task::Deploy::ActionProcessor::Action::Cmd::empty called at C:/Program Files/GLPI-Agent/perl/agent/GLPI/Agent/Task/Deploy/ActionProcessor/Action/Cmd.pm line 85.
Running	Files preparation:success
Running	Files download:success
Running	Files download:Test.ps1 downloaded
Running	Files download:fetching Test.ps1
Running	Files download:downloading files
Running	Checks:all checks are ok
Running	Checks:check #1, Test1 passed
Running	Checks:starting
Prepared

@g-bougard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mostafa0017

indeed it seems I missed to include one lib and the following code at the beginning should fix this problem.

use GLPI::Agent::Tools

Anyway, you should have better open an issue in place of comment the code so this bug would have the visibility it deserves.

But thank you very much for this problem submission just before the next release.

@g-bougard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix included in 40294c3

Please sign in to comment.