glpi-project / glpi-agent

GLPI Agent
GNU General Public License v2.0
212 stars 51 forks source link

Deployment Task Message is Garbled on Client #655

Closed cautiouscoyote closed 1 month ago

cautiouscoyote commented 2 months ago

Bug reporting acknowledgment

Yes, I read it

Professional support

Yes, I know

Describe the bug

When using the GLPI Inventory plugin to deploy a task on a client, and display a message afterwards, the formatting of this message is being screwed up: carriage return and line feed characters are being displayed instead of the proper new lines and what-not; see attached pictures.

To reproduce

  1. In the GLPI Inventory plugin, compose a deployment task with a package deployment action doing something whatever (can be some simple command).
  2. Make sure to add a Message under User Interactions "after actions".
  3. Let the client/agent do a run where it should pick up the deployment task.
  4. Behold the garbled message being displayed on the client screen.

Expected behavior

The message should be displayed on the client in the same markup with new lines as composed in the User Interactions field.

Operating system

Windows

GLPI Agent version

1.7.1

GLPI version

10.0.11

GLPIInventory plugin or other plugin version

GLPI Inventory v1.3.5

Additional context

Composed package action message: image

Actual message as displayed on client: image

Have reported this matter earlier at the issue page of the Inventory plugin here: https://github.com/glpi-project/glpi-inventory-plugin/issues/493 but it is suggested this is likely an agent issue, so there you have it.

g-bougard commented 1 month ago

Hi @cautiouscoyote

can you make a test on one agent ?

First enable debug = 2 in registry and don't forget to restart the service.

Then make an installation test and share the log part related to the installation.

This should help to know if it's an agent or a server issue.

cautiouscoyote commented 1 month ago

Hi @g-bougard,

Done! Please find attached:

I am guessing the output you're looking for can be found at around line 145 in the provided log section.

glpi-agent_debug2-test

glpi-agent.trimmed.log

g-bougard commented 1 month ago

Okay, after some tests, I noticed you didn't select a "User Interaction Template". This parameter is required. In your case, the simplest one requiring only "OK" from the user is sufficient.

On my side, if I don't select a template, I obtain the same output than you. If I select a template, the output is correct.

The problem here seems in the plugin to me as there's a red asterisk on the UI Template but the form permits you to leave it empty.

Can you confirm it's okay for you when setting up a UI template ?

cautiouscoyote commented 1 month ago

"Can you confirm it's okay for you when setting up a UI template ?"

Done! And indeed, upon removing the installed test application "igs-viewer" and then forcibly re-running the deployment job, it got installed again as expected, while displaying a now properly formatted message box:

glpi-agent_deployment-message_layout_ok

In both cases though, first without and now with forced user action, the message box comes with an "OK" button. In the first case the message box disappears after a while, in the latter case ... I may not have waited long enough for that; I manually pushed the OK button.

g-bougard commented 1 month ago

Hi @cautiouscoyote

indeed, the format problem was really in GLPIInventory plugin. I proposed a PR to fix it.