units: unify deps between service and socket units

The current arrangement of service and socket units is
sort of all over the place. Let's clean it up a little,
roughly following the principles below:

- socket units have implicit ordering deps (not to be confused
  with default ones which are subject to DefaultDependencies=)
  before associated service, so drop any explicit After=

- If socket can be enabled, remember to link to it in service
  via Also= and Sockets= (the latter replaces Wants=).
  If the service Requires= socket however, Sockets= is omitted.

- If socket is statically enabled, no need for service
  to pull it in - machined
This commit is contained in:
Mike Yuan
2025-04-30 21:05:02 +02:00
parent 366dd4a662
commit e803ec1e25
8 changed files with 11 additions and 11 deletions

View File

@@ -12,7 +12,6 @@ Description=Disk Image Download Service
Documentation=man:systemd-importd.service(8)
Documentation=man:org.freedesktop.import1(5)
DefaultDependencies=no
After=systemd-importd.socket
WantsMountsFor=/var/lib/machines /var/lib/portables /var/lib/extensions /var/lib/confexts
After=systemd-remount-fs.service
Before=shutdown.target

View File

@@ -12,8 +12,8 @@ Description=Virtual Machine and Container Registration Service
Documentation=man:systemd-machined.service(8)
Documentation=man:org.freedesktop.machine1(5)
Wants=machine.slice systemd-machined.socket
After=machine.slice systemd-machined.socket
Wants=machine.slice
After=machine.slice
RequiresMountsFor=/var/lib/machines
[Service]

View File

@@ -12,7 +12,7 @@ Description=DDI File System Mounter
Documentation=man:systemd-mountfsd.service(8)
Wants=modprobe@loop.service modprobe@dm_mod.service
Requires=systemd-mountfsd.socket
After=systemd-mountfsd.socket modprobe@loop.service modprobe@dm_mod.service
After=modprobe@loop.service modprobe@dm_mod.service
Conflicts=shutdown.target
Before=sysinit.target shutdown.target
DefaultDependencies=no

View File

@@ -14,10 +14,10 @@ Documentation=man:org.freedesktop.network1(5)
ConditionCapability=CAP_NET_ADMIN
DefaultDependencies=no
# systemd-udevd.service can be dropped once tuntap is moved to netlink
After=systemd-networkd.socket systemd-udevd.service network-pre.target systemd-sysusers.service systemd-sysctl.service
After=systemd-udevd.service network-pre.target systemd-sysusers.service systemd-sysctl.service
Before=network.target multi-user.target shutdown.target initrd-switch-root.target
Conflicts=shutdown.target initrd-switch-root.target
Wants=systemd-networkd.socket network.target systemd-networkd-persistent-storage.service
Wants=network.target systemd-networkd-persistent-storage.service
[Service]
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_BPF CAP_SYS_ADMIN
@@ -46,6 +46,7 @@ RestrictRealtime=yes
RestrictSUIDSGID=yes
RuntimeDirectory=systemd/netif
RuntimeDirectoryPreserve=yes
Sockets=systemd-networkd.socket
SystemCallArchitectures=native
SystemCallErrorNumber=EPERM
SystemCallFilter=@system-service bpf

View File

@@ -11,7 +11,6 @@
Description=Namespace Resource Manager
Documentation=man:systemd-nsresourced.service(8)
Requires=systemd-nsresourced.socket
After=systemd-nsresourced.socket
Conflicts=shutdown.target
Before=sysinit.target shutdown.target
DefaultDependencies=no

View File

@@ -20,7 +20,7 @@ ConditionPathExists=/proc/pressure/cpu
ConditionPathExists=/proc/pressure/io
ConditionPathExists=/proc/pressure/memory
Requires=systemd-oomd.socket
After=systemd-oomd.socket systemd-sysusers.service
After=systemd-sysusers.service
[Service]
AmbientCapabilities=CAP_KILL CAP_DAC_OVERRIDE
@@ -60,3 +60,4 @@ User=systemd-oom
[Install]
WantedBy=multi-user.target
Alias=dbus-org.freedesktop.oom1.service
Also=systemd-oomd.socket

View File

@@ -15,10 +15,10 @@ Documentation=https://systemd.io/WRITING_NETWORK_CONFIGURATION_MANAGERS
Documentation=https://systemd.io/WRITING_RESOLVER_CLIENTS
DefaultDependencies=no
After=systemd-sysctl.service systemd-sysusers.service systemd-resolved-varlink.socket systemd-resolved-monitor.socket
After=systemd-sysctl.service systemd-sysusers.service
Before=sysinit.target network.target nss-lookup.target shutdown.target initrd-switch-root.target
Conflicts=shutdown.target initrd-switch-root.target
Wants=nss-lookup.target systemd-resolved-varlink.socket systemd-resolved-monitor.socket
Wants=nss-lookup.target
[Service]
AmbientCapabilities=CAP_SETPCAP CAP_NET_RAW CAP_NET_BIND_SERVICE
@@ -45,6 +45,7 @@ RestrictRealtime=yes
RestrictSUIDSGID=yes
RuntimeDirectory=systemd/resolve
RuntimeDirectoryPreserve=yes
Sockets=systemd-resolved-varlink.socket systemd-resolved-monitor.socket
SystemCallArchitectures=native
SystemCallErrorNumber=EPERM
SystemCallFilter=@system-service

View File

@@ -11,7 +11,6 @@
Description=User Database Manager
Documentation=man:systemd-userdbd.service(8)
Requires=systemd-userdbd.socket
After=systemd-userdbd.socket
Before=sysinit.target
Wants=systemd-userdb-load-credentials.service
DefaultDependencies=no