]> granicus.if.org Git - php/commitdiff
Better check for root user
authorRaghubansh Kumar <kraghuba@php.net>
Fri, 6 Jul 2007 03:24:27 +0000 (03:24 +0000)
committerRaghubansh Kumar <kraghuba@php.net>
Fri, 6 Jul 2007 03:24:27 +0000 (03:24 +0000)
ext/standard/tests/file/006_basic.phpt
ext/standard/tests/file/006_variation1.phpt
ext/standard/tests/file/006_variation2.phpt

index 50bf26e6678cfa16c6362fefcefbe2590d1f7ff0..eeb07fbc01fc66451b33bb7470935140e1c05eb8 100644 (file)
@@ -5,9 +5,17 @@ Test fileperms() & chmod() functions: basic functionality
 if (substr(PHP_OS, 0, 3) == 'WIN') {
  die('skip Not on Windows');
 }
-elseif (get_current_user() == 'root') {
- die("skip Do not run with root permissions");
+// Skip if being run by root
+$filename = dirname(__FILE__)."/006_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);
+
 ?>
 --FILE--
 <?php
index 937dfb12ceac6c01523627e014ea3f9d6f29c618..c7c6c114e1611c8cf8a919167977b6189b7791cc 100644 (file)
@@ -5,9 +5,17 @@ Test fileperms() & chmod() functions: usage variation - perms(0000-0777)
 if (substr(PHP_OS, 0, 3) == 'WIN') {
     die('skip Not on Windows');
 }
-elseif (get_current_user() == 'root') {
- die( "skip Do not run with root permissions" );
+// Skip if being run by root
+$filename = dirname(__FILE__)."/006_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);
+
 ?>
 --FILE--
 <?php
index 8a70c8efba4e6520fbfebfe88ac2342ff3c10ab8..5e029b2cc806ef80b4ca40d705ef551c4431a5c3 100644 (file)
@@ -5,9 +5,17 @@ Test fileperms() & chmod() functions: usage variation - misc. perms
 if (substr(PHP_OS, 0, 3) == 'WIN') {
     die('skip Not on Windows');
 }
-elseif (get_current_user() == 'root') {
- die( "skip Do not run with root permissions" );
+// Skip if being run by root
+$filename = dirname(__FILE__)."/006_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);
+
 ?>
 --FILE--
 <?php