]> git.pld-linux.org Git - packages/php.git/blob - php-sapi-ini-file.patch
- update to 5.2.7
[packages/php.git] / php-sapi-ini-file.patch
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 @@
4                         }
5                 }
6  
7 -               /* Otherwise search for php-%sapi-module-name%.ini file in search path */
8 +               /* Search (global) php.ini file in search path */
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);
15 +                       fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
16                         if (fh.handle.fp) {
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);
24 +                               PG(safe_mode) = 0;
25 +                               PG(open_basedir) = NULL;
26 +                               fh.handle.fp = NULL;
27 +                               efree(php_ini_opened_path);
28 +                               fh.filename = php_ini_opened_path = NULL;
29                         }
30                 }
31  
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) {
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  
54                 if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
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"))) {
59 @@ -564,6 +579,38 @@
60                                 free(namelist[i]);
61                         }
62                         free(namelist);
63 +               }
64 +               
65 +               if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) {
66 +                       found += ndir;
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;
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);
91 +               }
92 +               efree(sapi_scan_dir);
93 +
94 +               if (found) {
95  
96                         /*
97                          * Don't need an extra byte for the \0 in this malloc as the last
This page took 0.033302 seconds and 3 git commands to generate.