php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36873 is_writable() does not know about open_basedir
Submitted: 2006-03-27 15:59 UTC Modified: 2006-03-27 20:26 UTC
From: rebe at unit01 dot net Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.1.2 OS: linux
Private report: No CVE-ID: None
 [2006-03-27 15:59 UTC] rebe at unit01 dot net
Description:
------------
Latest go-pear:
 $Id: go-pear,v 1.81 2006/03/11 14:15:20 pajoye Exp $
fails on php5 with open_basedir restriction.
Function tmp_dir() about line 1156 has check code:

        $_temp = my_env('TMPDIR');
        if (!$_temp) {
            if (is_writable('/tmp')) {
                $_temp = '/tmp';
            }
        }
which fails cause is_writable('/tmp') return true (!!) even if php cannot write anything there because of restrictions, so then in line 423:

$ptmp = tempnam($foo, 'gope');

$ptmp becomes ampty - script is downloading packages into current dir which makes then conflicts and errors.

I suggest to change this:
        if (!$_temp) {
            if (is_writable('/tmp')) {
                $_temp = '/tmp';
            }
        }

to something like that:
        if (!$_temp) {
		$test = '/tmp/'.uniqid();
            if (@mkdir($test)) {
		    @rmdir($test);
                $_temp = '/tmp';
            }
        }
which forces to create something to check if its possible.

------------------------

Second small bug is that after i fixed that code above and installation finished with success i got link:
"Start Web Frontend of the PEAR Installer >>"
which points to pear/pear/index.php dir instead of pear/index.php dir (where "pear" was my dir i choosed to put go-pear.php there and run with defaults).



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-27 16:08 UTC] bjori@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please report bugs in PEAR in the PEAR bug tracker at http://pear.php.net/bugs/
Thank you.
 [2006-03-27 16:11 UTC] pajoye@php.net
Please open a PEAR bug using pear.php.net:
http://pear.php.net/bugs/report.php?package=PEAR
 [2006-03-27 20:25 UTC] cellog@php.net
The original subject is misleading, changing to what is the real problem.

this is not a problem in PEAR per se, but the documentation for is_writable() should state that it ignores open_basedir settings.

As the original report states, open_basedir did not include /tmp and so is_writable('/tmp') falsely returns "true" when open_basedir in fact prevents writing to /tmp
 [2006-03-27 20:26 UTC] cellog@php.net
dupe of #36875 (didn't look closely enough)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 23:01:32 2025 UTC