Re: open_basedir bypass -> errata tempnam()
| From: | Reindl Harald | Date: | Wed, 28 Sep 2011 07:02:17 +0000 |
| Subject: | Re: open_basedir bypass -> errata tempnam() | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-55643@lists.php.net to get a copy of this message | ||
Am 28.09.2011 08:01, schrieb Antony Dovgal:
> On 09/28/2011 02:39 AM, Reindl Harald wrote:
>> PLEASE REPLY ONLY TO THE LIST
>
> Please provide a short (10 lines max) but complete reproduce script.
> At the moment your explanations do not make any sense.
what do you think was the content of my last mail where you quoted only
a part of the "mailing-list-manual"? this was code directly from the
library where te problem exists, well i will help you to complete a
5-liner to make its "wrong" permissions and replace a class-var....
what exactly does not make sense?
* /tmp MUST NOT be in open_basedir
* the temp-folder must be read only
* QUESTION1: why is tempnam() falling back to a dir outside open_basedir?
* QUESTION2: why is tempnam() creating a file OUTSIDE open_basedir?
* QUESTION3: why is there no error-msg taht $dir is readonly instead unexpected fallback
<?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);
}
?>
Warning: fopen() [function.fopen.php]: open_basedir restriction in effect. File(/tmp/rhcsv5f9RIs) is
not within the
allowed path(s):
(/mnt/data/www/beta.rhsoft.net:/Volumes/dune/www-servers/phpincludes:/var/www/uploadtemp) in
/mnt/data/www/beta.rhsoft.net/tempname.php on line 6
Warning: fopen(/tmp/rhcsv5f9RIs) [function.fopen.php]: failed to open stream: Operation not
permitted in
/mnt/data/www/beta.rhsoft.net/tempname.php on line 6
[harry@srv-rhsoft:~]$ stat /tmp/rhcsv5f9RIs
Datei: „/tmp/rhcsv5f9RIs“
Größe: 0 Blöcke: 0 EA Block: 4096 reguläre leere Datei
Gerät: 809h/2057d Inode: 48 Verknüpfungen: 1
Zugriff: (0600/-rw-------) Uid: ( 48/ apache) Gid: ( 48/ apache)
Zugriff : 2011-09-28 08:58:01.046916064 +0200
Modifiziert: 2011-09-28 08:58:01.046916064 +0200
Geändert : 2011-09-28 08:58:01.046916064 +0200
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc