php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27498 wrong error message generated by opendir when safe mode is in effect
Submitted: 2004-03-04 16:57 UTC Modified: 2004-03-16 18:14 UTC
From: fd@php.net Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.3.4 OS: debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fd@php.net
New email:
PHP Version: OS:

 

 [2004-03-04 16:57 UTC] fd@php.net
Description:
------------
while trying to open a dir that diddent exist, i recieved a wrong error-message. this caused me to waste a lot of time, before i finally figured out the real problem.

1. php is running as module under apache in safe mode. version = 4.3.3
2. /home/virtual/site1/fst/var/www/html/ is my www root
3. /home/virtual/site1/fst/var/www/html/data/ is a dir, end it's CHMOD 777
4. /home/virtual/site1/fst/var/www/html/data/subdir is non-existent

i recieve this error message :

Warning in line 3 of file /home/virtual/site1/fst/var/www/html/index.php
[2] opendir(): SAFE MODE Restriction in effect. The script whose uid is 503 is not allowed to access /home/virtual/site1/fst/var/www/html/data/subdir owned by uid 0 

witch gave my a few hours messing around until i finally discovered that i just forgot to create the dir in mention.
however - if php had given me a more precise error, i would have saved a lot of time. when it comes down to it, safemode had nothing to do with the real problem.

Reproduce code:
---------------
[index.php : begin]
<?php
$dir = "/home/virtual/site1/fst/var/www/html/data/subdir";
$handle = opendir($dir);
?>
[index.php : end]


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-05 13:36 UTC] nlopess@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 [2004-03-05 13:44 UTC] et@php.net
This is definitely a bug.

et@edea:~$ php -d'safe_mode=on' -r 'opendir("/home/et/nonexistant");'

Warning: opendir(): SAFE MODE Restriction in effect.  The script whose uid is 500 is not allowed to access /home/et owned by uid 0 in Command line code on line 1

Warning: opendir(/home/et/nonexistant): failed to open dir: No such file or directory in Command line code on line 1
et@edea:~$ ls -dla /home/et
drwxr-xr-x   61 et       et           4096 Mar  5 19:41 /home/et

 [2004-03-05 13:56 UTC] troels at kyberfabrikken dot dk
why is this not a bug ?

i get the message that my script is not allowed to access /home/virtual/site1/fst/var/www/html/data/

but that is false - it DOES in fact have thoose rights.
 [2004-03-06 13:34 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Not a bug. 
 [2004-03-16 14:19 UTC] fd@php.net
This is a bug! Why shouldn't it be one?

seric@debian:/home/seric$ php -d'safe_mode=on' -r 'opendir("/home/seric/bar");'

Warning: opendir(): SAFE MODE Restriction in effect.  The script whose uid is 1000 is not allowed to access /home/seric owned by uid 0 in Command line code on line 1

Warning: opendir(/home/seric/bar): failed to open dir: No such file or directory in Command line code on line 1

seric@debian:/home/seric$ php -v
PHP 4.3.4 (cli) (built: Dec 14 2003 17:50:17)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
 [2004-03-16 18:14 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 15:01:30 2024 UTC