You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When editing properties of remote pollers the query for detecting duplicate poller hostnames and database hostnames is missing critical brackets
To Reproduce
Deploy Cacti with a remote poller, try to edit any property of that remote poller. I receive an error to "Please enter a non-duplicate hostname" as well as "Please enter a non-duplicate database hostname".
SELECT id FROM poller WHERE id != 2 AND dbhost IN ('192.168.1.2') OR ((dbhost = 'cacti-poller-01' OR dbhost LIKE 'cacti-poller-01%' OR dbhost = 'cacti-poller-01.example.com'))
When the poller already exists in the database with the id of 2 it is returned in this query because of the 'OR' expression not being bracketed together with the dbhost part of the clause.
I believe the query should be written as follows:
SELECT id FROM poller WHERE id != 2 AND (dbhost IN ('192.168.1.2') OR ((dbhost = 'cacti-poller-01' OR dbhost LIKE 'cacti-poller-01%' OR dbhost = 'cacti-poller-01.example.com')))
Note the extra brackets that begin after the 'AND'
The text was updated successfully, but these errors were encountered:
I can try to put a PR together for this - I'm just finishing up some other tasks at the moment but recognize that I definitely should make an effort to contribute back to a project that gives us so much.
I am curious about like 397, where it adds the wildcard to the host portion of the name. I don't feel like this is right, if you had a remote poller named cacti-poller.example.com then later added cacti-poller-2.example.com it would falsely call that a duplicate. Perhaps it should match only on the first section or the FQDN, and not just match anything that starts with the first portion of the host name (in this case cacti-poller%)?
If I submit a fix for this, would it be okay for me to remove that line?
I'm not sure why it's so inclusive. When you highlighted the code, my first thought was that it could match extra numbers or other suffixes of additional hosts but there must have been a user case for it.
Feel free to amend the query as you see right, it will get peer reviewed anyway:)
netniV
changed the title
Unable to edit properties of remote pollers - please enter a non-duplicate hostname/database hostname
When updating poller name, matches may be too wide in scope
Nov 7, 2021
netniV
changed the title
When updating poller name, matches may be too wide in scope
When updating poller name, duplicate name protection may be over zealous
Apr 3, 2022
Describe the bug
When editing properties of remote pollers the query for detecting duplicate poller hostnames and database hostnames is missing critical brackets
To Reproduce
Deploy Cacti with a remote poller, try to edit any property of that remote poller. I receive an error to "Please enter a non-duplicate hostname" as well as "Please enter a non-duplicate database hostname".
Expected behavior
The remote poller gets renamed.
Initial analysis
The query building that starts here:
https://github.com/Cacti/cacti/blob/1.2.x/pollers.php#L386
Ends with a query being written like this:
When the poller already exists in the database with the id of 2 it is returned in this query because of the 'OR' expression not being bracketed together with the dbhost part of the clause.
I believe the query should be written as follows:
Note the extra brackets that begin after the 'AND'
The text was updated successfully, but these errors were encountered: