diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 6888a304b1bc2..13b39c194c46e 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -706,6 +706,17 @@ int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */ } while (0) #define FPM_WPC_STR_CP(_cfg, _scfg, _field) FPM_WPC_STR_CP_EX(_cfg, _scfg, _field, _field) +void fpm_conf_apply_kv_array_to_kv_array(struct key_value_s *src, void *dest) { + struct key_value_s *kv; + + for (kv = src; kv; kv = kv->next) { + zval k, v; + ZVAL_STRING(&k, kv->key); + ZVAL_STRING(&v, kv->value); + fpm_conf_set_array(&k, &v, &dest, 0); + } +} + static int fpm_worker_pool_shared_status_alloc(struct fpm_worker_pool_s *shared_wp) { /* {{{ */ struct fpm_worker_pool_config_s *config, *shared_config; config = fpm_worker_pool_config_alloc(); @@ -738,6 +749,9 @@ static int fpm_worker_pool_shared_status_alloc(struct fpm_worker_pool_s *shared_ FPM_WPC_STR_CP(config, shared_config, group); FPM_WPC_STR_CP(config, shared_config, pm_status_path); + fpm_conf_apply_kv_array_to_kv_array(shared_config->php_values, (char *)config + WPO(php_values)); + fpm_conf_apply_kv_array_to_kv_array(shared_config->php_admin_values, (char *)config + WPO(php_admin_values)); + config->pm = PM_STYLE_ONDEMAND; config->pm_max_children = 2; diff --git a/sapi/fpm/tests/response.inc b/sapi/fpm/tests/response.inc index 9112da6ed7756..80f2b178e70b0 100644 --- a/sapi/fpm/tests/response.inc +++ b/sapi/fpm/tests/response.inc @@ -107,9 +107,20 @@ class Response * * @return Response */ - public function expectHeader($name, $value): Response + public function expectHeader($name, $value, $useRegex = false): Response { - $this->checkHeader($name, $value); + $this->checkHeader($name, $value, $useRegex); + + return $this; + } + + /** + * @param string $name + * @return Response + */ + public function expectNoHeader($name) + { + $this->checkNoHeader($name); return $this; } @@ -264,6 +275,21 @@ class Response return true; } + /** + * @param string $name + * @return bool + */ + private function checkNoHeader(string $name) + { + $lcName = strtolower($name); + $headers = $this->getHeaders(); + if (isset($headers[$lcName])) { + return $this->error("The header $name is present"); + } + + return true; + } + /** * Get all headers. * diff --git a/sapi/fpm/tests/status-listen-expose-php-off.phpt b/sapi/fpm/tests/status-listen-expose-php-off.phpt new file mode 100644 index 0000000000000..2fca8151c2084 --- /dev/null +++ b/sapi/fpm/tests/status-listen-expose-php-off.phpt @@ -0,0 +1,39 @@ +--TEST-- +FPM: Status pool is inheriting FPM setting overrides test - expose_php = off +--SKIPIF-- + +--FILE-- +start(); +$tester->expectLogStartNotices(); +$response = $tester->request('', [], '/status', '{{ADDR[status]}}'); +$response->expectNoHeader('X-Powered-By'); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- + diff --git a/sapi/fpm/tests/status-listen-expose-php-on.phpt b/sapi/fpm/tests/status-listen-expose-php-on.phpt new file mode 100644 index 0000000000000..06360e7f0d4e1 --- /dev/null +++ b/sapi/fpm/tests/status-listen-expose-php-on.phpt @@ -0,0 +1,39 @@ +--TEST-- +FPM: Status pool is inheriting FPM setting overrides test - expose_php = on +--SKIPIF-- + +--FILE-- +start(); +$tester->expectLogStartNotices(); +$response = $tester->request('', [], '/status', '{{ADDR[status]}}'); +$response->expectHeader('X-Powered-By', '|^PHP/8|', true); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +