| 1 |
############################################################################# |
| 2 |
# Original Author: JBM # |
| 3 |
# Original Date: Aug/22/2005 # |
| 4 |
# Update: 08/29/2005 Added save pos and sync # |
| 5 |
############################################################################# |
| 6 |
#TEST: SP to test security and current_user and user # |
| 7 |
############################################################################# |
| 8 |
|
| 9 |
|
| 10 |
# Includes |
| 11 |
-- source include/not_group_replication_plugin.inc |
| 12 |
-- source include/have_binlog_format_row.inc |
| 13 |
-- source include/set_privilege_checks_user_as_system_user.inc |
| 14 |
-- let $rpl_privilege_checks_user_grant_option = 1 |
| 15 |
-- source include/master-slave.inc |
| 16 |
|
| 17 |
|
| 18 |
# Begin clean up test section |
| 19 |
connection master; |
| 20 |
--disable_warnings |
| 21 |
DROP PROCEDURE IF EXISTS test.p1; |
| 22 |
DROP PROCEDURE IF EXISTS test.p2; |
| 23 |
DROP PROCEDURE IF EXISTS test.p3; |
| 24 |
|
| 25 |
# Begin test section 1 |
| 26 |
# Create user user1 with no particular access rights |
| 27 |
CREATE USER user1@localhost; |
| 28 |
flush privileges; |
| 29 |
|
| 30 |
SELECT CURRENT_USER(); |
| 31 |
SELECT USER(); |
| 32 |
CREATE PROCEDURE test.p1 () SQL SECURITY INVOKER SELECT CURRENT_USER(), USER(); |
| 33 |
CREATE PROCEDURE test.p2 () SQL SECURITY DEFINER CALL test.p1(); |
| 34 |
CREATE PROCEDURE test.p3 () SQL SECURITY INVOKER CALL test.p1(); |
| 35 |
GRANT EXECUTE ON PROCEDURE p1 TO user1@localhost; |
| 36 |
GRANT EXECUTE ON PROCEDURE p2 TO user1@localhost; |
| 37 |
GRANT EXECUTE ON PROCEDURE p3 TO user1@localhost; |
| 38 |
|
| 39 |
# Need to wait for the rights to be applied at the slave |
| 40 |
--source include/sync_slave_sql_with_master.inc |
| 41 |
|
| 42 |
let $message=<******** Master user1 p3 & p2 calls *******>; |
| 43 |
--source include/show_msg.inc |
| 44 |
connect (muser1,localhost,user1,,); |
| 45 |
connection muser1; |
| 46 |
SELECT CURRENT_USER(); |
| 47 |
SELECT USER(); |
| 48 |
CALL test.p3(); |
| 49 |
CALL test.p2(); |
| 50 |
|
| 51 |
let $message=<******** Slave user1 p3 & p2 calls *******>; |
| 52 |
--source include/show_msg.inc |
| 53 |
connect (suser1,127.0.0.1,user1,,test,$SLAVE_MYPORT,); |
| 54 |
|
| 55 |
connection master; |
| 56 |
save_master_pos; |
| 57 |
connection suser1; |
| 58 |
sync_with_master; |
| 59 |
|
| 60 |
SELECT CURRENT_USER(); |
| 61 |
SELECT USER(); |
| 62 |
CALL test.p3(); |
| 63 |
CALL test.p2(); |
| 64 |
|
| 65 |
# Cleanup |
| 66 |
connection master; |
| 67 |
DROP PROCEDURE IF EXISTS test.p1; |
| 68 |
DROP PROCEDURE IF EXISTS test.p3; |
| 69 |
DROP PROCEDURE IF EXISTS test.p2; |
| 70 |
DROP TABLE IF EXISTS test.t1; |
| 71 |
DROP TABLE IF EXISTS test.t2; |
| 72 |
DROP USER user1@localhost; |
| 73 |
--source include/sync_slave_sql_with_master.inc |
| 74 |
--enable_warnings |
| 75 |
|
| 76 |
# End of 5.0 test case |
| 77 |
|
| 78 |
--source include/rpl_end.inc |