Icinga / icingaweb2

A lightweight and extensible web interface to keep an eye on your environment. Analyse problems and act on them.
https://icinga.com/get-started/
GNU General Public License v2.0
806 stars 279 forks source link

Setup does not work when there is an underscore in the database name #5232

Closed NielsH closed 2 months ago

NielsH commented 2 months ago

Describe the bug

A clear and concise description of what the issue is.

We are performing a manual install of Icingaweb2. During the installation wizard (the webinterface) we have to validate our database credentials. The initial validation succeeds, but the page after says that there is something wrong with validating the credentials. I have an option here to skip validation, but if I do so the user to login to Icingaweb2 is not created.

In a database log, we see this query being executed:

SELECT COUNT(*) as matches FROM information_schema.schema_privileges WHERE grantee = '\'icingaweb_7d\'@\'127.0.0.1\'' AND table_schema = 'icingaweb\\_7d' AND privilege_type IN ('CREATE','ALTER','REFERENCES');

The matches count here is 0, which is why I think Icinga thinks the validation fails.

If I edit the query to this, it works as expected:

SELECT COUNT(*) as matches FROM information_schema.schema_privileges WHERE grantee = '\'icingaweb_7d\'@\'127.0.0.1\'' AND table_schema = 'icingaweb_7d' AND privilege_type IN ('CREATE','ALTER','REFERENCES');

This gives a matches result of 3.

I have managed to work around the issue like this:

  1. Edit modules/setup/library/Setup/Utils/DbTool.php
  2. Go to the function escapeTableWildcards
  3. Comment return str_replace(array('_', '%'), array('\_', '\%'), $tableName);
  4. Replace it with return $tableName;
  5. Now the installation proceeds as expected.

To Reproduce

Provide a link to a live example, or an unambiguous set of steps to reproduce this issue. Include configuration, logs, etc. to reproduce, if relevant.

  1. Perform the installation wizard.
  2. Use MySQL to configure the backend and make sure the database has an underscore in its name.
  3. See the error that the validation cannot be performed

Expected behavior

Installing Icingaweb2 with a database that has an underscore in it works.

Screenshots

If applicable, add screenshots to help explain your problem.

Your Environment

Include as many relevant details about the environment you experienced the problem in

Additional context

Add any other context about the problem here.

nilmerg commented 2 months ago

Please have a look here

nilmerg commented 2 months ago

Duplicate of #5147