]>
Commit | Line | Data |
---|---|---|
1015d69e ER |
1 | --- php-5.2.7/main/php_ini.c 2008-08-14 19:34:30.000000000 +0300 |
2 | +++ php-5.2.7-inidir/main/php_ini.c 2008-12-05 12:53:24.747685251 +0200 | |
3 | @@ -474,6 +474,24 @@ | |
4 | } | |
80259e0d JB |
5 | } |
6 | } | |
7 | + /* Search (global) php.ini file in search path */ | |
1015d69e | 8 | + if (!fh.handle.fp) { |
80259e0d | 9 | + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); |
1015d69e ER |
10 | + if (fh.handle.fp) { |
11 | + fh.filename = php_ini_opened_path; | |
708beb0c JB |
12 | + PG(safe_mode) = safe_mode_state; |
13 | + PG(open_basedir) = open_basedir; | |
14 | + fh.type = ZEND_HANDLE_FP; | |
15 | + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists); | |
16 | + safe_mode_state = PG(safe_mode); | |
17 | + open_basedir = PG(open_basedir); | |
18 | + PG(safe_mode) = 0; | |
19 | + PG(open_basedir) = NULL; | |
20 | + fh.handle.fp = NULL; | |
bb44e93f JB |
21 | + efree(php_ini_opened_path); |
22 | + fh.filename = php_ini_opened_path = NULL; | |
1015d69e ER |
23 | + } |
24 | + } | |
4eea33b4 | 25 | |
1015d69e | 26 | /* Otherwise search for php-%sapi-module-name%.ini file in search path */ |
633983a3 | 27 | if (!fh.handle.fp) { |
1015d69e | 28 | @@ -486,14 +504,6 @@ |
633983a3 AM |
29 | fh.filename = php_ini_opened_path; |
30 | } | |
1015d69e ER |
31 | } |
32 | - | |
33 | - /* If still no ini file found, search for php.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 | - if (fh.handle.fp) { | |
37 | - fh.filename = php_ini_opened_path; | |
38 | - } | |
39 | - } | |
40 | } | |
41 | ||
42 | if (free_ini_search_path) { | |
43 | @@ -533,9 +543,13 @@ | |
633983a3 AM |
44 | /* Scan and parse any .ini files found in scan path if path not empty. */ |
45 | if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) { | |
38d9a36f ER |
46 | struct dirent **namelist; |
47 | - int ndir, i; | |
48 | + int ndir, i, found = 0; | |
49 | + const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d"; | |
50 | + char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name)); | |
51 | + sprintf(sapi_scan_dir, fmt, sapi_module.name); | |
52 | ||
633983a3 | 53 | if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) { |
38d9a36f ER |
54 | + found += ndir; |
55 | for (i = 0; i < ndir; i++) { | |
56 | /* check for a .ini extension */ | |
57 | if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { | |
1015d69e ER |
58 | @@ -556,6 +570,35 @@ |
59 | /* Here, add it to the list of ini files read */ | |
60 | l = strlen(ini_file); | |
61 | total_l += l + 2; | |
62 | + p = estrndup(ini_file, l); | |
63 | + zend_llist_add_element(&scanned_ini_list, &p); | |
64 | + } | |
65 | + } | |
66 | + } | |
67 | + free(namelist[i]); | |
68 | + } | |
69 | + free(namelist); | |
38d9a36f | 70 | + } |
1015d69e | 71 | + |
38d9a36f ER |
72 | + if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) { |
73 | + found += ndir; | |
1015d69e | 74 | + |
38d9a36f ER |
75 | + for (i = 0; i < ndir; i++) { |
76 | + /* check for a .ini extension */ | |
77 | + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { | |
78 | + free(namelist[i]); | |
79 | + continue; | |
80 | + } | |
81 | + snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name); | |
82 | + if (VCWD_STAT(ini_file, &sb) == 0) { | |
83 | + if (S_ISREG(sb.st_mode)) { | |
84 | + if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) { | |
85 | + fh.filename = ini_file; | |
86 | + fh.type = ZEND_HANDLE_FP; | |
87 | + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists); | |
88 | + /* Here, add it to the list of ini files read */ | |
89 | + l = strlen(ini_file); | |
90 | + total_l += l + 2; | |
1015d69e ER |
91 | p = estrndup(ini_file, l); |
92 | zend_llist_add_element(&scanned_ini_list, &p); | |
93 | } | |
94 | @@ -564,8 +607,11 @@ | |
95 | free(namelist[i]); | |
96 | } | |
97 | free(namelist); | |
38d9a36f ER |
98 | + } |
99 | + efree(sapi_scan_dir); | |
633983a3 | 100 | |
1015d69e ER |
101 | - /* |
102 | + if (found) { | |
103 | + /* | |
38d9a36f | 104 | * Don't need an extra byte for the \0 in this malloc as the last |
1015d69e ER |
105 | * element will not get a trailing , which gives us the byte for the \0 |
106 | */ |