Merge #16839 - Fix password management for Percona Server lacking PASSWORD function.

This commit is contained in:
William Desportes 2021-04-20 18:37:49 +02:00
commit 9d166afd58
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
2 changed files with 13 additions and 9 deletions

View File

@ -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') {

View File

@ -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 '