Edit report at https://bugs.php.net/bug.php?id=18332&edit=1

 ID:                 18332
 Updated by:         re...@php.net
 Reported by:        ilia at prohost dot org
 Summary:            is_readable/is_writable/is_executable support under
                     safe mode
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   any
 PHP Version:        4.2.1
-Assigned To:        
+Assigned To:        reeze
 Block user comment: N
 Private report:     N

 New Comment:

Safe mode was gone.


Previous Comments:
------------------------------------------------------------------------
[2002-09-24 21:55:46] ekilf...@php.net

I recently ran into this same problem.  With the open_basedir config option 
set, is_readable() can report unexpected results.

Perhaps a solution may be to run through all of the security checks that fopen 
goes through and find out if the file is readable.  Another solution would be 
to actually just flat out open the file with php_fopen() for read or append 
(for is_writable()) and see what is returned.

Perhaps an argument can be added such as:

is_readable(STRICT) where STRICT checks everything

is_readable(STRICT | ATTEMPT) would actually attempt the open.

I'm just throwing out ideas.  My problem is that I would like a way to 
guarantee that no errors or warnings are returned by a call to fopen() with the 
E_ALL error level set.  I was using:

file_exists() && is_readable()

I can't think of any check to perform other than writing a function in my 
script that does a "safe" open such as:

function is_truly_readable()
{
  $e = error_reporting(0);
  if ($f = fopen($file, "r"))
  {
    fclose($f);
    error_reporting($e);
    return(TRUE);
  }
  error_reporting($e);
  return(FALSE);
}

------------------------------------------------------------------------
[2002-09-22 16:37:38] il...@php.net

In the current release of the manual is_readable/is_writable now mention the 
fact that they will not check safe_mode limitation. The is_executable however, 
still needs to be documented.

------------------------------------------------------------------------
[2002-07-15 21:52:19] yohg...@php.net

I think stat function can be used to know actual permissions. is_* function 
supposed to return if current process can do something or not. IMO.

We may need to change doc a bit. -> Documentation Problem


------------------------------------------------------------------------
[2002-07-13 18:31:32] ilia at prohost dot org

It would be very useful if is_readable/is_writable/is_executable
series of functions would work with safe mode. Currently is_writable() will 
report a file that in reality cannot be accessed undersafe mode is writeable, 
which is clearly misleading.

At least, could the manual be modified in such a way as to document that those 
functions will not work properly under safe_mode.

------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=18332&edit=1

Reply via email to