|
| 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 | +$tempDir = sys_get_temp_dir(); |
| 11 | +$socketFilePrefix = $tempDir . '/socket-file'; |
| 12 | +$socketFile = $socketFilePrefix . '-that-is-too-long-0000-1111-2222-3333-4444-5555-6666-7777-8888-9999-aaaa-bbbb-cccc-dddd-eeee-ffff-gggg-hhhh-iiii.sock'; |
| 13 | +$cfg = <<<EOT |
| 14 | +[global] |
| 15 | +error_log = {{FILE:LOG}} |
| 16 | +
|
| 17 | +[fpm_pool] |
| 18 | +listen = $socketFile |
| 19 | +pm = static |
| 20 | +pm.max_children = 1 |
| 21 | +catch_workers_output = yes |
| 22 | +EOT; |
| 23 | + |
| 24 | +$tester = new FPM\Tester($cfg); |
| 25 | +$tester->start(); |
| 26 | +$tester->expectLogStartNotices(); |
| 27 | + |
| 28 | +$warningPattern = sprintf( |
| 29 | + '/\[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 \'.+\'/', |
| 30 | + preg_quote($socketFile, '/'), |
| 31 | + strlen($socketFile) |
| 32 | +); |
| 33 | +$tester->expectLogPattern($warningPattern, true); |
| 34 | + |
| 35 | +$files = []; |
| 36 | + |
| 37 | +foreach (glob($socketFilePrefix . '*') as $file) { |
| 38 | + $files[] = $file; |
| 39 | +} |
| 40 | + |
| 41 | +if ($files !== []) { |
| 42 | + ?>Socket files were found. |
| 43 | +<?php |
| 44 | +} else { |
| 45 | + ?>Socket files were not found. |
| 46 | +<?php |
| 47 | +} |
| 48 | + |
| 49 | +if ($socketFile !== $files[0]) { |
| 50 | + ?>Socket file is not the same as configured. |
| 51 | +<?php |
| 52 | +} else { |
| 53 | + ?>Socket file is the same as configured. |
| 54 | +<?php |
| 55 | +} |
| 56 | + |
| 57 | +$tester->terminate(); |
| 58 | +$tester->expectLogTerminatingNotices(); |
| 59 | +$tester->close(); |
| 60 | + |
| 61 | +echo ini_get('fpm_pool.listen'); |
| 62 | +?> |
| 63 | +Done |
| 64 | +--EXPECT-- |
| 65 | +Socket files were found. |
| 66 | +Socket file is not the same as configured. |
| 67 | +Done |
| 68 | +--CLEAN-- |
| 69 | +<?php |
| 70 | +require_once "tester.inc"; |
| 71 | +FPM\Tester::clean(); |
| 72 | + |
| 73 | +// cleanup socket file if php-fpm was not killed |
| 74 | +$tempDir = sys_get_temp_dir(); |
| 75 | +$socketFilePrefix = $tempDir . '/socket-file'; |
| 76 | +$socketFile = $socketFilePrefix . '-that-is-too-long-0000-1111-2222-3333-4444-5555-6666-7777-8888-9999-aaaa-bbbb-cccc-dddd-eeee-ffff-gggg-hhhh-iiii.sock'; |
| 77 | + |
| 78 | +if (is_file($socketFile)) { |
| 79 | + unlink($socketFile); |
| 80 | +} |
| 81 | +?> |
0 commit comments