Bug->Doc #43817 [Opn->Ver]: opendir() fails on Windows directories with parent directory unaccessible

From: Date: Thu, 23 Sep 2021 15:08:34 +0000
Subject: Bug->Doc #43817 [Opn->Ver]: opendir() fails on Windows directories with parent directory unaccessible
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19209@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=43817&edit=1 ID: 43817 Updated by: cmb@php.net Reported by: losd at mail dot dk Summary: opendir() fails on Windows directories with parent directory unaccessible -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem Package: Directory function related Operating System: win32 only - Windows Server 2003 PHP Version: 5.3.0beta1 Block user comment: N Private report: N New Comment: For opendir(), all parent folders need at least read data/list directory (RA) rights; for some other operations more permissions might be needed, but read and execute access (RX) sjould be sufficient in any case. This is by design, and while it may not be explicitly documented for all file functions, the realpath() docs already state: | The running script must have executable permissions on all | directories in the hierarchy, otherwise realpath() will return | false. What may be more surprising is that fileperms() on a folder with RA rights yields 0777, although that folder isn't writable, and is_writable() returns false. This is because is_writable() also does an actual access() like check, while stat() does not, for perfomance reasons. That might be worth documenting as well. Previous Comments: ------------------------------------------------------------------------ [2018-04-22 07:46:19] spam2 at rhsoft dot net outside the windows world this is normal behavior and php aims to behave as identical as possible on every platform it's bad allow access deep in the tree just because somewhere are permissions wrong and in case of a script running on a web server say thank you for the increased security, either the access was not intended or set proper permissions ------------------------------------------------------------------------ [2018-04-22 01:38:51] rujjinjakka at rocketmail dot com Same problem with PHP 7.1.1 with Windows NT build 7601 (Windows 7 Ultimate Edition Service Pack 1) i586 It looks like chmod does not work either. I noticed that IIS does not have direct permission to access the file. Maybe to have access to the file, the direct editing is necessary. I used the Chmod ( chmod 777 ) for the file, but it was only applied in the directory, not being applicable to the files inside that directory. In my case, it was a case of file import by form (move_uploaded_file($tmp_name, $prev)). $prev = $dir. "/" .basename( $filename ); if(move_uploaded_file($tmp_name, $prev)){ echo "Success!". $prev } The file is copied but is not displayed in previews. The file does not have the permissions for the IIS_IUSRS user. ------------------------------------------------------------------------ [2016-12-28 04:02:12] kthprog at gmail dot com I have the same problems. PHP 7.1 NTS on IIS ...10? Running Windows 10. The workaround appending a subdir + .. worked for me. ------------------------------------------------------------------------ [2016-11-08 11:03:24] knagis at miga dot lv I have the same problem on Windows Server 2012 R2 and both PHP 5.6.24 and PHP 7.0.9. In my case the DirectoryIterator::__construct was failing with Access is denied. (code: 5) ------------------------------------------------------------------------ [2015-01-22 19:13:44] scott at phphq dot net This bug still exists in php 5.4.36. win32 - Windows Server 2003, iis6. I can readfile, chdir but if I try to read the files (scandir, opendir, DirectoryIterator) I get an access denied error. C:/Website/ -- Not accessible C:/Website/public_html -- Accessible C:/Website/public_html/etc... -- Accessible User has correct permission to C:/Website but no permissions for access on C:/. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=43817 -- Edit this bug report at https://bugs.php.net/bug.php?id=43817&edit=1

« previous php.doc.bugs (#19209) next »