From 7e7d5c1069d55c92f6571ab825baa84cbcecfe8a Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 26 Apr 2026 21:36:08 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20CheckUpdates=20nutzt=20exec()=20statt=20?= =?UTF-8?q?shell=5Fexec()=20f=C3=BCr=20--check-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit shell_exec kann auf PHP-FPM Servern deaktiviert sein, wodurch version_remote nie aktualisiert wurde und kein Update angezeigt wurde. Co-Authored-By: Claude Sonnet 4.6 --- app/Console/Commands/CheckUpdates.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/CheckUpdates.php b/app/Console/Commands/CheckUpdates.php index 1c3c0df..b87d756 100644 --- a/app/Console/Commands/CheckUpdates.php +++ b/app/Console/Commands/CheckUpdates.php @@ -24,25 +24,27 @@ class CheckUpdates extends Command $updateBin = '/usr/local/sbin/mailwolt-update'; $fetchHelper = '/usr/local/sbin/mailwolt-fetch-tags'; - // Beide versuchen — --check-only schreibt version_remote, fetch-tags als Fallback + // --check-only via exec() (shell_exec kann auf manchen Servern deaktiviert sein) $fetched = false; if (file_exists($updateBin) && str_contains((string) @file_get_contents($updateBin), '--check-only')) { - $result = @shell_exec('sudo -n ' . escapeshellarg($updateBin) . ' --check-only 2>/dev/null'); - $fetched = ($result !== null); + @exec('sudo -n ' . escapeshellarg($updateBin) . ' --check-only 2>/dev/null', $_, $rc); + $fetched = ($rc === 0); } if (!$fetched && file_exists($fetchHelper)) { - @shell_exec('sudo -n ' . escapeshellarg($fetchHelper) . ' 2>/dev/null'); + @exec('sudo -n ' . escapeshellarg($fetchHelper) . ' 2>/dev/null'); } - // Version_remote wurde von einem der Helfer geschrieben; frisch genug wenn < 2h alt + // version_remote von Helfer geschrieben; als frisch wenn < 2h alt $remoteFile = '/var/lib/mailwolt/version_remote'; $remoteRaw = ''; if (file_exists($remoteFile) && (time() - filemtime($remoteFile)) < 7200) { $remoteRaw = trim((string) file_get_contents($remoteFile)); } - $latestTagRaw = $remoteRaw !== '' ? $remoteRaw - : trim((string) shell_exec("git -C " . escapeshellarg($appPath) . " tag -l 'v*' --sort=-v:refname 2>/dev/null | head -n1")); + // Fallback: lokale Tags (funktioniert nur wenn Tags lokal vorhanden) + $out = []; + @exec("git -C " . escapeshellarg($appPath) . " tag -l 'v*' --sort=-v:refname 2>/dev/null", $out); + $latestTagRaw = $remoteRaw !== '' ? $remoteRaw : trim($out[0] ?? ''); $latestNorm = $this->normalizeVersion($latestTagRaw);