From: jmboyd at bluebottle dot com
Operating system: Windows 2000
PHP version: 5.2.4
PHP Bug Type: Directory function related
Bug description: scandir fails unless user has permissions in the parent
directory
Description:
------------
A user must have permissions for a directory's parent in order to scan it
with scandir. If the user does not have permissions (for instance, user
has "Full Control" over the subdir but is not in the parent's ACL at all),
php fails with a "failed to open dir: Bad file descriptor" error followed
by a "(errno 9): Bad file descriptor" error.
Based on the quick test in the "Actual results" box below, this bug seems
to have arrived between 5.2.1 and 5.2.2. No php.ini is in use in any of
the tests.
Reproduce code:
---------------
Any use of scandir will work, here's a quick one to do from the command
line, after cding to the subdir:
php -r "foreach(scandir('.') as $f) { echo($f); }"
Expected result:
----------------
The subdirectory's filenames (all run together):
...file1.txtfile2.txtfile3.txt
Actual result:
--------------
C:\>cd \parentdir
Access is denied.
C:\>cd \parentdir\subdir
C:\parentdir\subdir>dir /B
file1.txt
file2.txt
file3.txt
C:\parentdir\subdir>\php521\php -r "foreach(scandir('.') as $f) {
echo($f); }"
...file1.txtfile2.txtfile3.txt
C:\parentdir\subdir>\php522\php -r "foreach(scandir('.') as $f) {
echo($f); }"
Warning: scandir(.): failed to open dir: Bad file descriptor in Command
line code on line 1
Warning: scandir(): (errno 9): Bad file descriptor in Command line code on
line 1
Warning: Invalid argument supplied for foreach() in Command line code on
line 1
C:\parentdir\subdir>\php524\php -r "foreach(scandir('.') as $f) {
echo($f); }"
Warning: scandir(.): failed to open dir: Bad file descriptor in Command
line code on line 1
Warning: scandir(): (errno 9): Bad file descriptor in Command line code on
line 1
Warning: Invalid argument supplied for foreach() in Command line code on
line 1
--
Edit bug report at http://bugs.php.net/?id=42832&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42832&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42832&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42832&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42832&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42832&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42832&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42832&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42832&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42832&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42832&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42832&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42832&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42832&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42832&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42832&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42832&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42832&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42832&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42832&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42832&r=mysqlcfg