File: check_auto_permission.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (58 lines) | stat: -rw-r--r-- 1,991 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#############################################################################
# Bug#17786581:SERVER WRITES INTO WORLD-WRITEABLE FILE EVEN AFTER WARNING ABOUT
# IT.
#
# Problem:
# ========
# UUID exists in a file named "auto.cnf", make this auto.cnf  file as world
# writable. The server starts, and it sees the auto.cnf is world writable and
# writes a following warning:
#
# Warning: World-writable con-fig file './auto.cnf' is ignored
#
# A new UUID is generated and the new UUID is once again  written to the same
# world writable file which is not safe.
#
# Test:
# =====
# During the execution of the script change file permissions of 'auto.cnf' to
# 777. Restart the server and check that the newly generated 'auto.cnf' file
# has valid 660 file permissions.
###############################################################################
# Run only on Linux:Since file permissions vary from one os to the other
# we execute this script only on linux to avoid test failures.
--source include/linux.inc

CALL mtr.add_suppression("World-writable config file .* is ignored");
CALL mtr.add_suppression("World-writable config file .* has been removed.");

# Change file permissions to world writable
--let $MYSQL_DATA_DIR=`select @@datadir`
--let _INPUT_FILE_=$MYSQL_DATA_DIR/auto.cnf
--let _FILE_PERMS_=0777
--source include/change_file_perms.inc

# Restart the server
--source include/restart_mysqld.inc

# Check that it has 660 valid permissions.
--perl
 use strict;
 my $input_file= $ENV{'_INPUT_FILE_'};
 my $mode = (stat($input_file))[2];
 open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/permissions.inc") or die;
 my $perm= $mode & 07777;
 print FILE "let \$FILE_PERMISSIONS= $perm;\n";
 close FILE;
EOF

--source $MYSQL_TMP_DIR/permissions.inc
--remove_file $MYSQL_TMP_DIR/permissions.inc

--let $assert_cond= $FILE_PERMISSIONS= 432
--let $assert_text= File permissions should be equl to decimal 432(i.e octal 660).
--source include/assert.inc

# Clear
--let _FILE_PERMS_=
--let _INPUT_FILE_=