Bug #81179 [NEW]: fileperms() return wrong access information

From: Date: Sun, 20 Jun 2021 04:20:16 +0000
Subject: Bug #81179 [NEW]: fileperms() return wrong access information
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234522@lists.php.net to get a copy of this message
From:             jhr at informedwebmaster dot com
Operating system: Windows Server 2019 Ver.: 1809
PHP version:      8.0.7
Package:          *Directory/Filesystem functions
Bug Type:         Bug
Bug description:fileperms() return wrong access information

Description:
------------
This bug can be reproduced by creating a directory called test in the
root of drive C:, add an text file in the directory named "test.txt",
give the IUSR user read but not write access to the file. IUSR is the
user account php uses on IIS 10 when running php-scripts. Then runthe
following php-code:

echo substr(sprintf('%o', fileperms('C:\test\test.txt')), -4);

It will show "0666" even thou the current user does not have write
permission to the file. If it's helpful, is_writable('C:\test\test.txt')
does correctly return false.

Test script:
---------------
I did not write this code, i found it on php.net. But it works fine to
reproduce the bug(please read description):

echo substr(sprintf('%o', fileperms('C:\test\test.txt')), -4);

Expected result:
----------------
I expected to see "0644".

Actual result:
--------------
Actual result was "0666".

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81179&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81179&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81179&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81179&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81179&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81179&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81179&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81179&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81179&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81179&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81179&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81179&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81179&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81179&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81179&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81179&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81179&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81179&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#234522) next »