|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-21 11:00 UTC] ri at kamp dot de
Description:
------------
require cannot open a file in the same directory as the calling script [like require('./includefile.php')]. All dirs in the path have permission 755. OS is solaris 8, documentroot mounted as NFS, include_path has "." within. In the case this happens also getcwd() or passthru("/bin/pwd") gives no result but passthru("/bin/ls") list the "current" dir.
The function expand_filepath in main/fopen_wrappers.c gets an empty result when calling VCWD_GETCWD(cwd, MAXPATHLEN);
This may not be a php bug (maybe solaris8 or nfs) but occurs only within php. As workaround I changed expand_filepath to:
------------------
int cwd_pos;
result = VCWD_GETCWD(cwd, MAXPATHLEN);
if (!result) {
//cwd[0] = '\0';
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"cwd not working for %s",SG(request_info).path_translated);
strlcpy(cwd, SG(request_info).path_translated, sizeof(cwd));
cwd_pos = strlen(cwd) - 1;
/* Strip filename */
while (!IS_SLASH(cwd[cwd_pos])
&& (cwd_pos >= 0)) {
cwd[cwd_pos--] = 0;
}
}
------------------
I know this is no final solution but the scripts work thereafter.
Reproduce code:
---------------
include_path = ".:/usr/local/lib/php"
documentroot = "/home/htdocs"
script is in /home/htdocs/ (documentroot)
<? require('./somefile.php'; ?>
or
<? require('somefile.php'; ?>
Actual result:
--------------
Fatal error: main(): Failed opening required './somefile.php' (include_path='.:/usr/local/lib/php')
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
The output of /bin/pwd is correct if executed from the shell (even as user nobody). Also leaving out "." from include_path does not solve the problem but behaves different: 1.) ini_set("include_path","/usr/local/lib/php"); require("somefile.php"); works but it should not (or am I wrong?) 2.) ini_set("include_path","/usr/local/lib/php"); require("./somefile.php"); does not work even if its nearly the same also other commands (e.g. show_source) have problems. I can send you a link in private mail if you like to see the results Maybe its a solaris or apache bug but it seems to hit only php, so there may be reasons to solve the problem (if not a bug) in php.