~ubuntu-branches/ubuntu/utopic/mysql-5.6/utopic-proposed

1.1.3 by James Page
Import upstream version 5.6.19
1
#############################################################################
2
# Bug#17786581:SERVER WRITES INTO WORLD-WRITEABLE FILE EVEN AFTER WARNING ABOUT
3
# IT.
4
#
5
# Problem:
6
# ========
7
# UUID exists in a file named "auto.cnf", make this auto.cnf  file as world
8
# writable. The server starts, and it sees the auto.cnf is world writable and
9
# writes a following warning:
10
#
11
# Warning: World-writable con-fig file './auto.cnf' is ignored
12
#
13
# A new UUID is generated and the new UUID is once again  written to the same
14
# world writable file which is not safe.
15
#
16
# Test:
17
# =====
18
# During the execution of the script change file permissions of 'auto.cnf' to
19
# 777. Restart the server and check that the newly generated 'auto.cnf' file
20
# has valid 660 file permissions.
21
###############################################################################
22
# Run only on Linux:Since file permissions vary from one os to the other
23
# we execute this script only on linux to avoid test failures.
24
--source include/linux.inc
25
# include/restart_mysqld.inc does not work in embedded mode
26
--source include/not_embedded.inc
27
28
CALL mtr.add_suppression("World-writable config file './auto.cnf' is ignored");
29
CALL mtr.add_suppression("World-writable config file './auto.cnf' has been removed.");
30
31
# Change file permissions to world writable
32
--let $MYSQL_DATA_DIR=`select @@datadir`
33
--let _INPUT_FILE_=$MYSQL_DATA_DIR/auto.cnf
34
--let _FILE_PERMS_=0777
35
--source include/change_file_perms.inc
36
37
# Restart the server
38
--source include/restart_mysqld.inc
39
40
# Check that it has 660 valid permissions.
41
--perl
42
 use strict;
43
 my $input_file= $ENV{'_INPUT_FILE_'};
44
 my $mode = (stat($input_file))[2];
45
 open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/permissions.inc") or die;
46
 my $perm= $mode & 07777;
47
 print FILE "let \$FILE_PERMISSIONS= $perm;\n";
48
 close FILE;
49
EOF
50
51
--source $MYSQL_TMP_DIR/permissions.inc
52
--remove_file $MYSQL_TMP_DIR/permissions.inc
53
54
--let $assert_cond= $FILE_PERMISSIONS= 432
55
--let $assert_text= File permissions should be equl to decimal 432(i.e octal 660).
56
--source include/assert.inc
57
58
# Clear
59
--let _FILE_PERMS_=
60
--let _INPUT_FILE_=