From 64d8bf4fba76a1abcf4a2d11bc480dc35a3228b5 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Wed, 15 Mar 2023 13:18:43 +0100 Subject: [PATCH] avoid socket length limitations leading to cut-off/invalid filename for very long domain and/or loginnames, fixes #1108 Signed-off-by: Michael Kaufmann --- lib/Froxlor/Cron/Http/Php/Fpm.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Froxlor/Cron/Http/Php/Fpm.php b/lib/Froxlor/Cron/Http/Php/Fpm.php index 96721cb1..1cf84901 100644 --- a/lib/Froxlor/Cron/Http/Php/Fpm.php +++ b/lib/Froxlor/Cron/Http/Php/Fpm.php @@ -342,8 +342,17 @@ pm.max_children = 1 public function getSocketFile($createifnotexists = true) { $socketdir = FileDir::makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir')); - // add fpm-config-id to filename so it's unique for the fpm-daemon and doesn't interfere with running configs when reuilding - $socket = strtolower(FileDir::makeCorrectFile($socketdir . '/' . $this->domain['fpm_config_id'] . '-' . $this->domain['loginname'] . '-' . $this->domain['domain'] . '-php-fpm.socket')); + // add fpm-config-id to filename, so it's unique for the fpm-daemon and doesn't interfere with running configs when reuilding + $socket_filename = $socketdir . '/' . $this->domain['fpm_config_id'] . '-' . $this->domain['loginname'] . '-' . $this->domain['domain'] . '-php-fpm.socket'; + if (strlen($socket_filename) > 100) { + // respect the unix socket-length limitation + $socket_filename = $socketdir . '/' . $this->domain['fpm_config_id'] . '-' . $this->domain['loginname'] . '-' . $this->domain['id'] . '-php-fpm.socket'; + if (strlen($socket_filename) > 100) { + // even a long loginname it seems + $socket_filename = $socketdir . '/' . $this->domain['fpm_config_id'] . '-' . $this->domain['guid'] . '-' . $this->domain['id'] . '-php-fpm.socket'; + } + } + $socket = strtolower(FileDir::makeCorrectFile($socket_filename)); if (!is_dir($socketdir) && $createifnotexists) { FileDir::safe_exec('mkdir -p ' . escapeshellarg($socketdir));