From bd49edfb90aef82c20ad27de5143691f754d5a54 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Sat, 10 Oct 2015 22:57:07 +0530 Subject: [PATCH] Fix 11561 Signed-off-by: Deven Bansod --- libraries/dbi/DBIDummy.class.php | 5 + libraries/display_change_password.lib.php | 140 ++++++++++------------ libraries/server_privileges.lib.php | 122 +++++++++++++------ 3 files changed, 151 insertions(+), 116 deletions(-) diff --git a/libraries/dbi/DBIDummy.class.php b/libraries/dbi/DBIDummy.class.php index fd2b5f9a2c..58ab193d4e 100644 --- a/libraries/dbi/DBIDummy.class.php +++ b/libraries/dbi/DBIDummy.class.php @@ -653,6 +653,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 0b65e3d6b8..0ed22b3a9f 100644 --- a/libraries/display_change_password.lib.php +++ b/libraries/display_change_password.lib.php @@ -77,88 +77,74 @@ 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_Util::getServerType() == 'MySQL' - && PMA_MYSQL_INT_VERSION >= 50705 + $html .= '' + . '' . __('Password Hashing:') . ''; + + $serverType = PMA_Util::getServerType(); + if (($serverType == 'MySQL' + && PMA_MYSQL_INT_VERSION >= 50507) + || ($serverType == 'MariaDB' + && PMA_MYSQL_INT_VERSION >= 50200) ) { - $html .= '' - . '' . __('Password Hashing:') . '' - . '' - . '' - . __('MySQL native password') - . '' - . '' - . '' - . '' - . ' ' - . '' - . '' - . __('SHA256 password') - . '' - . '' - . ''; - } elseif (PMA_Util::getServerType() == 'MySQL' - && PMA_MYSQL_INT_VERSION >= 50606 - ) { - $html .= '' - . '' . __('Password Hashing:') . '' - . '' - . '' - . '' - . '' - . ''; - } else { - $html .= '' - . '' . __('Password Hashing:') . '' - . '' - . '' - . '' - . '' - . '' - . '' - . ' ' - . '' - . '' - . '' - . '' - . ''; - } - $html .= ''; + $active_auth_plugins = PMA_getActiveAuthPlugins(); - $html .= '
' - . PMA_Message::notice( - __( - 'This method requires using an \'SSL connection\' ' - . 'or an \'unencrypted connection that encrypts the password ' - . 'using RSA\'; while connecting to the server.' + $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 .= '
' + . PMA_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_Util::showMySQLDocu('sha256-authentication-plugin') ) - . PMA_Util::showMySQLDocu('sha256-authentication-plugin') - ) - ->getDisplay() - . '
'; + ->getDisplay() + . '
'; + } else { + $html .= '' + . '' + . '' + . '' + . ''; + } $html .= '' . '' . "\n"; @@ -1883,7 +1920,9 @@ function PMA_updatePassword($err_url, $username, $hostname) $local_query = $query_prefix . PMA_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' @@ -4108,6 +4147,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'); } @@ -4968,6 +5009,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' @@ -4975,6 +5023,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, @@ -5000,11 +5049,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