| 1 |
------------------------------------------------------------------------ |
| 2 |
# Setup |
| 3 |
CREATE DATABASE db1; |
| 4 |
CREATE TABLE db1.t1(c1 int); |
| 5 |
INSERT INTO db1.t1 VALUES (1), (2), (3); |
| 6 |
------------------------------------------------------------------------ |
| 7 |
# Case: - Connecting user has sufficient privileges |
| 8 |
# - Effective user does not have required privileges |
| 9 |
CREATE USER qa_test_3_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_3_dest'; |
| 10 |
GRANT SELECT ON *.* TO qa_test_3_user; |
| 11 |
CREATE USER qa_test_3_dest IDENTIFIED BY 'dest_passwd'; |
| 12 |
GRANT SELECT ON *.* TO qa_test_3_dest; |
| 13 |
REVOKE SELECT ON db1.* FROM qa_test_3_dest; |
| 14 |
GRANT PROXY ON qa_test_3_dest TO qa_test_3_user; |
| 15 |
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 |
| 16 |
mysql: [Warning] Using a password on the command line interface can be insecure. |
| 17 |
*************************** 1. row *************************** |
| 18 |
current_user(): qa_test_3_dest@% |
| 19 |
user(): qa_test_3_user@localhost |
| 20 |
@@local.proxy_user: 'qa_test_3_user'@'%' |
| 21 |
@@local.external_user: qa_test_3_dest |
| 22 |
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 |
| 23 |
mysql: [Warning] Using a password on the command line interface can be insecure. |
| 24 |
ERROR 1142 (42000) at line 1: SELECT command denied to user 'qa_test_3_dest'@'localhost' for table 't1' |
| 25 |
DROP USER qa_test_3_dest, qa_test_3_user; |
| 26 |
------------------------------------------------------------------------ |
| 27 |
# Case: - Connecting user does not have required privileges |
| 28 |
# - Effective user has sufficient privileges |
| 29 |
CREATE USER qa_test_4_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_4_dest'; |
| 30 |
GRANT SELECT ON *.* TO qa_test_4_user; |
| 31 |
REVOKE SELECT ON db1.* FROM qa_test_4_user; |
| 32 |
CREATE USER qa_test_4_dest IDENTIFIED BY 'dest_passwd'; |
| 33 |
GRANT SELECT ON *.* TO qa_test_4_dest; |
| 34 |
GRANT PROXY ON qa_test_4_dest TO qa_test_4_user; |
| 35 |
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 |
| 36 |
mysql: [Warning] Using a password on the command line interface can be insecure. |
| 37 |
*************************** 1. row *************************** |
| 38 |
current_user(): qa_test_4_dest@% |
| 39 |
user(): qa_test_4_user@localhost |
| 40 |
@@local.proxy_user: 'qa_test_4_user'@'%' |
| 41 |
@@local.external_user: qa_test_4_dest |
| 42 |
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 |
| 43 |
mysql: [Warning] Using a password on the command line interface can be insecure. |
| 44 |
COUNT(*) |
| 45 |
3 |
| 46 |
DROP USER qa_test_4_dest, qa_test_4_user; |
| 47 |
------------------------------------------------------------------------ |
| 48 |
# Cleanup |
| 49 |
DROP TABLE db1.t1; |
| 50 |
DROP DATABASE db1; |
| 51 |
------------------------------------------------------------------------ |