Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29026 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40690 invoked by uid 1010); 25 Apr 2007 19:43:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 40675 invoked from network); 25 Apr 2007 19:43:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2007 19:43:05 -0000 Authentication-Results: pb1.pair.com header.from=edin@krug.dk; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=edin@krug.dk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain krug.dk designates 82.103.137.104 as permitted sender) X-PHP-List-Original-Sender: edin@krug.dk X-Host-Fingerprint: 82.103.137.104 khaled.krug.dk Received: from [82.103.137.104] ([82.103.137.104:52997] helo=khaled.krug.dk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/08-00993-74FAF264 for ; Wed, 25 Apr 2007 15:43:04 -0400 Message-ID: <462FAF41.9020001@krug.dk> Date: Wed, 25 Apr 2007 21:42:57 +0200 User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: Stanislav Malyshev CC: Hannes Magnusson , PHP Developers Mailing List References: <7f3ed2c30704231001j721c2c35q55be1fce5d78fa87@mail.gmail.com> <462F6386.7040308@zend.com> <7f3ed2c30704250812x5563d1dx2f7fc9bb988ac8f@mail.gmail.com> <462FAB60.40508@zend.com> In-Reply-To: <462FAB60.40508@zend.com> X-Enigmail-Version: 0.95.0 OpenPGP: id=157D0FA8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PATCH] PHP-cli ini search path From: edin@krug.dk (Edin Kadribasic) Hi Stas, The problem is with the following scenario: Say your php cli is in /usr/bin/php and /usr/bin is in your path. You change dir to /tmp. Now issue php -v and watch where php looks up its php.ini. main()'s argv[0] will in this case be just "php" since we got called form the path. The code in main/php_ini.c will try to do a realpath() on "php" which will fail on Linux (since php does not exist in the current dir). On BSD it will return /tmp/php due to the fact that BSD realpath does not check for file existance. Then our code will basically do dirname on the result, which will result in php.ini path being set to /tmp in effect adding CWD in the php.ini search path which was definitely not what we wanted there. On Linux same thing will happened if you have any file named php in your CWD. So touch php && php -v will produce the exact same problem on Linux. Windows uses win32 api call designed to lookup the binary name and is not affected by this. Edin Stanislav Malyshev wrote: > How BSD is different from any other Unix? And as far as I see, > tsrm_realpath uses getcwd anyway, so what's the difference? > > Hannes Magnusson wrote: >> It fixes the bug on BSDs where the ini is picked up from cwd - and >> when you do "touch php && php -v" >> >