Fix: isInstalled via systemctl list-unit-files statt Dateipfad-Check
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main v1.1.327
parent
7d738392b2
commit
1bcd93908e
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue