An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(ssh): never disable the SSH command timeout
Andras Bacsai714b09fa2462
diff --git a/config/constants.php b/config/constants.phpindex 83b8b22301..6bc8885be2 100644--- a/config/constants.php+++ b/config/constants.php@@ -1,5 +1,8 @@<?php+// 0 or an invalid value would remove the time limit of every remote command.+$sshCommandTimeout = (int) env('SSH_COMMAND_TIMEOUT', 3600);+return ['coolify' => ['version' => env('COOLIFY_VERSION') ?: '4.4',@@ -79,7 +82,7 @@ return ['mux_orphan_reap_enabled' => env('SSH_MUX_ORPHAN_REAP_ENABLED', false), // false = dry-run, only log orphans'connection_timeout' => 10,'server_interval' => 20,- 'command_timeout' => env('SSH_COMMAND_TIMEOUT', 3600),+ 'command_timeout' => $sshCommandTimeout > 0 ? $sshCommandTimeout : 3600,'max_retries' => env('SSH_MAX_RETRIES', 3),'retry_base_delay' => env('SSH_RETRY_BASE_DELAY', 2), // seconds'retry_max_delay' => env('SSH_RETRY_MAX_DELAY', 30), // secondsdiff --git a/tests/Feature/SshCommandTimeoutConfigTest.php b/tests/Feature/SshCommandTimeoutConfigTest.phpnew file mode 100644index 0000000000..1bbeb188f0--- /dev/null+++ b/tests/Feature/SshCommandTimeoutConfigTest.php@@ -0,0 +1,47 @@+<?php++/**+ * Load config/constants.php with SSH_COMMAND_TIMEOUT set to the given value.+ */+function sshCommandTimeoutFromEnv(?string $value): mixed+{+ $original = [$_SERVER['SSH_COMMAND_TIMEOUT'] ?? null, $_ENV['SSH_COMMAND_TIMEOUT'] ?? null, getenv('SSH_COMMAND_TIMEOUT')];++ try {+ if ($value === null) {+ unset($_SERVER['SSH_COMMAND_TIMEOUT'], $_ENV['SSH_COMMAND_TIMEOUT']);+ putenv('SSH_COMMAND_TIMEOUT');+ } else {+ $_SERVER['SSH_COMMAND_TIMEOUT'] = $_ENV['SSH_COMMAND_TIMEOUT'] = $value;+ putenv("SSH_COMMAND_TIMEOUT={$value}");+ }++ return (require config_path('constants.php'))['ssh']['command_timeout'];+ } finally {+ [$server, $env, $putenv] = $original;+ if ($server === null) {+ unset($_SERVER['SSH_COMMAND_TIMEOUT']);+ } else {+ $_SERVER['SSH_COMMAND_TIMEOUT'] = $server;+ }+ if ($env === null) {+ unset($_ENV['SSH_COMMAND_TIMEOUT']);+ } else {+ $_ENV['SSH_COMMAND_TIMEOUT'] = $env;+ }+ putenv($putenv === false ? 'SSH_COMMAND_TIMEOUT' : "SSH_COMMAND_TIMEOUT={$putenv}");+ }+}++it('never disables the SSH command timeout', function (?string $value) {+ expect(sshCommandTimeoutFromEnv($value))->toBe(3600);+})->with([+ 'not set' => null,+ 'zero' => '0',+ 'negative' => '-5',+ 'not a number' => 'never',+]);++it('keeps a positive SSH command timeout', function () {+ expect(sshCommandTimeoutFromEnv('7200'))->toBe(7200);+});