Bug #51271 Compiling MySQL 5.1.43 make test "information_schema_chmod" failed as root
Submitted: 18 Feb 2010 7:01 Modified: 5 May 2011 9:47
Reporter: Boa Thor Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Tests: Server Severity:S3 (Non-critical)
Version:5.1.43, 5.1.45-bzr OS:Any
Assigned to: Joerg Bruehe CPU Architecture:Any
Tags: information_schema_chmod, Result length mismatch, root

[18 Feb 2010 7:01] Boa Thor
Description:
Everything works fine until the test "information_schema_chmod" crashes when using a super user (root) to make test (which I and many other people do).

###############################################################################
root@115v:/app/mysql-build/mysql-5.1.43/mysql-test # ./mtr information_schema_chmod
Logging: ./mtr information_schema_chmod
100218  7:48:58 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

100218  7:48:58 [ERROR] Aborting

MySQL Version 5.1.43
Checking supported features...
 - skipping ndbcluster, mysqld not compiled with ndbcluster
 - skipping SSL, mysqld not compiled with SSL
Collecting tests...
vardir: /app/mysql-build/mysql-5.1.43/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/app/mysql-build/mysql-5.1.43/mysql-test/var'...
Installing system database...
Using server port 44588

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
worker[1] mysql-test-run: WARNING: running this script as _root_ will cause some tests to be skipped
main.information_schema_chmod            [ fail ]
        Test ended at 2010-02-18 07:48:59

CURRENT_TEST: main.information_schema_chmod
--- /app/mysql-build/mysql-5.1.43/mysql-test/r/information_schema_chmod.result    2010-01-15 20:46:44.000000000 +0300
+++ /app/mysql-build/mysql-5.1.43/mysql-test/r/information_schema_chmod.reject    2010-02-18 09:48:59.000000000 +0300
@@ -2,4 +2,5 @@
 create table mysqltest.t1(a int);
 select table_schema from information_schema.tables where table_schema='mysqltest';
 table_schema
+mysqltest
 drop database mysqltest;

mysqltest: Result length mismatch

 - saving '/app/mysql-build/mysql-5.1.43/mysql-test/var/log/main.information_schema_chmod/' to '/app/mysql-build/mysql-5.1.43/mysql-test/var/log/main.information_schema_chmod/'
------------------------------------------------------------
The servers were restarted 0 times
Spent 0.000 of 1 seconds executing testcases

Failed 1/1 tests, 0.00% were successful.

Failing test(s): main.information_schema_chmod

The log files in var/log may give you some hint of what went wrong.

If you want to report this error, please read first the documentation
at http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html

mysql-test-run: *** ERROR: there were failing test cases
###############################################################################

How to repeat:
Compiling MySQL Src from SRC-RPM x64 on Debian 5.04 x64 or Suse 10.3 using the super user.

su - 
./configure --prefix=...
make
make test

Suggested fix:
Skip or ignore the test, when making tests as a super user.
[19 Feb 2010 11:03] Valeriy Kravchuk
I've easily reproduced this bug. Actually, one should NEVER compile or run make or make test as root, only make install (after all tests passed). 

But as this is NOT clearly documented at http://dev.mysql.com/doc/refman/5.1/en/mysql-test-suite.html and mtr does NOT complain clearly (it says only about security implications of running mysqld as root), I'd still say that there is something to fix here. Either test should be skipped or it should work correctly.
[5 May 2011 9:47] Joerg Bruehe
Sorry, I cannot reproduce this:
When running the test using root privileges, it is skipped.

This is what it looks like for me:
=====
PROMPT> sudo ./mysql-test-run.pl information_schema_chmod
Logging: ./mysql-test-run.pl  information_schema_chmod
110505 11:21:55 [Note] Plugin 'FEDERATED' is disabled.
110505 11:21:55 [Note] Plugin 'ndbcluster' is disabled.
MySQL Version 5.1.58
Checking supported features...
 - skipping ndbcluster
 - SSL connections supported
Collecting tests...
vardir: /MySQL/REPO/V51/work-5.1/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/MySQL/REPO/V51/work-5.1/mysql-test/var'...
Installing system database...
Using server port 41596
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] mysql-test-run: WARNING: running this script as _root_ will cause some tests to be skipped
main.information_schema_chmod            [ skipped ]  Not as root
------------------------------------------------------------
The servers were restarted 0 times
Spent 0.000 of 6 seconds executing testcases

Completed: All 0 tests were successful.
=====

Checking the test source, it looks ok:
=====
PROMPT> cat t/information_schema_chmod.test
#
# Due to "Bug#18474  Unlistable directories yield no info from
...

# This test uses chmod, can't be run with root permissions
-- source include/not_as_root.inc
...
=====

Checking the test history using BZR, I see that this protection was added to the test in early 2006, still in MySQL 5.0, so it should have been present in all 5.1 versions.

The included file implementing the check, "include/not_as_root.inc", is unchanged since August, 2008.
The necessary infrastructure for this check, function "check_running_as_root()" in the Perl script "mysql-test-run.pl", is unchanged even since May, 2006.

So I don't see how this test could (in recent years) have been attempted when the suite is being run with root privileges.
I set this report to "Cannot repeat", and there is no need to document a non-change.

That said, all the usual warnings about (not) doing normal work when having root privileges apply to building, testing, and running MySQL like they do for any other work.
I do not consider it necessary to add a specific warning against this to the manual, it should be evident for every developer or tester.

In the specific case of building RPMs, for me it works well to set up my environment such that I can do the build (and the test) using ordinary user privileges, and I strongly recommend to the bug reporter to do the same.

The RPM documentation has information how to do that.