systemd units should not be placed in /etc/systemd (cannot mask a service)

Bug #1868909 reported by Trent Lloyd
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Triaged
Medium
Unassigned

Bug Description

snapd should not place generated unit files in /etc/systemd and instead place them in another location.

The systemd documentation notes under the "Table 1. Load path when running in system mode (--system)." section of https://www.freedesktop.org/software/systemd/man/systemd.unit.html#id-1.8.4

/usr/local/lib/systemd/system System units installed by the administrator
/usr/lib/systemd/system System units installed by the distribution package manager
run/systemd/generator Generated units with medium priority (see normal-dir in systemd.generator(7))

In practice this causes problems, for example "systemctl mask" does not work:
root@skc:~# systemctl mask snap.maas.supervisor.service
Failed to mask unit: File /etc/systemd/system/snap.maas.supervisor.service already exists.

There are 2 main solutions I envisage to this problem. Firstly it should just install them to the normal package manager location of /usr/lib/systemd/system. Given that snapd currently prefixes all units with "snap." that is not likely to cause a conflict with other system package managers.

Secondly a potentially better or alternative solution would be to harness the systemd.generator functionality which is natively designed to have "non-native" configuration converted to systemd units - and is automatically run on boot and daemon-reload (which is required to pickup generated config files anyway). And would store them in the above generator location instead.

Documentation: https://www.freedesktop.org/software/systemd/man/systemd.generator.html#

This was discovered when looking for a workaround to Bug #1868908 snap update causes disabled systemd service to start again

Tags: seg
Trent Lloyd (lathiat)
tags: added: seg
Changed in snapd:
importance: Undecided → Medium
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.