| 1 |
# |
| 2 |
# MDEV-13655: SET ROLE does not properly grant privileges. |
| 3 |
# |
| 4 |
# We must test that if aditional db privileges get granted to a role |
| 5 |
# which previously inherited privileges from another granted role |
| 6 |
# keep the internal memory structures intact. |
| 7 |
# |
| 8 |
create role simple; |
| 9 |
# |
| 10 |
# First we create an entry with privileges for databases for the simple role. |
| 11 |
# |
| 12 |
grant select, insert, update, delete, lock tables, execute on t.* to simple; |
| 13 |
create role admin; |
| 14 |
# |
| 15 |
# Now we grant the simple role to admin. This means that db privileges |
| 16 |
# should propagate to admin. |
| 17 |
# |
| 18 |
grant simple to admin; |
| 19 |
show grants for admin; |
| 20 |
Grants for admin |
| 21 |
GRANT `simple` TO `admin` |
| 22 |
GRANT USAGE ON *.* TO `admin` |
| 23 |
GRANT USAGE ON *.* TO `simple` |
| 24 |
GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `t`.* TO `simple` |
| 25 |
# |
| 26 |
# Finally, we give the admin all the available privileges for the db. |
| 27 |
# |
| 28 |
grant all on t.* to admin; |
| 29 |
# |
| 30 |
# Create a user to test out the new roles; |
| 31 |
# |
| 32 |
create user foo; |
| 33 |
grant admin to foo; |
| 34 |
connect foo,localhost,foo,,,,,; |
| 35 |
create database t; |
| 36 |
ERROR 42000: Access denied for user 'foo'@'%' to database 't' |
| 37 |
set role admin; |
| 38 |
show grants; |
| 39 |
Grants for foo@% |
| 40 |
GRANT `admin` TO `foo`@`%` |
| 41 |
GRANT USAGE ON *.* TO `foo`@`%` |
| 42 |
GRANT `simple` TO `admin` |
| 43 |
GRANT USAGE ON *.* TO `admin` |
| 44 |
GRANT ALL PRIVILEGES ON `t`.* TO `admin` |
| 45 |
GRANT USAGE ON *.* TO `simple` |
| 46 |
GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `t`.* TO `simple` |
| 47 |
create database t; |
| 48 |
drop database t; |
| 49 |
connection default; |
| 50 |
drop role simple; |
| 51 |
drop role admin; |
| 52 |
drop user foo; |