From: Mike Yuan Date: Wed, 30 Apr 2025 19:05:02 +0000 (+0200) Subject: units: unify deps between service and socket units X-Git-Tag: v258-rc1~695^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e803ec1e253a2d6593c3a7cc075f6f0bc4e696ac;p=thirdparty%2Fsystemd.git 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 --- diff --git a/units/systemd-importd.service.in b/units/systemd-importd.service.in index e119d409292..e7a40f20573 100644 --- a/units/systemd-importd.service.in +++ b/units/systemd-importd.service.in @@ -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 diff --git a/units/systemd-machined.service.in b/units/systemd-machined.service.in index 7f70c87e80e..47aa5deeedc 100644 --- a/units/systemd-machined.service.in +++ b/units/systemd-machined.service.in @@ -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] diff --git a/units/systemd-mountfsd.service.in b/units/systemd-mountfsd.service.in index 00a0827fbcd..381408da9cc 100644 --- a/units/systemd-mountfsd.service.in +++ b/units/systemd-mountfsd.service.in @@ -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 diff --git a/units/systemd-networkd.service.in b/units/systemd-networkd.service.in index 1bd423e2cac..6fb2b7e2dba 100644 --- a/units/systemd-networkd.service.in +++ b/units/systemd-networkd.service.in @@ -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 diff --git a/units/systemd-nsresourced.service.in b/units/systemd-nsresourced.service.in index 3c927059e8b..6ecfefc7cf1 100644 --- a/units/systemd-nsresourced.service.in +++ b/units/systemd-nsresourced.service.in @@ -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 diff --git a/units/systemd-oomd.service.in b/units/systemd-oomd.service.in index 2486afe4053..0bc2c3c358f 100644 --- a/units/systemd-oomd.service.in +++ b/units/systemd-oomd.service.in @@ -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 diff --git a/units/systemd-resolved.service.in b/units/systemd-resolved.service.in index a9224f09dae..fd046f284f2 100644 --- a/units/systemd-resolved.service.in +++ b/units/systemd-resolved.service.in @@ -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 diff --git a/units/systemd-userdbd.service.in b/units/systemd-userdbd.service.in index e853bb0c6fc..6f98704b0a2 100644 --- a/units/systemd-userdbd.service.in +++ b/units/systemd-userdbd.service.in @@ -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