Current Path : /home/usr.opt/mysql57/mysql-test/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/t/grant_debug.test |
# The include statement below is a temp one for tests that are yet to #be ported to run with InnoDB, #but needs to be kept for tests that would need MyISAM in future. --source include/force_myisam_default.inc # Grant tests not performed with embedded server --source include/not_embedded.inc --source include/have_debug.inc --echo # --echo # WL#9262: All system tables should support 32 character length user names --echo # call mtr.add_suppression("Cannot load from mysql.*. The table is probably corrupted"); CREATE USER user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; GRANT ALL PRIVILEGES ON *.* TO user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char WITH GRANT OPTION; CREATE USER user_name_robert_golebiowski1234@localhost; GRANT ALL PRIVILEGES ON *.* TO user_name_robert_golebiowski1234@localhost WITH GRANT OPTION; CREATE USER some_user@localhost; connect (con_1, localhost, user_name_robert_golebiowski1234,,); --echo # This will change CURRENT_USER from user_name_robert_golebiowski1234@localhost to --echo # user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char --echo # We have to do this in the server code as we are not able to simulate connecting to --echo # such a host from MTR SET DEBUG='+d,wl_9262_set_max_length_hostname'; FLUSH PRIVILEGES; SET DEBUG='-d,wl_9262_set_max_length_hostname'; SELECT CURRENT_USER(); CREATE DATABASE db_1; CREATE TABLE db_1.test_table(ID INT); --echo # This should just work and Grantor should not be truncated GRANT SELECT ON db_1.test_table TO some_user@localhost; SELECT Grantor FROM mysql.tables_priv WHERE USER = 'some_user'; SELECT LENGTH(Grantor) FROM mysql.tables_priv WHERE USER = 'some_user'; DROP USER user_name_robert_golebiowski1234@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; DROP USER user_name_robert_golebiowski1234@localhost; DROP USER some_user@localhost; DROP DATABASE db_1; --connection default --disconnect con_1 --echo #Make sure CURRENT_USER is root@localhost SELECT CURRENT_USER(); --echo # Changing mysql.tables_priv.Grantor column to char(77) - i.e. old layout (5.7.12) SET @orig_sql_mode= @@sql_mode; SET sql_mode=''; ALTER TABLE mysql.tables_priv MODIFY Grantor char(77) DEFAULT '' NOT NULL; SET sql_mode= @orig_sql_mode; --echo # Now let us do the same for the procedure privileges --echo # Changing mysql.procs_priv.Grantor column to char(77) - i.e. old layout (5.7.12) SET @orig_sql_mode= @@sql_mode; SET sql_mode=''; ALTER TABLE mysql.procs_priv MODIFY Grantor char(77) DEFAULT '' NOT NULL; SET sql_mode= @orig_sql_mode; CREATE DATABASE db_1; CREATE TABLE db_1.test_table(ID INT); --error ER_CANNOT_LOAD_FROM_TABLE_V2 CREATE USER user_name_robert_golebiowski@localhost; --error ER_PASSWORD_NO_MATCH GRANT ALL PRIVILEGES ON *.* TO user_name_robert_golebiowski@localhost WITH GRANT OPTION; --echo #Create user with length > 77 (username length + hostname length) --error ER_CANNOT_LOAD_FROM_TABLE_V2 CREATE USER user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; --error ER_PASSWORD_NO_MATCH GRANT ALL PRIVILEGES ON *.* TO user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char WITH GRANT OPTION; --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect (con_grant,localhost,user_name_robert_golebiowski,,); --echo # This will change CURRENT_USER from user_name_robert_golebiowski@localhost to --echo # user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char --echo # We have to do this in the server code as we are not able to simulate connecting to --echo # such a host from MTR SET DEBUG='+d,wl_9262_set_max_length_hostname'; FLUSH PRIVILEGES; SET DEBUG='-d,wl_9262_set_max_length_hostname'; SELECT CURRENT_USER(); --error ER_CANNOT_LOAD_FROM_TABLE_V2 CREATE USER lucky_user@localhost; --echo # Now we should get error as the length of the Grantor (user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char - 93 chars) --echo # is longer then mysql.tables_priv.Grantor column length - 77 chars) --error ER_PASSWORD_NO_MATCH GRANT SELECT ON db_1.test_table TO lucky_user@localhost; CREATE PROCEDURE db_1.p_def() SQL SECURITY DEFINER SELECT 1; --echo # We should get error as the length of the Grantor (user_name_robert_golebiowski@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char - 93 chars) --echo # is longer then mysql.procs_priv.Grantor column length - 77 chars) --error ER_PASSWORD_NO_MATCH GRANT EXECUTE ON PROCEDURE db_1.p_def TO lucky_user@localhost; --echo #Now we make sure if usernames with length of 77 or less work with --echo #this old db schema --echo #First create user of length 77 chars. --error ER_CANNOT_LOAD_FROM_TABLE_V2 CREATE USER robert_golebiows@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char; --error ER_PASSWORD_NO_MATCH GRANT ALL PRIVILEGES ON *.* TO robert_golebiows@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char WITH GRANT OPTION; --echo #Create user for connecting --error ER_CANNOT_LOAD_FROM_TABLE_V2 CREATE USER robert_golebiows@localhost; --error ER_PASSWORD_NO_MATCH GRANT ALL PRIVILEGES ON *.* TO robert_golebiows@localhost WITH GRANT OPTION; --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect (con_grant_2,localhost,robert_golebiows,,); --echo # Again we change localhost to oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char --echo # for CURRENT_USER SET DEBUG='+d,wl_9262_set_max_length_hostname'; FLUSH PRIVILEGES; SET DEBUG='-d,wl_9262_set_max_length_hostname'; SELECT CURRENT_USER(); --echo # Now the CURRENT_USER is robert_golebiows@oh_my_gosh_this_is_a_long_hostname_look_at_it_it_has_60_char --echo #Now it should pass as mysql.tables_priv.Grantor is 77 chars --error ER_PASSWORD_NO_MATCH GRANT SELECT ON db_1.test_table TO lucky_user@localhost; SELECT Grantor FROM mysql.tables_priv WHERE User = 'lucky_user'; SELECT LENGTH(Grantor) FROM mysql.tables_priv WHERE User = 'lucky_user'; --echo #Now it should pass as mysql.procs_priv.Grantor is 77 chars --error ER_PASSWORD_NO_MATCH GRANT EXECUTE ON PROCEDURE db_1.p_def TO lucky_user@localhost; SELECT Grantor FROM mysql.procs_priv WHERE User = 'lucky_user'; SELECT LENGTH(Grantor) FROM mysql.procs_priv WHERE User = 'lucky_user'; --echo #cleanup --echo Restore mysql.procs_priv SET @orig_sql_mode= @@sql_mode; SET sql_mode=''; ALTER TABLE mysql.procs_priv MODIFY Grantor char(93) DEFAULT '' NOT NULL; SET sql_mode= @orig_sql_mode; --echo Restore mysql.tables_priv SET @orig_sql_mode= @@sql_mode; SET sql_mode=''; ALTER TABLE mysql.tables_priv MODIFY Grantor char(93) DEFAULT '' NOT NULL; SET sql_mode= @orig_sql_mode; --connection default DROP PROCEDURE db_1.p_def; DROP DATABASE db_1; --echo ### --echo ### Bug#27302337: MYSQL ABORTS WITHOUT PROPER ERROR MESSAGE ON --echo ### STARTUP IF GRANT TABLES ARE CORRUPT --echo ### let $DDIR= `select @@datadir`; let server_log= $MYSQLTEST_VARDIR/log/mysqld.1.err; --echo # Shutdown the server --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc --echo # Start the server to simulate acl_init() failure --error 1 --exec $MYSQLD_CMD --datadir=$DDIR --debug=d,simulate_acl_init_failure --loose-console > $server_log 2>&1 let SEARCH_FILE=$server_log; let SEARCH_PATTERN=Table 'user' is marked as crashed and should be repaired; --source include/search_pattern.inc let SEARCH_PATTERN=Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.; --source include/search_pattern.inc let SEARCH_PATTERN=Aborting; --source include/search_pattern.inc --echo # Restart the server --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc