MDEV-6401 SET ROLE returning ERROR 1959 Invalid role specification for valid role
Use user's ip address when verifying privileges for SET ROLE (just like check_access() does)
This commit is contained in:
parent
86362129a2
commit
b9ddeeff24
13
mysql-test/suite/roles/ip-6401.result
Normal file
13
mysql-test/suite/roles/ip-6401.result
Normal file
@ -0,0 +1,13 @@
|
||||
create role r1;
|
||||
create user foo@'127.0.0.1';
|
||||
grant r1 to foo@'127.0.0.1';
|
||||
show grants;
|
||||
Grants for foo@127.0.0.1
|
||||
GRANT r1 TO 'foo'@'127.0.0.1'
|
||||
GRANT USAGE ON *.* TO 'foo'@'127.0.0.1'
|
||||
set role r1;
|
||||
select * from information_schema.enabled_roles;
|
||||
ROLE_NAME
|
||||
r1
|
||||
drop user foo@'127.0.0.1';
|
||||
drop role r1;
|
13
mysql-test/suite/roles/ip-6401.test
Normal file
13
mysql-test/suite/roles/ip-6401.test
Normal file
@ -0,0 +1,13 @@
|
||||
--source include/not_embedded.inc
|
||||
create role r1;
|
||||
create user foo@'127.0.0.1';
|
||||
grant r1 to foo@'127.0.0.1';
|
||||
|
||||
--connect (con1,127.0.0.1,foo,,)
|
||||
show grants;
|
||||
set role r1;
|
||||
select * from information_schema.enabled_roles;
|
||||
|
||||
connection default;
|
||||
drop user foo@'127.0.0.1';
|
||||
drop role r1;
|
@ -300,7 +300,7 @@ public:
|
||||
|
||||
bool eq(const char *user2, const char *host2) { return !cmp(user2, host2); }
|
||||
|
||||
bool wild_eq(const char *user2, const char *host2, const char *ip2 = 0)
|
||||
bool wild_eq(const char *user2, const char *host2, const char *ip2)
|
||||
{
|
||||
if (strcmp(safe_str(user.str), safe_str(user2)))
|
||||
return false;
|
||||
@ -1883,7 +1883,7 @@ int acl_check_setrole(THD *thd, char *rolename, ulonglong *access)
|
||||
acl_user= (ACL_USER *)acl_user_base;
|
||||
/* Yes! priv_user@host. Don't ask why - that's what check_access() does. */
|
||||
if (acl_user->wild_eq(thd->security_ctx->priv_user,
|
||||
thd->security_ctx->host))
|
||||
thd->security_ctx->host, thd->security_ctx->ip))
|
||||
{
|
||||
is_granted= TRUE;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user