Bug#1091519: deb-systemd-helper: Fails when non-existing unit is listed in Also= line
MichaIng
micha at dietpi.com
Fri Sep 12 15:21:58 BST 2025
I think false conclusions are drawn here:
Also= lines for non-existing units are not a problem, but skipped
silently. The problem here is, there multiple units of libvirt packages
have an Also= loop:
libvirtd-admin.socket:
```
Also=libvirtd.socket
Also=libvirtd-ro.socket
```
libvirtd-ro.socket:
```
Also=libvirtd.socket
Also=libvirtd-admin.socket
```
libvirtd.socket:
```
Also=libvirtd-ro.socket
Also=libvirtd-admin.socket
```
libvirt-daemon.postrm or on distro upgrades the previous
libvirt-daemon-system.postrm call "deb-systemd-helper purge" for each of
those, and perl even warns about the resulting recursion:
```
recursion on subroutine "main::remove_links" at
/usr/bin/deb-systemd-helper line 488, <$fh> line 14.
```
The function contains this code block:
```
sub update_state {
...
# Read $service_path, recurse for all Also= units.
# This might not work when $service_path was already deleted,
# i.e. after apt-get remove. In this case we just return
# silently in order to not confuse the user about whether
# disabling actually worked or not — the case is handled by
# dh_installsystemd generating an appropriate disable
# command by parsing the service file at debhelper-time.
open(my $fh, '<', "$dpkg_root$service_path") or return;
while (my $line = <$fh>) {
chomp($line);
my $service_link;
if ($line =~ /^\s*Also=(.+)$/i) {
remove_links(find_unit($1));
}
}
close($fh);
```
So using deb-systemd-helper on libvirtd.socket repeats the function on
libvirtd-ro.socket which repeats it on libvirtd.socket again and so on
and so forth.
As can be seen and as the comment explains, missing units are gracefully
handled, and they would even break the endless loop in this case.
Generally, for all such kind of dependencies and ordering, there must
never be loops in systemd units, but they must have a clear
single-direction parent/child or before/after structure. Choose one of
those units as the primary one which is enabled on install and disabled
on uninstall, and add Also= lines only to this one, but remove them from
the other two. That should fix the hanging issue.
Best regards,
Micha
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x0442B9ADE65643FE.asc
Type: application/pgp-keys
Size: 9878 bytes
Desc: OpenPGP public key
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20250912/be47a162/attachment.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20250912/be47a162/attachment.sig>
More information about the Pkg-systemd-maintainers
mailing list