-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
systemd version the issue has been seen with
v241
Used distribution
Arch
Expected behaviour you didn't see
service masked to prevent starting, e.g:
# systemctl mask foo
Created symlink /etc/systemd/systemctl/foo.service /dev/null.
Unexpected behaviour you saw
# systemctl mask foo
Failed to mask unit: File /etc/systemd/system/foo.service already exists.
Steps to reproduce the problem
Configure a service in /etc/systemd/system, and try to mask it using systemctl.
One must manually delete, rename or otherwise backup the service file just because it's a locally configured service in order to mask it.
From the perspective of the user running systemctl mask foo, who may or may not have been responsible for configuring the foo service, this is completely spurious and inconsistent behavior and it's entirely undocumented in the systemctl man page for the mask command.
The scenario where I encountered this was I needed to prevent an old, locally-configured service, from getting started via systemctl. I had no intention of removing the service, messing with its configuration, or anything of the sort. It was being started and stopped by udev rules based on solar-powered AC availability, and I needed to temporarily prevent those rules from succeeding in starting the unit because the service is too power hungry and the skies are too cloudy this month (solar) to support it. So a simple systemctl mask foo is all that was desired, to be unmasked when the skies cleared at a later date.
It's my opinion that systemctl should have a dedicated top-priority directory for sticking such overriding service links, rather than sharing the /etc/systemd/system namespace with other local configuration. Mask links are arguably overrides to the global configuration, including local configuration, rather than part of the local configuration itself. That's certainly how they relate to distro-provided services in /lib/systemd/system, I see no good reason for them to be narrowly applicable to only those.
In the example above I used /etc/systemd/systemctl as such a directory, but anything reasonable would work. Maybe /etc/systemd/overrides or something would make more sense, but that's implementation detail.
My intention here is to illuminate the issue and try get us to at least agree this is a warty bug.