mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

There's a test that tries to make /etc world-writable, and asserts that it fails. Although this test is guarded by a root user check, there are situations where you don't need to be root to be able to do this. This may thus have unwanted effects on your live filesystem. The simple solution is to remove that part of the test. It doesn't really add value anyway: we're trying to test the chmod error path, but that exact same error path can be reached with any failure condition that the kernel gives. For example, trying to chmod a non-existent file will trigger the same code path. While at it, also prefix the test path for the non-existent file such that we don't accidentally modify the filesystem. The chroot now has a better root-user check, that will not modify the filesystem. Other root-modifying mkdir tests were removed because they added no value either. Closes GH-13566.
31 lines
689 B
PHP
31 lines
689 B
PHP
--TEST--
|
|
Test fileperms(), chmod() functions: error conditions
|
|
--SKIPIF--
|
|
<?php
|
|
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
|
die('skip Not on Windows');
|
|
}
|
|
require __DIR__ . '/../skipif_root.inc';
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
echo "*** Testing error conditions for fileperms(), chmod() ***\n";
|
|
|
|
/* With non-existing file or dir */
|
|
var_dump( chmod(__DIR__ . "/no/such/file/dir", 0777) );
|
|
var_dump( fileperms(__DIR__ . "/no/such/file/dir") );
|
|
echo "\n";
|
|
|
|
echo "\n*** Done ***\n";
|
|
?>
|
|
--EXPECTF--
|
|
*** Testing error conditions for fileperms(), chmod() ***
|
|
|
|
Warning: chmod(): %s in %s on line %d
|
|
bool(false)
|
|
|
|
Warning: fileperms(): stat failed for %s/no/such/file/dir in %s on line %d
|
|
bool(false)
|
|
|
|
|
|
*** Done ***
|