php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43977 chdir() not working with absolute path / CWD not properly reset
Submitted: 2008-01-29 21:49 UTC Modified: 2013-02-18 00:33 UTC
Votes:27
Avg. Score:4.3 ± 0.8
Reproduced:25 of 26 (96.2%)
Same Version:17 (68.0%)
Same OS:12 (48.0%)
From: sysdev at gmx dot net Assigned:
Status: No Feedback Package: IIS related
PHP Version: 5.2.6 OS: Windows Server 2003
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sysdev at gmx dot net
New email:
PHP Version: OS:

 

 [2008-01-29 21:49 UTC] sysdev at gmx dot net
Description:
------------
IIS 6 with PHP 5 SAPI:

In some cases, the CWD of a PHP-script run is not properly reset to the script's directory. Its instead the directory of another previously run script.

chdir() with an absulote path fails in these cases if the desired path is no child of the script's path itself, while chdir() with a relative path to the same destination succeedes.

Reproduce code:
---------------
Script located in d:\webshare\web3

echo '<div>CWD is '.getcwd().'</div>';
chdir( 'd:\\webshare\\web3' );
echo '<div>CWD is '.getcwd().'</div>';
chdir( 'd:\\webshare\\web3\\test' );
echo '<div>CWD is '.getcwd().'</div>';

Expected result:
----------------
Script located in d:\webshare\web3

CWD is 'd:\webshare\web3'
CWD is 'd:\webshare\web3'
CWD is 'd:\webshare\web3\test'

Actual result:
--------------
Script located in d:\webshare\web3

CWD is 'd:\webshare\another\scripts\path'
Warning: chdir() [function.chdir]: No such file or directory (errno 2) in D:\webshare\web3\test.php on line 4
CWD is 'd:\webshare\another\scripts\path'
CWD is 'd:\webshare\web3\test'

-- or sometimes --

Script located in d:\webshare\web3

CWD is 'd:\webshare\another\scripts\path'
Warning: chdir() [function.chdir]: No error (errno 0) in D:\webshare\web3\test.php on line 4
CWD is 'd:\webshare\another\scripts\path'
CWD is 'd:\webshare\web3\test'



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-26 08:09 UTC] php5 dot 20 dot cheef-daniel at spamgoumet dot com
I checked it with php 5.2.5 and 5.2.6 + IIS + Win 2003 Server SP1.
Same error on both versions, I even can't include files because of this.

include(config.php) [function.include]: failed to open stream: No such file or directory

config.php is in the same directory and has same rights than the calling index.php.

getcwd, placed on top of index.php shows me everytime I run this script another dir out of the docroot. chdir(basename(__FILE__)) under/above getcwd fails with error 0 like in this bugreport.
 [2008-10-21 15:32 UTC] jani@php.net
We are aware of PHP's problems with stability under IIS and are working 
to rectify the problem. Unfortunatly your bug report does not contain any
extra useful information and we already have enough bug reports open about
this issue. If you can provide more detailed information such as a 
reproducable crash or a backtrace please do so and reopen this bug. 
Otherwise please keep trying new releases as we are working to resolve 
the problems on this platform
 
Thanks for your interest in PHP.


 [2010-07-23 19:40 UTC] dscotese at litmocracy dot com
I am using XAMPP and I just got the "No error(errno 0)" error on an attempt to change directory to /var/www/a_misspelled_dirname.  The error should have been No such file or directory (errno 2).  I thought this info might be useful, as I'm not using IIS at all.

PHP Version 5.2.5

System 	Windows NT DAVESTOSHIBA 5.1 build 2600
Build Date 	Nov 8 2007 23:18:08
Configure Command 	cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
Server API 	Apache 2.0 Handler
Virtual Directory Support 	enabled
Configuration File (php.ini) Path 	C:\WINDOWS
Loaded Configuration File 	C:\xampp\apache\bin\php.ini
PHP API 	20041225
PHP Extension 	20060613
Zend Extension 	220060519
 [2010-07-23 19:41 UTC] pajoye@php.net
-Status: Bogus +Status: Feedback
 [2010-07-23 19:41 UTC] pajoye@php.net
@dscotese at litmocracy dot com

Please try using a recent PHP version and provide
 [2013-02-18 00:33 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 12:01:27 2024 UTC