Nextcloud Snap Installation ClamAV findet Socket nicht

Hallo liebe Community,

ich habe auf einem Ubuntu 22.04 per SNAP-Installation die Nextcloud installiert.
Jedoch bekomme ich ClamAV nicht korrekt zum laufen.

Fehler:
Cannot connect to “/var/run/clamav/clamd.ctl”: Permission denied (code 13)
stream_socket_client(): Unable to connect to unix:///var/run/clamav/clamd.ctl (Permission denied) at /var/snap/nextcloud/39212/nextcloud/extra-apps/files_antivirus/lib/Scanner/ExternalClam.php#38

Meine /etc/clamav/clamd.conf:
LocalSocket /var/run/clamav/clamd.ctl
FixStaleSocket true
LocalSocketGroup clamav
LocalSocketMode 666
User clamav

systemctl status clamav-daemon:
clamav-daemon.service - Clam AntiVirus userspace daemon
Loaded: loaded (/lib/systemd/system/clamav-daemon.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/clamav-daemon.service.d
└─extend.conf
Active: active (running) since Fri 2024-01-05 12:44:57 CET; 4min 40s ago
Docs: man:clamd(8)
man:clamd.conf(5)
https://docs.clamav.net/
Process: 1017 ExecStartPre=/bin/mkdir -p /run/clamav (code=exited, status=0/SUCCESS)
Process: 1049 ExecStartPre=/bin/chown clamav /run/clamav (code=exited, status=0/SUCCESS)
Main PID: 1051 (clamd)
Tasks: 2 (limit: 4558)
Memory: 1.6G
CPU: 19.715s
CGroup: /system.slice/clamav-daemon.service
└─1051 /usr/sbin/clamd --foreground=true

Jan 05 12:45:22 owncloud clamd[1051]: Portable Executable support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: ELF support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: Mail files support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: OLE2 support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: PDF support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: SWF support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: HTML support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: XMLDOCS support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: HWP3 support enabled.
Jan 05 12:45:22 owncloud clamd[1051]: Self checking every 300 seconds.

Nextcloud Antiviruseinstellungen sind auf:
Modus: ClamAV-Daemon-Socket
Socket: /var/run/clamav/clamd.ctl

ll /var/run/clamav/clamd.ctl
srw-rw-rw- 1 clamav clamav 0 Jan 5 12:45 /var/run/clamav/clamd.ctl=

Auch diese Anleitung bringt den gleichen Fehler.
Add /{,var/}snap/nextcloud/[0-9]/clamd.ctl w, to /etc/apparmor.d/usr.sbin.clamd like below.
32 /{,var/}run/clamav/clamd.ctl w,
33 /{,var/}snap/nextcloud/[0-9]
/clamd.ctl w,
34 /{,var/}run/clamav/clamd.pid w,

then apply it to apparmor:
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.clamd

edit /etc/clamav/clamd.conf and change it to this (LocalSocket, LocalSocketGroup, User):

4 LocalSocket /var/snap/nextcloud/current/clamd.ctl
5 FixStaleSocket true
6 #LocalSocketGroup clamav
7 LocalSocketGroup root
8 LocalSocketMode 666
9 # TemporaryDirectory is not set to its default /tmp here to make overriding
10 # the default with environment variables TMPDIR/TMP/TEMP possible
11 #User clamav
12 User root
13 ScanMail tr

restart clamav:
sudo systemctl restart clamav-daemon

sudo mv /var/run/clamav/clamd.ctl /var/snap/nextcloud/current/

Change LocalSocket option of /etc/clamav/clamd.conf and restart clamav-daemon:
LocalSocket /var/snap/nextcloud/current/clamd.ctl
sudo snap restart nextcloud

1 Like

Sry für die sehr späte Antwort.
Das ist ein Apparmor berechtigungs Problem.
Schau mal ob in dieser Datei:
/var/lib/snapd/apparmor/profiles/snap.nextcloud.php-fpm

diese Zeile vorhanden ist:
/run/clamav/clamd.ctl rw,

eventuell musst du die Pfade anpassen je nach dem welche Versionen du verwendest.

Falls die Zeile nicht vorhanden ist musst du sie einfügen.(ist egal wo Hauptsache nicht direkt an den Anfang und wichtig: Nach der Snap Deklaration.

Dann einmal Apparmor reloaden mit diesem Befehl:
apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.nextcloud.php-fpm
Dann sollte es funktionieren

ClamAV is not contained inside the snap and because of snap confinement ClamAV cannot be accessed/executed from within Nextcloud snap.

Alternative; install ClamAV on host and scan Default path · nextcloud-snap/nextcloud-snap Wiki · GitHub