Commit 6c958d6e authored by Sergei Golubchik's avatar Sergei Golubchik

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.
parent 970e67b5
...@@ -237,5 +237,9 @@ ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: ...@@ -237,5 +237,9 @@ ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password:
select user(), current_user(); select user(), current_user();
user() current_user() user() current_user()
mysqltest_up2@localhost mysqltest_up2@% 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_up1@'%';
DROP USER mysqltest_up2@'%'; DROP USER mysqltest_up2@'%';
...@@ -352,6 +352,19 @@ connection pcon4; ...@@ -352,6 +352,19 @@ connection pcon4;
select user(), current_user(); select user(), current_user();
disconnect pcon4; 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; connection default;
DROP USER mysqltest_up1@'%'; DROP USER mysqltest_up1@'%';
DROP USER mysqltest_up2@'%'; DROP USER mysqltest_up2@'%';
......
...@@ -6980,16 +6980,16 @@ struct MPVIO_EXT : public MYSQL_PLUGIN_VIO ...@@ -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 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), my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
thd->main_security_ctx.user, thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip, 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), general_log_print(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
thd->main_security_ctx.user, thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip, 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); status_var_increment(thd->status_var.access_denied_errors);
/* /*
Log access denied messages to the error log when log-warnings = 2 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) ...@@ -7001,7 +7001,7 @@ static void login_failed_error(THD *thd, bool passwd_used)
sql_print_warning(ER(ER_ACCESS_DENIED_ERROR), sql_print_warning(ER(ER_ACCESS_DENIED_ERROR),
thd->main_security_ctx.user, thd->main_security_ctx.user,
thd->main_security_ctx.host_or_ip, 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) ...@@ -7266,7 +7266,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio, Security_context *sctx)
if (!mpvio->acl_user) if (!mpvio->acl_user)
{ {
login_failed_error(mpvio->thd, 0); login_failed_error(mpvio->thd);
return 1; return 1;
} }
...@@ -7583,8 +7583,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, ...@@ -7583,8 +7583,11 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
return packet_error; return packet_error;
} }
thd->password= passwd_len > 0;
if (find_mpvio_user(mpvio, sctx)) if (find_mpvio_user(mpvio, sctx))
{
return packet_error; return packet_error;
}
if (thd->client_capabilities & CLIENT_PLUGIN_AUTH) 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 ...@@ -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); DBUG_ASSERT(mpvio.status == MPVIO_EXT::FAILURE);
if (!thd->is_error()) if (!thd->is_error())
login_failed_error(thd, thd->password); login_failed_error(thd);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -8092,7 +8095,7 @@ bool acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_le ...@@ -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)) if (acl_check_ssl(thd, acl_user))
{ {
login_failed_error(thd, thd->password); login_failed_error(thd);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment