php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53041 is_file() and open_basedir
Submitted: 2010-10-11 10:38 UTC Modified: 2015-06-04 14:53 UTC
Votes:13
Avg. Score:4.2 ± 0.9
Reproduced:12 of 13 (92.3%)
Same Version:6 (50.0%)
Same OS:3 (25.0%)
From: sunseb at live dot com Assigned: cmb (profile)
Status: Duplicate Package: *Directory/Filesystem functions
PHP Version: 5.3.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 + 16 = ?
Subscribe to this entry?

 
 [2010-10-11 10:38 UTC] sunseb at live dot com
Description:
------------
php.ini :

  open_basedir = /home/

directory :

  /home/my_file.txt

script :

  is_file('/home/my_file.txt'); // TRUE.

  is_file('/home/my_file.txt/whatever'); // FALSE but "Warning: is_file():
open_basedir restriction in effect." Why this warning (open_basedir is OK) ?

Thank you ! (And sorry for my english.)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-12 05:48 UTC] cataphract@php.net
-Status: Open +Status: Verified
 [2010-10-13 02:58 UTC] uramihsayibok at gmail dot com
Same as bugs #52065 and #44901. Reproduced on Windows.

some file function (eg, is_file) calls the C functions:
-> php_stat
-> php_check_specific_open_basedir(_ex) [1]
-> expand_filepath(_ex)
-> virtual_file_ex
-> tsrm_realpath_r [2]:
Unable to access /home/my_file.txt/whatever, [2] next checks that /home/my_file.txt exists *and is a directory*. Since it isn't a directory, everything fails all the way back up to [1], which then, assuming it was a problem specifically with the open_basedir restriction, issues the warning.
 [2011-01-07 14:08 UTC] sjon at react dot com
this problem still occurs in 5.3.5
 [2011-02-01 19:06 UTC] mjk at emmjaykay dot org
I setup my machine as described in this bug and changed my /etc/php.ini so that open_basedir = /home/, mkdir /home/my_file.txt and did a touch /home/my_file.txt/whatever. I then ran this script

<?php
var_dump (is_file("/home/my_file.txt"));
var_dump (is_file("/home/my_file.txt/whatever"));
?>

and got this

bool(false)
bool(true)

Is there another change I need to make to php.ini or something I'm missing?
 [2011-02-02 12:39 UTC] sjon at react dot com
apart from you not reproducing the bug correctly (my_file.txt should obviously be a file, not a directory), this seems to have been fixed by now.

I suspect this to fix it:

http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c?r1=264931&r2=264932&
 [2011-02-02 17:26 UTC] mjk at emmjaykay dot org
My apologies. But it says "directory: /home/my_file.txt" so I the directions were a little unclear. sry
 [2011-02-26 22:32 UTC] info at riastudio dot fr
Still occurs in 5.3.5, more than annoying when you have a lot of vhosts with 
open_basedir + error_reporting E_ALL
 [2011-07-21 07:59 UTC] kev at dewsolutions dot co dot uk
Still occurs in PHP 5.3.6.

to replicate:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

echo 'testing open basedir problems <br />';

// append text to current directory name which should be the dir of open_basedir to trigger open_basedir warning
echo 'checking ' . dirname(__FILE__) . 'test <br />';
var_dump(file_exists(dirname(__FILE__) . 'test'));

// no warning should occur here whether index.php exists or not
echo 'checking ' . dirname(__FILE__) . '/index.php <br />';
var_dump(file_exists(dirname(__FILE__) . '/index.php'));

// if index.php exists a open_basedir warning will be thrown
echo 'checking ' . dirname(__FILE__) . '/index.php/test <br />';
var_dump(file_exists(dirname(__FILE__) . '/index.php/test'));
 [2011-07-21 10:57 UTC] pajoye@php.net
-Status: Verified +Status: Feedback
 [2011-07-21 10:57 UTC] pajoye@php.net
@kev at dewsolutions dot co dot uk


Given:

dirname(__FILE__) . '/index.php/test'

I suppose that index.php is a file, right?
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 [2014-03-06 14:27 UTC] lav at etersoft dot ru
Still reproduced on 5.4.17.20130704:

Still said about open_basedir restriction when checking the path contains real file instead dir in the middle of the path.


is_file('/home/my_file.txt/file');

where /home/my_file.txt is a real file.
 [2015-06-04 14:53 UTC] cmb@php.net
-Status: No Feedback +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-06-04 14:53 UTC] cmb@php.net
This is a duplicate of bug #52065.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 17:01:41 2019 UTC