Skip to content

When updating poller name, duplicate name protection may be over zealous #4455

Closed
@ctrowat

Description

@ctrowat

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:

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourguiUI related issueresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions