From 1bcd93908ec405b87581354fb1d719814d07449d Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 26 Apr 2026 20:35:34 +0200 Subject: [PATCH] Fix: isInstalled via systemctl list-unit-files statt Dateipfad-Check Co-Authored-By: Claude Sonnet 4.6 --- app/Livewire/Ui/Security/ClamavManager.php | 29 +++++++--------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/app/Livewire/Ui/Security/ClamavManager.php b/app/Livewire/Ui/Security/ClamavManager.php index f95dfc2..074d3ca 100644 --- a/app/Livewire/Ui/Security/ClamavManager.php +++ b/app/Livewire/Ui/Security/ClamavManager.php @@ -27,9 +27,10 @@ class ClamavManager extends Component public function refresh(): void { $this->lastError = ''; - $this->installed = $this->isInstalled(); - $this->running = $this->installed && $this->serviceActive(); - $this->enabled = $this->installed && $this->serviceEnabled(); + // serviceKnown() prüft ob systemd die Unit kennt (active, inactive, disabled → installiert) + $this->running = $this->serviceActive(); + $this->enabled = $this->serviceEnabled(); + $this->installed = $this->running || $this->serviceKnown(); $this->ramMb = $this->running ? $this->readRamMb() : null; [$this->dbDate, $this->dbVersion] = $this->readDbInfo(); } @@ -51,10 +52,6 @@ class ClamavManager extends Component public function enable(): void { - if (!$this->installed) { - $this->lastError = 'ClamAV ist nicht installiert.'; - return; - } $out = []; @exec('sudo -n /usr/local/sbin/mailwolt-clamav enable 2>&1', $out, $rc); if ($rc !== 0) { @@ -92,20 +89,12 @@ class ClamavManager extends Component $this->refresh(); } - private function isInstalled(): bool + private function serviceKnown(): bool { - // Systemd-Unit ist zuverlässiger als Binary-Pfade (keine exec-Rechte nötig) - $unitPaths = [ - '/lib/systemd/system/clamav-daemon.service', - '/usr/lib/systemd/system/clamav-daemon.service', - '/etc/systemd/system/clamav-daemon.service', - ]; - foreach ($unitPaths as $p) { - if (@file_exists($p)) return true; - } - // Fallback: bekannte Binary-Pfade - foreach (['/usr/bin/clamscan', '/usr/bin/clamdscan', '/usr/sbin/clamd', '/bin/clamscan'] as $b) { - if (@file_exists($b)) return true; + $out = []; + @exec('systemctl list-unit-files clamav-daemon.service 2>/dev/null', $out); + foreach ($out as $line) { + if (str_contains($line, 'clamav-daemon')) return true; } return false; }