|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-09-28 09:05 UTC] spam2 at rhsoft dot net
Description:
------------
tempnam() should NOT fall back to /tmp if the $dir-param is explicit set to a real-path inside the open_basedir and because of wrong permissions $dir is not writeable
Test script:
---------------
<?php
$temp_folder = dirname(__FILE__) . '/temp/';
mkdir($temp_folder);
chmod($temp_folder, 0555);
$tmp_name = str_replace("\\", '/', tempnam($temp_folder, 'rhcsv'));
$fp = fopen($tmp_name, 'wb+');
if($fp)
{
flock($fp, LOCK_EX);
fwrite($fp, 'test');
flock($fp, LOCK_UN);
fclose($fp);
}
?>
Expected result:
----------------
error message that $dir is not writeable
Actual result:
--------------
temporary file is created in /tmp which violates open_basedir and fopen() is failing with open_basedir restriction messages
Patchesdoc-55804 (last revision 2015-04-18 00:33 UTC by cmb@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 21:00:02 2025 UTC |
Actually, during the discussion of this ticket there have been raised three distinct issues: 1) tempnam() doesn't heed open_basedir, when falling back to the temp dir 2) when tempnam() falls back to the temp dir, no notice is thrown 3) it is not well documented under which circumstances tempnam() falls back to the temp dir That is always a bit unfortunate, but even more so in this case, because 1) could be considered a bug, 2) would be a feature/change request, and 3) is a documentation problem. Therefore I have split 2) to bug #69489 and 3) to bug #69488. With regard to 1): I can't reproduce the behavior of the given test script on somewhat recent versions of PHP. I get: Warning: tempnam(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (...) in ... on line 5 Is this issue still reproducable elsewhere?