summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2005-07-29 14:29:27 +0000
committerfoobar <sniper@php.net>2005-07-29 14:29:27 +0000
commitf66d5f0cc5209c1166ec4f1e64fa44998f76aa14 (patch)
treed42d46007779622f6f61d2a5fda3533405144145
parentb325b340b7694738af6ef29872d957c1c47f74c7 (diff)
downloadphp-git-f66d5f0cc5209c1166ec4f1e64fa44998f76aa14.tar.gz
- Fixed few logic errors in php*.ini search path creation as documented here:
http://fi.php.net/manual/en/configuration.php#configuration.file # # Before this patch: # # $ strace php -r 'echo 1;' 2>&1 | grep php.ini # open("/www/php/lib/php.ini", O_RDONLY) = 3 # lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0 # # With this patch: # # $ strace php -r 'echo 1;' 2>&1 | grep php.ini # open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) # open("/usr/src/php5_1_full/sapi/cli/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory) # open("/www/php/lib/php.ini", O_RDONLY) = 3 # lstat64("/www/php/lib/php.ini", {st_mode=S_IFREG|0640, st_size=46264, ...}) = 0 #
-rw-r--r--main/php_ini.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/main/php_ini.c b/main/php_ini.c
index 054f093522..e4c14f26b1 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -18,9 +18,6 @@
/* $Id$ */
-/* Check CWD for php.ini */
-#define INI_CHECK_CWD
-
#include "php.h"
#include "ext/standard/info.h"
#include "zend_ini.h"
@@ -261,11 +258,10 @@ static void php_load_zend_extension_cb(void *arg TSRMLS_DC)
*/
int php_init_config()
{
- char *env_location, *php_ini_search_path;
- char *binary_location;
+ char *php_ini_search_path = NULL;
int safe_mode_state;
char *open_basedir;
- int free_ini_search_path=0;
+ int free_ini_search_path = 0;
zend_file_handle fh;
struct stat sb;
char ini_file[MAXPATHLEN];
@@ -290,20 +286,27 @@ int php_init_config()
safe_mode_state = PG(safe_mode);
open_basedir = PG(open_basedir);
- env_location = getenv("PHPRC");
- if (!env_location) {
- env_location = "";
- }
if (sapi_module.php_ini_path_override) {
php_ini_search_path = sapi_module.php_ini_path_override;
free_ini_search_path = 0;
- } else {
+ } else if (!sapi_module.php_ini_ignore) {
char *default_location;
+ char *env_location;
+ char *binary_location;
static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
#ifdef PHP_WIN32
char *reg_location;
#endif
+ env_location = getenv("PHPRC");
+ if (!env_location) {
+ env_location = "";
+ }
+
+ /*
+ * Prepare search path
+ */
+
php_ini_search_path = (char *) emalloc(MAXPATHLEN * 4 + strlen(env_location) + 3 + 1);
free_ini_search_path = 1;
php_ini_search_path[0] = 0;
@@ -311,7 +314,7 @@ int php_init_config()
#ifdef PHP_WIN32
/* Add registry location */
reg_location = GetIniPathFromRegistry();
- if(reg_location != NULL) {
+ if (reg_location != NULL) {
if (*php_ini_search_path) {
strcat(php_ini_search_path, paths_separator);
}
@@ -319,9 +322,6 @@ int php_init_config()
efree(reg_location);
}
#endif
- /*
- * Prepare search path
- */
/* Add environment location */
if (env_location[0]) {
@@ -331,15 +331,13 @@ int php_init_config()
strcat(php_ini_search_path, env_location);
}
- /* Add cwd */
-#ifdef INI_CHECK_CWD
- if (strcmp(sapi_module.name, "cli") != 0) {
+ /* Add cwd (only with CLI) */
+ if (strcmp(sapi_module.name, "cli") == 0) {
if (*php_ini_search_path) {
strcat(php_ini_search_path, paths_separator);
}
strcat(php_ini_search_path, ".");
}
-#endif
/* Add binary directory */
#ifdef PHP_WIN32