teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0164-man-clarify-the-descriptions-of-aliases-and-linked-u.patch

594167
From 2c9079ca0eaa2a1df2a1775c28fa7a49785999df Mon Sep 17 00:00:00 2001
594167
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
594167
Date: Mon, 28 Mar 2022 11:46:38 +0200
594167
Subject: [PATCH] man: clarify the descriptions of aliases and linked unit
594167
 files
594167
594167
This just describes the rules that are implemented by the manager, and this
594167
pull request does not change any of them.
594167
594167
(cherry picked from commit ecd6c000d3a2e743a0f533d427250714c7593cf7)
594167
594167
Related: #2082131
594167
---
594167
 man/systemd.unit.xml | 58 ++++++++++++++++++++++++++++++++------------
594167
 1 file changed, 43 insertions(+), 15 deletions(-)
594167
594167
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
594167
index 2a44b8cfd8..4ba602b5ad 100644
594167
--- a/man/systemd.unit.xml
594167
+++ b/man/systemd.unit.xml
594167
@@ -140,7 +140,7 @@
594167
     a symlink, so when <command>systemd</command> is asked through D-Bus to load
594167
     <filename>dbus-org.freedesktop.network1.service</filename>, it'll load
594167
     <filename>systemd-networkd.service</filename>. As another example, <filename>default.target</filename> —
594167
-    the default system target started at boot — is commonly symlinked (aliased) to either
594167
+    the default system target started at boot — is commonly aliased to either
594167
     <filename>multi-user.target</filename> or <filename>graphical.target</filename> to select what is started
594167
     by default. Alias names may be used in commands like <command>disable</command>,
594167
     <command>start</command>, <command>stop</command>, <command>status</command>, and similar, and in all
594167
@@ -156,8 +156,12 @@
594167
     template instance (e.g. <literal>alias@inst.service</literal>) may be a symlink to different template
594167
     (e.g. <literal>template@inst.service</literal>). In that case, just this specific instance is aliased,
594167
     while other instances of the template (e.g. <literal>alias@foo.service</literal>,
594167
-    <literal>alias@bar.service</literal>) are not aliased. Those rule preserve the requirement that the
594167
-    instance (if any) is always uniquely defined for a given unit and all its aliases.</para>
594167
+    <literal>alias@bar.service</literal>) are not aliased. Those rules preserve the requirement that the
594167
+    instance (if any) is always uniquely defined for a given unit and all its aliases. The target of alias
594167
+    symlink must point to a valid unit file location, i.e. the symlink target name must match the symlink
594167
+    source name as described, and the destination path must be in one of the unit search paths, see UNIT FILE
594167
+    LOAD PATH section below for more details. Note that the target file may not exist, i.e. the symlink may
594167
+    be dangling.</para>
594167
 
594167
     <para>Unit files may specify aliases through the <varname>Alias=</varname> directive in the [Install]
594167
     section. When the unit is enabled, symlinks will be created for those names, and removed when the unit is
594167
@@ -177,11 +181,18 @@
594167
     exists for <varname>Requires=</varname> type dependencies as well, the directory suffix is
594167
     <filename>.requires/</filename> in this case. This functionality is useful to hook units into the
594167
     start-up of other units, without having to modify their unit files. For details about the semantics of
594167
-    <varname>Wants=</varname>, see below. The preferred way to create symlinks in the
594167
-    <filename>.wants/</filename> or <filename>.requires/</filename> directory of a unit file is by embedding
594167
-    the dependency in [Install] section of the target unit, and creating the symlink in the file system with
594167
-    the <command>enable</command> or <command>preset</command> commands of
594167
-    <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
594167
+    <varname>Wants=</varname> and <varname>Requires=</varname>, see below. The preferred way to create
594167
+    symlinks in the <filename>.wants/</filename> or <filename>.requires/</filename> directories is by
594167
+    specifying the dependency in [Install] section of the target unit, and creating the symlink in the file
594167
+    system with the <command>enable</command> or <command>preset</command> commands of
594167
+    <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.  The
594167
+    target can be a normal unit (either plain or a specific instance of a template unit). In case when the
594167
+    source unit is a template, the target can also be a template, in which case the instance will be
594167
+    "propagated" to the target unit to form a valid unit instance. The target of symlinks in
594167
+    <filename>.wants/</filename> or <filename>.requires/</filename> must thus point to a valid unit file
594167
+    location, i.e. the symlink target name must satisfy the described requirements, and the destination path
594167
+    must be in one of the unit search paths, see UNIT FILE LOAD PATH section below for more details. Note
594167
+    that the target file may not exist, i.e. the symlink may be dangling.</para>
594167
 
594167
     <para>Along with a unit file <filename>foo.service</filename>, a "drop-in" directory
594167
     <filename>foo.service.d/</filename> may exist. All files with the suffix
594167
@@ -503,13 +514,30 @@
594167
     <programlisting>systemd-analyze --user unit-paths</programlisting>
594167
     </para>
594167
 
594167
-    <para>Moreover, additional units might be loaded into systemd from
594167
-    directories not on the unit load path by creating a symlink pointing to a
594167
-    unit file in the directories. You can use <command>systemctl link</command>
594167
-    for this operation. See
594167
-    <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
594167
-    for its usage and precaution.
594167
-    </para>
594167
+    <para>Moreover, additional units might be loaded into systemd from directories not on the unit load path
594167
+    by creating a symlink pointing to a unit file in the directories. You can use <command>systemctl
594167
+    link</command> for this; see
594167
+    <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The file
594167
+    system where the linked unit files are located must be accessible when systemd is started (e.g. anything
594167
+    underneath <filename>/home/</filename> or <filename>/var/</filename> is not allowed, unless those
594167
+    directories are located on the root file system).</para>
594167
+
594167
+    <para>It is important to distinguish "linked unit files" from "unit file aliases": any symlink where the
594167
+    symlink <emphasis>target</emphasis> is within the unit load path becomes an alias: the source name and
594167
+    the target file name must satisfy specific constraints listed above in the discussion of aliases, but the
594167
+    symlink target doesn't have to exist, and in fact the symlink target path is not used, except to check
594167
+    whether the target is within the unit load path. In constrast, a symlink which goes outside of the unit
594167
+    load path signifies a linked unit file. The symlink is followed when loading the file, but the
594167
+    destination name is otherwise unused (and may even not be a valid unit file name). For example, symlinks
594167
+    <filename index='false'>/etc/systemd/system/alias1.service</filename> → <filename index='false'>service1.service</filename>,
594167
+    <filename index='false'>/etc/systemd/system/alias2.service</filename> → <filename index='false'>/usr/lib/systemd/service1.service</filename>,
594167
+    <filename index='false'>/etc/systemd/system/alias3.service</filename> → <filename index='false'>/etc/systemd/system/service1.service</filename>
594167
+    are all valid aliases and <filename index='false'>service1.service</filename> will have
594167
+    four names, even if the unit file is located at
594167
+    <filename index='false'>/run/systemd/system/service1.service</filename>. In contrast,
594167
+    a symlink <filename index='false'>/etc/systemd/system/link1.service</filename> → <filename index='false'>../link1_service_file</filename>
594167
+    means that <filename index='false'>link1.service</filename> is a "linked unit" and the contents of
594167
+    <filename index='false'>/etc/systemd/link1_service_file</filename> provide its configuration.</para>
594167
   </refsect1>
594167
 
594167
   <refsect1>