php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41767 realpath() is not working properly now
Submitted: 2007-06-21 16:16 UTC Modified: 2007-06-24 16:29 UTC
From: programatorfreez at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.3 OS: GNU/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: programatorfreez at gmail dot com
New email:
PHP Version: OS:

 

 [2007-06-21 16:16 UTC] programatorfreez at gmail dot com
Description:
------------
Hello,

In PHP <= 5.2.2 realpath('.") will return realpath to current working directory (for example /var/www/localhost/htdocs/mypages) but in PHP 5.2.3 function realpath('.') causes openbase_dir restriction related error.

Reason
======
echo realpath('/var/www/localhost/htdocs/mypages/'); in PHP <= 5.2.2 works, but in PHP 5.2.3 causes openbase_dir restriction error with something like "You have not access to /var/www/localhost/htdocs/mypages' (it's because the final slash is missing) the openbase_dir in php.ini is set to "/var/www/localhost/htdocs/mypages/", function realpath will cut the final slash and this will lead to error.

Reproduce code:
---------------
<?php
  echo 'It's described above =)';
?>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-22 18:04 UTC] programatorfreez at gmail dot com
Actually i'm happy that my PHP 5.2.2 is working and unfortunatelly i don't have enough time to compile CVS version and then stable again. I'll wait until it will be in Gentoo portage, it's the best way for me.

Do you have installed CVS version? If so, please try:
-----------------------------
<?php
echo realpath('./');
?>
-----------------------------

The directory with script must be in php.ini -> open_basedir, don't forget to add the final slash. Safe mode must be on.

The result with PHP 5.2.2 is something like /var/www/localhost/htdocs/mypages.

With PHP 5.2.3 the result is similar to open_basedir restriction in affect, directory /var/www/localhost/htdocs/mypages is not in allowed path.

PHP 5.2.3 is actually running only on webhosting, where are stored my pages.

Thanks for a try
 [2007-06-24 16:29 UTC] sniper@php.net
Works fine for me.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 04:01:30 2024 UTC