Browse Source
MDEV-13655: Set role does not properly grant privileges.
MDEV-13655: Set role does not properly grant privileges.
When granting a role to another role, DB privileges get propagated. If the grantee had no previous DB privileges, an extra ACL_DB entry is created to house those "indirectly received" privileges. If, afterwards, DB privileges are granted to the grantee directly, we must make sure to not create a duplicate ACL_DB entry.pull/552/head
4 changed files with 132 additions and 16 deletions
-
50mysql-test/suite/roles/set_role-13655.result
-
49mysql-test/suite/roles/set_role-13655.test
-
47sql/sql_acl.cc
-
2sql/structs.h
@ -0,0 +1,50 @@ |
|||
# |
|||
# MDEV-13655: SET ROLE does not properly grant privileges. |
|||
# |
|||
# We must test that if aditional db privileges get granted to a role |
|||
# which previously inherited privileges from another granted role |
|||
# keep the internal memory structures intact. |
|||
# |
|||
create role simple; |
|||
# |
|||
# First we create an entry with privileges for databases for the simple role. |
|||
# |
|||
grant select, insert, update, delete, lock tables, execute on t.* to simple; |
|||
create role admin; |
|||
# |
|||
# Now we grant the simple role to admin. This means that db privileges |
|||
# should propagate to admin. |
|||
# |
|||
grant simple to admin; |
|||
show grants for admin; |
|||
Grants for admin |
|||
GRANT simple TO 'admin' |
|||
GRANT USAGE ON *.* TO 'admin' |
|||
GRANT USAGE ON *.* TO 'simple' |
|||
GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `t`.* TO 'simple' |
|||
# |
|||
# Finally, we give the admin all the available privileges for the db. |
|||
# |
|||
grant all on t.* to admin; |
|||
# |
|||
# Create a user to test out the new roles; |
|||
# |
|||
create user foo; |
|||
grant admin to foo; |
|||
create database t; |
|||
ERROR 42000: Access denied for user 'foo'@'%' to database 't' |
|||
set role admin; |
|||
show grants; |
|||
Grants for foo@% |
|||
GRANT admin TO 'foo'@'%' |
|||
GRANT USAGE ON *.* TO 'foo'@'%' |
|||
GRANT simple TO 'admin' |
|||
GRANT USAGE ON *.* TO 'admin' |
|||
GRANT ALL PRIVILEGES ON `t`.* TO 'admin' |
|||
GRANT USAGE ON *.* TO 'simple' |
|||
GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `t`.* TO 'simple' |
|||
create database t; |
|||
drop database t; |
|||
drop role simple; |
|||
drop role admin; |
|||
drop user foo; |
@ -0,0 +1,49 @@ |
|||
source include/not_embedded.inc; |
|||
|
|||
--echo # |
|||
--echo # MDEV-13655: SET ROLE does not properly grant privileges. |
|||
--echo # |
|||
--echo # We must test that if aditional db privileges get granted to a role |
|||
--echo # which previously inherited privileges from another granted role |
|||
--echo # keep the internal memory structures intact. |
|||
--echo # |
|||
|
|||
create role simple; |
|||
|
|||
--echo # |
|||
--echo # First we create an entry with privileges for databases for the simple role. |
|||
--echo # |
|||
grant select, insert, update, delete, lock tables, execute on t.* to simple; |
|||
create role admin; |
|||
|
|||
--echo # |
|||
--echo # Now we grant the simple role to admin. This means that db privileges |
|||
--echo # should propagate to admin. |
|||
--echo # |
|||
grant simple to admin; |
|||
show grants for admin; |
|||
|
|||
--echo # |
|||
--echo # Finally, we give the admin all the available privileges for the db. |
|||
--echo # |
|||
grant all on t.* to admin; |
|||
|
|||
--echo # |
|||
--echo # Create a user to test out the new roles; |
|||
--echo # |
|||
create user foo; |
|||
grant admin to foo; |
|||
|
|||
connect (foo,localhost,foo,,,,,); |
|||
--error ER_DBACCESS_DENIED_ERROR |
|||
create database t; |
|||
set role admin; |
|||
show grants; |
|||
create database t; |
|||
drop database t; |
|||
|
|||
connection default; |
|||
|
|||
drop role simple; |
|||
drop role admin; |
|||
drop user foo; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue