Bug #14839 Updated: getcwd() and `pwd` report incorrect directory
| From: | imajes@php.net | Date: | Fri, 04 Jan 2002 05:47:59 +0000 |
| Subject: | Bug #14839 Updated: getcwd() and `pwd` report incorrect directory | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-75845@lists.php.net to get a copy of this message | ||
ID: 14839
Updated by: imajes
Reported By: php@chaska.com
Status: Open
Bug Type: *Directory/Filesystem functions
Operating System: Linux, FreeBSD, Solaris
PHP Version: 4.0.5
New Comment:
Ok, some comments, if i may.
Firstly, I have verified this behaviour, however (and I could be wrong), this is not unexpected.
The script executes relavtive to the directory it exists
within, not the directory you are currently in.
I can't particularly explain why, but this kind of makes sense. If you had a script in some
unsafe directory, allowing the moving and deleting of files, and you could run it in a secured
directory, in which the php process had sufficient access, and affect the files there, would that
not present potential security risks?
Anyhow, i could be wrong, so don't take what i said as corret.
Previous Comments:
------------------------------------------------------------------------
[2002-01-04 00:22:32] php@chaska.com
Oh, I suppose you want my configure line, even though it really doesn't make a difference.
Here it is:
CONFIGURE_COMMAND = './configure' '--with-gd=/usr/local'
'--with-mysql' '--with-openssl' '--with-apxs=/usr/local/sbin/apxs'
'--prefix=/usr/local'
------------------------------------------------------------------------
[2002-01-04 00:16:48] php@chaska.com
This problem was previously reported by someone against PHP 4.0.6 in Bug ID # 14214. Latest comment
on the that reports says they are going to close it for lack of information.
This bug has existed in every version of PHP I've used since 1999. It fails on Linux, FreeBSD
and Solaris.
Both mistaken report the directory which contains the script being run, NOT the current working
directory.
This fails when run from a directory other than where the script is saved:
#! /usr/local/bin/php -q
<?php
system("pwd");
echo
pwd;
echo getcwd();
echo "\n";
?>
Under any POSIX-compliant OS, or just about any version of Unix, calling the getcwd(3) library
routine should get the correct result. It appears the PHP interpreter startup is changing
directories without saving this value first, since even calling the OS gives incorrect values.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14839&edit=1