]> granicus.if.org Git - php/commitdiff
MFH: Fixed PHP CLI to use the php.ini from the binary location
authorHannes Magnusson <bjori@php.net>
Sun, 6 May 2007 14:01:26 +0000 (14:01 +0000)
committerHannes Magnusson <bjori@php.net>
Sun, 6 May 2007 14:01:26 +0000 (14:01 +0000)
NEWS
main/php_ini.c

diff --git a/NEWS b/NEWS
index 7408ef9c0b5d39e19fe26b4c0557bc40c299b6f1..efc0b8e5bde2fb1880d5bb3402b89f6678fa1a99 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ PHP                                                                        NEWS
 - Fixed ext/filter Email Validation Vulnerability (MOPB-24 by Stefan Esser)
   (Ilia)
 - Fixed altering $this via argument named "this". (Dmitry)
+- Fixed PHP CLI to use the php.ini from the binary location. (Hannes)
 - Fixed bug #41287 (Namespace functions don't allow xmlns defintion to be 
   optional). (Rob)
 - Fixed bug #41285 (Improved fix for CVE-2007-1887 to work with non-bundled
index 5fe320eeafe6c64df8880e7b3dfa7d7bf5b5ac95..ae39d81d5ba55796857c35ad2e7c0d9bf0073bc9 100644 (file)
@@ -353,7 +353,26 @@ int php_init_config(TSRMLS_D)
 #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;                  
                        }