Comment 2 for bug 1951903

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi Patrick,
I had to smile about you feeling "accused to modify files", on one does so.
It is an automated detection of files not matching or being part of the installed archive, but those listed here are generated on installation - so I can confirm you did not do anything wrong in regard to those files. BTW newer versions (I think 21.04+) will handle them slightly differently and no more 'accuse' people.

But all of that isn't the actual problem, the issue that you faced was this:

```
Removing libvirt-daemon dnsmasq configuration
Purging configuration files for libvirt-daemon-system (4.0.0-1ubuntu8.19) ...
/usr/sbin/delgroup: `libvirt-dnsmasq' still has `libvirtd' as their primary group!
/usr/sbin/delgroup: `libvirt-dnsmasq' still has `libvirt' as their primary group!
userdel: group libvirt-dnsmasq not removed because it is not the primary group of user libvirt-dnsmasq.
dpkg: error processing package libvirt-daemon-system (--purge):
```

I can't see why - as part of the upgrade - it tried to remove libvirt for you, the log isn't long enough to show that. But while removing it the user failed to be removed and that is the problem.

Back in 16.04 this was created as:
    if ! getent passwd libvirt-dnsmasq >/dev/null; then
        adduser --quiet \
            --system \
            --ingroup libvirtd \
            --quiet \
            --disabled-login \
            --disabled-password \
            --home /var/lib/libvirt/dnsmasq \
            --no-create-home \
            -gecos "Libvirt Dnsmasq" \
            libvirt-dnsmasq
    fi

In 18.04 that changed and it indeed got its own group also named libvirt-dnsmasq (which is better as it has less permissions).

    if ! getent group libvirt-dnsmasq >/dev/null; then
        addgroup --quiet --system libvirt-dnsmasq
    fi
    if ! getent passwd libvirt-dnsmasq >/dev/null; then
        adduser --quiet \
                --system \
                --ingroup libvirt-dnsmasq \
                --disabled-login \
                --disabled-password \
                --home /var/lib/libvirt/dnsmasq \
                --no-create-home \
                --gecos "Libvirt Dnsmasq" \
                libvirt-dnsmasq
    fi

It seems you still have the user as it was created back in Xenial.
Then the removal/purging code of Bionic runs and fails.

All the removals I find are properly guarded by || true to not make it fail if anything is odd (like here by having the old user/group relation). So I wonder why this breaks for you:

        if getent passwd libvirt-dnsmasq >/dev/null; then
                deluser libvirt-dnsmasq >/dev/null || true
        fi

    # a running libvirt-dnsmasq will break these removals
    # yet the lifecycle of the network is non-related to the pkg purge
    # Therefore ignore errors on these removals, better leave a user than break
    if getent group libvirt-dnsmasq >/dev/null; then
        delgroup libvirt-dnsmasq --system 2>/dev/null >/dev/null || true
    fi
    if getent passwd libvirt-dnsmasq >/dev/null; then
        deluser libvirt-dnsmasq --system 2>/dev/null >/dev/null || true
    fi

I'm trying to recreate this ...