@@ -5,17 +5,39 @@ CREATE TABLE t1 (c1 VARCHAR(50));
5
5
INSERT INTO t1 VALUES ("one"),("two"),("three"),("four"),("five");
6
6
SHOW VARIABLES LIKE 'secure_file_priv';
7
7
--disable_query_log
8
+
8
9
# Atempt to create a file where we normally aren't allowed to create one.
10
+ #
9
11
# Doing this in a portable manner is difficult but we should be able to
10
- # count on the depth of the directory hierarchy used. Three steps up from
11
- # the datadir is the 'mysql_test' directory.
12
- --let $PROTECTED_FILE=`SELECT concat(@@datadir,'/../../../bug50373.txt')`
13
- --eval SELECT * FROM t1 INTO OUTFILE '$PROTECTED_FILE';
14
- DELETE FROM t1;
15
- --eval LOAD DATA INFILE '$PROTECTED_FILE' INTO TABLE t1;
16
- SELECT * FROM t1;
17
- --eval SELECT load_file('$PROTECTED_FILE') AS loaded_file;
12
+ # count on the directory hierarchy used. A step up from MYSQLTEST_VARDIR
13
+ # should definitely lead us to a "protected" directory,
14
+ # but at the same time should still be writable since MTR was able
15
+ # to create the vardir itself there.
16
+ # If we run tests normally, it will be mysql-test directory.
17
+ # If we run tests with --mem, it will be /dev/shm.
18
+ # If we run tests with --parallel, it will be mysql-test/var
19
+ # (because MYSQLTEST_VARDIR in this case is mysql-test/var/N).
20
+
21
+ --perl
22
+ use File::Basename;
23
+ my $protected_file= dirname($ENV{MYSQLTEST_VARDIR}).'/bug50373.txt';
24
+ open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/bug50373.inc") or die;
25
+ print FILE "SELECT * FROM t1 INTO OUTFILE '".$protected_file."';\n";
26
+ print FILE "DELETE FROM t1;\n";
27
+ print FILE "LOAD DATA INFILE '".$protected_file."' INTO TABLE t1;\n";
28
+ print FILE "SELECT * FROM t1;\n";
29
+ print FILE "SELECT load_file('",$protected_file,"') AS loaded_file;\n";
30
+ close(FILE);
31
+ EOF
32
+
33
+ --source $MYSQL_TMP_DIR/bug50373.inc
34
+ --remove_file $MYSQL_TMP_DIR/bug50373.inc
18
35
--enable_query_log
19
- remove_file $PROTECTED_FILE;
36
+
20
37
DROP TABLE t1;
21
38
39
+ --perl
40
+ use File::Basename;
41
+ unlink dirname($ENV{MYSQLTEST_VARDIR}).'/bug50373.txt';
42
+ EOF
43
+
0 commit comments