Add fallback of removing systemd mount unit masks directly (!116)

On RHEL / CentOS 8 GParted reports this error to the terminal when it is
closed:
    # gparted
    GParted 1.5.0-git
    configuration --enable-online-resize
    libparted 3.2
>>  --runtime cannot be used with unmask
    # $?
    0

and leaves mount units masked:
    # systemctl list-units '*.mount'
      UNIT                  LOAD   ACTIVE SUB     DESCRIPTION
      ------------------------------------------------------------------
    * -.mount               masked active mounted Root Mount
    * boot.mount            masked active mounted boot.mount
      ...

This is because of this change [1] released in systemd 239.  Systemd bug
9393 [2] was raised and the change was reverted [3] in systemd 240.
According to repology.org only RHEL / CentOS 8 (and clones) and Fedora
29 shipped with systemd 239 [4].

Fix by detecting non-zero exit status from systemctl and falling back to
directly removing the runtime mount unit mask files instead.  Then have
to use systemctl daemon-reload to inform systemd to reload it's
configuration from disk to discover the masks have been removed.

[1] systemctl: when removing enablement or mask symlinks, cover both
    /run and /etc
   4910b35078
[2] systemctl no longer allows unmask in combination with --runtime
    #9393
    https://github.com/systemd/systemd/issues/9393
[3] Revert "systemctl: when removing enablement or mask symlinks, cover
    both /run and /etc"
    1830ac51a4
[4] Versions for systemd
    https://repology.org/project/systemd/versions

Closes !116 - Systemd mount masking and udev rule location updates
This commit is contained in:
Mike Fleetwood 2023-08-01 17:50:17 +01:00 committed by Curtis Gedak
parent d698f6a591
commit 1e15fc9385
1 changed files with 7 additions and 2 deletions

View File

@ -231,10 +231,15 @@ for rule in $UDEV_TEMP_RULES; do
done
#
# Use systemctl to restore that status of any mount points changed above
# Use systemctl to unmask those mount points masked above
#
if test "x$HAVE_SYSTEMCTL" = "xyes"; then
systemctl --runtime unmask --quiet -- $MOUNTLIST
systemctl --runtime unmask --quiet -- $MOUNTLIST 2> /dev/null || \
{
cd /run/systemd/system &&
rm -f -- $MOUNTLIST &&
systemctl daemon-reload
}
fi
exit $status