]> git.pld-linux.org Git - packages/php.git/blame - php-sapi-ini-file.patch
- release 12
[packages/php.git] / php-sapi-ini-file.patch
CommitLineData
4eea33b4
ER
1--- php5.2-200710301730/main/php_ini.c 2007-08-31 11:31:28.000000000 +0300
2+++ php5.2-200710301730-sapi-ini-file/main/php_ini.c 2007-10-30 21:28:48.493329368 +0200
3@@ -463,6 +463,24 @@
80259e0d
JB
4 }
5 }
6 }
7+ /* Search (global) php.ini file in search path */
8+ if (!fh.handle.fp) {
9+ fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
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;
80259e0d 23+ }
80259e0d
JB
24+ }
25 /* Search php-%sapi-module-name%.ini file in search path */
26 if (!fh.handle.fp) {
27 const char *fmt = "php-%s.ini";
4eea33b4
ER
28@@ -474,13 +492,6 @@
29 fh.filename = php_ini_opened_path;
80259e0d 30 }
bb44e93f 31 }
80259e0d
JB
32- /* Search php.ini file in search path */
33- if (!fh.handle.fp) {
34- fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
35- if (fh.handle.fp) {
36- fh.filename = php_ini_opened_path;
37- }
bb44e93f 38- }
9d6174b1 39 }
4eea33b4 40
80259e0d 41 if (free_ini_search_path) {
4eea33b4 42@@ -513,9 +524,13 @@
38d9a36f
ER
43 * parse any .ini files found in this directory. */
44 if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
45 struct dirent **namelist;
46- int ndir, i;
47+ int ndir, i, found = 0;
48+ const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d";
49+ char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name));
50+ sprintf(sapi_scan_dir, fmt, sapi_module.name);
51
52 if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) {
53+ found += ndir;
54 for (i = 0; i < ndir; i++) {
55 /* check for a .ini extension */
56 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
4eea33b4
ER
57@@ -532,6 +547,35 @@
58 /* Here, add it to the list of ini files read */
59 l = strlen(ini_file);
60 total_l += l + 2;
61+ p = estrndup(ini_file, l);
62+ zend_llist_add_element(&scanned_ini_list, &p);
63+ }
64+ }
65+ }
66+ free(namelist[i]);
67+ }
68+ free(namelist);
38d9a36f
ER
69+ }
70+
71+ if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) {
72+ found += ndir;
73+
74+ for (i = 0; i < ndir; i++) {
75+ /* check for a .ini extension */
76+ if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
77+ free(namelist[i]);
78+ continue;
79+ }
80+ snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name);
81+ if (VCWD_STAT(ini_file, &sb) == 0) {
82+ if (S_ISREG(sb.st_mode)) {
83+ if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
84+ fh.filename = ini_file;
85+ fh.type = ZEND_HANDLE_FP;
86+ zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
87+ /* Here, add it to the list of ini files read */
88+ l = strlen(ini_file);
89+ total_l += l + 2;
4eea33b4
ER
90 p = estrndup(ini_file, l);
91 zend_llist_add_element(&scanned_ini_list, &p);
92 }
93@@ -540,8 +584,11 @@
94 free(namelist[i]);
95 }
96 free(namelist);
38d9a36f
ER
97+ }
98+ efree(sapi_scan_dir);
99
4eea33b4 100- /*
38d9a36f 101+ if (found) {
4eea33b4 102+ /*
38d9a36f
ER
103 * Don't need an extra byte for the \0 in this malloc as the last
104 * element will not get a trailing , which gives us the byte for the \0
4eea33b4 105 */
This page took 0.081836 seconds and 4 git commands to generate.