| 1 |
--source include/have_plugin_interface.inc |
| 2 |
let PLUGIN_AUTH_OPT=`SELECT TRIM(TRAILING '/debug' FROM '$PLUGIN_AUTH_OPT')`; |
| 3 |
--echo ------------------------------------------------------------------------ |
| 4 |
--echo # Setup |
| 5 |
--disable_query_log |
| 6 |
--disable_warnings |
| 7 |
let $saved_partial_revokes = `SELECT @@global.partial_revokes`; |
| 8 |
SET GLOBAL partial_revokes= ON; |
| 9 |
--enable_warnings |
| 10 |
--enable_query_log |
| 11 |
|
| 12 |
CREATE DATABASE db1; |
| 13 |
CREATE TABLE db1.t1(c1 int); |
| 14 |
INSERT INTO db1.t1 VALUES (1), (2), (3); |
| 15 |
|
| 16 |
--echo ------------------------------------------------------------------------ |
| 17 |
--echo # Case: - Connecting user has sufficient privileges |
| 18 |
--echo # - Effective user does not have required privileges |
| 19 |
# Connecting user has sufficient privileges |
| 20 |
CREATE USER qa_test_3_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_3_dest'; |
| 21 |
GRANT SELECT ON *.* TO qa_test_3_user; |
| 22 |
# Effective user has partial revokes |
| 23 |
CREATE USER qa_test_3_dest IDENTIFIED BY 'dest_passwd'; |
| 24 |
GRANT SELECT ON *.* TO qa_test_3_dest; |
| 25 |
REVOKE SELECT ON db1.* FROM qa_test_3_dest; |
| 26 |
GRANT PROXY ON qa_test_3_dest TO qa_test_3_user; |
| 27 |
|
| 28 |
--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user\G" 2>&1 |
| 29 |
--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user\G" 2>&1 |
| 30 |
|
| 31 |
# Following should throw error because effective user does not have sufficient |
| 32 |
# privileges and connecting user's privileges are not considered in case of a |
| 33 |
# proxy grant. |
| 34 |
--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest -e "SELECT COUNT(*) FROM db1.t1\G" 2>&1 |
| 35 |
--error 1 |
| 36 |
--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest -e "SELECT COUNT(*) FROM db1.t1\G" 2>&1 |
| 37 |
|
| 38 |
DROP USER qa_test_3_dest, qa_test_3_user; |
| 39 |
|
| 40 |
--echo ------------------------------------------------------------------------ |
| 41 |
--echo # Case: - Connecting user does not have required privileges |
| 42 |
--echo # - Effective user has sufficient privileges |
| 43 |
# Connecting user has partial revokes |
| 44 |
CREATE USER qa_test_4_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_4_dest'; |
| 45 |
GRANT SELECT ON *.* TO qa_test_4_user; |
| 46 |
REVOKE SELECT ON db1.* FROM qa_test_4_user; |
| 47 |
# Effective user has sufficient privileges |
| 48 |
CREATE USER qa_test_4_dest IDENTIFIED BY 'dest_passwd'; |
| 49 |
GRANT SELECT ON *.* TO qa_test_4_dest; |
| 50 |
GRANT PROXY ON qa_test_4_dest TO qa_test_4_user; |
| 51 |
|
| 52 |
--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user\G" 2>&1 |
| 53 |
--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user\G" 2>&1 |
| 54 |
|
| 55 |
# Following should work because effective user has sufficient privileges and |
| 56 |
# connecting user's privileges are not considered in case of a proxy grant |
| 57 |
--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest -e "SELECT COUNT(*) FROM db1.t1;" 2>&1 |
| 58 |
--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest -e "SELECT COUNT(*) FROM db1.t1;" 2>&1 |
| 59 |
|
| 60 |
DROP USER qa_test_4_dest, qa_test_4_user; |
| 61 |
|
| 62 |
--echo ------------------------------------------------------------------------ |
| 63 |
--echo # Cleanup |
| 64 |
|
| 65 |
DROP TABLE db1.t1; |
| 66 |
DROP DATABASE db1; |
| 67 |
--disable_query_log |
| 68 |
--disable_warnings |
| 69 |
eval SET GLOBAL partial_revokes = $saved_partial_revokes; |
| 70 |
--enable_warnings |
| 71 |
--enable_query_log |
| 72 |
|
| 73 |
--echo ------------------------------------------------------------------------ |