php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: n dot escuder at intra-links dot com
New email:
PHP Version: OS:

 

 [2006-05-10 11:41 UTC] n dot escuder at intra-links dot com
Description:
------------
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);
touch("/tmp/php/one.php");

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

require_once "one.php";

@mkdir("/tmp/essai");
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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-15 21:49 UTC] tony2001@php.net
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] tony2001@php.net
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
http://snaps.php.net/.
 
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] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [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: Thu Nov 21 10:01:29 2024 UTC