Skip to content

Commit ea5d556

Browse files
ssorumgarddahlerlend
authored andcommitted
Bug#27674311: Protect dd tables from access in init-file during --initialize
Followup fix: Remove a misplaced semicolon (which confused windows runs), and make server log files be saved for the mtr test dd_bootstrap_debug. Change-Id: I36d301c63d59f40b33cdae5d9139bdbf38b3deac
1 parent f307774 commit ea5d556

File tree

2 files changed

+44
-33
lines changed

2 files changed

+44
-33
lines changed

mysql-test/r/dd_bootstrap_debug.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
# 1.3 Restart the server against DDIR - should fail.
1414
# 1.4 Look for error.
1515
# Data Dictionary initialization error found 1 times.
16-
# 1.5 Delete bootstrap file, log file and datadir.
16+
# 1.5 Delete bootstrap file and datadir.
1717
#
1818
# 2. Try restart after dropping the properties table.
1919
# ---------------------------------------------------
2020
# 2.1 Create bootstrap file.
2121
# 2.2 First start the server with --initialize, and drop the properties table. Should fail.
2222
# 2.3 Look for error.
2323
# Data Dictionary initialization error found 1 times.
24-
# 2.4 Delete bootstrap file, log file and datadir.
24+
# 2.4 Delete bootstrap file and datadir.
2525
#
2626
# 3. Try restart after dropping the tables table.
2727
# -----------------------------------------------
2828
# 3.1 Create bootstrap file.
2929
# 3.2 First start the server with --initialize, and drop the tables table: Should fail.
3030
# 3.3 Look for error.
3131
# Data Dictionary initialization error found 1 times.
32-
# 3.4 Delete bootstrap file, log file and datadir.
32+
# 3.4 Delete bootstrap file and datadir.
3333
#
3434
# 4. Try restart after altering the schemata table.
3535
# -------------------------------------------------
@@ -48,15 +48,15 @@ Altered table
4848
SET SESSION debug= '-d,skip_dd_table_access_check';
4949
# 4.6 Shut server down.
5050
# 4.7 Close the test connection.
51-
# 4.8 Delete bootstrap file, log file and datadir.
51+
# 4.8 Delete bootstrap file and datadir.
5252
#
5353
# 5. Try to access a DD table in an init-file during --initialize.
5454
# ----------------------------------------------------------------
5555
# 5.1 Create bootstrap file.
5656
# 5.2 First start the server with --initialize, and submit the init file.
5757
# 5.3 Look for error.
5858
# Data Dictionary table access error found 1 times.
59-
# 5.4 Delete bootstrap file, log file and datadir.
59+
# 5.4 Delete bootstrap file and datadir.
6060
#
6161
# 6. Try to access a DD table in an init-file during plain restart.
6262
# -----------------------------------------------------------------
@@ -66,6 +66,6 @@ SET SESSION debug= '-d,skip_dd_table_access_check';
6666
# 6.4 An init file error does not make the server exit, so we need to stop the server.
6767
# 6.5 Look for error.
6868
# Data Dictionary initialization error found 1 times.
69-
# 6.6 Delete bootstrap file, log file and datadir.
69+
# 6.6 Delete bootstrap file and datadir.
7070
#
7171
# Cleanup: Restarting the server against default datadir.

mysql-test/t/dd_bootstrap_debug.test

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
let BASEDIR= `select @@basedir`;
1212
let DDIR= $MYSQL_TMP_DIR/dd_bootstrap_test;
13-
let MYSQLD_LOG= $MYSQL_TMP_DIR/server.log;
14-
let extra_args= --no-defaults --innodb_dedicated_server=OFF --log-error=$MYSQLD_LOG --log-syslog=0 --secure-file-priv="" --loose-skip-auto_generate_certs --loose-skip-sha256_password_auto_generate_rsa_keys --skip-ssl --basedir=$BASEDIR --lc-messages-dir=$MYSQL_SHAREDIR;
13+
let extra_args= --no-defaults --innodb_dedicated_server=OFF --log-syslog=0 --secure-file-priv="" --loose-skip-auto_generate_certs --loose-skip-sha256_password_auto_generate_rsa_keys --skip-ssl --basedir=$BASEDIR --lc-messages-dir=$MYSQL_SHAREDIR;
1514
let BOOTSTRAP_SQL= $MYSQL_TMP_DIR/tiny_bootstrap.sql;
1615
let PASSWD_FILE= $MYSQL_TMP_DIR/password_file.txt;
1716

