Subject: systemctl-service-shim: Breaks automatic grub menu updating

From: "Plasma (David Paul)" <[email-masked]>
Date: Mon, 30 Jun 2025 13:13:55 -0500

Control: affects -1 grub2-common
Package: systemctl-service-shim
Version: 0.0.1
Severity: important
X-Debbugs-CC: [email-masked]

# Problem
If the systemctl-service-shim package is installed, the grub menu is
not automatically updated when a new linux kernel version is installed.

# Description
Following each linux kernel installation or update, the scripts in the
directory /etc/kernel/postinst.d are run in ascii-betical order.  When
the grub2-common package is installed, one of these scripts is the file
zz-update-grub which is responsible for updating the grub boot menu
entries to include an entry for the newly install kernel and to update
the default kernel option, as appropriate.

The zz-update-grub script starts with a few checks to verify that
certain conditions are met and, if not, it aborts. Relevant to this
bug, it checks to see whether it is running within a container and, if
so, it aborts.  The utility it uses to make this check is
systemd-detect-virt which, on Debian, comes from the systemd package.
systemd-detect-virt is one of the three utilities that
systemctl-service-shim provides compatibility shims for. However,
currently in the case of systemd-detect-virt, this is accomplished by
simply always returning with "exit 0".  As a result, the zz-update-grub
script always *erroneously* detects that it is running in a container
and always prematurely exits and never updates the grub menu.

(Note: The grub-legacy package also includes its own zz-update-grub
script for automatically updating the grub v1 menu, but it doesn't
check if it is running in a container (should it?), so it is not
affected by this issue.)

# Questions/Analysis
- What in Devuan currently requires systemd-detect-virt, and what
  functionality is required for its shim to provide?

  AFAICT, only the dummy-systemd-dev and python3-ipalib binary packages
  (from the dummy-systemd-dev and freeipa source packages,
  respectively) depend on the systemctl-service-shim package.

  Grepping for 'systemd-detect-virt' (or 'hostnamectl' for that matter)
  in the dummy-systemd-dev source code turns up nothing, so
  dummy-systemd-dev can be safely ignored.

  This leaves just the freeipa source package to evaluate. CC-ing
  bgstack15 to request his subject matter expertise in this regard.

- Currently, systemctl-service-shim provides shims for systemctl,
  hostnamectl, and systemd-detect-virt.  However, this is presently
  accomplished by having both systemd-detect-virt and hostnamectl be
  symlinks to the systemctl shim script, and simply checking the name
  under which the script was executed, and if that name was either of
  hostnamectl or systemd-detect-virt then merely terminate with an exit
  code of 0. Should these 2 scripts be independent of the systemctl
  script instead of being shoehorned onto the side? Are they even
  needed?

-- 
Plasma