dropin: when looking for dropins for a unit, also look within "-" prefix unit dirs
This extends the logic by which we look for drop-ins for unit files when loading them. Previously for a unit "foo-quux-bar.service" we'd look in a directory "foo-quux-bar.service.d" accompanying it for extension dropins. With this change we'll additionally look in: "foo-quux-.service.d" and "foo-.service.d", i.e. we'll truncate the unit name after every dash. This is an alternative to templating for many services, as it permits configuring defaults for sets of units that all use the same prefix in the unit name. This is particularly useful in slice, mount and automount units which reflect a hierarchy of concepts, as it permits setting defaults for specific subsets of the tree. For example, in order to provide every user with a memory of 1G it's now possible to do: # mkdir -p /etc/systemd/system/user-.slice.d # cat > /etc/systemd/system/user-.slice.d/50-memory.conf << EOF [Slice] MemoryMax=1G EOF # systemctl daemon-reload This makes use of the fact that every user gets his own slice unit when logging in, named "user-$UID.slice". This doesn't precisely provide what is requested in #2556, but it does provide equivalent functionality. Fixes: #2556 See: #3504 #7599
Loading
Please register or sign in to comment