php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34842 Can't "chdir('./../');" when parent dir equals root dir
Submitted: 2005-10-12 23:22 UTC Modified: 2005-11-10 01:00 UTC
Votes:15
Avg. Score:4.1 ± 1.1
Reproduced:11 of 12 (91.7%)
Same Version:6 (54.5%)
Same OS:8 (72.7%)
From: marcel at hjortronet dot se Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5CVS-2005-10-12 (snap) OS: Windows Server 2003
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marcel at hjortronet dot se
New email:
PHP Version: OS:

 

 [2005-10-12 23:22 UTC] marcel at hjortronet dot se
Description:
------------
Consider this example web server:
'D:\wwwroot\myweb\' (published as http://www.myweb.com/)

IF the web servers access (or actually the 'IUSR_<computername>' user which enables IIS anonymous web access) is restricted to 'D:\wwwroot\myweb\' directory (and its subdirectories) and is not allowed to access any other local directory, like for example 'D:\wwwroot\', the code below ('chdir("../")') won't function if it is put into 'D:\wwwroot\myweb\test\' (published as http://www.myweb.com/test/reproducecode.php).

Otherwise, thanks for doing a wonderful job! //Marcel, Sweden

Reproduce code:
---------------
<?
  echo getcwd()."<br/>\n";
  echo chdir("../")."<br/>\n";
  echo getcwd()."<br/>\n";
?>

Expected result:
----------------
D:\wwwroot\myforum\test
1
D:\wwwroot\myforum

Actual result:
--------------
D:\wwwroot\myforum\test

D:\wwwroot\myforum\test

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-12 23:36 UTC] tony2001@php.net
Are you able to reproduce it with Apache ?
 [2005-10-17 22:18 UTC] marcel at hjortronet dot se
Yes, the results are exactly the same using Apache HTTPd v2.0.55 (Win32) and PHP (php5.1-win32-200510171430). I've just verified the test/results myself.

Sincerely // Marcel
 [2005-10-17 22:27 UTC] marcel at hjortronet dot se
more info on the apache test:

Actual Apache result @ the web client when no permission, for the user running the apache service, allowed to "D:\TEMP\apache-php-test\wwwroot\" but to "D:\TEMP\apache-php-test\wwwroot\a\" (the actual VirtualHost directory being published) and running the script* from within "D:\TEMP\apache-php-test\wwwroot\a\sub\":

"D:\TEMP\apache-php-test\wwwroot\a\sub
Warning: chdir() [function.chdir]: No such file or directory (errno 2) in D:\TEMP\apache-php-test\wwwroot\a\sub\index.php on line 3
D:\TEMP\apache-php-test\wwwroot\a\sub"

When allowing for access to "D:\TEMP\apache-php-test\wwwroot\" (outside the actual web) the result becomes:

"D:\TEMP\apache-php-test\wwwroot\a\sub
1
D:\TEMP\apache-php-test\wwwroot\a"

* Script:

"<?
  echo getcwd()."<br/>\n";
  echo chdir("../")."<br/>\n";
  echo getcwd()."<br/>\n";
?>"

Sincerely // Marcel
 [2005-11-02 14:13 UTC] sniper@php.net
Does it work if you do just chdir(".."); ??
 [2005-11-08 06:01 UTC] pault at briandunn dot com dot au
We recently moved from a linux server to a windows server and I beleive we may have come across this same problem.

// This code will result in the error.
$curPath = getcwd();  // Save current path.
chdir( $curPath );  // Restore path.

// Even this code will produce the error.
chdir( getcwd() );  

Warning: chdir() [function.chdir]: No such file or directory (errno 2) in...
 [2005-11-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC