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
parent a21b899b
-- 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 (); ...@@ -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 () { ...@@ -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 () { ...@@ -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 () {
......
# 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
......
# 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment