The clamav-base.postinst.in includes code to create the clamav user, but
this only runs on fresh installations (i.e. when the second arg to the
postinst is blank).  If somehow you had clamav installed but the clamav
user and/or group had been removed (or had never been properly set up to
begin with), then the code to create the user is skipped.  The
subsequent chown then fails, obviously.

My proposed fix would be:


--- a/debian/clamav-base.postinst
+++ b/debian/clamav-base.postinst
@@ -23,20 +23,18 @@
  configure)
  
  DATABASEDIR=/var/lib/clamav
  LOGDIR=/var/log/clamav
  user=clamav
 
  # Set up the clamav user on new install
-  if [ -z "$2" ]; then
-    if ! getent passwd clamav >/dev/null; then
-        adduser --system --no-create-home --quiet \
-            --disabled-password --disabled-login \
-            --shell /bin/false --group --home /var/lib/clamav clamav
-    fi
-    if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
-      if ! grep -qi "^clamav" /etc/aliases; then
-        echo "clamav: root" >> /etc/aliases
-        newal=`which newaliases || true`
-        if [ -n "$newal" ] && [ -x "$newal" ]; then
-          $newal || true
-        fi
-      fi
-    fi
-  fi
+ if ! getent passwd clamav >/dev/null; then
+   adduser --system --no-create-home --quiet \
+       --disabled-password --disabled-login \
+       --shell /bin/false --group --home /var/lib/clamav clamav
+ fi
+ if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
+   if ! grep -qi "^clamav" /etc/aliases; then
+     echo "clamav: root" >> /etc/aliases
+     newal=`which newaliases || true`
+     if [ -n "$newal" ] && [ -x "$newal" ]; then
+       $newal || true
+     fi
+   fi
+ fi
  chown $user:$user $DATABASEDIR
  chown $user:$user $LOGDIR
  ;;

This patch will move the entire user creation and aliases setup block
outside the if [ -z "$2" ] conditional, ensuring that the clamav user
and group are always created if missing, regardless of whether it's a
first install or an upgrade.  I think this should fix the issue.

** Tags added: server-todo

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2115832

Title:
  package clamav-base 1.4.3+dfsg-0ubuntu0.24.04.1 failed to
  install/upgrade: chown: invalid user: ‘clamav:clamav’

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/clamav/+bug/2115832/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to