From 9f44b21a045b2438b746f64abf0442b89f40373a Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 10 May 2024 12:37:38 +0200 Subject: [PATCH] check for global customer mysql user existence when updating password Signed-off-by: Michael Kaufmann --- customer_index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/customer_index.php b/customer_index.php index f052cef6..4a863bc8 100644 --- a/customer_index.php +++ b/customer_index.php @@ -228,7 +228,12 @@ if ($page == 'overview') { $dbm = new DbManager($log); // give permission to the user on every access-host we have foreach (array_map('trim', explode(',', Settings::Get('system.mysql_access_host'))) as $mysql_access_host) { - $dbm->getManager()->grantPrivilegesTo($userinfo['loginname'], $new_password, $mysql_access_host, false, true); + if ($dbm->getManager()->userExistsOnHost($userinfo['loginname'], $mysql_access_host)) { + $dbm->getManager()->grantPrivilegesTo($userinfo['loginname'], $new_password, $mysql_access_host, false, true); + } else { + // create global mysql user if not exists + $dbm->getManager()->grantPrivilegesTo($userinfo['loginname'], $new_password, $mysql_access_host, false, false, true); + } } $dbm->getManager()->flushPrivileges(); }