Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55641 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13369 invoked from network); 27 Sep 2011 22:39:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2011 22:39:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=h.reindl@thelounge.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=h.reindl@thelounge.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thelounge.net designates 91.118.73.15 as permitted sender) X-PHP-List-Original-Sender: h.reindl@thelounge.net X-Host-Fingerprint: 91.118.73.15 mail.thelounge.net Windows 98 (1) Received: from [91.118.73.15] ([91.118.73.15:60629] helo=mail.thelounge.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/72-24312-980528E4 for ; Tue, 27 Sep 2011 18:39:06 -0400 Received: from srv-rhsoft.rhsoft.net (openvpn-241.thelounge.net [10.0.0.241]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.thelounge.net (Postfix) with ESMTPSA id 0AA5698 for ; Wed, 28 Sep 2011 00:39:00 +0200 (CEST) Message-ID: <4E825084.4040703@thelounge.net> Date: Wed, 28 Sep 2011 00:39:00 +0200 Organization: the lounge interactive design User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2 MIME-Version: 1.0 To: internals@lists.php.net References: <4E81902E.1020304@thelounge.net> <4E824B36.4040209@gmail.com> <4E824BF7.9070405@thelounge.net> <4E824F69.1010703@gmail.com> In-Reply-To: <4E824F69.1010703@gmail.com> X-Enigmail-Version: 1.3.2 OpenPGP: id=7F780279; url=http://arrakis.thelounge.net/gpg/h.reindl_thelounge.net.pub.txt Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig334C476DE6586EAD25FF557D" Subject: Re: [PHP-DEV] open_basedir bypass -> errata tempnam() From: h.reindl@thelounge.net (Reindl Harald) --------------enig334C476DE6586EAD25FF557D Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Am 28.09.2011 00:34, schrieb =C1ngel Gonz=E1lez: > Reindl Harald schrieb: >> [root@arrakis:~]$ stat /tmp/rhcsvz8QeBL >> File: =84/tmp/rhcsvz8QeBL=93 >>> Are you sure it is the fopen() what is making it? >>> I think that some other function/extension may be creating the tempor= ary file >>> /tmp/rhcsvz8QeBL for you to open, which then fails due to the open_ba= sedir. >> errata - it is tempnam() if $dir is not writeable which falls back to = /tmp >> this fallback should not happen if /tmp is NOT in open_basedir and >> tempname() should spit out the error instead the following fopen() >> >> better would be if tempnam() stops and gives out a warning that $dir i= s >> not writeable - it had a reason that the $dir param was used and if >> there is an error it is a bad behavior that php takes something else >> >> we are speaking about a programming language and not a gambling machin= e :-) > I had also tried with tempnam() [there's not tempname()], and it correc= tly spitted > an open_basedir error and didn't create the file. > Which php version are you using? PLEASE REPLY ONLY TO THE LIST this was the second time that i used one of your two copies and replied off-list the first time, if you get a mail from a mailing-list the sender gets your answer if it goes to the list only :-) 5.3.8 $GLOBALS['cl_api']->folders->temp =3D dirname(__FILE__) . '/temp/'; that was why i did first not understand why /tmp ever was used and than it took some time to realize that /tmp is used because $GLOBALS['cl_api']->folders->temp was not writeable and that the temporary files were created with zero bytes $tmp_name =3D str_replace("\\", '/', tempnam($GLOBALS['cl_api']->folders-= >temp, 'rhcsv')); $fp =3D fopen($tmp_name, 'wb+'); if($fp) { flock($fp, LOCK_EX); fwrite($fp, $data); flock($fp, LOCK_UN); fclose($fp); } --------------enig334C476DE6586EAD25FF557D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6CUIQACgkQhmBjz394Anml6QCfduvni9torPvcGafqtFnQyxO5 /0MAn2iX7C0vZ/MERT1YX+X0+nKgW+QW =G93F -----END PGP SIGNATURE----- --------------enig334C476DE6586EAD25FF557D--