|
| 1 | +--TEST-- |
| 2 | +FPM: gh11066 - listen filename is too long for OS socket path limitation but starts anyway |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +include "skipif.inc"; ?> |
| 6 | +--FILE-- |
| 7 | +<?php |
| 8 | + |
| 9 | +require_once "tester.inc"; |
| 10 | +$socketFilePrefix = __DIR__ . '/socket-file'; |
| 11 | +$socketFile = $socketFilePrefix . '-fpm-unix-socket-too-long-filename-but-starts-anyway' . str_repeat('-0000', 11) . '.sock'; |
| 12 | +$cfg = <<<EOT |
| 13 | +[global] |
| 14 | +error_log = {{FILE:LOG}} |
| 15 | +
|
| 16 | +[fpm_pool] |
| 17 | +listen = $socketFile |
| 18 | +pm = static |
| 19 | +pm.max_children = 1 |
| 20 | +catch_workers_output = yes |
| 21 | +EOT; |
| 22 | + |
| 23 | +$tester = new FPM\Tester($cfg); |
| 24 | +$tester->start(); |
| 25 | +$tester->expectLogStartNotices(); |
| 26 | + |
| 27 | +$warningPattern = sprintf( |
| 28 | + '/\[pool fpm_pool\] cannot bind to UNIX socket \'%s\' as path is too long \(found length: %d, maximal length: \d+\), trying cut socket path instead \'.+\'/', |
| 29 | + preg_quote($socketFile, '/'), |
| 30 | + strlen($socketFile) |
| 31 | +); |
| 32 | +$tester->expectLogPattern($warningPattern, true); |
| 33 | + |
| 34 | +$files = glob($socketFilePrefix . '*'); |
| 35 | + |
| 36 | +if ($files === []) { |
| 37 | + echo 'Socket files were not found.' . PHP_EOL; |
| 38 | +} |
| 39 | + |
| 40 | +if ($socketFile === $files[0]) { |
| 41 | + // this means the socket file path length is not an issue (anymore). Might be not long enough |
| 42 | + echo 'Socket file is the same as configured.' . PHP_EOL; |
| 43 | +} |
| 44 | + |
| 45 | +$tester->terminate(); |
| 46 | +$tester->expectLogTerminatingNotices(); |
| 47 | +$tester->close(); |
| 48 | +?> |
| 49 | +Done |
| 50 | +--EXPECT-- |
| 51 | +Done |
| 52 | +--CLEAN-- |
| 53 | +<?php |
| 54 | +require_once "tester.inc"; |
| 55 | +FPM\Tester::clean(); |
| 56 | + |
| 57 | +// cleanup socket file if php-fpm was not killed |
| 58 | +$socketFilePrefix = __DIR__ . '/socket-file'; |
| 59 | +$socketFile = $socketFilePrefix . '-fpm-unix-socket-too-long-filename-but-starts-anyway' . str_repeat('-0000', 11) . '.sock'; |
| 60 | + |
| 61 | +if (is_file($socketFile)) { |
| 62 | + unlink($socketFile); |
| 63 | +} |
| 64 | +?> |
0 commit comments