Merge commit '57451f31c8ef8ba0d9dd695dd9004dbdaec2e10c'
This commit is contained in:
commit
198e257da4
@ -5222,6 +5222,31 @@ function PMA_getHashedPassword($password)
|
||||
return $hashedPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if MariaDB's 'simple_password_check'
|
||||
* OR 'cracklib_password_check' is ACTIVE
|
||||
*
|
||||
* @return boolean if atleast one of the plugins is ACTIVE
|
||||
*/
|
||||
function PMA_checkIfMariaDBPwdCheckPluginActive()
|
||||
{
|
||||
if (Util::getServerType() !== 'MariaDB') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW PLUGINS SONAME LIKE \'%_password_check%\''
|
||||
);
|
||||
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
if ($row['Status'] === 'ACTIVE') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get SQL queries for Display and Add user
|
||||
@ -5245,6 +5270,7 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password)
|
||||
$slashedUsername,
|
||||
$slashedHostname
|
||||
);
|
||||
$isMariaDBPwdPluginActive = PMA_checkIfMariaDBPwdCheckPluginActive();
|
||||
|
||||
// See https://github.com/phpmyadmin/phpmyadmin/pull/11560#issuecomment-147158219
|
||||
// for details regarding details of syntax usage for various versions
|
||||
@ -5264,6 +5290,7 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password)
|
||||
if ($serverType == 'MariaDB'
|
||||
&& PMA_MYSQL_INT_VERSION >= 50200
|
||||
&& isset($_REQUEST['authentication_plugin'])
|
||||
&& ! $isMariaDBPwdPluginActive
|
||||
) {
|
||||
$create_user_stmt .= ' IDENTIFIED VIA '
|
||||
. $_REQUEST['authentication_plugin'];
|
||||
@ -5293,9 +5320,10 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password)
|
||||
$_REQUEST['authentication_plugin']
|
||||
);
|
||||
}
|
||||
|
||||
// Use 'CREATE USER ... WITH ... AS ..' syntax for
|
||||
// newer MySQL versions
|
||||
// and 'CREATE USER ... USING .. VIA ..' syntax for
|
||||
// and 'CREATE USER ... VIA .. USING ..' syntax for
|
||||
// newer MariaDB versions
|
||||
if ((($serverType == 'MySQL' || $serverType == 'Percona Server')
|
||||
&& PMA_MYSQL_INT_VERSION >= 50706)
|
||||
@ -5310,8 +5338,13 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password)
|
||||
);
|
||||
|
||||
// MariaDB uses 'USING' whereas MySQL uses 'AS'
|
||||
if ($serverType == 'MariaDB') {
|
||||
// but MariaDB with validation plugin needs cleartext password
|
||||
if ($serverType == 'MariaDB'
|
||||
&& ! $isMariaDBPwdPluginActive
|
||||
) {
|
||||
$create_user_stmt .= ' USING \'%s\'';
|
||||
} elseif ($serverType == 'MariaDB') {
|
||||
$create_user_stmt .= ' IDENTIFIED BY \'%s\'';
|
||||
} else {
|
||||
$create_user_stmt .= ' AS \'%s\'';
|
||||
}
|
||||
@ -5335,7 +5368,14 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password)
|
||||
'***'
|
||||
);
|
||||
} else {
|
||||
$hashedPassword = PMA_getHashedPassword($_POST['pma_pw']);
|
||||
if (! ($serverType == 'MariaDB'
|
||||
&& $isMariaDBPwdPluginActive)
|
||||
) {
|
||||
$hashedPassword = PMA_getHashedPassword($_POST['pma_pw']);
|
||||
} else {
|
||||
// MariaDB with validation plugin needs cleartext password
|
||||
$hashedPassword = $_POST['pma_pw'];
|
||||
}
|
||||
$create_user_real = sprintf(
|
||||
$create_user_stmt,
|
||||
$hashedPassword
|
||||
|
||||
Loading…
Reference in New Issue
Block a user