diff -Naur php-5.6.0.orig/main/php_ini.c php-5.6.0/main/php_ini.c --- php-5.6.0.orig/main/php_ini.c 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/main/php_ini.c 2014-09-23 17:10:10.155726841 +0200 @@ -781,6 +781,54 @@ } /* }}} */ +/* {{{ php_parse_extra_ini + */ +PHPAPI int php_parse_extra_ini(const char *ini_file) { + if (!sapi_module.php_ini_ignore && ini_file) { + struct stat sb; + zend_file_handle fh; + RESET_ACTIVE_INI_HASH(); + memset(&fh, 0, sizeof(fh)); + + if (VCWD_STAT(ini_file, &sb) == 0) { + if (S_ISREG(sb.st_mode)) { + if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) { + fh.filename = ini_file; + fh.type = ZEND_HANDLE_FP; + + /* add a fake-host section so our settings will be changed to PHP_INI_SYSTEM during merge */ + zval fakehost; + Z_STRLEN(fakehost) = sizeof("HOST=\%fake\%") - 1; + Z_STRVAL(fakehost) = zend_strndup("HOST=\%fake\%", Z_STRLEN(fakehost)); + Z_TYPE(fakehost) = IS_STRING; + php_ini_parser_cb(&fakehost, NULL, NULL, ZEND_INI_PARSER_SECTION, &configuration_hash TSRMLS_CC); + + if (zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) { + /* add the file to the list of ini files read */ + int add_len = strlen(ini_file) + 2; + + int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0; + php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + add_len + 1); + if (!php_ini_scanned_files_len) { + *php_ini_scanned_files = '\0'; + } + add_len += php_ini_scanned_files_len; + if (php_ini_scanned_files_len) { + php_ini_scanned_files[php_ini_scanned_files_len - 2] = '\0'; + strlcat(php_ini_scanned_files, ",\n", add_len); + } + strlcat(php_ini_scanned_files, ini_file, add_len); + strlcat(php_ini_scanned_files, "\n", add_len); + return SUCCESS; + } + } + } + } + } + return FAILURE; +} +/* }}} */ + /* {{{ php_ini_activate_config */ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage TSRMLS_DC) diff -Naur php-5.6.0.orig/main/php_ini.h php-5.6.0/main/php_ini.h --- php-5.6.0.orig/main/php_ini.h 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/main/php_ini.h 2014-09-23 17:10:10.155726841 +0200 @@ -33,6 +33,7 @@ PHPAPI int cfg_get_double(const char *varname, double *result); PHPAPI int cfg_get_string(const char *varname, char **result); PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC); +PHPAPI int php_parse_extra_ini(const char *ini_file); PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage TSRMLS_DC); PHPAPI int php_ini_has_per_dir_config(void); PHPAPI int php_ini_has_per_host_config(void); diff -Naur php-5.6.0.orig/sapi/cgi/cgi_main.c php-5.6.0/sapi/cgi/cgi_main.c --- php-5.6.0.orig/sapi/cgi/cgi_main.c 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/sapi/cgi/cgi_main.c 2014-09-23 17:10:10.155726841 +0200 @@ -839,6 +839,9 @@ } if (php_ini_has_per_host_config()) { + /* activate our fake host entries. lowercase string required! */ + php_ini_activate_per_host_config("\%fake\%", sizeof("\%fake\%") TSRMLS_CC); + /* Activate per-host-system-configuration defined in php.ini and stored into configuration_hash during startup */ if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); @@ -939,6 +942,7 @@ if (php_module_startup(sapi_module, &cgi_module_entry, 1) == FAILURE) { return FAILURE; } + php_parse_extra_ini(getenv("PHP_INI_EXTRA")); return SUCCESS; } diff -Naur php-5.6.0.orig/sapi/cli/php_cli.c php-5.6.0/sapi/cli/php_cli.c --- php-5.6.0.orig/sapi/cli/php_cli.c 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/sapi/cli/php_cli.c 2014-09-23 17:10:10.156726857 +0200 @@ -417,6 +417,7 @@ if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { return FAILURE; } + php_parse_extra_ini(getenv("PHP_INI_EXTRA")); return SUCCESS; } /* }}} */ @@ -1371,6 +1372,12 @@ CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; } + if (php_ini_has_per_host_config()) { + /* activate our fake host entries. lowercase string required! */ + php_ini_activate_per_host_config("\%fake\%", sizeof("\%fake\%") TSRMLS_CC); + php_ini_activate_per_host_config("\%cli\%", sizeof("\%cli\%") TSRMLS_CC); + } + zend_first_try { #ifndef PHP_CLI_WIN32_NO_CONSOLE if (sapi_module == &cli_sapi_module) { diff -Naur php-5.6.0.orig/sapi/fpm/fpm/fpm_conf.c php-5.6.0/sapi/fpm/fpm/fpm_conf.c --- php-5.6.0.orig/sapi/fpm/fpm/fpm_conf.c 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/sapi/fpm/fpm/fpm_conf.c 2014-09-23 17:10:55.786498819 +0200 @@ -150,6 +150,7 @@ { "catch_workers_output", &fpm_conf_set_boolean, WPO(catch_workers_output) }, { "clear_env", &fpm_conf_set_boolean, WPO(clear_env) }, { "security.limit_extensions", &fpm_conf_set_string, WPO(security_limit_extensions) }, + { "extra_ini", &fpm_conf_set_string, WPO(extra_ini) }, #ifdef HAVE_APPARMOR { "apparmor_hat", &fpm_conf_set_string, WPO(apparmor_hat) }, #endif @@ -649,6 +650,7 @@ free(wpc->chroot); free(wpc->chdir); free(wpc->security_limit_extensions); + free(wpc->extra_ini); #ifdef HAVE_APPARMOR free(wpc->apparmor_hat); #endif @@ -1061,6 +1063,11 @@ } } + /* extra_ini */ + if (wp->config->extra_ini && *wp->config->extra_ini) { + fpm_evaluate_full_path(&wp->config->extra_ini, wp, NULL, 0); + } + /* env[], php_value[], php_admin_values[] */ if (!wp->config->chroot) { struct key_value_s *kv; @@ -1613,6 +1620,7 @@ zlog(ZLOG_NOTICE, "\tcatch_workers_output = %s", BOOL2STR(wp->config->catch_workers_output)); zlog(ZLOG_NOTICE, "\tclear_env = %s", BOOL2STR(wp->config->clear_env)); zlog(ZLOG_NOTICE, "\tsecurity.limit_extensions = %s", wp->config->security_limit_extensions); + zlog(ZLOG_NOTICE, "\textra_ini = %s", STR2STR(wp->config->extra_ini)); for (kv = wp->config->env; kv; kv = kv->next) { zlog(ZLOG_NOTICE, "\tenv[%s] = %s", kv->key, kv->value); diff -Naur php-5.6.0.orig/sapi/fpm/fpm/fpm_conf.h php-5.6.0/sapi/fpm/fpm/fpm_conf.h --- php-5.6.0.orig/sapi/fpm/fpm/fpm_conf.h 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/sapi/fpm/fpm/fpm_conf.h 2014-09-23 17:10:10.156726857 +0200 @@ -85,6 +85,7 @@ int catch_workers_output; int clear_env; char *security_limit_extensions; + char *extra_ini; struct key_value_s *env; struct key_value_s *php_admin_values; struct key_value_s *php_values; diff -Naur php-5.6.0.orig/sapi/fpm/fpm/fpm_main.c php-5.6.0/sapi/fpm/fpm/fpm_main.c --- php-5.6.0.orig/sapi/fpm/fpm/fpm_main.c 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/sapi/fpm/fpm/fpm_main.c 2014-09-23 17:10:10.157726874 +0200 @@ -777,6 +777,9 @@ } if (php_ini_has_per_host_config()) { + /* activate our fake host entries. lowercase string required! */ + php_ini_activate_per_host_config("\%fake\%", sizeof("\%fake\%") TSRMLS_CC); + /* Activate per-host-system-configuration defined in php.ini and stored into configuration_hash during startup */ server_name = sapi_cgibin_getenv("SERVER_NAME", sizeof("SERVER_NAME") - 1 TSRMLS_CC); /* SERVER_NAME should also be defined at this stage..but better check it anyway */ diff -Naur php-5.6.0.orig/sapi/fpm/fpm/fpm_php.c php-5.6.0/sapi/fpm/fpm/fpm_php.c --- php-5.6.0.orig/sapi/fpm/fpm/fpm_php.c 2014-08-27 15:31:35.000000000 +0200 +++ php-5.6.0/sapi/fpm/fpm/fpm_php.c 2014-09-23 17:10:10.157726874 +0200 @@ -218,6 +218,8 @@ int fpm_php_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ { + php_parse_extra_ini(wp->config->extra_ini); + if (0 > fpm_php_apply_defines(wp) || 0 > fpm_php_set_allowed_clients(wp)) { return -1;