From 86f239ca445f03bea8b31ca47463a1e17e61b376 Mon Sep 17 00:00:00 2001 From: David Sinquin Date: Tue, 20 Apr 2021 11:42:38 +0200 Subject: [PATCH] Fix password management for Percona Server. Simply stick to what is done for Oracle MySQL. Signed-off-by: David Sinquin --- libraries/classes/Server/Privileges.php | 3 ++- libraries/classes/UserPassword.php | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php index 99473e6912..d771da2eec 100644 --- a/libraries/classes/Server/Privileges.php +++ b/libraries/classes/Server/Privileges.php @@ -1038,7 +1038,8 @@ class Privileges )); // Use 'ALTER USER ...' syntax for MySQL 5.7.6+ - if ($serverType === 'MySQL' + if ( + in_array($serverType, ['MySQL', 'Percona Server'], true) && $serverVersion >= 50706 ) { if ($authentication_plugin !== 'mysql_old_password') { diff --git a/libraries/classes/UserPassword.php b/libraries/classes/UserPassword.php index 70c15758b4..744d19b50c 100644 --- a/libraries/classes/UserPassword.php +++ b/libraries/classes/UserPassword.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin; use PhpMyAdmin\Html\Generator; use PhpMyAdmin\Server\Privileges; use function strlen; +use function in_array; /** * Functions for user password @@ -86,19 +87,18 @@ class UserPassword $sql_query = 'SET password = ' . ($password == '' ? '\'\'' : $hashing_function . '(\'***\')'); - if ($serverType === 'MySQL' - && $serverVersion >= 50706 + $isPerconaOrMySql = in_array($serverType, ['MySQL', 'Percona Server'], true); + if ($isPerconaOrMySql && $serverVersion >= 50706 ) { $sql_query = 'ALTER USER \'' . $dbi->escapeString($username) . '\'@\'' . $dbi->escapeString($hostname) . '\' IDENTIFIED WITH ' . $orig_auth_plugin . ' BY ' . ($password == '' ? '\'\'' : '\'***\''); - } elseif (($serverType === 'MySQL' - && $serverVersion >= 50507) - || ($serverType === 'MariaDB' - && $serverVersion >= 50200) + } elseif ( + ($isPerconaOrMySql && $serverVersion >= 50507) + || ($serverType === 'MariaDB' && $serverVersion >= 50200) ) { - // For MySQL versions 5.5.7+ and MariaDB versions 5.2+, + // For MySQL and Percona versions 5.5.7+ and MariaDB versions 5.2+, // explicitly set value of `old_passwords` so that // it does not give an error while using // the PASSWORD() function @@ -171,7 +171,10 @@ class UserPassword $serverType = Util::getServerType(); $serverVersion = $dbi->getVersion(); - if ($serverType === 'MySQL' && $serverVersion >= 50706) { + if ( + in_array($serverType, ['MySQL', 'Percona Server'], true) + && $serverVersion >= 50706 + ) { $local_query = 'ALTER USER \'' . $dbi->escapeString($username) . '\'@\'' . $dbi->escapeString($hostname) . '\'' . ' IDENTIFIED with ' . $orig_auth_plugin . ' BY '