Debian Codegraph @

mysql-test/suite/audit_null/t/audit_plugin_bugs.test

raw
1 --source include/have_null_audit_plugin.inc
2 --source include/have_debug.inc
3
4 call mtr.add_suppression("Event 'MYSQL_AUDIT_GENERAL_ERROR' cannot be aborted.");
5
6 let $expected_extension= so;
7 if(`SELECT CONVERT(@@version_compile_os USING latin1)
8 IN ("Win32","Win64","Windows")`)
9 {
10 let $expected_extension= dll;
11 }
12
13 --echo #
14 --echo # Bug #22142209: MY_MESSAGE FAILS TO ABORT MYSQL_AUDIT_SERVER_STARTUP_CLASS EVENT
15 --echo #
16
17 let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
18
19 --error 0,1
20 --remove_file $error_log
21
22 --echo # Shutdown the server
23 let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
24 --exec echo "wait" > $restart_file
25 --shutdown_server
26 --source include/wait_until_disconnected.inc
27
28 --echo # Load the plugin at startup and abort on STARTUP with default message
29 --replace_regex /\.dll/.so/
30 --error 1
31 --exec $MYSQLD_CMD --loose-console $AUDIT_NULL_OPT --plugin-load=null_audit=adt_null.$expected_extension --null_audit_event_order_check="MYSQL_AUDIT_SERVER_STARTUP_STARTUP;;ABORT_RET" > $error_log 2>&1
32
33 --echo # Search for default abort message
34 let SEARCH_FILE= $error_log;
35 let SEARCH_PATTERN= \[ERROR\] \[[^]]*\] \[[^]]*\] Aborted by Audit API \(\'MYSQL_AUDIT_SERVER_STARTUP_STARTUP\'.1\)\.;
36 --source include/search_pattern.inc
37
38 --error 0,1
39 --remove_file $error_log
40
41 --echo # Load the plugin at startup and abort on STARTUP event with custom message
42 --replace_regex /\.dll/.so/
43 --error 1
44 --exec $MYSQLD_CMD --loose-console $AUDIT_NULL_OPT --plugin-load=null_audit=adt_null.$expected_extension --null_audit_event_order_check="MYSQL_AUDIT_SERVER_STARTUP_STARTUP;;ABORT_RET" --null_audit_abort_message="Abort message custom" > $error_log 2>&1
45
46 --echo # Search for custom abort message
47 let SEARCH_PATTERN= \[ERROR\] \[[^]]*\] \[[^]]*\] Abort message custom;
48 --source include/search_pattern.inc
49
50 --error 0,1
51 --remove_file $error_log
52
53 --echo # Startup the server
54 --exec echo "restart" > $restart_file
55 --enable_reconnect
56 --source include/wait_until_connected_again.inc
57 --disable_reconnect
58
59 --echo #
60 --echo # Bug #22136709: INFINITE RECURSION BY CALLING MY_MESSAGE FROM
61 --echo # MYSQL_AUDIT_GENERAL_CLASS HANDLER
62
63 --replace_regex /\.dll/.so/
64 eval INSTALL PLUGIN null_audit SONAME '$AUDIT_NULL';
65
66 # Save the initial number of concurrent sessions
67 --source include/count_sessions.inc
68
69 SET @@GLOBAL.null_audit_event_order_check= "MYSQL_AUDIT_GENERAL_ERROR;;ABORT_RET";
70 SET @@GLOBAL.null_audit_abort_message= "Abort message.";
71
72 --echo # Try to enter error state recursively 2 times.
73 SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 2;
74 --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
75 --error ER_ACCESS_DENIED_ERROR
76 connect(user1_con,localhost,wrong_root,);
77 SELECT @@null_audit_event_order_check_consume_ignore_count;
78
79 --echo # Try to enter error state infinitely. my_message calls cause stack overrun.
80 SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 10000;
81 --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
82 --disable_result_log
83 --error ER_ACCESS_DENIED_ERROR
84 connect(user1_con,localhost,wrong_root,);
85 --enable_result_log
86 SELECT @@null_audit_event_order_check_consume_ignore_count;
87
88 # Clean up global variables
89 SET @@GLOBAL.null_audit_event_order_check= NULL;
90 SET @@GLOBAL.null_audit_abort_message= NULL;
91 # Let's hope 10000 calls will overrun the stack frame
92 SET @@GLOBAL.null_audit_event_order_check_consume_ignore_count= 0;
93
94 # Wait till we reached the initial number of concurrent sessions
95 --source include/wait_until_count_sessions.inc
96
97 --echo End of 5.7 tests
98
99 --echo #
100 --echo # Bug#24961932 - create function at bootstrap attempts to evaluate
101 --echo # non-resolved expressions
102 --echo #
103
104 --echo # Initial value of the status variable "Audit_null_global_variable_get".
105 SELECT variable_value FROM performance_schema.global_status
106 WHERE variable_name = 'Audit_null_global_variable_get'
107 INTO @initial_global_var_get_count;
108
109 DELIMITER $;
110 # Procedure to check value of the status variable
111 # "Audit_null_global_variable_get".
112 CREATE PROCEDURE check_global_var_count()
113 BEGIN
114 SELECT variable_value FROM performance_schema.global_status
115 WHERE variable_name = 'Audit_null_global_variable_get'
116 INTO @cur_global_var_get_count;
117 SELECT @cur_global_var_get_count - @initial_global_var_get_count AS
118 global_var_count;
119 END
120 $
121
122 --echo # Procedure p1 using global system variables.
123 CREATE PROCEDURE p1()
124 BEGIN
125 SET @a=@@global.max_execution_time;
126 CREATE TABLE t1 AS SELECT @@global.max_execution_time;
127 DROP TABLE t1;
128 SELECT @@global.optimizer_trace, @@session.max_execution_time;
129 END
130 $
131 DELIMITER ;$
132
133 --echo # Without fix, non-resolved expression is evaluated to audit the global
134 --echo # system variable get event while creating the stored routines.
135 --echo # The audit for the system variable get event should be done while
136 --echo # executing the stored routine but not while creating it. With the fix,
137 --echo # global system variable get event is audited while executing the stored
138 --echo # routine. At this time, expression is resolved. Hence status variable
139 --echo # "Audit_null_global_variable_get" remains unchanged while creating the
140 --echo # stored routine.
141 CALL check_global_var_count();
142
143 --echo # The same issue exits with the prepared statement too. With the fix,
144 --echo # system variable get event is not audited while preparing the statement.
145 --echo # Instead it is done while executing the statement. Hence status variable
146 --echo # "Audit_null_global_variable_get" remains same here too.
147 PREPARE stmt FROM 'SELECT @@global.max_execution_time,@@global.optimizer_trace';
148 CALL check_global_var_count();
149
150 --echo # With the fix, system variable get event is audited on each execution of
151 --echo # the routine. Hence status variable "Audit_null_global_variable_get" is
152 --echo # incremented by value three by p1() here.
153 CALL p1();
154 CALL check_global_var_count();
155
156 --echo # With the fix, system variable get event is audited on each execution of
157 --echo # the routine. Hence status variable "Audit_null_global_variable_get" is
158 --echo # incremented by value three by p1() here.
159 CALL p1();
160 CALL check_global_var_count();
161
162 --echo # System variable get event is audited for global variables only. Hence
163 --echo # status variable "Audit_null_global_variable_get" remain same here.
164 SELECT @@session.max_execution_time, @@session.optimizer_trace;
165 CALL check_global_var_count();
166
167 --echo # With the fix, system variable get event is audited on each execution of
168 --echo # the prepared statement. Hence status "Audit_null_global_variable_get"
169 --echo # variable is incremented by value two here.
170 EXECUTE stmt;
171 CALL check_global_var_count();
172
173 --echo # With the fix, system variable get event is audited on each execution of
174 --echo # the prepared statement. Hence status "Audit_null_global_variable_get"
175 --echo # variable is incremented by value two here.
176 EXECUTE stmt;
177 CALL check_global_var_count();
178
179 --echo # Verify if system variable get event is audited in the simple select.
180 --echo # Status variable "Audit_null_global_variable_get" is incremented by
181 --echo # value two here.
182 SELECT @@global.max_execution_time, @@global.optimizer_trace;
183 CALL check_global_var_count();
184
185 # Cleanup
186 DROP PROCEDURE p1;
187 DROP PROCEDURE check_global_var_count;
188 DROP PREPARE stmt;
189
190 --echo
191 --echo #
192 --echo # Bug#27638290 - Set @@null_audit_event_record_def =
193 --echo # 'mysql_audit_authentication_flush'; crashed
194 --echo #
195 --echo # New connection, unbound thread
196 connect (con1,localhost,root,,);
197
198 --echo # Expect NULL
199 SELECT @@null_audit_event_record_def;
200 --echo
201 --echo # Invalid data
202 SET @@null_audit_event_record_def = 'ABSOLUTE_NONSENSE';
203 SELECT 1;
204 --echo # Expect NULL
205 --replace_regex /;command_id="[0-9]+"/;command_id="<expected_command_id>"/
206 SELECT @@null_audit_event_record;
207 SELECT @@null_audit_event_record_def;
208
209 --echo
210 --echo # Invalid data again
211 SET @@null_audit_event_record_def = 'MYSQL_AUDIT_AUTHENTICATION_FLUSH;JUNK';
212 SELECT 1;
213 --echo # Expect NULL
214 --replace_regex /;command_id="[0-9]+"/;command_id="<expected_command_id>"/
215 SELECT @@null_audit_event_record;
216 SELECT @@null_audit_event_record_def;
217 --echo
218
219 --echo # Valid data
220 SET @@null_audit_event_record_def = 'MYSQL_AUDIT_GENERAL_RESULT;MYSQL_AUDIT_COMMAND_END';
221 SELECT 1;
222 --replace_regex /;command_id="[0-9]+"/;command_id="<expected_command_id>"/
223 SELECT @@null_audit_event_record;
224 --disconnect con1
225 connection default;
226
227 --echo
228 --echo End of 8.0 tests
229
230 --echo # cleanup
231 UNINSTALL PLUGIN null_audit;