@@ -24,6 +23,9 @@ let PASSWD_FILE= $MYSQL_TMP_DIR/password_file.txt;
2423
--echo # 1. Try restart after setting an invalid version.
2524
--echo # ------------------------------------------------
2625

26+
let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_1.log;
27+
let ENV_MYSQLD_LOG= $MYSQLD_LOG;
28+
2729
--echo # 1.1 Create bootstrap file.
2830
write_file $BOOTSTRAP_SQL;
2931
SET SESSION debug= '+d,skip_dd_table_access_check';
@@ -33,31 +35,33 @@ write_file $BOOTSTRAP_SQL;
3335
EOF
3436

3537
--echo # 1.2 First start the server with --initialize, and update the version.
36-
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
38+
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
3739

3840
--echo # 1.3 Restart the server against DDIR - should fail.
3941
--error 1
40-
--exec $MYSQLD $extra_args --datadir=$DDIR
42+
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --datadir=$DDIR
4143

4244
--echo # 1.4 Look for error.
4345
perl;
4446
use strict;
45-
my $log= $ENV{'MYSQLD_LOG'} or die;
47+
my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
4648
open(FILE, "$log") or die;
4749
my $c_w= grep(/No data dictionary version number found./gi,<FILE>);
4850
print "# Data Dictionary initialization error found $c_w times.\n";
4951
close(FILE);
5052
EOF
5153

52-
--echo # 1.5 Delete bootstrap file, log file and datadir.
54+
--echo # 1.5 Delete bootstrap file and datadir.
5355
remove_file $BOOTSTRAP_SQL;
54-
remove_file $MYSQLD_LOG;
5556
--force-rmdir $DDIR
5657

5758
--echo #
5859
--echo # 2. Try restart after dropping the properties table.
5960
--echo # ---------------------------------------------------
6061

62+
let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_2.log;
63+
let ENV_MYSQLD_LOG= $MYSQLD_LOG;
64+
6165
--echo # 2.1 Create bootstrap file.
6266
write_file $BOOTSTRAP_SQL;
6367
CREATE SCHEMA test;
@@ -68,27 +72,29 @@ EOF
6872

6973
--echo # 2.2 First start the server with --initialize, and drop the properties table. Should fail.
7074
--error 1
71-
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
75+
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
7276

7377
--echo # 2.3 Look for error.
7478
perl;
7579
use strict;
76-
my $log= $ENV{'MYSQLD_LOG'} or die;
80+
my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
7781
open(FILE, "$log") or die;
7882
my $c_w= grep(/The used command is not allowed with this MySQL version/gi,<FILE>);
7983
print "# Data Dictionary initialization error found $c_w times.\n";
8084
close(FILE);
8185
EOF
8286

83-
--echo # 2.4 Delete bootstrap file, log file and datadir.
87+
--echo # 2.4 Delete bootstrap file and datadir.
8488
remove_file $BOOTSTRAP_SQL;
85-
remove_file $MYSQLD_LOG;
8689
--force-rmdir $DDIR
8790

8891
--echo #
8992
--echo # 3. Try restart after dropping the tables table.
9093
--echo # -----------------------------------------------
9194

95+
let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_3.log;
96+
let ENV_MYSQLD_LOG= $MYSQLD_LOG;
97+
9298
--echo # 3.1 Create bootstrap file.
9399
write_file $BOOTSTRAP_SQL;
94100
CREATE SCHEMA test;
@@ -100,27 +106,29 @@ EOF
100106

101107
--echo # 3.2 First start the server with --initialize, and drop the tables table: Should fail.
102108
--error 1
103-
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
109+
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
104110

105111
--echo # 3.3 Look for error.
106112
perl;
107113
use strict;
108-
my $log= $ENV{'MYSQLD_LOG'} or die;
114+
my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
109115
open(FILE, "$log") or die;
110116
my $c_w= grep(/The used command is not allowed with this MySQL version/gi,<FILE>);
111117
print "# Data Dictionary initialization error found $c_w times.\n";
112118
close(FILE);
113119
EOF
114120

115-
--echo # 3.4 Delete bootstrap file, log file and datadir.
121+
--echo # 3.4 Delete bootstrap file and datadir.
116122
remove_file $BOOTSTRAP_SQL;
117-
remove_file $MYSQLD_LOG;
118123
--force-rmdir $DDIR
119124

120125
--echo #
121126
--echo # 4. Try restart after altering the schemata table.
122127
--echo # -------------------------------------------------
123128

