Skip to content

Commit 8904fbc

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: NEWS adapt test for error message introduce in fix for #68463 Fix bug #68463 listen.allowed_clients can silently result in no allowed access
2 parents 9081e8a + 15d8601 commit 8904fbc

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

sapi/fpm/fpm/fastcgi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@ void fcgi_set_allowed_clients(char *ip)
280280
}
281281
allowed_clients[n].sa.sa_family = 0;
282282
free(ip);
283+
if (!n) {
284+
zlog(ZLOG_ERROR, "There are no allowed addresses for this pool");
285+
/* don't clear allowed_clients as it will create an "open for all" security issue */
286+
}
283287
}
284288
}
285289

sapi/fpm/tests/015.phpt

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,28 @@ FPM: Test various messages on start, from master and childs
88
include "include.inc";
99

1010
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
11-
$port = 9000+PHP_INT_SIZE;
11+
$port1 = 9000+PHP_INT_SIZE;
12+
$port2 = 9001+PHP_INT_SIZE;
1213

1314
$cfg = <<<EOT
1415
[global]
1516
error_log = $logfile
1617
log_level = notice
17-
[unconfined]
18-
listen = 127.0.0.1:$port
19-
listen.allowed_clients=127.0.0.1,xxx
18+
[pool1]
19+
listen = 127.0.0.1:$port1
20+
listen.allowed_clients=127.0.0.1
2021
user = foo
2122
pm = dynamic
2223
pm.max_children = 5
23-
;pm.start_servers = 2
24+
pm.min_spare_servers = 1
25+
pm.max_spare_servers = 3
26+
catch_workers_output = yes
27+
[pool2]
28+
listen = 127.0.0.1:$port2
29+
listen.allowed_clients=xxx
30+
pm = dynamic
31+
pm.max_children = 5
32+
pm.start_servers = 1
2433
pm.min_spare_servers = 1
2534
pm.max_spare_servers = 3
2635
catch_workers_output = yes
@@ -29,7 +38,7 @@ EOT;
2938
$fpm = run_fpm($cfg, $tail);
3039
if (is_resource($fpm)) {
3140
$i = 0;
32-
while (($i++ < 30) && !($fp = @fsockopen('127.0.0.1', $port))) {
41+
while (($i++ < 30) && !($fp = @fsockopen('127.0.0.1', $port1))) {
3342
usleep(10000);
3443
}
3544
if ($fp) {
@@ -38,11 +47,16 @@ if (is_resource($fpm)) {
3847
}
3948
for ($i=0 ; $i<10 ; $i++) {
4049
try {
41-
run_request('127.0.0.1', $port);
50+
run_request('127.0.0.1', $port1);
4251
} catch (Exception $e) {
43-
echo "Error\n";
52+
echo "Error 1\n";
4453
}
4554
}
55+
try {
56+
run_request('127.0.0.1', $port2);
57+
} catch (Exception $e) {
58+
echo "Error 2\n";
59+
}
4660
proc_terminate($fpm);
4761
if (!feof($tail)) {
4862
echo stream_get_contents($tail);
@@ -55,12 +69,14 @@ if (is_resource($fpm)) {
5569
Done
5670
--EXPECTF--
5771
Started
58-
[%s] NOTICE: [pool unconfined] pm.start_servers is not set. It's been set to 2.
59-
[%s] NOTICE: [pool unconfined] 'user' directive is ignored when FPM is not running as root
72+
Error 2
73+
[%s] NOTICE: [pool pool1] pm.start_servers is not set. It's been set to 2.
74+
[%s] NOTICE: [pool pool1] 'user' directive is ignored when FPM is not running as root
6075
[%s] NOTICE: fpm is running, pid %d
6176
[%s] NOTICE: ready to handle connections
62-
[%s] WARNING: [pool unconfined] child %d said into stderr: "ERROR: Wrong IP address 'xxx' in listen.allowed_clients"
63-
[%s] WARNING: [pool unconfined] child %d said into stderr: "ERROR: Wrong IP address 'xxx' in listen.allowed_clients"
77+
[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: Wrong IP address 'xxx' in listen.allowed_clients"
78+
[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: There are no allowed addresses for this pool"
79+
[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: Connection disallowed: IP address '127.0.0.1' has been dropped."
6480
[%s] NOTICE: Terminating ...
6581
[%s] NOTICE: exiting, bye-bye!
6682
Done

0 commit comments

Comments
 (0)