Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
51 changes: 51 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,51 @@
--TEST--
FPM: Process user setting unset when running as root
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die("skip not for Windows");
}
require_once "tester.inc";

if (!FPM\Tester::findExecutable()) {
die("skip php-fpm binary not found");
}

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();
$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();
?>