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)');
}
$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
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
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--
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
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
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
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
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
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
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
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
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
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
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
<?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
<?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
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
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
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
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
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
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
Test is_readable() function: usage variations - invalid file names
--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_variation3_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
Test is_writable() and its alias is_writeable() function: basic functionality
--SKIPIF--
<?php
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/is_writable_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
Test is_writable() and its alias is_writeable() function: usage variations - diff. path 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_writable_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
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. only on LINUX');
}
-// Skip if being run by root
-$filename = __DIR__."/is_writable_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
Test is_writable() and its alias is_writeable() function: usage variations - invalid file names
--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_writable_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
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
if (!function_exists("posix_getuid")) die("skip no posix_getuid()");
-// Skip if being run by root
-$filename = __DIR__."/lchow_error_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
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. only on LINUX');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/mkdir_rmdir_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
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. only on LINUX');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/mkdir_rmdir_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
if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
die('skip no symlinks on Windows');
}
-
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/symlink_link_linkinfo_is_link6_check_root.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
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not valid for Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/tempnam_variation4-0_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
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not valid for Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/tempnam_variation4-1_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
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip only on Linux');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/unlink_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
--- /dev/null
+<?php
+
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = @tempnam(__DIR__, 'root_check_');
+if (!file_exists($filename)) {
+ die('WARN Unable to create the "root check" file');
+}
+
+$isRoot = fileowner($filename) == 0;
+
+unlink($filename);
+
+if ($isRoot) {
+ die('SKIP Cannot be run as root');
+}
+