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

index f7da0e8c9489591613c1e703975d3feb59d3c80a..b4eee97d374665423caaee9ea88489da87cbe335 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 5418a2d08c38bb2b2abb613dc41ffd9188049b3c..5162181bf7e5e8a9e67fa9e16a8c1f533b253448 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 024436282d77bd90f54a9c614475005dd46a0704..e224be2b1fbb20a201825b72e7b2b94899dc79b9 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