129+
let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_4.log;
130+
let ENV_MYSQLD_LOG= $MYSQLD_LOG;
131+
124132
--echo # 4.1 Create bootstrap file.
125133
write_file $BOOTSTRAP_SQL;
126134
CREATE SCHEMA test;
@@ -130,7 +138,7 @@ write_file $BOOTSTRAP_SQL;
130138
EOF
131139

132140
--echo # 4.2 First start the server with --initialize, and alter the schemata table.
133-
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
141+
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
134142

135143
--echo # 4.3 Restart the server against DDIR.
136144
--exec echo "restart: --datadir=$DDIR --no-console --log-error=$MYSQLD_LOG" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
@@ -157,54 +165,58 @@ SET SESSION debug= '-d,skip_dd_table_access_check';
157165
connection default;
158166
disconnect root_con;
159167

160-
--echo # 4.8 Delete bootstrap file, log file and datadir.
168+
--echo # 4.8 Delete bootstrap file and datadir.
161169
remove_file $BOOTSTRAP_SQL;
162-
remove_file $MYSQLD_LOG;
163170
--force-rmdir $DDIR
164171

165172
--echo #
166173
--echo # 5. Try to access a DD table in an init-file during --initialize.
167174
--echo # ----------------------------------------------------------------
168175

176+
let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_5.log;
177+
let ENV_MYSQLD_LOG= $MYSQLD_LOG;
178+
169179
--echo # 5.1 Create bootstrap file.
170180
write_file $BOOTSTRAP_SQL;
171181
SELECT * FROM mysql.st_spatial_reference_systems;
172182
EOF
173183

174184
--echo # 5.2 First start the server with --initialize, and submit the init file.
175185
--error 1
176-
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL;
186+
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL
177187

178188
--echo # 5.3 Look for error.
179189
perl;
180190
use strict;
181-
my $log= $ENV{'MYSQLD_LOG'} or die;
191+
my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
182192
open(FILE, "$log") or die;
183193
my $c_w= grep(/Access to data dictionary table \'mysql.st_spatial_reference_systems\' is rejected/gi,<FILE>);
184194
print "# Data Dictionary table access error found $c_w times.\n";
185195
close(FILE);
186196
EOF
187197

188-
--echo # 5.4 Delete bootstrap file, log file and datadir.
198+
--echo # 5.4 Delete bootstrap file and datadir.
189199
remove_file $BOOTSTRAP_SQL;
190-
remove_file $MYSQLD_LOG;
191200
--force-rmdir $DDIR
192201

193202
--echo #
194203
--echo # 6. Try to access a DD table in an init-file during plain restart.
195204
--echo # -----------------------------------------------------------------
196205

206+
let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_6.log;
207+
let ENV_MYSQLD_LOG= $MYSQLD_LOG;
208+
197209
--echo # 6.1 Create bootstrap file.
198210
write_file $BOOTSTRAP_SQL;
199211
CREATE SCHEMA test;
200212
SELECT * FROM mysql.tables;
201213
EOF
202214

203215
--echo # 6.2 First start the server with --initialize.
204-
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR
216+
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR
205217

206218
--echo # 6.3 Restart the server against DDIR with an init-file.
207-
--exec echo "restart: --datadir=$DDIR --no-console --log-error=$MYSQLD_LOG" --init-file=$BOOTSTRAP_SQL > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
219+
--exec echo "restart: --datadir=$DDIR --no-console --log-error=$MYSQLD_LOG --init-file=$BOOTSTRAP_SQL" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
208220
--enable_reconnect
209221
--source include/wait_until_connected_again.inc
210222

@@ -216,16 +228,15 @@ EOF
216228
--echo # 6.5 Look for error.
217229
perl;
218230
use strict;
219-
my $log= $ENV{'MYSQLD_LOG'} or die;
231+
my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
220232
open(FILE, "$log") or die;
221233
my $c_w= grep(/Access to data dictionary table \'mysql.tables\' is rejected/gi,<FILE>);
222234
print "# Data Dictionary initialization error found $c_w times.\n";
223235
close(FILE);
224236
EOF
225237

226-
--echo # 6.6 Delete bootstrap file, log file and datadir.
238+
--echo # 6.6 Delete bootstrap file and datadir.
227239
remove_file $BOOTSTRAP_SQL;
228-
remove_file $MYSQLD_LOG;
229240
--force-rmdir $DDIR
230241

231242
--echo #

0 commit comments

Comments
 (0)