|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2016-07-15 06:55 UTC] w1s2j3229 at 163 dot com
  [2024-01-04 21:07 UTC] bukka@php.net
 
-Package: *Directory/Filesystem functions
+Package: Streams related
 | |||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 10:00:02 2025 UTC | 
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)