mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#17002 mysql-test-run as root user
- Add test to see if tests are running with root permissions - Disables tests that uses chmod if that is the case
This commit is contained in:
4
mysql-test/include/not_as_root.inc
Normal file
4
mysql-test/include/not_as_root.inc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
-- require r/not_as_root.require
|
||||||
|
disable_query_log;
|
||||||
|
select $MYSQL_TEST_ROOT as running_as_root;
|
||||||
|
enable_query_log;
|
@ -338,6 +338,7 @@ sub environment_setup ();
|
|||||||
sub kill_running_server ();
|
sub kill_running_server ();
|
||||||
sub kill_and_cleanup ();
|
sub kill_and_cleanup ();
|
||||||
sub check_ssl_support ();
|
sub check_ssl_support ();
|
||||||
|
sub check_running_as_root();
|
||||||
sub check_ndbcluster_support ();
|
sub check_ndbcluster_support ();
|
||||||
sub ndbcluster_install ();
|
sub ndbcluster_install ();
|
||||||
sub ndbcluster_start ($);
|
sub ndbcluster_start ($);
|
||||||
@ -376,6 +377,7 @@ sub main () {
|
|||||||
|
|
||||||
check_ndbcluster_support();
|
check_ndbcluster_support();
|
||||||
check_ssl_support();
|
check_ssl_support();
|
||||||
|
check_running_as_root();
|
||||||
|
|
||||||
environment_setup();
|
environment_setup();
|
||||||
signal_setup();
|
signal_setup();
|
||||||
@ -1337,6 +1339,33 @@ sub kill_and_cleanup () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub check_running_as_root () {
|
||||||
|
# Check if running as root
|
||||||
|
# i.e a file can be read regardless what mode we set it to
|
||||||
|
my $test_file= "test_running_as_root.txt";
|
||||||
|
mtr_tofile($test_file, "MySQL");
|
||||||
|
chmod(oct("0000"), $test_file);
|
||||||
|
|
||||||
|
my $result="";
|
||||||
|
if (open(FILE,"<",$test_file))
|
||||||
|
{
|
||||||
|
$result= join('', <FILE>);
|
||||||
|
close FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
chmod(oct("0755"), $test_file);
|
||||||
|
unlink($test_file);
|
||||||
|
|
||||||
|
$ENV{'MYSQL_TEST_ROOT'}= "NO";
|
||||||
|
if ($result eq "MySQL")
|
||||||
|
{
|
||||||
|
mtr_warning("running this script as _root_ will cause some " .
|
||||||
|
"tests to be skipped");
|
||||||
|
$ENV{'MYSQL_TEST_ROOT'}= "YES";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub check_ssl_support () {
|
sub check_ssl_support () {
|
||||||
|
|
||||||
|
2
mysql-test/r/not_as_root.require
Normal file
2
mysql-test/r/not_as_root.require
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
running_as_root
|
||||||
|
NO
|
@ -1,6 +1,9 @@
|
|||||||
# This test uses grants, which can't get tested for embedded server
|
# This test uses grants, which can't get tested for embedded server
|
||||||
-- source include/not_embedded.inc
|
-- source include/not_embedded.inc
|
||||||
|
|
||||||
|
# This test uses chmod, can't be run with root permissions
|
||||||
|
-- source include/not_as_root.inc
|
||||||
|
|
||||||
# Test for information_schema.schemata &
|
# Test for information_schema.schemata &
|
||||||
# show databases
|
# show databases
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# This test uses chmod, can't be run with root permissions
|
||||||
|
-- source include/not_as_root.inc
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test is run with max_binlog_size=2048 to force automatic rotation of the
|
# Test is run with max_binlog_size=2048 to force automatic rotation of the
|
||||||
# binary log
|
# binary log
|
||||||
|
Reference in New Issue
Block a user