From: justin dot white at mci dot com Operating system: Windows 2000 PHP version: 4.3.3 PHP Bug Type: Filesystem function related Bug description: fileperms() inaccurately reports permissions
Description: ------------ On Linux, PHP 4.3.3 correctly returns file permissions from the filesystem. With Windows 2000 and IIS, PHP in CGI or ISAPI mode does not. The reproduce code assumes that another file (TEST.PHP) already exists in the filesystem. Any other file or directory could be used (although the permissions are returned differently for directories). TEST.PHP can have any permissions, including explicitly DENY "Full Access" for EVERYONE group. Reproduce code: --------------- <?php clearstatcache(); $test = fileperms('c:/inetpub/wwwroot/test.php'); echo '<H1>PERMS = '; $read = ($test & 0x0004) ? 'r' : '-'; $write = ($test & 0x0002) ? 'w' : '-'; $execute = ($test & 0x0001) ? 'x' : '-'; echo $read.$write.$execute.'</H1>'; ?> Expected result: ---------------- For files, returned results should be "<H1>PERMS = r--</H1>' if permissions were set to READ. Returned results should be "<H1>PERMS = rw-</H1>" if permissions were set to READ/WRITE or READ/WRITE/MODIFY. Returned results should be "<H1>PERMS = rwx</H1>" if permissions were set to READ/EXECUTE/WRITE or READ/EXECUTE/WRITE/MODIFY or FULL CONTROL. For directories, returned result should be similar (although permissions on directory are more well-defined). Actual result: -------------- For files, returned results will always be "<H1>PERMS = rw-</H1>'; For directories, returned result will always be "<H1>PERMS = rwx</H1>'; Even attempting this operation on "C:/pagefile.sys" returned "<H1>PERMS = rw-". Curiously, when marking the file as "read-only" in the file properties (not security tab), the returned results are "<H1>PERMS = r--</H1>" for files and "<H1>PERMS = r-x</H1>" for directories. -- Edit bug report at http://bugs.php.net/?id=26224&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26224&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26224&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26224&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26224&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26224&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=26224&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26224&r=support Expected behavior: http://bugs.php.net/fix.php?id=26224&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26224&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26224&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26224&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26224&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26224&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26224&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26224&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26224&r=float