Req #72600 [NEW]: Consider root special perms with stream_wrapper

From: Date: Fri, 15 Jul 2016 06:41:03 +0000
Subject: Req #72600 [NEW]: Consider root special perms with stream_wrapper
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202340@lists.php.net to get a copy of this message
From: w1s2j3229 at 163 dot com Operating system: Linux PHP version: Irrelevant Package: *Directory/Filesystem functions Bug Type: Feature/Change Request Bug description:Consider root special perms with stream_wrapper Description: ------------ I found the problem when calling is_writable() after stream_wrapper_register(). It is OK with non-root user, but the result is not as expected with root user. I want to remain the same permission as no stream_wrapper so I return just what "stat()" returns in "url_stat()" with my stream_wrapper class. However, in the filestat.c source code, it does special check to root user( getuid() == 0) only with php_plain_files_wrapper. So I got false while calling is_writable after stream_wrapper_register(). I wonder if it is possible to add a function "is_super_user" in the stream_wrapper, and call it while calling permission check functions such as is_readable, is_writable and is_executable in case to keep consistent with system root user where needed. Test script: --------------- class TestStream{ public static function wrap() { stream_wrapper_unregister('file'); stream_wrapper_register('file', get_called_class()); } public static function unwrap(){ stream_wrapper_restore('file'); } public function url_stat($path, $flags){ $this->unwrap(); $result = stat($path); $this->wrap(); return $result; } } $file = __DIR__."/tmp"; @mkdir($file, 0777, true); chmod($file, 0); clearstatcache(); var_dump(is_writable($file)); clearstatcache(); TestStream::wrap(); var_dump(is_writable($file)); TestStream::unwrap(); chmod($file, 0777); rmdir($file); Expected result: ---------------- bool(true) bool(true) Actual result: -------------- bool(true) bool(false) -- Edit bug report at https://bugs.php.net/bug.php?id=72600&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72600&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72600&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72600&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72600&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72600&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72600&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72600&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72600&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72600&r=support Expected behavior: https://bugs.php.net/fix.php?id=72600&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72600&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72600&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72600&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72600&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72600&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72600&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72600&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72600&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72600&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72600&r=mysqlcfg

« previous php.bugs (#202340) next »