php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8638 PHP handles permission problems ungracefully rather than letting Apache do it
Submitted: 2001-01-10 10:31 UTC Modified: 2001-05-16 07:43 UTC
From: jon at serf dot org Assigned:
Status: Closed Package: Apache related
PHP Version: 4.0.5 OS: Linux 2.2.17
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: jon at serf dot org
New email:
PHP Version: OS:

 

 [2001-01-10 10:31 UTC] jon at serf dot org
I'm using Apache 1.3 with the config line:
AddType application/x-httpd-php php
When the permissions on any .php file are not set correctly for Apache to read them, the error:
Warning: Failed opening '/path/to/page.php' for inclusion (include_path='/path/to/phplib') in Unknown on line 0
appears.
The same problem still occurs with include_path='.:/path/to/phplib' in php.ini.
This is user-hostile - what ought to happen would be that Apache's normal 403 error mechanism should be invoked.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-31 08:08 UTC] cynic@php.net
Does it still happen? IIRC it was fixed.
 [2001-04-02 05:07 UTC] jon at serf dot org
Yes, still happens with php4.04pl1.

 [2001-05-08 09:17 UTC] jon at serf dot org
Still happens with php 4.0.5.

 [2001-05-16 07:43 UTC] jon at serf dot org
That's a complete red herring; if file perms prevent your
script from even being read, it can't get as far as calling
set_error_handler().

However, after some further digging, I have discovered a
workaround; if you set auto_prepend_file in your php.ini
file, and call set_error_handler in that, it will be
triggered when the error above is generated. And if you put
code in it like:

if (($level == E_WARNING) && ($file == "Unknown")
    && ($line == 0)) {
  header("Location: /path/to/errordocument.html");
  exit;
}

then this will emulate Apache's normal behaviour when it
finds a file with bad permissions.

It's only a workaround, but as no-one seems interested in
fixing the underlying problem, it'll have to do.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 09:01:28 2025 UTC