AppArmor prevents ClamAV from access file or directory

 Problem

Ubuntu/Linux’s AppArmor may prevent access to file or directory causing Anti-Virus scanner to throw an error.

 Solution

Few ways to prevent this error:

  1. Disabling AppArmor

    1. sudo systemctl stop apparmor.service
      sudo systemctl disable apparmor.service

  2. Set AppArmor to complain instead of denying access

    1. apt-get install apparmor-utils
      aa-complain /path/to/your/scanner (e.g. /usr/sbin/clamd)

 

https://ubuntu.com/server/docs/security-apparmor#:~:text=AppArmor%20can%20be%20disabled%2C%20and%20the%20kernel%20module%20unloaded%20by%20entering%20the%20following%3A

https://wiki.dhits.nl/index.php/ClamAV#:~:text=clamdscan-,Can%27t%20open%20file%20or%20directory%20ERROR,-Could%20be%20apparmor

https://superuser.com/questions/671116/why-clamav-cant-scan-some-files