Skip to content

Avoid file clash in root_check skipifs #4779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions ext/sockets/tests/socket_create_listen-nobind.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ Test if socket_create_listen() returns false, when it cannot bind to the port.
if (!extension_loaded('sockets')) {
die('SKIP The sockets extension is not loaded.');
}
$filename = __DIR__ . '/006_root_check.tmp';
$filename = __FILE__ . '.root_check.tmp';
$fp = fopen($filename, 'w');
fclose($fp);
if (fileowner($filename) == 0) {
unlink ($filename);
unlink($filename);
die('SKIP Test cannot be run as root.');
}
unlink($filename);
if (@socket_create_listen(80)) {
die('SKIP Test cannot be run in environment that will allow binding to port 80 (azure)');
}
Expand All @@ -20,9 +21,6 @@ if (@socket_create_listen(80)) {
$sock = socket_create_listen(80);
--EXPECTF--
Warning: socket_create_listen(): unable to bind to given address [13]: Permission denied in %s on line %d
--CLEAN--
<?php
unlink(__DIR__ . '/006_root_check.tmp');
--CREDITS--
Till Klampaeckel, till@php.net
PHP Testfest Berlin 2009-05-09
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ if (!extension_loaded('sockets')) {
if (PHP_OS == 'Darwin') {
die('skip Not for OSX');
}
$filename = __DIR__ . '/006_root_check.tmp';
$filename = __FILE__ . '.root_check.tmp';
$fp = fopen($filename, 'w');
fclose($fp);
if (fileowner($filename) == 0) {
unlink ($filename);
unlink($filename);
die('SKIP Test cannot be run as root.');
}
unlink($filename);
?>
--FILE--
<?php
Expand All @@ -26,9 +27,6 @@ if (!$socket) {
socket_set_option( $socket, SOL_SOCKET, 1, 1);
socket_close($socket);
?>
--CLEAN--
<?php
unlink(__DIR__ . '/006_root_check.tmp');
--EXPECTF--
Warning: socket_set_option(): unable to set socket option [%d]: Permission denied in %s on line %d
--CREDITS--
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/dir/dir_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test dir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/dir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/dir/dir_variation7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test dir() function : usage variations - directories with restricted permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/dir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/dir/opendir_variation5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test opendir() function : usage variations - directories with restricted permiss
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/dir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/dir/opendir_variation7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test opendir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__ . "/opendir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/dir/readdir_variation5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test readdir() function : usage variations - different permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/readdir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/dir/scandir_variation5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test scandir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/dir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/dir/scandir_variation7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test scandir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__ . "/dir_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip...cannot be run as root\n');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
12 changes: 1 addition & 11 deletions ext/standard/tests/file/006_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ Test fileperms() & chmod() functions: basic functionality
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
// Skip if being run by root
$filename = __DIR__."/006_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);

require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
12 changes: 1 addition & 11 deletions ext/standard/tests/file/006_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ Test fileperms(), chmod() functions: error conditions
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
// Skip if being run by root
$filename = __DIR__."/006_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);

require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
12 changes: 1 addition & 11 deletions ext/standard/tests/file/006_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ Test fileperms() & chmod() functions: usage variation - perms(0000-0777)
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
// Skip if being run by root
$filename = __DIR__."/006_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);

require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
12 changes: 1 addition & 11 deletions ext/standard/tests/file/006_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ Test fileperms() & chmod() functions: usage variation - misc. perms
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
// Skip if being run by root
$filename = __DIR__."/006_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);

require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/file/copy_variation15.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ Test copy() function: usage variations - destination dir access perms
<?php
if(substr(PHP_OS, 0, 3) == 'WIN')
die("skip do not run on Windows");
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/copy_variation15_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
11 changes: 1 addition & 10 deletions ext/standard/tests/file/copy_variation9.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@ Test copy() function: usage variations - destination file access perms
<?php
if(substr(PHP_OS, 0, 3) == 'WIN')
die("skip do not run on Windows");

// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/copy_variation9_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
11 changes: 1 addition & 10 deletions ext/standard/tests/file/is_executable_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ Test is_executable() function: basic functionality
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/is_executable_basic_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
11 changes: 1 addition & 10 deletions ext/standard/tests/file/is_executable_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ Test is_executable() function: usage variations - file/dir with diff. perms
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
// Skip if being run by root
$filename = __DIR__."/is_executable_variation2_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
11 changes: 1 addition & 10 deletions ext/standard/tests/file/is_executable_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ Test is_executable() function: usage variations - invalid file names
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/is_executable_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
11 changes: 1 addition & 10 deletions ext/standard/tests/file/is_readable_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ Test is_readable() function: basic functionality
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/is_readable_basic_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}

unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
12 changes: 1 addition & 11 deletions ext/standard/tests/file/is_readable_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
Test is_readable() function: usage variations - diff. file notations
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') {
// Skip if being run by root (files are always readable, writeable and executable)
$filename = __DIR__."/is_readable_variation1_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}
unlink($filename);
}
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
10 changes: 1 addition & 9 deletions ext/standard/tests/file/is_readable_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ Test is_readable() function: usage variations - file/dir with diff. perms
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
// Skip if being run by root
$filename = __DIR__."/is_readable_variation2_root_check.tmp";
$fp = fopen($filename, 'w');
fclose($fp);
if(fileowner($filename) == 0) {
unlink ($filename);
die('skip cannot be run as root');
}
unlink($filename);
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
Expand Down
Loading