]> git.pld-linux.org Git - packages/php.git/blob - php-sapi-ini-file.patch
use /usr/sbin/php-fpm as other branches
[packages/php.git] / php-sapi-ini-file.patch
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 @@
17                                 }
18                         }
19                 }
20 +               /* Search (global) php.ini file in search path */
21 +               if (!fh.handle.fp) {
22 +                       fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
23 +                       if (fh.handle.fp) {
24 +                               fh.filename = php_ini_opened_path;
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;
34 +                               efree(php_ini_opened_path);
35 +                               fh.filename = php_ini_opened_path = NULL;
36 +                       }
37 +               }
38  
39                 /* Otherwise search for php-%sapi-module-name%.ini file in search path */
40                 if (!fh.handle.fp) {
41 @@ -486,14 +510,6 @@
42                                 fh.filename = php_ini_opened_path;
43                         }
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) {
56 @@ -533,9 +549,13 @@
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) {
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  
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) {
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"))) {
72 @@ -556,6 +576,35 @@
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);
84 +               }
85 +
86 +               if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_csort)) > 0) {
87 +                       found += ndir;
88 +
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;
105                                                         p = estrndup(ini_file, l);
106                                                         zend_llist_add_element(&scanned_ini_list, &p);
107                                                 }
108 @@ -564,8 +613,11 @@
109                                 free(namelist[i]);
110                         }
111                         free(namelist);
112 +               }
113 +               efree(sapi_scan_dir);
114  
115 -                       /*
116 +               if (found) {
117 +                       /* 
118                          * Don't need an extra byte for the \0 in this malloc as the last
119                          * element will not get a trailing , which gives us the byte for the \0
120                          */
This page took 0.036505 seconds and 3 git commands to generate.