Bug #41518 [Com]: file_exists() warns of open_basedir restriction on non-existent file
| From: | modelmonikasharma at gmail dot com | Date: | Mon, 15 Mar 2021 07:02:28 +0000 |
| Subject: | Bug #41518 [Com]: file_exists() warns of open_basedir restriction on non-existent file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232718@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=41518&edit=1
ID: 41518
Comment by: modelmonikasharma at gmail dot com
Reported by: ruben dot willmes at emil2001 dot de
Summary: file_exists() warns of open_basedir restriction on
non-existent file
Status: Closed
Type: Bug
Package: Safe Mode/open_basedir
Operating System: Linux
PHP Version: 5.2.2
Assigned To: tony2001
Block user comment: N
Private report: N
New Comment:
I Don't thing anyone write better that this. Amazing Post!! Keep it up!
<a href="https://www.aarinkaur.com/">Mumbai
Escorts</a>
<a href="https://www.aarinkaur.com/">Escorts
Mumbai</a>
Previous Comments:
------------------------------------------------------------------------
[2007-07-03 07:05:55] 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.
------------------------------------------------------------------------
[2007-06-18 18:41:24] paul at moonkhan dot org
@Ruben
Running PHP 5.2.3 on Redhat Enterprise Linux 4 I get the following:
#php -d open_basedir=/tmp -r 'var_dump(file_exists("/tmp/nosuch"));'
bool(false)
But if I switch /tmp to /tmp/ (ie, with trailing slash):
#php -d open_basedir=/tmp/ -r 'var_dump(file_exists("/tmp/nosuch"));'
PHP Warning: file_exists(): open_basedir restriction in effect. File(/tmp/nosuch) is not within the
allowed path(s): (/tmp/) in Command line code on line 1
Warning: file_exists(): open_basedir restriction in effect. File(/tmp/nosuch) is not within the
allowed path(s): (/tmp/) in Command line code on line 1
bool(false)
We can eliminate this problem in our environment if we remove the trailing slashes from our
open_basedir settings but that's not how open_basedir was intended to work, since trailing
slashes prevent "wildcarding". For example, "/tmp" matches "/tmpfoo"
and "/tmpbar" but "/tmp/" should only match, well, /tmp/.
-Paul
------------------------------------------------------------------------
[2007-06-01 00:02:29] phpbugs at thequod dot de
This might be related to bug #39123, where open_basedir=/tmp/
started to fail, as internally only "/tmp" (without trailing slash)
got considered. (http://bugs.php.net/bug.php?id=39123)
------------------------------------------------------------------------
[2007-05-31 12:40:31] ruben dot willmes at emil2001 dot de
Your example is correct, that does work, but what if you change the
following:
Instead of
#php -d open_basedir=/tmp -r 'var_dump(file_exists("/tmp/nosuch"));'
try
#php -d open_basedir=/tmp/ -r 'var_dump(file_exists("/tmp/nosuch"));'
Notice the slash behind "open_basedir=/tmp/". With that you get
Warning: file_exists(): open_basedir restriction in effect. File(/tmp/
nosuch) is not within the allowed path(s): (/tmp/) in Command line
code on line 1
bool(false)
------------------------------------------------------------------------
[2007-05-31 11:06:13] tony2001@php.net
I don't think I get what you're talking about:
# ls -l /tmp/nosuch
ls: cannot access /tmp/nosuch: No such file or directory
#php -d open_basedir=/tmp -r 'var_dump(file_exists("/tmp/nosuch"));'
bool(false)
No warning whatsoever.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=41518
--
Edit this bug report at https://bugs.php.net/bug.php?id=41518&edit=1