#994983 clamav-daemon: Postinst script assumes /var/lib/clamav/ to be writable, which is not always the case

Package:
clamav-daemon
Source:
clamav
Description:
anti-virus utility for Unix - scanner daemon
Submitter:
Dominik
Date:
2021-09-24 10:27:03 UTC
Severity:
normal
Tags:
#994983#5
Date:
2021-09-24 10:26:11 UTC
From:
To:
Dear Maintainer,

in order to limit network bandwith and harddisk capacity, we use a setup
with shared virus patterns. For this, the directory /var/lib/clamav is
shared by multiple systems, only the master system (responsible for
pattern update) having write access.

This breaks the post-install process:

clamav-daemon (0.103.3+dfsg-0+deb10u1) wird eingerichtet ...
/var/lib/dpkg/info/clamav-daemon.postinst: 464: /var/lib/dpkg/info/clamav-daemon.postinst: cannot create /var/lib/clamav/clamav.conf: Permission denied
dpkg: Fehler beim Bearbeiten des Paketes clamav-daemon (--configure):
 »installiertes clamav-daemon-Skript des Paketes post-installation«-Unterprozess gab den Fehlerwert 2 zurück
Fehler traten auf beim Bearbeiten von:
 clamav-daemon

Which we can fix by modifying /var/lib/dpkg/info/clamav-daemon.postinst

sudo patch --forward /var/lib/dpkg/info/clamav-daemon.postinst << EOF
--- /tmp/clamav-daemon.postinst	2021-05-21 12:53:07.386753639 +0200
+++ /tmp/clamav-daemon.postinst.new	2021-05-21 12:53:48.410539251 +0200
@@ -264,11 +264,11 @@
   configure)

   # The DEB*FILE files are used temporarily during the update of the CLAMAV* files.
-  DEBCONFFILE=/var/lib/clamav/clamav.conf
+  DEBCONFFILE=/tmp/clamav.conf
   CLAMAVCONF=/etc/clamav/clamd.conf
-  DEBROTATEFILE=/var/lib/clamav/clamdrotate.debconf
+  DEBROTATEFILE=/tmp/clamdrotate.debconf
   CLAMAVROTATEFILE=/etc/logrotate.d/clamav-daemon
-  DEBSYSTEMDCLAMDCONF=/var/lib/clamav/extend.conf
+  DEBSYSTEMDCLAMDCONF=/tmp/extend.conf
   CLAMAVSYSTEMDCLAMDONF=/etc/systemd/system/clamav-daemon.service.d/extend.conf

   # Update the configuration file
EOF


sudo apt -y install --fix-broken


Please consider not to use /var/lib/clamav/ as temporary location to
generate configuration files.
--- data dir ---
total 626904
-rw-r--r-- 1 clamav clamav   1438720 Mar  8  2021 bytecode.cld
drwxr-xr-x 1 clamav clamav      4096 Aug 15  2019 clamav-3d4e0a7c395899723db1e57cc2909f46.tmp
-rw-r--r-- 1 clamav clamav 176437760 Sep 24 12:08 daily.cld
-rw-r--r-- 1 clamav clamav        69 Sep 24 11:08 freshclam.dat
-rw-r--r-- 1 clamav clamav 464053248 Sep 16 21:01 main.cld
-rw------- 1 clamav clamav        69 Sep  5 08:00 mirrors.dat