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

From: Date: Fri, 15 Jul 2016 06:55:06 +0000
Subject: Req #72600 [Opn]: Consider root special perms with stream_wrapper
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202341@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72600&edit=1 ID: 72600 User updated by: w1s2j3229 at 163 dot com Reported by: w1s2j3229 at 163 dot com Summary: Consider root special perms with stream_wrapper Status: Open Type: Feature/Change Request Package: *Directory/Filesystem functions Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Test script must run as root user Previous Comments: ------------------------------------------------------------------------ [2016-07-15 06:40:51] w1s2j3229 at 163 dot com 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 this bug report at https://bugs.php.net/bug.php?id=72600&edit=1

« previous php.bugs (#202341) next »