redddcyclone / glpi-agentmonitor

GLPI-Agent monitoring utility for Windows (systray icon)
GNU General Public License v2.0
9 stars 5 forks source link

Error getting GLPI server url clicking on New ticket #6

Closed kintaro1981 closed 1 year ago

kintaro1981 commented 1 year ago

I'm trying the New ticket button and I'm getting the error:

Error getting GLPI server URL! The Agent must be reinstalled.

In the registry the value of the server registry key is: http://<mydomain>/plugins/glpiinventory

The monitor is working without any problem.

redddcyclone commented 1 year ago

Hi @kintaro1981

Are you using any released version or compiled by yourself?

Could you post a screenshot from regedit.exe at path HKEY_LOCAL_MACHINE\SOFTWARE\GLPI-Agent?

Edit: I could reproduce the issue already, gonna work on it

redddcyclone commented 1 year ago

@kintaro1981

Just found the problem. Could you test it now?

kintaro1981 commented 1 year ago

Yes it's working now.

kintaro1981 commented 1 year ago

I re-open this because I notice that I get the same error if the URL option is set with single quote or double quote like:

'http://glpiserver/' "http://glpiserver/"

I get the same error.

To reproduce:

  1. edit registry server value adding single quote
  2. close glpi agent monitor
  3. open glpi agent monitor
  4. click on "new ticket"
g-bougard commented 1 year ago

@kintaro1981

I don't think editing the url in registry to set it to something wrong justify this issue to be reopened. Even if the agent accepts url with quotes or double-quotes, the url is wrong in registry. The fact GLPI-Agent accepts it is a side-effect of config file support where it seems legit to set the value with quotes or double-quotes.

Should we also open the issue if you set a URL to something really wrong ?

But maybe the glpi-agentmonitor should just validate the url with a dedicated API, then fail and report an error on wrong url (including url with quotes or double-quotes).

redddcyclone commented 1 year ago

Hi @kintaro1981

For this problem, I added code to remove any quotes from the server URL string. As this URL is used by the Monitor only for loading the ticket page, I think this should be a better way to do it instead of displaying an error.

@g-bougard

As the Agent accepts quotes on the URL, even if it's not intended to do so, I think this behavior for the Monitor is more consistent than reporting an error. If the Agent ever stops supporting quotes, I'll update the Monitor to match its behavior.

kintaro1981 commented 1 year ago

@kintaro1981 I don't think editing the url in registry to set it to something wrong justify this issue to be reopened. Even if the agent accepts url with quotes or double-quotes, the url is wrong in registry. The fact GLPI-Agent accepts it is a side-effect of config file support where it seems legit to set the value with quotes or double-quotes.

I edited the url in registry only to test the behaviour of glpi-agent monitor with or without quotes because I inherited a fusioninventory installation base with double quotes in the registry key value "server" and noticed, once I start to test migration, the issue with glpi-agent monitor. It could happen the same thing installing glpi-agent from scratch with quote or double quotes in the URL.

I don't want to steal time to devs but I thought that maybe could happens to others too as glpi-agent is accepting them.