diff --git a/libraries/dbi/DBIDummy.php b/libraries/dbi/DBIDummy.php index 21625c4741..acb5b3f503 100644 --- a/libraries/dbi/DBIDummy.php +++ b/libraries/dbi/DBIDummy.php @@ -644,6 +644,11 @@ $GLOBALS['dummy_queries'] = array( array( 'query' => "SELECT @@lower_case_table_names", 'result' => array() + ), + array( + 'query' => "SELECT `PLUGIN_NAME`, `PLUGIN_DESCRIPTION` " + . "FROM `information_schema`.`PLUGINS` WHERE `PLUGIN_TYPE` = 'AUTHENTICATION';", + 'result' => array() ) ); /** diff --git a/libraries/display_change_password.lib.php b/libraries/display_change_password.lib.php index ed99d1002a..742a4bf219 100644 --- a/libraries/display_change_password.lib.php +++ b/libraries/display_change_password.lib.php @@ -79,74 +79,51 @@ function PMA_getHtmlForChangePassword($username, $hostname) . $chg_evt_handler . '="nopass[1].checked = true" />' . '' . ''; - $default_auth_plugin = PMA_getCurrentAuthenticationPlugin( - 'change', $username, $hostname - ); - // See http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-5.html - if (PMA\libraries\Util::getServerType() == 'MySQL' - && PMA_MYSQL_INT_VERSION >= 50705 - ) { - $html .= '' - . '' . __('Password Hashing:') . '' - . '' - . '' - . __('MySQL native password') - . '' - . '' - . '' - . '' - . ' ' - . '' - . '' - . __('SHA256 password') - . '' - . '' - . ''; - } elseif (PMA\libraries\Util::getServerType() == 'MySQL' - && PMA_MYSQL_INT_VERSION >= 50606 - ) { - $html .= '' - . '' . __('Password Hashing:') . '' - . '' - . '' - . '' - . '' - . ''; - } else { - $html .= '' - . '' . __('Password Hashing:') . '' - . '' - . '' - . '' - . '' - . '' - . '' - . ' ' - . '' - . '' - . '' - . '' - . ''; - } + $html .= '' + . '' . __('Password Hashing:') . ''; - $html .= ''; + $serverType = PMA\libraries\Util::getServerType(); + if (($serverType == 'MySQL' + && PMA_MYSQL_INT_VERSION >= 50507) + || ($serverType == 'MariaDB' + && PMA_MYSQL_INT_VERSION >= 50200) + ) { + + $active_auth_plugins = PMA_getActiveAuthPlugins(); + + $default_auth_plugin = PMA_getCurrentAuthenticationPlugin( + 'change', $username, $hostname + ); + + $iter = 0; + $total_plugins = count($active_auth_plugins); + foreach ($active_auth_plugins as $plugin) { + if ($plugin['PLUGIN_NAME'] == 'mysql_old_password') { + continue; + } + + if ($iter != 0) { + $html .= ' '; + } + $html .= '' + . '' + . ''; + + if ($iter == $total_plugins - 2) { + $html .= ''; + } else if ($iter != $total_plugins - 1) { + $html .= ''; + } + $iter++; + } + + $html .= ''; + $html .= ''; $html .= '
getDisplay() . '
'; + $html .= '
' + . Message::notice( + __( + 'This method requires using an \'SSL connection\' ' + . 'or an \'unencrypted connection that encrypts the password ' + . 'using RSA\'; while connecting to the server.' + ) + . PMA\libraries\Util::showMySQLDocu('sha256-authentication-plugin') + ) + ->getDisplay() + . '
'; + } else { + $html .= '' + . '' + . '' + . '' + . ''; + } + $html .= '' . '' . "\n"; @@ -1986,7 +2023,9 @@ function PMA_updatePassword($err_url, $username, $hostname) $local_query = $query_prefix . Util::sqlAddSlashes($_POST['pma_pw']) . "'"; } else { - if (! empty($_REQUEST['pw_hash']) && $_REQUEST['pw_hash'] == 'old') { + if (! empty($_REQUEST['pw_hash']) + && $_REQUEST['pw_hash'] == 'mysql_old_password' + ) { $hashing_function = 'OLD_PASSWORD'; } elseif (! empty($_REQUEST['pw_hash']) && $_REQUEST['pw_hash'] == 'sha256_password' @@ -4151,6 +4190,8 @@ function PMA_setProperPasswordHashing($auth_plugin) // to be of type depending upon $authentication_plugin if ($auth_plugin == 'sha256_password') { $GLOBALS['dbi']->tryQuery('SET `old_passwords` = 2'); + } else if ($auth_plugin == 'mysql_old_password') { + $GLOBALS['dbi']->tryQuery('SET `old_passwords` = 1'); } else { $GLOBALS['dbi']->tryQuery('SET `old_passwords` = 0'); } @@ -5024,6 +5065,13 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password) ); $real_sql_query = $sql_query = $sql_query_stmt; + // Set the proper hashing method + if (isset($_REQUEST['authentication_plugin'])) { + PMA_setProperPasswordHashing( + $_REQUEST['authentication_plugin'] + ); + } + // Use 'SET PASSWORD' for pre-5.7.6 MySQL versions // and pre-5.2.0 MariaDB if (($serverType == 'MySQL' @@ -5031,6 +5079,7 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password) || ($serverType == 'MariaDB' && PMA_MYSQL_INT_VERSION < 50200) ) { + if ($_POST['pred_password'] == 'keep') { $password_set_real = sprintf( $password_set_stmt, @@ -5056,11 +5105,6 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password) } else { $password_set_real = null; - // Set the proper hashing method - PMA_setProperPasswordHashing( - $_REQUEST['authentication_plugin'] - ); - // Required for binding '%' with '%s' $create_user_stmt = str_replace( '%', '%%', $create_user_stmt