diff --git a/php5/main/main.c b/php5/main/main.c index 9d976bb..853c4a1 100644 --- a/php5/main/main.c +++ b/php5/main/main.c @@ -456,6 +456,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("realpath_cache_size", "16K", PHP_INI_SYSTEM, OnUpdateLong, realpath_cache_size_limit, virtual_cwd_globals, cwd_globals) STD_PHP_INI_ENTRY("realpath_cache_ttl", "120", PHP_INI_SYSTEM, OnUpdateLong, realpath_cache_ttl, virtual_cwd_globals, cwd_globals) + STD_PHP_INI_ENTRY("alt_sapi_config_ini_scan_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, alt_sapi_config_ini_scan_dir, php_core_globals, core_globals) PHP_INI_END() /* }}} */ diff --git a/php5/main/php_globals.h b/php5/main/php_globals.h index ecf14d4..aee83d0 100644 --- a/php5/main/php_globals.h +++ b/php5/main/php_globals.h @@ -161,6 +161,7 @@ struct _php_core_globals { #endif long max_input_nesting_level; zend_bool in_user_include; + char *alt_sapi_config_ini_scan_dir; }; diff --git a/php5/main/php_ini.c b/php5/main/php_ini.c index ed69841..0a37f43 100644 --- a/php5/main/php_ini.c +++ b/php5/main/php_ini.c @@ -509,20 +509,30 @@ int php_init_config(TSRMLS_D) } } + /* If sapi is define the path to search .ini files, we must overwrite standart search path by sapi + * defined path. */ + char * config_file_scan_dir = NULL; + if (!sapi_module.php_ini_ignore) { + if (cfg_get_string("alt_sapi_config_ini_scan_dir", &config_file_scan_dir) == FAILURE) { + if (PHP_CONFIG_FILE_SCAN_DIR != NULL && strlen(PHP_CONFIG_FILE_SCAN_DIR)) + config_file_scan_dir = PHP_CONFIG_FILE_SCAN_DIR; + } + } + /* If the config_file_scan_dir is set at compile-time, go and scan this directory and * parse any .ini files found in this directory. */ - if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) { + if (!sapi_module.php_ini_ignore && config_file_scan_dir != NULL && strlen(config_file_scan_dir)) { struct dirent **namelist; int ndir, i; - if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) { + if ((ndir = php_scandir(config_file_scan_dir, &namelist, 0, php_alphasort)) > 0) { for (i = 0; i < ndir; i++) { /* check for a .ini extension */ if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { free(namelist[i]); continue; } - snprintf(ini_file, MAXPATHLEN, "%s%c%s", PHP_CONFIG_FILE_SCAN_DIR, DEFAULT_SLASH, namelist[i]->d_name); + snprintf(ini_file, MAXPATHLEN, "%s%c%s", config_file_scan_dir, DEFAULT_SLASH, namelist[i]->d_name); if (VCWD_STAT(ini_file, &sb) == 0) { if (S_ISREG(sb.st_mode)) { if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {