Don't try to mask non-existent Systemd \xe2\x97\x8f.service (#129)

With Systemd 246 on Fedora 33, running GParted reports this error and no
longer masks the system mount units:

    $ gparted
    Unit \xe2\x97\x8f.service does not exist, proceeding anyway.
    Unit \xe2\x97\x8f.service does not exist, proceeding anyway.
    GParted 1.1.0
    configuration --enable-libparted-dmraid --enable-online-resize
    libparted 3.3

    $ systemctl list-units -t mount --full --all --no-legend
      -.mount                       loaded    active   mounted Root Mount
      boot.mount                    loaded    active   mounted /boot
      dev-hugepages.mount           loaded    active   mounted Huge Pages File System
      dev-mqueue.mount              loaded    active   mounted POSIX Message Queue File System
      home.mount                    loaded    active   mounted /home
      proc-fs-nfsd.mount            loaded    inactive dead    NFSD configuration filesystem
      proc-sys-fs-binfmt_misc.mount loaded    inactive dead    Arbitrary Executable File Formats File System
      run-user-1000-gvfs.mount      loaded    active   mounted /run/user/1000/gvfs
      run-user-1000.mount           loaded    active   mounted /run/user/1000
      run-user-42.mount             loaded    active   mounted /run/user/42
      sys-fs-fuse-connections.mount loaded    active   mounted FUSE Control File System
      sys-kernel-config.mount       loaded    active   mounted Kernel Configuration File System
      sys-kernel-debug.mount        loaded    active   mounted Kernel Debug File System
      sys-kernel-tracing.mount      loaded    active   mounted Kernel Trace File System
    * sysroot.mount                 not-found inactive dead    sysroot.mount
      tmp.mount                     loaded    active   mounted Temporary Directory (/tmp)
      var-lib-machines.mount        loaded    inactive dead    Virtual Machine and Container Storage (Compatibility)
      var-lib-nfs-rpc_pipefs.mount  loaded    active   mounted RPC Pipe File System
    * var.mount                     not-found inactive dead    var.mount

    ^
   [Unicode Black Circle character (U+25CF) replaced with star to avoid
   making this this commit message Unicode.]

Currently the gparted shell wrapper lists the Systemd mount units and
takes the first space separated column as the unit name.  If the LOAD
status of the unit is not "loaded" then Systemd prefixes the name with
an optional Black Circle.  Prior to Systemd 246 these extra 2 characters
at the start of the line, including the optional Black Circle, were
suppressed by the --no-legend option, but with Systemd 246 this no
longer happens.  As the mount unit names no longer start in the first
character of the line no units are masked.  Instead the Unicode Black
Circle character, UTF-8 byte sequence E2 97 8F, is found at the start of
highlighted lines which results in this error:
    Unit \xe2\x97\x8f.service does not exist, proceeding anyway.

Fix by adding the --plain option to suppress the optional Black Circle
in the systemctl output.  Confirmed this option is available in the
oldest supported distributions with Systemd.
    RedHat / CentOS 7   Systemd 219   systemctl has --plain option.
    Ubuntu 16.04 LTS    Systemd 229   systemctl has --plain option.

Closes #129 - Unit \xe2\x97\x8f.service does not exist, proceeding
              anyway
This commit is contained in:
Mike Fleetwood 2021-01-04 21:46:56 +00:00 committed by Curtis Gedak
parent 39136a26bd
commit 3c9ae05cd8

View file

@ -144,7 +144,7 @@ done
# Use systemctl to prevent automount by masking currently unmasked mount points
#
if test "x$HAVE_SYSTEMCTL" = "xyes"; then
MOUNTLIST=`systemctl list-units --full --all -t mount --no-legend \
MOUNTLIST=`systemctl list-units --full --all -t mount --no-legend --plain \
| grep -v masked | cut -f1 -d' ' \
| egrep -v '^(dev-hugepages|dev-mqueue|proc-sys-fs-binfmt_misc|run-user-.*-gvfs|sys-fs-fuse-connections|sys-kernel-config|sys-kernel-debug)'`
systemctl --runtime mask --quiet -- $MOUNTLIST