From 420a9d58e7cbaf659fd45da85b01c73b98878752 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Mon, 19 Mar 2007 15:06:53 +0000 Subject: [PATCH] bug #1662976 Authentication fails when controluser/pass is set --- ChangeLog | 1 + libraries/common.lib.php | 4 +++- libraries/dbi/mysql.dbi.lib.php | 8 +++++++- libraries/dbi/mysqli.dbi.lib.php | 4 ++++ main.php | 15 +++++++++++++-- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc236ed96..ee50b5b33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ $HeadURL$ - bug #1664212 querywindow loses url encoded characters - bug #1682044 Export file even if file not selected - bug #1672789 Undefined offset: 4 in sqlparser.lib.php #1674 +- bug #1662976 Authentication fails when controluser/pass is set - [gui] avoid displaying a wide selector in server selection + [core] added PMA_fatalError() and made use of it . [i18n] use generic $strOptions diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 94b73300e..45bb6300e 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -3378,10 +3378,12 @@ if (! defined('PMA_MINIMUM_COMMON')) { // get the privileges list for the current user but the true user link // must be open after this one so it would be default one for all the // scripts) + $controllink = false; if ($cfg['Server']['controluser'] != '') { $controllink = PMA_DBI_connect($cfg['Server']['controluser'], $cfg['Server']['controlpass'], true); - } else { + } + if (! $controllink) { $controllink = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password'], true); } // end if ... else diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index 489e2b782..187410faf 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -78,7 +78,13 @@ function PMA_DBI_connect($user, $password, $is_controluser = FALSE) { $link = PMA_DBI_real_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, '', empty($client_flags) ? NULL : $client_flags); } - if (empty($link)) { + debug_print_backtrace(); + die; + if (empty($link) && ! $is_controluser) { + if ($is_controluser) { + define('PMA_DBI_CONNECT_FAILED_CONTROLUSER', true); + return false; + } PMA_auth_fails(); } // end if diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index d8149f4b0..3e4e896ac 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -107,6 +107,10 @@ function PMA_DBI_connect($user, $password, $is_controluser = false) } if ($return_value == false) { + if ($is_controluser) { + define('PMA_DBI_CONNECT_FAILED_CONTROLUSER', true); + return false; + } PMA_auth_fails(); } // end if diff --git a/main.php b/main.php index 3b95649b2..6b5611322 100644 --- a/main.php +++ b/main.php @@ -345,8 +345,8 @@ if (! empty($GLOBALS['PMA_errors']) && is_array($GLOBALS['PMA_errors'])) { * modified: 2004-05-05 mkkeck */ if ($server != 0 - && $cfg['Server']['user'] == 'root' - && $cfg['Server']['password'] == '') { + && $cfg['Server']['user'] == 'root' + && $cfg['Server']['password'] == '') { echo '
' . $strInsecureMySQL . '
' . "\n"; } @@ -391,6 +391,9 @@ if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 32332) { echo '
' . sprintf($strUpgrade, 'MySQL', '3.23.32') . '
' . "\n"; } +/** + * Warning about different MySQL library and server version + */ if ($server > 0 && PMA_MYSQL_CLIENT_API !== PMA_MYSQL_INT_VERSION) { echo '
' . PMA_sanitize(sprintf($strMysqlLibDiffersServerVersion, @@ -399,6 +402,14 @@ if ($server > 0 && PMA_MYSQL_CLIENT_API !== PMA_MYSQL_INT_VERSION) { . '
' . "\n"; } +/** + * Warning about wrong controluser settings + */ +$strControluserFailed = 'Connection for controluser as defined in your config.inc.php failed.'; +if (defined('PMA_DBI_CONNECT_FAILED_CONTROLUSER')) { + echo '
' . $strControluserFailed . '
' . "\n"; +} + if (defined('PMA_WARN_FOR_MCRYPT')) { echo '
' . PMA_sanitize(sprintf($strCantLoad, 'mcrypt')) . '
' . "\n"; }