From 658e2f9057b9efe25b63a31141621ac33001856b Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Wed, 10 Jun 2026 05:53:25 +0000 Subject: [PATCH] Fix PHP-FPM pool not removed on account termination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs that together left stale pool files behind after termination, crashing php-fpm on next startup (exit-code 78, user not found): 1. removePool() used file_exists() to guard the rm — fails silently when www-data can't read /etc/php/*/fpm/pool.d/; now always attempts sudo rm -f 2. reloadFPM() called systemctl without sudo — silently failed as www-data, leaving the old pool loaded even when the file was successfully removed Co-Authored-By: Claude Sonnet 4.6 --- panel/lib/PHPManager.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/panel/lib/PHPManager.php b/panel/lib/PHPManager.php index 263bfab..857cd88 100644 --- a/panel/lib/PHPManager.php +++ b/panel/lib/PHPManager.php @@ -48,7 +48,10 @@ php_value[max_execution_time] = 30 public static function removePool(string $username): void { foreach (['7.4','8.1','8.2','8.3'] as $ver) { $file = str_replace('{ver}', $ver, self::$poolDir) . "/{$username}.conf"; - if (file_exists($file)) { shell_exec("sudo rm -f " . escapeshellarg($file)); self::reloadFPM($ver); } + // Always attempt removal — don't rely on file_exists() which fails when + // www-data can't read the pool.d directory; rm -f is a no-op if missing + shell_exec("sudo rm -f " . escapeshellarg($file) . " 2>/dev/null"); + self::reloadFPM($ver); } } @@ -112,6 +115,6 @@ php_value[max_execution_time] = 30 } private static function reloadFPM(string $ver): void { - shell_exec("systemctl reload php{$ver}-fpm 2>/dev/null || true"); + shell_exec("sudo systemctl reload php{$ver}-fpm 2>/dev/null || true"); } }