#21565 [Fbk->Opn]: include/require fail under safe-mode.
| From: | komanek at natur dot cuni dot cz | Date: | Tue, 14 Jan 2003 06:12:46 +0000 |
| Subject: | #21565 [Fbk->Opn]: include/require fail under safe-mode. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-29969@lists.php.net to get a copy of this message | ||
ID: 21565
User updated by: komanek@natur.cuni.cz
Reported By: komanek@natur.cuni.cz
-Status: Feedback
+Status: Open
Bug Type: Scripting Engine problem
Operating System: Tru64Unix 5.1A
PHP Version: 4.3.0
New Comment:
I turned all errors and warnings reporting to have maximum info. Here
is a real example from my web, with real paths in filesystem. Both
"include" and "require" are used to demonstrate the difference,
previously, I used only "require". Strange is that in php 4.2.2 it
worked fine for me. The only difference is the upgraded php dynamic
module for Apache. It is not the problem of non-existing files or paths
because with safe_mode = Off the included and required files are found
and opened with no errors.
<?php
include "header.php";?>
<center>
<p>
<b>
<a href="free_catalogue.php">The Catalogue</a>
</b>
</p>
</center>
<?php
require "footer.php";?>
</body>
</html>
The output of this is:
Warning: main() [function.main]: Unable to access ./header.php in
/usr/users/dbminer/public_html/index.php on line 2
Warning: main(header.php) [function.main]: failed to create stream: No
such file or directory in /usr/users/dbminer/public_html/index.php on
line 2
Warning: main() [function.main]: Failed opening 'header.php' for
inclusion
(include_path='.:./:/usr/users/komanek/public_html/TEST/phpclasses:/usr/local/lib/php:/usr/local/www/apache/htdocs/MINER:/usr/users/dbminer/public_html:/usr/users/popin/html2/statistics/i')
in /usr/users/dbminer/public_html/index.php on line 2
The Catalogue
Warning: main() [function.main]: Unable to access ./footer.php in
/usr/users/dbminer/public_html/index.php on line 11
Warning: main(footer.php) [function.main]: failed to create stream: No
such file or directory in /usr/users/dbminer/public_html/index.php on
line 11
Fatal error: main() [function.main]: Failed opening required
'footer.php'
(include_path='.:./:/usr/users/komanek/public_html/TEST/phpclasses:/usr/local/lib/php:/usr/local/www/apache/htdocs/MINER:/usr/users/dbminer/public_html:/usr/users/popin/html2/statistics/i')
in /usr/users/dbminer/public_html/index.php on line 11
From filesystem:
lib[0]:/usr/users/dbminer/public_html(07:04)# ls -al index.php
header.php footer.php
-rw-r--r-- 1 dbminer users 174 Oct 30 2000 footer.php
-rw-r--r-- 1 dbminer users 1047 Nov 7 2001 header.php
-rw-r--r-- 1 dbminer users 161 Jan 13 12:08 index.php
Configure switches:
--with-apache=/scratch/sources/apache_1.3.26 --with-openssl
--with-zlib=/usr/local --with-zlib-dir=/usr/local --with-bz2=/usr/local
--with-db --enable-dbase --with-gd --with-dom --enable-ftp
--enable-gd-native-ttf --with-freetype-dir=/usr/local/freetype2
--with-iconv --with-mysql --enable-trans-sid
--with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib
--enable-sockets --enable-discard-path --enable-safe-mode
--enable-bcmatch --enable-calendar --enable-ctype --enable-mailparse
--enable-force-cgi-redirect --enable-memory-limit
--with-expat-dir=/usr/local --with-xml --with-gettext --with-mcrypt
--with-imap=/scratch/sources/imap/imap-2002.RC2
--with-imap-ssl=/scratch/sources/imap/imap-2002.RC2 --disable-cgi
Previous Comments:
------------------------------------------------------------------------
[2003-01-13 17:45:48] iliaa@php.net
Do you get any other warning/error messages, something about UID of the
script not matching that of the file?
------------------------------------------------------------------------
[2003-01-13 17:37:23] sniper@php.net
updated the summary line.
------------------------------------------------------------------------
[2003-01-13 04:09:18] komanek@natur.cuni.cz
Well, you are right with the difference fatal error vs. warning. After
I turned the warning messages on I can see the difference. So, the
problem should be re-classified as a problem of both include and
require.
Still, with safe_mode on, it does not work, with safe_mode off, it
works fine.
------------------------------------------------------------------------
[2003-01-10 16:56:46] iliaa@php.net
It is likely that your error reporting level is such that warning
messages do not get shown. Unlike require which fails with an error
include will only output a warning on failure.
Beyond that there is very little difference between the require/include
code none of which is the code reponsible for actually openning files.
------------------------------------------------------------------------
[2003-01-10 03:35:37] komanek@natur.cuni.cz
After upgrade from PHP 4.2.2 to 4.3.0 I encountered the problem with
safe_mode in conjunction with require().
Example:
[php.ini]
safe_mode = On;
include_path = ".:./:/path/to/my/app/dir";
safe_mode_include_dir = ".:./:/path/to/my/app/dir";
[/path/to/my/app/dir/index_working.php] - works fine for me
<?php
include "header.php";
?>
[/path/to/my/app/dir/index_buggy.php] - throws error
<?php
require "header.php";
?>
The error:
[error] PHP Fatal error: main() [<a
href='http://www.php.net/function.main'>function.main</a>]:
Failed
opening required 'header.php' (include_path='.:./:/path/to/my/app/dir')
in /path/to/my/app/dir/index_buggy.php on line 2
Operating system: Tru64Unix 5.1a
Webserver: Apache 1.3.26
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21565&edit=1