summaryrefslogtreecommitdiff
path: root/main/php_ini.c
diff options
context:
space:
mode:
authorHannes Magnusson <bjori@php.net>2007-05-06 14:01:26 +0000
committerHannes Magnusson <bjori@php.net>2007-05-06 14:01:26 +0000
commit448dbac84f310885c35f42c34de9e503c2c9b95b (patch)
tree4b88f3003e65b56980066b89cf3b0a2882e5da15 /main/php_ini.c
parent1d2c53b2494752d23255e3566b997ac4b467dfe0 (diff)
downloadphp-git-448dbac84f310885c35f42c34de9e503c2c9b95b.tar.gz
MFH: Fixed PHP CLI to use the php.ini from the binary location
Diffstat (limited to 'main/php_ini.c')
-rw-r--r--main/php_ini.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/main/php_ini.c b/main/php_ini.c
index 5fe320eeaf..ae39d81d5b 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -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;
}