|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37395 fopen don't work in some conditions
Submitted: 2006-05-10 11:41 UTC Modified: 2007-02-21 13:19 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: n dot escuder at intra-links dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5.2.0 OS: Linux
Private report: No CVE-ID: None
 [2006-05-10 11:41 UTC] n dot escuder at intra-links dot com
fopen report no such file or directory when open in w mode.
It's seem to be related with include path with symlink as you can see in sample

if the include path is /tmp/php all work.
but if the include path is /tmp/link ( sym link ) the script fail.

Reproduce code:
ini_set('include_path', "/tmp/link");

@mkdir("/tmp/php", 0777, true);

@symlink( "/tmp/php", "/tmp/link" );

require_once "one.php";

chroot("/tmp/essai" );

@mkdir("/tmp/link/interfaces", 0777, true);

$fd = fopen("/tmp/link/one.php", "wb");

Expected result:
No error and an file pointer in $fd 

Actual result:
Warning: fopen(/tmp/link/one.php): failed to open stream: No such file or directory in /tmp/essai.php on line 16


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-15 21:49 UTC]
Remove all those @ and you'll see the very expected error messages.
 [2006-05-16 11:38 UTC] n dot escuder at intra-links dot com
I jave made a little mistake in my expample here is the good test file :

ini_set( "include_path", "/tmp/link" );
mkdir( "/tmp/php", 0777, true );
touch( "/tmp/php/one.php" );
symlink( "/tmp/php", "/tmp/link" );
require_once "one.php";
mkdir( "/tmp/essai" );
chroot( "/tmp/essai" );
mkdir( "/tmp/link", 0777, true );
$fd = fopen( "/tmp/link/one.php", "wb" );

as you can see we just created /tmp/essai 
and /tmp/link in chrooted of /tmp/essai
and after trye to create /tmp/link/one.php fail !

It's due to the link in the include_path
 [2006-05-16 13:07 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

There was a different issue, but now it's fixed in CVS.
 [2007-01-10 16:27 UTC] n dot escuder at intra-links dot com
The bug is come back in version 5.2.0 and i think this is the same bug that the report #40092.
 [2007-02-20 22:43 UTC]
Please try using this CVS snapshot:
For Windows:

 [2007-02-21 13:19 UTC] n dot escuder at intra-links dot com
fix by dimitry this was the same bug of #40092

add realpath_cache when chroot.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Feb 27 15:01:32 2024 UTC