ClamAV conflicts with AppArmor

Nov 12, 2025
67
6
8
There are dozen of entries in syslog like this:

Code:
2026-11-13T10:57:30.054103+01:00 mailgw kernel: audit: type=1400 audit(1794563850.052:46216): apparmor="DENIED" operation="open" class="file" profile="/usr/sbin/clamd" name="/var/spool/pmg/active/1014436AF6DF09E99DA" pid=606154 comm="clamd" requested_mask="r" denied_mask="r" fsuid=107 ouid=988

Looks like the installed AppArmor-profile needs to be tweaked a bit. Should I report an issue for that?
Thanks!
 
Those denials look like clamd trying to read the mail files in /var/spool/pmg/active, so the profile just doesn't cover that path. Does virus scanning still work for you or is it only log noise? I'd report it either way.
 
Hi, I have no idea if it works at all. There are no visible error messages or something in the web-ui. Still, the counter of detected viruses is zero since I installed it. So, yes, probably the scanner never worked.
 
Easy way to check whether it works, send an EICAR test file through the gateway and see if the virus counter goes up. If it doesn't, the scanner is broken, not just noisy.
 
No, the message then simply disappears! o_O
It seems to reach the PMG, but then simply vanishes. It is neither visible in the tracking-list, nor does it appear in the virus quarantine list.
The good thing is, that is does not reach my mailbox. But I think that infected emails simply vanish without a trace is not the way is should work?
 
I found another suspicious entry in syslog:

Code:
2026-11-19T16:08:23.130359+01:00 mailgw kernel: audit: type=1400 audit(1795100903.127:6641): apparmor="DENIED" operation="create" class="net" info="failed protocol match" error=-13 profile="/usr/sbin/clamd" pid=833 comm="clamd" family="unix" sock_type="dgram" protocol=0 requested="create" denied="create" addr=none
 
That confirms it, AppArmor is choking clamd both on the unix socket for logging and on accessing the PMG spool directory. When pmg-smtp-filter passes the incoming mail to the scanner, clamd fails or times out, causing the message to get stuck or dropped before tracking.
The quickest way to verify is to temporarily put the ClamAV AppArmor profile into complain mode so it logs without blocking execution:

```bash
aa-complain /usr/sbin/clamd
systemctl restart clamav-daemon pmg-smtp-filter
```

Then try sending another EICAR test email. If the virus counter ticks up and the message is properly blocked and logged in the PMG Tracking Center, you have 100% confirmation.

From there, you can either leave clamd unconfined (which is standard for PMG since it ships without a strict clamd profile by default) or add the missing permissions to `/etc/apparmor.d/local/usr.sbin.clamd`:
```
/var/spool/pmg/** rw,
network unix dgram,
```
and reload it with `apparmor_parser -r /etc/apparmor.d/usr.sbin.clamd`.