Skip to content

/migrations: Can't connect to database server without a password #5427

@Al2Klimov

Description

@Al2Klimov

To Reproduce

  1. Setup a module, in my case https://github.com/RISE-GmbH/icingaweb2-module-oidc v0.6.7, which meets the following criteria:
    • Provides DbMigration hook
    • Has released a newer version than yours, in my case v0.6.9, which actually uses its DbMigration hook for a schema upgrade
    • Also in my case, it should be enough to just import the schema and select a new DB resource
    • Do not use a password for DB access! (*nix socket required, example below.)
  2. Upgrade that module to a newer version containing a schema upgrade
  3. Visit /migrations
[oidc]
charset=utf8
db=mysql
dbname=oidc
host=localhost
type=db
username=icingaweb2

Describe the bug

/migrations throws an exception.

Screenshots

Can't connect to database server without a password

Expected behavior

Err.. yes, you can! If you can connect without a password during setup, you can also during migration.

My workaround even proves it:

--- a/modules/setup/library/Setup/Utils/DbTool.php
+++ b/modules/setup/library/Setup/Utils/DbTool.php
@@ -184,2 +183,0 @@
-        } elseif (! isset($this->config['password'])) {
-            throw new ConfigurationError('Can\'t connect to database server without a password');

It re-enabled /migrations and I successfully applied the schema upgrade.

I can make a PR if you wish, but I guess you'd prefer a more fine check instead on whether the resource points to a *nix socket. E.g "localhost" in case of MySQL.

Your Environment

  • Icinga Web 2 version and modules (System - About): d658c73
  • Web browser used: Safari
  • Icinga 2 version used (icinga2 --version): -
  • PHP version used (php --version): 8.3.25
  • Server operating system and version: NixOS 25.05

Additional context

This is the whole system, for reference: https://github.com/Al2Klimov/iw2.aklimov.net-dump.de

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions