Skip to content

Commit

Permalink
MDEV-6625 SHOW GRANTS for current_user_name@wrong_host_name
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Golubchik committed Aug 21, 2014
1 parent b5ebc21 commit 57a43b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mysql-test/r/grant5.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SHOW GRANTS FOR root@invalid_host;
ERROR 42000: There is no such grant defined for user 'root' on host 'invalid_host'
7 changes: 7 additions & 0 deletions mysql-test/t/grant5.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- source include/not_embedded.inc

#
# MDEV-6625 SHOW GRANTS for current_user_name@wrong_host_name
#
--error ER_NONEXISTING_GRANT
SHOW GRANTS FOR root@invalid_host;
5 changes: 3 additions & 2 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4335,8 +4335,9 @@ case SQLCOM_PREPARE:
if (!grant_user)
goto error;

if (grant_user->user.str &&
!strcmp(thd->security_ctx->priv_user, grant_user->user.str))
if (grant_user->user.str && grant_user->host.str &&
!strcmp(thd->security_ctx->priv_user, grant_user->user.str) &&
!strcmp(thd->security_ctx->priv_host, grant_user->host.str))
grant_user->user= current_user;

if (grant_user->user.str == current_user.str ||
Expand Down

0 comments on commit 57a43b8

Please sign in to comment.