diff --git a/library/Icinga/Web/Setup/DbTool.php b/library/Icinga/Web/Setup/DbTool.php index 6155f7740..76b7d8bb0 100644 --- a/library/Icinga/Web/Setup/DbTool.php +++ b/library/Icinga/Web/Setup/DbTool.php @@ -423,18 +423,17 @@ class DbTool public function addLogin($username, $password) { if ($this->config['db'] === 'mysql') { + list($_, $host) = explode('@', $this->query('select current_user()')->fetchColumn()); $this->exec( 'CREATE USER :user@:host IDENTIFIED BY :passw', - array(':user' => $username, ':host' => '%', ':passw' => $password) + array(':user' => $username, ':host' => $host, ':passw' => $password) ); - return true; } elseif ($this->config['db'] === 'pgsql') { $this->exec(sprintf( 'CREATE USER %s WITH PASSWORD %s', $this->quoteIdentifier($username), $this->quote($password) )); - return true; } }