|
1 |
| -# Save the initial number of concurrent sessions |
2 |
| ---source include/count_sessions.inc |
3 |
| ---source include/have_debug.inc |
4 |
| - |
5 |
| ---echo # |
6 |
| ---echo # Bug#28395115: permission denied if grants are given through role |
7 |
| ---echo # |
8 |
| -# We are verifying the after effects of revoking a privilege from a user and |
9 |
| -# a role from another session while a user is in the middle of executing current |
10 |
| -# SQL statement. Expected Behavior : |
11 |
| -# 1. In case of privileges are revoked from a role changes are invisible |
12 |
| -# until next SQL statement is executed. |
13 |
| -# 2. In case of privileges are revokes from a user changes are visible |
14 |
| -# immediately to the current SQL statement. |
15 |
| - |
16 |
| -# Setup |
17 |
| -CREATE DATABASE my_db; |
18 |
| -CREATE table my_db.t1 (id int primary key); |
19 |
| -CREATE ROLE foo_role; |
20 |
| -CREATE USER foo, bar; |
21 |
| -# Grant required column privileges to a role and user. |
22 |
| -GRANT INSERT(id), UPDATE(id), SELECT(id) ON my_db.t1 to foo_role, bar; |
23 |
| -GRANT EXECUTE, SYSTEM_VARIABLES_ADMIN ON *.* TO foo, bar; |
24 |
| -GRANT foo_role TO foo; |
25 |
| -SET DEFAULT ROLE foo_role TO foo; |
26 |
| - |
27 |
| ---connect(foo_con, localhost, foo,,,) |
28 |
| -SET DEBUG_SYNC='in_check_grant_all_columns SIGNAL s1 WAIT_FOR s2'; |
29 |
| ---echo # Inserts are now allowed if grants are given through role |
30 |
| -send INSERT into my_db.t1 values(8) on duplicate key UPDATE id = values(id) + 80; |
31 |
| - |
32 |
| -connection default; |
33 |
| ---echo # Now revoke all privileges from the role |
34 |
| -SET DEBUG_SYNC='now WAIT_FOR s1'; |
35 |
| -SET DEBUG_SYNC='after_table_grant_revoke SIGNAL s2'; |
36 |
| -REVOKE ALL ON my_db.t1 FROM foo_role; |
37 |
| -connection foo_con; |
38 |
| ---echo # Despite all privileges are revoked current SQL statement will succeed. |
39 |
| -reap; |
40 |
| -SET DEBUG_SYNC= 'RESET'; |
41 |
| ---echo # But the subsequent statement will fail. |
42 |
| ---error ER_TABLEACCESS_DENIED_ERROR |
43 |
| -INSERT into my_db.t1 values(9) on duplicate key UPDATE id = values(id) + 90; |
44 |
| - |
45 |
| - |
46 |
| ---connect(bar_con, localhost, bar,,,) |
47 |
| -SET DEBUG_SYNC='in_check_grant_all_columns SIGNAL s1 WAIT_FOR s2'; |
48 |
| ---echo # Inserts are now allowed if grants are given through role |
49 |
| -send INSERT into my_db.t1 values(6) on duplicate key UPDATE id = values(id) + 60; |
50 |
| -connection default; |
51 |
| ---echo # Now revoke all privileges from the user |
52 |
| -SET DEBUG_SYNC='now WAIT_FOR s1'; |
53 |
| -SET DEBUG_SYNC='after_table_grant_revoke SIGNAL s2'; |
54 |
| -REVOKE ALL ON my_db.t1 FROM bar; |
55 |
| -connection bar_con; |
56 |
| ---echo # Since all privileges are revoked therefore current SQL statement will fail. |
57 |
| ---error ER_COLUMNACCESS_DENIED_ERROR |
58 |
| -reap; |
59 |
| ---echo # Subsequent statement will fail as well. |
60 |
| ---error ER_TABLEACCESS_DENIED_ERROR |
61 |
| -INSERT into my_db.t1 values(9) on duplicate key UPDATE id = values(id) + 90; |
62 |
| - |
63 |
| ---echo # Cleanup |
64 |
| -connection default; |
65 |
| -SET DEBUG_SYNC= 'RESET'; |
66 |
| -disconnect foo_con; |
67 |
| -disconnect bar_con; |
68 |
| -DROP DATABASE my_db; |
69 |
| -DROP USER foo, bar; |
70 |
| -DROP ROLE foo_role; |
71 |
| - |
72 |
| ---echo |
73 |
| ---echo # End of 8.0 tests |
74 |
| ---echo |
75 |
| - |
76 |
| -# Wait till we reached the initial number of concurrent sessions |
77 |
| ---source include/wait_until_count_sessions.inc |
| 1 | +# Save the initial number of concurrent sessions |
| 2 | +--source include/count_sessions.inc |
| 3 | +--source include/have_debug.inc |
| 4 | + |
| 5 | +--echo # |
| 6 | +--echo # Bug#28395115: permission denied if grants are given through role |
| 7 | +--echo # |
| 8 | +# We are verifying the after effects of revoking a privilege from a user and |
| 9 | +# a role from another session while a user is in the middle of executing current |
| 10 | +# SQL statement. Expected Behavior : |
| 11 | +# 1. In case of privileges are revoked from a role changes are invisible |
| 12 | +# until next SQL statement is executed. |
| 13 | +# 2. In case of privileges are revokes from a user changes are visible |
| 14 | +# immediately to the current SQL statement. |
| 15 | + |
| 16 | +# Setup |
| 17 | +CREATE DATABASE my_db; |
| 18 | +CREATE table my_db.t1 (id int primary key); |
| 19 | +CREATE ROLE foo_role; |
| 20 | +CREATE USER foo, bar; |
| 21 | +# Grant required column privileges to a role and user. |
| 22 | +GRANT INSERT(id), UPDATE(id), SELECT(id) ON my_db.t1 to foo_role, bar; |
| 23 | +GRANT EXECUTE, SYSTEM_VARIABLES_ADMIN ON *.* TO foo, bar; |
| 24 | +GRANT foo_role TO foo; |
| 25 | +SET DEFAULT ROLE foo_role TO foo; |
| 26 | + |
| 27 | +--connect(foo_con, localhost, foo,,,) |
| 28 | +SET DEBUG_SYNC='in_check_grant_all_columns SIGNAL s1 WAIT_FOR s2'; |
| 29 | +--echo # Inserts are now allowed if grants are given through role |
| 30 | +send INSERT into my_db.t1 values(8) on duplicate key UPDATE id = values(id) + 80; |
| 31 | + |
| 32 | +connection default; |
| 33 | +--echo # Now revoke all privileges from the role |
| 34 | +SET DEBUG_SYNC='now WAIT_FOR s1'; |
| 35 | +SET DEBUG_SYNC='after_table_grant_revoke SIGNAL s2'; |
| 36 | +REVOKE ALL ON my_db.t1 FROM foo_role; |
| 37 | +connection foo_con; |
| 38 | +--echo # Despite all privileges are revoked current SQL statement will succeed. |
| 39 | +reap; |
| 40 | +SET DEBUG_SYNC= 'RESET'; |
| 41 | +--echo # But the subsequent statement will fail. |
| 42 | +--error ER_TABLEACCESS_DENIED_ERROR |
| 43 | +INSERT into my_db.t1 values(9) on duplicate key UPDATE id = values(id) + 90; |
| 44 | + |
| 45 | + |
| 46 | +--connect(bar_con, localhost, bar,,,) |
| 47 | +SET DEBUG_SYNC='in_check_grant_all_columns SIGNAL s1 WAIT_FOR s2'; |
| 48 | +--echo # Inserts are now allowed if grants are given through role |
| 49 | +send INSERT into my_db.t1 values(6) on duplicate key UPDATE id = values(id) + 60; |
| 50 | +connection default; |
| 51 | +--echo # Now revoke all privileges from the user |
| 52 | +SET DEBUG_SYNC='now WAIT_FOR s1'; |
| 53 | +SET DEBUG_SYNC='after_table_grant_revoke SIGNAL s2'; |
| 54 | +REVOKE ALL ON my_db.t1 FROM bar; |
| 55 | +connection bar_con; |
| 56 | +--echo # Since all privileges are revoked therefore current SQL statement will fail. |
| 57 | +--error ER_COLUMNACCESS_DENIED_ERROR |
| 58 | +reap; |
| 59 | +--echo # Subsequent statement will fail as well. |
| 60 | +--error ER_TABLEACCESS_DENIED_ERROR |
| 61 | +INSERT into my_db.t1 values(9) on duplicate key UPDATE id = values(id) + 90; |
| 62 | + |
| 63 | +--echo # Cleanup |
| 64 | +connection default; |
| 65 | +SET DEBUG_SYNC= 'RESET'; |
| 66 | +disconnect foo_con; |
| 67 | +disconnect bar_con; |
| 68 | +DROP DATABASE my_db; |
| 69 | +DROP USER foo, bar; |
| 70 | +DROP ROLE foo_role; |
| 71 | + |
| 72 | + |
| 73 | +--echo # |
| 74 | +--echo # Bug #35471453: MySQL debug server stops when executing query |
| 75 | +--echo # |
| 76 | + |
| 77 | +CREATE USER b35471453@localhost; |
| 78 | +GRANT CREATE ROLE, DROP ROLE ON *.* TO b35471453@localhost; |
| 79 | +--connect(b35471453_con, localhost, b35471453,,,) |
| 80 | +CREATE TABLE t35471453(c1 INT); |
| 81 | +--echo # test1: should fail |
| 82 | +--error ER_SPECIFIC_ACCESS_DENIED_ERROR |
| 83 | +CREATE OR REPLACE DEFINER = 'role_35471453' VIEW v35471453 |
| 84 | + AS TABLE t35471453; |
| 85 | +--echo # Now grant SET_USER_ID and retry |
| 86 | +connection default; |
| 87 | +GRANT SET_USER_ID ON *.* TO b35471453@localhost; |
| 88 | +connection b35471453_con; |
| 89 | +--echo # test2: should complete with a warning |
| 90 | +CREATE OR REPLACE DEFINER = 'role_35471453' VIEW v35471453 |
| 91 | + AS TABLE t35471453; |
| 92 | +--echo # Now revoke SET_USER_ID and try dropping the role |
| 93 | +connection default; |
| 94 | +REVOKE SET_USER_ID ON *.* FROM b35471453@localhost; |
| 95 | +connection b35471453_con; |
| 96 | + |
| 97 | +--echo # test3: should fail |
| 98 | +--error ER_CANNOT_USER_REFERENCED_AS_DEFINER |
| 99 | +DROP ROLE IF EXISTS role_35471453; |
| 100 | +--echo # Now grant SET_USER_ID and retry |
| 101 | +connection default; |
| 102 | +GRANT SET_USER_ID ON *.* TO b35471453@localhost; |
| 103 | +connection b35471453_con; |
| 104 | +--echo # test4: should pass with a warning |
| 105 | +DROP ROLE IF EXISTS role_35471453; |
| 106 | + |
| 107 | +DROP VIEW v35471453; |
| 108 | +DROP TABLE t35471453; |
| 109 | +connection default; |
| 110 | +disconnect b35471453_con; |
| 111 | + |
| 112 | +REVOKE CREATE ROLE, DROP ROLE, SET_USER_ID ON *.* FROM b35471453@localhost; |
| 113 | +DROP USER b35471453@localhost; |
| 114 | + |
| 115 | + |
| 116 | +--echo |
| 117 | +--echo # End of 8.0 tests |
| 118 | +--echo |
| 119 | + |
| 120 | +# Wait till we reached the initial number of concurrent sessions |
| 121 | +--source include/wait_until_count_sessions.inc |
0 commit comments