From: ri at kamp dot de
Operating system: Solaris 8
PHP version: 4CVS-2003-08-21 (stable)
PHP Bug Type: Filesystem function related
Bug description: require() not findings files when "." is in include_path
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')
--
Edit bug report at http://bugs.php.net/?id=25194&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25194&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25194&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=25194&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=25194&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25194&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=25194&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=25194&r=support
Expected behavior: http://bugs.php.net/fix.php?id=25194&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=25194&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=25194&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=25194&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25194&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=25194&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=25194&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=25194&r=gnused