php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53011 Error using relative paths are used with *only* Read permissions
Submitted: 2010-10-07 15:51 UTC Modified: 2010-10-07 17:45 UTC
From: saurabh0 at gmail dot com Assigned:
Status: Duplicate Package: Filesystem function related
PHP Version: 5.3.3 OS: Windows Server 2003
Private report: No CVE-ID: None
 [2010-10-07 15:51 UTC] saurabh0 at gmail dot com
Description:
------------
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 to the same file it 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. There is no need to "List Folder Contents" just to read a file (even if the path is relative).

This bug has been reported before but not fixed:
http://bugs.php.net/bug.php?id=50163

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.

Test script:
---------------
file_get_contents('./path/file.txt');

Expected result:
----------------
No error

Actual result:
--------------
Warning: file_get_contents(./path/file.txt): failed to open stream: No such file or directory

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-07 16:08 UTC] saurabh0 at gmail dot com
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.
 [2010-10-07 17:45 UTC] cataphract@php.net
-Status: Open +Status: Duplicate
 [2010-10-07 17:45 UTC] cataphract@php.net
Closing as duplicate of bug #50163. Continue the discussion there, as Pierre has it picked it up over there.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC