1 --- php-5.2.7/main/php_ini.c.org 2008-12-05 23:30:07.843241117 +0100
2 +++ php-5.2.7/main/php_ini.c 2008-12-05 23:36:18.096968965 +0100
7 - /* Otherwise search for php-%sapi-module-name%.ini file in search path */
8 + /* Search (global) php.ini file in search path */
10 - const char *fmt = "php-%s.ini";
12 - spprintf(&ini_fname, 0, fmt, sapi_module.name);
13 - fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
15 + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
17 fh.filename = php_ini_opened_path;
18 + PG(safe_mode) = safe_mode_state;
19 + PG(open_basedir) = open_basedir;
20 + fh.type = ZEND_HANDLE_FP;
21 + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
22 + safe_mode_state = PG(safe_mode);
23 + open_basedir = PG(open_basedir);
25 + PG(open_basedir) = NULL;
26 + fh.handle.fp = NULL;
27 + efree(php_ini_opened_path);
28 + fh.filename = php_ini_opened_path = NULL;
32 - /* If still no ini file found, search for php.ini file in search path */
33 + /* Otherwise search for php-%sapi-module-name%.ini file in search path */
35 - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
36 + const char *fmt = "php-%s.ini";
38 + spprintf(&ini_fname, 0, fmt, sapi_module.name);
39 + fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
42 fh.filename = php_ini_opened_path;
45 /* Scan and parse any .ini files found in scan path if path not empty. */
46 if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
47 struct dirent **namelist;
49 + int ndir, i, found = 0;
50 + const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d";
51 + char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name));
52 + sprintf(sapi_scan_dir, fmt, sapi_module.name);
54 if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
56 for (i = 0; i < ndir; i++) {
57 /* check for a .ini extension */
58 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
65 + if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) {
67 + for (i = 0; i < ndir; i++) {
68 + /* check for a .ini extension */
69 + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
73 + snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name);
74 + if (VCWD_STAT(ini_file, &sb) == 0) {
75 + if (S_ISREG(sb.st_mode)) {
76 + if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
77 + fh.filename = ini_file;
78 + fh.type = ZEND_HANDLE_FP;
79 + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
80 + /* Here, add it to the list of ini files read */
81 + l = strlen(ini_file);
83 + p = estrndup(ini_file, l);
84 + zend_llist_add_element(&scanned_ini_list, &p);
92 + efree(sapi_scan_dir);
97 * Don't need an extra byte for the \0 in this malloc as the last