#40326 [Fbk->Opn]: Can't open file from cwd if parent folder not readable
| From: | sborrill at precedence dot co dot uk | Date: | Sat, 03 Feb 2007 09:32:01 +0000 |
| Subject: | #40326 [Fbk->Opn]: Can't open file from cwd if parent folder not readable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-108367@lists.php.net to get a copy of this message | ||
ID: 40326
User updated by: sborrill at precedence dot co dot uk
Reported By: sborrill at precedence dot co dot uk
-Status: Feedback
+Status: Open
Bug Type: Streams related
Operating System: NetBSD 3.1_STABLE
PHP Version: 5.2.0
New Comment:
What OS? Are you sure you've checked file ownership? What do you get on
the getcwd() lines?
We are finding this is 100% reproducible on all our customers' servers
when they are using php in a UserDir.
I've checked the package definition and patches at:
http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/php5/
Nothing relevant has been altered betweeen 5.1.6 and 5.2.0 in the
NetBSD pkg.
php.ini file remains the same throughout. We aren't using safe mode or
open_basedir. I looked at the CVS log for fopen_wrapper.c but didn't
spot anything relevant. I'm not familiar enough with PHP internals to
know where to add much debugging, but I'm happy to follow any
suggestions.
Previous Comments:
------------------------------------------------------------------------
[2007-02-02 18:44:36] tony2001@php.net
Cannot reproduce.
Both PHP 5.2-CVS and PHP 6-CVS work just fine with Apache 1.x.
------------------------------------------------------------------------
[2007-02-02 15:22:59] sborrill at precedence dot co dot uk
Description:
------------
With PHP versions prior to 5.2.0 (e.g. 5.1.6), you could fopen() a file
in the current working directory (i.e. same as the script) even if a
parent directory only had +x permission and not +rx for the webserver.
With 5.2.0 (and today's 5.2 snapshot) you get "Warning: fopen(file)
[function.fopen]: failed to open stream: No such file or directory
[...]".
If it's of any relevance, with all versions, getcwd() returns FALSE on
NetBSD if a parent folder is not readable, but this does not affect
fopen().
This is affecting any user whose home area is mode 0711 when they run
php from their public_html folder (which is mode 0755).
Reproduce code:
---------------
Ensuring ownership is not same as web server process (e.g. in
public_html in user's home area):
mkdir one
mkdir one/two
chmod 711 one
chmod 755 one/two
echo "test" > one/two/testfile
one/two/index.php contains:
<?php
echo "cwd:".getcwd()."<br>";
$fp=fopen("testfile","r");
if($fp) fpassthru($fp);
?>
Stage one:
chmod 711 one
Stage two:
chmod 755 one
Expected result:
----------------
(stage one):
cwd:
test
(stage two)
cwd: /home/testuser/public_html
test
Actual result:
--------------
(stage 1):
cwd:
Warning: fopen(file) [function.fopen]: failed to open stream: No such
file or directory [...]
(stage two)
cwd: /home/testuser/public_html
test
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40326&edit=1