summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2010-12-20 19:19:24 +0100
committerSergei Golubchik <sergii@pisem.net>2010-12-20 19:19:24 +0100
commit6c958d6e80f681c207f4298b754c8b18170d3224 (patch)
tree96b8f5ca4d1a282310ba916b698a2f9db6870e45
parent970e67b5e3c459d0a6b8a0e4ce4a3bf602362fba (diff)
downloadmariadb-git-6c958d6e80f681c207f4298b754c8b18170d3224.tar.gz
bug#683112 Maria 5.2 incorrectly reports "(using password: NO)" even when password is specified
set thd->password appropriately also for cases when a user was not found.
-rw-r--r--mysql-test/r/connect.result4
-rw-r--r--mysql-test/t/connect.test13
-rw-r--r--sql/sql_acl.cc17
3 files changed, 27 insertions, 7 deletions
diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result
index 690a6fb3bc3..00602093425 100644
--- a/mysql-test/r/connect.result
+++ b/mysql-test/r/connect.result
@@ -237,5 +237,9 @@ ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password:
select user(), current_user();
user() current_user()
mysqltest_up2@localhost mysqltest_up2@%
+connect(localhost,mysqltest_nouser,newpw,test,MASTER_PORT,MASTER_SOCKET);
+ERROR 28000: Access denied for user 'mysqltest_nouser'@'localhost' (using password: YES)
+connect(localhost,mysqltest_nouser,,test,MASTER_PORT,MASTER_SOCKET);
+ERROR 28000: Access denied for user 'mysqltest_nouser'@'localhost' (using password: NO)
DROP USER mysqltest_up1@'%';
DROP USER mysqltest_up2@'%';
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
index a8c8b659c3c..8fbdd709364 100644
--- a/mysql-test/t/connect.test
+++ b/mysql-test/t/connect.test
@@ -352,6 +352,19 @@ connection pcon4;
select user(), current_user();
disconnect pcon4;
+#
+# lpbug#683112 Maria 5.2 incorrectly reports "(using password: NO)"
+# even when password is specified
+#
+# test "access denied" error for nonexisting user with and without a password
+#
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error ER_ACCESS_DENIED_ERROR
+connect(pcon5,localhost,mysqltest_nouser,newpw,,$MASTER_MYPORT,);
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error ER_ACCESS_DENIED_ERROR
+connect(pcon5,localhost,mysqltest_nouser,,,$MASTER_MYPORT,);
+
connection default;
DROP USER mysqltest_up1@'%';
DROP USER mysqltest_up2@'%';
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 87e27d68b98..9b1d0df4251 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -6980,16 +6980,16 @@ struct MPVIO_EXT : public MYSQL_PLUGIN_VIO
a helper function to report an access denied error in all the proper places
*/
-static void login_failed_error(THD *thd, bool passwd_used)
+static void login_failed_error(THD *thd)
{
my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip,
- passwd_used ? ER(ER_YES) : ER(ER_NO));
+ thd->password ? ER(ER_YES) : ER(ER_NO));
general_log_print(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip,
- passwd_used ? ER(ER_YES) : ER(ER_NO));
+ thd->password ? ER(ER_YES) : ER(ER_NO));
status_var_increment(thd->status_var.access_denied_errors);
/*
Log access denied messages to the error log when log-warnings = 2
@@ -7001,7 +7001,7 @@ static void login_failed_error(THD *thd, bool passwd_used)
sql_print_warning(ER(ER_ACCESS_DENIED_ERROR),
thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip,
- passwd_used ? ER(ER_YES) : ER(ER_NO));
+ thd->password ? ER(ER_YES) : ER(ER_NO));
}
}
@@ -7266,7 +7266,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio, Security_context *sctx)
if (!mpvio->acl_user)
{
- login_failed_error(mpvio->thd, 0);
+ login_failed_error(mpvio->thd);
return 1;
}
@@ -7583,8 +7583,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
return packet_error;
}
+ thd->password= passwd_len > 0;
if (find_mpvio_user(mpvio, sctx))
+ {
return packet_error;
+ }
if (thd->client_capabilities & CLIENT_PLUGIN_AUTH)
{
@@ -8072,7 +8075,7 @@ bool acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_le
DBUG_ASSERT(mpvio.status == MPVIO_EXT::FAILURE);
if (!thd->is_error())
- login_failed_error(thd, thd->password);
+ login_failed_error(thd);
DBUG_RETURN(1);
}
@@ -8092,7 +8095,7 @@ bool acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_le
*/
if (acl_check_ssl(thd, acl_user))
{
- login_failed_error(thd, thd->password);
+ login_failed_error(thd);
DBUG_RETURN(1);
}