2013-10-18 15:47:49 +02:00
|
|
|
create user 'test_user'@'localhost';
|
|
|
|
create role test_role1;
|
|
|
|
create role test_role2;
|
|
|
|
|
|
|
|
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
|
|
|
|
'test_user',
|
|
|
|
'test_role1');
|
|
|
|
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
|
|
|
|
'test_role1',
|
|
|
|
'test_role2');
|
|
|
|
--sorted_result
|
|
|
|
select user, host from mysql.user where user not like 'root';
|
|
|
|
--sorted_result
|
|
|
|
select * from mysql.roles_mapping;
|
|
|
|
|
|
|
|
grant select (RoleFk) on mysql.roles_mapping to test_role2@'';
|
|
|
|
|
|
|
|
flush privileges;
|
|
|
|
|
|
|
|
change_user 'test_user';
|
|
|
|
|
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
|
|
|
select * from mysql.roles_mapping;
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
show grants;
|
|
|
|
|
2013-10-18 15:55:26 +02:00
|
|
|
select current_user(), current_role();
|
2013-10-18 15:47:49 +02:00
|
|
|
set role test_role1;
|
2013-10-18 15:55:26 +02:00
|
|
|
select current_user(), current_role();
|
2013-10-18 15:47:49 +02:00
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
show grants;
|
|
|
|
|
2013-10-18 17:10:51 +02:00
|
|
|
--error ER_COLUMNACCESS_DENIED_ERROR
|
2013-10-18 15:47:49 +02:00
|
|
|
select * from mysql.roles_mapping;
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
select RoleFk from mysql.roles_mapping;
|
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
show grants;
|
|
|
|
|
|
|
|
use mysql;
|
|
|
|
|
|
|
|
set role none;
|
2013-10-18 15:55:26 +02:00
|
|
|
select current_user(), current_role();
|
2013-10-18 15:47:49 +02:00
|
|
|
|
|
|
|
--sorted_result
|
|
|
|
--error ER_TABLEACCESS_DENIED_ERROR
|
|
|
|
select RoleFk from mysql.roles_mapping;
|
|
|
|
|
|
|
|
change_user 'root';
|
|
|
|
drop user 'test_user'@'localhost';
|
|
|
|
select * from mysql.tables_priv;
|
|
|
|
revoke select on mysql.roles_mapping from test_role2@'';
|
|
|
|
delete from mysql.user where user like'test_%';
|
|
|
|
delete from mysql.roles_mapping where RoleFk like 'test%';
|
|
|
|
|
|
|
|
flush privileges;
|