|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2009-11-13 09:23 UTC] be3ch at centrum dot cz
 Description: ------------ Hello, I have installed PHP 5.2.11 on Windows 2003 Server, IIS6 and FastCGI handler. For this configuration is recommended usage of non-ts version of PHP. I'm encountered a problem with this version. If I'm using PHP 5.2.11 ts and for IUSR are on webroot directory only READ permissions, all works correctly. If I'm using PHP 5.2.11 non-ts and for IUSR are on webroot directory only READ permissions, files functions don't work. But functions like include or require work correctly. If I'm using PHP 5.2.11 non-ts and for IUSR are on webroot directory READ+EXECUTE permissions, all works correctly. There are some my test results : Web=test.com RootPath=D:\wwwroot\testcom\www\ TestScript=http://test.com/test.php IUSR=IUSR_testcom 1) IUSR_testcom NTFS permissions on RootPath : READ (OK) PHP 5.2.11 ts - test script result: bool(true) (KO) PHP 5.2.11 non-ts - test script result: Warning: file_exists(): open_basedir restriction in effect. File(test.php) is not within the allowed path(s): (D:\wwwroot\testcom;D:\tmp\System;D:\tmp\Php) in D:\wwwroot\testcom\www\test.php on line 3 bool(false) 2) IUSR_testcom NTFS permissions on RootPath : READ + EXECUTE (OK) PHP 5.2.11 ts - test script result: bool(true) (OK) PHP 5.2.11 non-ts - test script result: bool(true) Why PHP non-ts not working correctly when on root path are only READ permissions for IUSR? FastCGI and PHP are running with impersonate. Reproduce code: --------------- Test script test.php source code: <?php var_dump(file_exists('test.php')); ?> Expected result: ---------------- bool(true) Actual result: -------------- Warning: file_exists(): open_basedir restriction in effect. File(test.php) is not within the allowed path(s): (D:\wwwroot\testcom;D:\tmp\System;D:\tmp\Php) in D:\wwwroot\testcom\www\test.php on line 3 bool(false) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 02:00:02 2025 UTC | 
I'm think it's not problem with ACL, because with PHP 5.2.11 ts-version it works correctly and if script will be changed to FULL path : <?php var_dump(file_exists('D:\wwwroot\testcom\www\test.php')); ?> it works with PHP 5.2.11 non-ts and only READ permissions correctly too.D:\wwwroot>icacls D:\wwwroot\testcom\ D:\wwwroot\testcom\ NT AUTHORITY\SYSTEM:(OI)(CI)(F) NT AUTHORITY\NETWORK SERVICE:(OI)(CI)(R) BUILTIN\Administrators:(OI)(CI)(F) TEST_SERVER\G6FTPUser:(OI)(CI)(R,W,D,DC) TEST_SERVER\IUSR_testcom:(OI)(CI)(R) Successfully processed 1 files; Failed processing 0 files D:\wwwroot>icacls D:\wwwroot\testcom\www D:\wwwroot\testcom\www BUILTIN\Administrators:(OI)(CI)(F) TEST_SERVER\G6FTPUser:(OI)(CI)(R,W,D,DC) TEST_SERVER\IUSR_testcom:(OI)(CI)(R) NT AUTHORITY\NETWORK SERVICE:(OI)(CI)(R) NT AUTHORITY\SYSTEM:(OI)(CI)(F) Successfully processed 1 files; Failed processing 0 filesCan you paste the value of include_path directive (ini_get('include_path')) for each of the cases? Given that fullpath to file works with just read permissions tell that relative path test.php is getting resolved to some other path which is outside open_basedir. Strange that adding execute permission make it resolve to a different path.You can try this procedure to reproduce this problem: - install Windows 2008 Server (x86) - add Web Server role (for IIS7 support) - download Web Platform Installer and install PHP 5.2.11 Now you have in IIS7 default web with PHP 5.2.11 support. Create test script test.php with this content : <?php var_dump(file_exists('test.php')); ?> and copy test.php to C:\Inetpub\wwwroot . Now you can try http://localhost/test.php and you can see result of script : bool(true). There is default icacls result on C:\Inetpub\wwwroot directory : wwwroot BUILTIN\IIS_IUSRS:(RX) BUILTIN\IIS_IUSRS:(OI)(CI)(IO)(GR,GE) NT SERVICE\TrustedInstaller:(I)(F) NT SERVICE\TrustedInstaller:(I)(OI)(CI)(IO)(F) NT AUTHORITY\SYSTEM:(I)(F) NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F) BUILTIN\Administrators:(I)(F) BUILTIN\Administrators:(I)(OI)(CI)(IO)(F) BUILTIN\Users:(I)(RX) BUILTIN\Users:(I)(OI)(CI)(IO)(GR,GE) CREATOR OWNER:(I)(OI)(CI)(IO)(F) Successfully processed 1 files; Failed processing 0 files Now on folder C:\inetpub\wwwroot delete inheritance and change permissions to : Administrators:F IUSR:R NETWORK SERVICE:R System:F icacls result will be: wwwroot NT AUTHORITY\IUSR:(OI)(CI)(R) NT AUTHORITY\SYSTEM:(OI)(CI)(F) NT AUTHORITY\NETWORK SERVICE:(OI)(CI)(R) BUILTIN\Administrators:(OI)(CI)(F) Successfully processed 1 files; Failed processing 0 files Restart IIS service and try http://localhost/test.php now. Result of script will be : bool(false). Now you can try change test script to full path and result will be bool(true). If you change PHP to TS version, result with relative path will be correct bool(true). PHP 5.3 NonTS same problem.I am facing the same problem. Running PHP Version 5.3.3 (FastCgi, non-thread safe) on IIS6/Windows Server 2003. All file functions give error when relative paths are used and with *only* Read permissions on the folder. e.g. file_get_contents('./path/file.txt'); The above gives: Warning: file_get_contents(./path/file.txt): failed to open stream: No such file or directory If you give the full path its works fine. i.e. the follow works: file_get_contents('C:/full/path/file.txt'); If you add "List Folder Contents" permission to the folder it starts to work with relative folders as well. I am guessing the when relative paths are used php tries to get some information about the current folder which fails as the "List Folder Contents" is not given. Note: I had php (5.2) running as ISAPI before and didn't have this problem. So it seems to be specific to non-thread safe version.Some additional info: var_dump(getcwd(), realpath(".")); gives: string(7) "c:\php5" string(7) "C:\php5" As expected, when you give "List Folder Contents" permission (in addition to read) to the web root folder both functions return the correct path.Forgot to add. The script was this one: <?php var_dump(chdir('c:\Users\Cataphract\Documents\SDK\php54dev\vc9\x86\php54-trunk\Debug_TS\teste')); echo file_get_contents("./relative/file.txt"); The permissions on [...]\Debug_TS\teste were "Read" (i.e., List Folder/Read data, Read attributes and extended attributes, Read permissions, on the folder, subfolders and files). The simple permission "List folder contents" is actually giving additionally the permission Traverse Folder/execute files to the folder and subfolders.While chdir() requires traverse/execute permissions on the target folder (a permission that is ignored anyway, because bypass traverse checking is enabled by default), I cannot reproduce the bug using the CLI SAPI. Setting the working directory to c:\Users\Cataphract\Documents\SDK\php54dev\vc9\x86\php54-trunk\Debug_TS\teste, and running the non-zts PHP with the script: <?php echo file_get_contents("./relative/file.txt"); worked perfectly. So this may be specific to the CGI SAPI.