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