| 1 |
############################################################################### |
| 2 |
# WL#12364: Kill administration for system users # |
| 3 |
# # |
| 4 |
# This test file covers the scenarios around prohibiting the killing # |
| 5 |
# connections of a user who is granted the SYSTEM_USER dynamic privilege # |
| 6 |
# from the connections of a user who is not granted the SYSTEM_USER # |
| 7 |
# dynamic privilege. # |
| 8 |
# # |
| 9 |
############################################################################### |
| 10 |
|
| 11 |
--source include/xplugin_preamble.inc |
| 12 |
--source include/xplugin_create_user.inc |
| 13 |
|
| 14 |
create user unpriv@localhost; |
| 15 |
set password for unpriv@localhost = 'x'; |
| 16 |
grant connection_admin on *.* to unpriv@localhost; |
| 17 |
create role sys_user_role; |
| 18 |
grant system_user on *.* to sys_user_role; |
| 19 |
grant sys_user_role to unpriv@localhost; |
| 20 |
|
| 21 |
## Test starts here |
| 22 |
--write_file $MYSQL_TMP_DIR/system_user_kill.xpl |
| 23 |
## Test data |
| 24 |
|
| 25 |
-->stmtadmin list_clients |
| 26 |
## expect Mysqlx.Sql.StmtExecuteOk |
| 27 |
-->recvresult |
| 28 |
|
| 29 |
## create and activate new session |
| 30 |
-->newsession aux x_root |
| 31 |
|
| 32 |
-->stmtadmin list_clients |
| 33 |
## expect Mysqlx.Sql.StmtExecuteOk |
| 34 |
-->recvresult |
| 35 |
|
| 36 |
## switch back to default session |
| 37 |
-->setsession |
| 38 |
|
| 39 |
-->stmtadmin list_clients |
| 40 |
## expect Mysqlx.Sql.StmtExecuteOk |
| 41 |
-->recvresult |
| 42 |
|
| 43 |
### Create a separate session with diff account |
| 44 |
-->newsession unpriv unpriv x |
| 45 |
|
| 46 |
-->echo Should list unprivs session only |
| 47 |
-->stmtadmin list_clients |
| 48 |
-->recvresult |
| 49 |
|
| 50 |
-->echo Try to kill a x_root session from regular session |
| 51 |
-->stmtadmin kill_client {"id": 2 } |
| 52 |
-->recverror 1095 |
| 53 |
|
| 54 |
-->echo promote regular session to power session |
| 55 |
-->sql |
| 56 |
set role sys_user_role; |
| 57 |
-->endsql |
| 58 |
|
| 59 |
-->echo Try to kill a x_root session from unpriv |
| 60 |
-->stmtadmin kill_client {"id": 2} |
| 61 |
|
| 62 |
## expect Mysqlx.Sql.StmtExecuteOk |
| 63 |
-->recvresult |
| 64 |
|
| 65 |
-->setsession |
| 66 |
|
| 67 |
-->quiet |
| 68 |
-->wait_for 2 SELECT count(*) FROM information_schema.processlist WHERE info LIKE "PLUGIN%" |
| 69 |
-->noquiet |
| 70 |
|
| 71 |
-->echo Should two sessions |
| 72 |
-->stmtadmin list_clients |
| 73 |
-->recvresult |
| 74 |
|
| 75 |
|
| 76 |
-->echo Now kill one power_session from another power_session |
| 77 |
-->stmtadmin kill_client {"id": 3} |
| 78 |
-->recvresult |
| 79 |
|
| 80 |
-->quiet |
| 81 |
-->wait_for 1 SELECT count(*) FROM information_schema.processlist WHERE info LIKE "PLUGIN%" |
| 82 |
-->noquiet |
| 83 |
|
| 84 |
-->echo Should list only x_root session |
| 85 |
-->stmtadmin list_clients |
| 86 |
-->recvresult |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
## Cleanup |
| 91 |
-->sql |
| 92 |
drop schema if exists xtest; |
| 93 |
drop user unpriv@localhost; |
| 94 |
drop role sys_user_role; |
| 95 |
-->endsql |
| 96 |
EOF |
| 97 |
|
| 98 |
--replace_regex /([a-z]*.+localhost[ ]+)[0-9]+/\1$SESSION/ /You are not owner of thread [0-9]+/You are not owner of thread/ |
| 99 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/system_user_kill.xpl 2>&1 |
| 100 |
|
| 101 |
## Cleanup |
| 102 |
--source ../include/xplugin_cleanup.inc |