Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/fpm_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ static int fpm_conf_process_all_pools(void)

/* alert if user is not set; only if we are root and fpm is not running with --allow-to-run-as-root */
if (!wp->config->user && !geteuid() && !fpm_globals.run_as_root) {
zlog(ZLOG_ALERT, "[pool %s] user has not been defined", wp->config->name);
zlog(ZLOG_ALERT, "[pool %s] 'user' directive has not been specified when running as a root without --allow-to-run-as-root", wp->config->name);
return -1;
}

Expand Down
45 changes: 45 additions & 0 deletions sapi/fpm/tests/proc-user-not-set-when-root.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--TEST--
FPM: Process user setting unset when running as root
--SKIPIF--
<?php
include "skipif.inc";
FPM\Tester::skipIfNotRoot();
?>
--FILE--
<?php

require_once "tester.inc";

$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
[unconfined]
listen = {{ADDR}}
ping.path = /ping
ping.response = pong
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
EOT;

$tester = new FPM\Tester($cfg);
$tester->start(envVars: [
'TEST_FPM_RUN_AS_ROOT' => 0,
]);
$tester->expectLogAlert(
"'user' directive has not been specified when running as a root without --allow-to-run-as-root",
'unconfined'
);
$tester->close();

?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>
2 changes: 1 addition & 1 deletion sapi/fpm/tests/tester.inc
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ class Tester
$cmd[] = '-d' . $iniEntryName . '=' . $iniEntryValue;
}

if (getenv('TEST_FPM_RUN_AS_ROOT')) {
if ($envVars['TEST_FPM_RUN_AS_ROOT'] ?? getenv('TEST_FPM_RUN_AS_ROOT')) {
$cmd[] = '--allow-to-run-as-root';
}
$cmd = array_merge($cmd, $extraArgs);
Expand Down