]> granicus.if.org Git - php/commitdiff
- Don't pick up php.ini from cwd on BSDs
authorHannes Magnusson <bjori@php.net>
Wed, 25 Apr 2007 10:02:23 +0000 (10:02 +0000)
committerHannes Magnusson <bjori@php.net>
Wed, 25 Apr 2007 10:02:23 +0000 (10:02 +0000)
- "Resolve" (with the help of $PATH) to /path/to/php and pick up
the php.ini from there

main/php_ini.c

index f705996ba1a38a788fafb6f12763cc10017afcf8..9af002e1aa64b7cf1c39919ac9dfdf4ff0405ddc 100644 (file)
@@ -351,7 +351,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;                  
                        }