Hi all
Attached is a patch for the PHP-cli php.ini search path feature which
fixes two things:
a) php.ini from cwd was picked up on BSDs
b) "resolves" to correct php-binary-location and picks up the php.ini
file from there
The php.ini-from-binary-location feature has never worked properly
before on *nix except with /path/to/php :(
Any objections?
-Hannes
Index: main/php_ini.c
===================================================================
RCS file: /repository/php-src/main/php_ini.c,v
retrieving revision 1.136.2.4.2.8
diff -u -r1.136.2.4.2.8 php_ini.c
--- main/php_ini.c 16 Apr 2007 08:09:56 -0000 1.136.2.4.2.8
+++ main/php_ini.c 23 Apr 2007 16:41:20 -0000
@@ -353,7 +353,26 @@
#else
if (sapi_module.executable_location) {
binary_location = (char *)emalloc(PATH_MAX);
- if (!realpath(sapi_module.executable_location,
binary_location)) {
+ if(!strchr(sapi_module.executable_location, '/')) {
+ char *path;
+ int found = 0;
+
+ if((path = getenv("PATH")) != NULL) {
+ char *search_dir,
search_path[MAXPATHLEN];
+
+ while ((search_dir = strsep(&path,
":")) != NULL) {
+ snprintf(search_path,
MAXPATHLEN, "%s/%s", search_dir, sapi_module.executable_location);
+ if (VCWD_REALPATH(search_path,
binary_location) && !VCWD_ACCESS(binary_location, X_OK)) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ if(!found) {
+ efree(binary_location);
+ binary_location = NULL;
+ }
+ } else if
(!VCWD_REALPATH(sapi_module.executable_location, binary_location) ||
VCWD_ACCESS(binary_location, X_OK)) {
efree(binary_location);
binary_location = NULL;
}
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php