--- main/fopen_wrappers.c.orig Wed Oct 23 11:49:40 2002 +++ main/fopen_wrappers.c Thu Oct 24 12:01:27 2002 @@ -189,13 +189,31 @@ /* Only check when open_basedir is available */ if (PG(open_basedir) && *PG(open_basedir)) { char *pathbuf; + char *newpath; char *ptr; char *end; pathbuf = estrdup(PG(open_basedir)); + newpath = estrdup(zend_get_executed_filename(TSRMLS_C)); ptr = pathbuf; + while (ptr && *ptr) { + end = strchr(ptr, DEFAULT_DIR_SEPARATOR); + if (end != NULL) { + *end = '\0'; + end++; + } + if (php_check_specific_open_basedir(ptr, newpath TSRMLS_CC) == 0) { + efree(pathbuf); + efree(newpath); + return 0; + } + + ptr = end; + } + + ptr = pathbuf; while (ptr && *ptr) { end = strchr(ptr, DEFAULT_DIR_SEPARATOR); if (end != NULL) { @@ -205,13 +223,16 @@ if (php_check_specific_open_basedir(ptr, path TSRMLS_CC) == 0) { efree(pathbuf); + efree(newpath); return 0; } ptr = end; } - php_error(E_WARNING, "open_basedir restriction in effect. File is in wrong directory"); + php_error(E_WARNING, "open_basedir: File should be in %s, but is in %s file (%s)", + pathbuf, path, newpath); efree(pathbuf); + efree(newpath); errno = EPERM; /* we deny permission to open it */ return -1; } @@ -226,8 +247,8 @@ PHPAPI int php_check_safe_mode_include_dir(char *path TSRMLS_DC) { /* Only check when safe_mode on and safe_mode_include_dir is available */ - if (PG(safe_mode) && PG(safe_mode_include_dir) && - *PG(safe_mode_include_dir)) + if (((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) + && PG(safe_mode_include_dir) && *PG(safe_mode_include_dir)) { char *pathbuf; char *ptr; @@ -268,7 +289,7 @@ } /* Nothing to check... */ - return -1; + return 0; } /* }}} */