]>
Commit | Line | Data |
---|---|---|
633983a3 AM |
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 | |
3 | @@ -475,21 +475,32 @@ | |
80259e0d JB |
4 | } |
5 | } | |
633983a3 AM |
6 | |
7 | - /* Otherwise search for php-%sapi-module-name%.ini file in search path */ | |
80259e0d | 8 | + /* Search (global) php.ini file in search path */ |
633983a3 AM |
9 | if (!fh.handle.fp) { |
10 | - const char *fmt = "php-%s.ini"; | |
11 | - char *ini_fname; | |
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); | |
14 | - efree(ini_fname); | |
80259e0d | 15 | + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); |
633983a3 AM |
16 | if (fh.handle.fp) { |
17 | fh.filename = php_ini_opened_path; | |
708beb0c JB |
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); | |
24 | + PG(safe_mode) = 0; | |
25 | + PG(open_basedir) = NULL; | |
26 | + fh.handle.fp = NULL; | |
bb44e93f JB |
27 | + efree(php_ini_opened_path); |
28 | + fh.filename = php_ini_opened_path = NULL; | |
80259e0d | 29 | } |
bb44e93f | 30 | } |
4eea33b4 | 31 | |
633983a3 AM |
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 */ | |
34 | if (!fh.handle.fp) { | |
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"; | |
37 | + char *ini_fname; | |
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); | |
40 | + efree(ini_fname); | |
41 | if (fh.handle.fp) { | |
42 | fh.filename = php_ini_opened_path; | |
43 | } | |
44 | @@ -533,9 +544,13 @@ | |
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) { | |
38d9a36f ER |
47 | struct dirent **namelist; |
48 | - int ndir, i; | |
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); | |
53 | ||
633983a3 | 54 | if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) { |
38d9a36f ER |
55 | + found += ndir; |
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"))) { | |
633983a3 AM |
59 | @@ -564,6 +579,38 @@ |
60 | free(namelist[i]); | |
61 | } | |
62 | free(namelist); | |
38d9a36f | 63 | + } |
633983a3 | 64 | + |
38d9a36f ER |
65 | + if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) { |
66 | + found += ndir; | |
38d9a36f ER |
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"))) { | |
70 | + free(namelist[i]); | |
71 | + continue; | |
72 | + } | |
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); | |
82 | + total_l += l + 2; | |
633983a3 AM |
83 | + p = estrndup(ini_file, l); |
84 | + zend_llist_add_element(&scanned_ini_list, &p); | |
85 | + } | |
86 | + } | |
87 | + } | |
88 | + free(namelist[i]); | |
89 | + } | |
90 | + free(namelist); | |
38d9a36f ER |
91 | + } |
92 | + efree(sapi_scan_dir); | |
633983a3 | 93 | + |
38d9a36f | 94 | + if (found) { |
633983a3 AM |
95 | |
96 | /* | |
38d9a36f | 97 | * Don't need an extra byte for the \0 in this malloc as the last |