Page MenuHomePhabricator

UploadedFileStreamTest::testConstruct_notReadable failed when run as root
Open, Needs TriagePublic

Description

	/**
	 * @expectedException RuntimeException
	 * @expectedExceptionMessage Failed to open file:
	 */
	public function testConstruct_notReadable() {
		$filename = $this->makeTemp( __FUNCTION__ );
		chmod( $filename, 0000 );
		$stream = new UploadedFileStream( $filename );
	}

When I run phpunit test as root

1) Wikimedia\ParamValidator\Util\UploadedFileStreamTest::testConstruct_notReadable
Failed asserting that exception of type "RuntimeException" is thrown.

/root/mediawiki-core/maintenance/doMaintenance.php:99

That means the script that run as root can read the file even the file mode is 0000. Example:

$filename = 'test.txt';
file_put_contents($filename, '');
chmod($filename, 0000);
var_dump(is_readable($filename)); // bool (true)
unlink($filename);

Event Timeline

RazeSoldier renamed this task from Skip UploadedFileStreamTest::testConstruct_notReadable when run as root to UploadedFileStreamTest::testConstruct_notReadable failed when run as root.Jul 11 2019, 4:18 PM

Change #1183219 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Skip UploadedFileStreamTest::testConstruct_notReadable when run as root

https://gerrit.wikimedia.org/r/1183219