Skip to content

Commit 66ec60c

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Skip fpm tests not designed to be run as root Allow fpm tests to be run with long socket path
2 parents 319c21b + 87375fa commit 66ec60c

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

sapi/fpm/tests/bug68391-conf-include-order.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FPM: bug68391 - Configuration inclusion in alphabetical order
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6+
FPM\Tester::skipIfRoot();
67
?>
78
--FILE--
89
<?php

sapi/fpm/tests/proc-user-ignored.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FPM: Process user setting ignored when FPM is not running as root
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6+
FPM\Tester::skipIfRoot();
67
?>
78
--FILE--
89
<?php

sapi/fpm/tests/socket-uds-numeric-ugid-nonroot.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FPM: UNIX socket owner and group settings can be numeric
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6+
FPM\Tester::skipIfRoot();
67
FPM\Tester::skipIfPosixNotLoaded();
78
?>
89
--FILE--

sapi/fpm/tests/tester.inc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,16 @@ class Tester
278278
}
279279
}
280280

281+
/**
282+
* Skip if running as root.
283+
*/
284+
static public function skipIfRoot()
285+
{
286+
if (getmyuid() == 0) {
287+
die('skip running as root');
288+
}
289+
}
290+
281291
/**
282292
* Skip if posix extension not loaded.
283293
*/
@@ -856,7 +866,17 @@ class Tester
856866
{
857867
$port = $this->getPort($type, $pool, true);
858868
if ($type === 'uds') {
859-
return $this->getFile($port . '.sock');
869+
$address = $this->getFile($port . '.sock');
870+
871+
// Socket max path length is 108 on Linux and 104 on BSD,
872+
// so we use the latter
873+
if (strlen($address) <= 104) {
874+
return $address;
875+
}
876+
877+
return sys_get_temp_dir().'/'.
878+
hash('crc32', dirname($address)).'-'.
879+
basename($address);
860880
}
861881

862882
return $this->getHost($type) . ':' . $port;

0 commit comments

Comments
 (0)