#39421 [Bgs]: tempnam() unexpected behavior
| From: | ruslan_y at list dot ru | Date: | Wed, 08 Nov 2006 17:16:59 +0000 |
| Subject: | #39421 [Bgs]: tempnam() unexpected behavior | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-104631@lists.php.net to get a copy of this message | ||
ID: 39421
User updated by: ruslan_y at list dot ru
Reported By: ruslan_y at list dot ru
Status: Bogus
Bug Type: *Directory/Filesystem functions
Operating System: Windows XP SP2
PHP Version: 5.2.0
New Comment:
I'm sorry, but I'm was not talking about open_basedir itself but about
some changes of using local path in tempnam() function then php is an
apache module!
You can see in the example that it's a really different as cli and sapi
module!
(php -q 1.php)
...
$tmpfname3 = 2\FOOFC.tmp
...
and
(http://localhost/1.php)
...
$tmpfname3 = C:\WINDOWS\TEMP\FOO10C.tmp
...
Why It so different? Why I cannot get an expected result? That's the
question!
Previous Comments:
------------------------------------------------------------------------
[2006-11-08 16:47:16] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
As of PHP 5.2.0 tempnam() enforces open_basedir limit, which
is why the temporary directory needs to be within the
open_basedir.
------------------------------------------------------------------------
[2006-11-08 06:19:16] ruslan_y at list dot ru
Description:
------------
After the upgrade from old php 4.x to 5.2.0. Some of my web scripts
stop working. One of the reason is the changes in tempnam() behavior
which stop working with local path like "./dir" or "dir/" and force me
to add system temporary folder to open_basedir path.
Configuration:
Windows XP SP2 | PHP 5.2.0 | Apache 2.0.55 (+ php5apache2.dll)
P.S. php.exe works as expected (except DOCUMENT_ROOT is null)
(php.exe -q 1.php)
Reproduce code:
---------------
<?php
if (!is_dir('2')) mkdir('2');
$tmpfname1 = tempnam('2/', "FOO");
$tmpfname2 = tempnam('./2/', "FOO");
$tmpfname3 = tempnam('2\\', "FOO");
$tmpfname4 = tempnam('.\2', "FOO");
$tmpfname5 = tempnam('C:\root\www\host2\www\2\\', "FOO");
echo '<pre>'."\n";
echo 'DOCUMENT_ROOT = '.$_SERVER['DOCUMENT_ROOT']."\n";
echo '$tmpfname1 = '.$tmpfname1."\n";
echo '$tmpfname2 = '.$tmpfname2."\n";
echo '$tmpfname3 = '.$tmpfname3."\n";
echo '$tmpfname4 = '.$tmpfname4."\n";
echo '$tmpfname5 = '.$tmpfname5."\n";
echo '</pre>'."\n";
?>
Expected result:
----------------
A new directory "2" and five files in it.
DOCUMENT_ROOT = C:/root/www/host2/www
$tmpfname1 = 2/FOOFA.tmp
$tmpfname2 = ./2/FOOFB.tmp
$tmpfname3 = 2\FOOFC.tmp
$tmpfname4 = .\2\FOOFD.tmp
$tmpfname5 = C:\root\www\host2\www\2\FOOFE.tmp
Actual result:
--------------
A new directory "2" and only one file in it. all other files in the
windows temp folder.
DOCUMENT_ROOT = C:/root/www/host2/www
$tmpfname1 = C:\WINDOWS\TEMP\FOO10A.tmp
$tmpfname2 = C:\WINDOWS\TEMP\FOO10B.tmp
$tmpfname3 = C:\WINDOWS\TEMP\FOO10C.tmp
$tmpfname4 = C:\WINDOWS\TEMP\FOO10D.tmp
$tmpfname5 = C:\root\www\host2\www\2\FOO10E.tmp
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39421&edit=1