]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - man/systemd.exec.xml
man: systemd-measure. Remove 'tpm2-pcrs=' from cryptenroll command (#39590)
[thirdparty/systemd.git] / man / systemd.exec.xml
... / ...
CommitLineData
1<?xml version='1.0'?>
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6<refentry id="systemd.exec" xmlns:xi="http://www.w3.org/2001/XInclude">
7 <refentryinfo>
8 <title>systemd.exec</title>
9 <productname>systemd</productname>
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>systemd.exec</refentrytitle>
14 <manvolnum>5</manvolnum>
15 </refmeta>
16
17 <refnamediv>
18 <refname>systemd.exec</refname>
19 <refpurpose>Execution environment configuration</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23 <para><filename><replaceable>service</replaceable>.service</filename>,
24 <filename><replaceable>socket</replaceable>.socket</filename>,
25 <filename><replaceable>mount</replaceable>.mount</filename>,
26 <filename><replaceable>swap</replaceable>.swap</filename></para>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
32 <para>Unit configuration files for services, sockets, mount points, and swap devices share a subset of
33 configuration options which define the execution environment of spawned processes.</para>
34
35 <para>This man page lists the configuration options shared by these four unit types. See
36 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for the common
37 options of all unit configuration files, and
38 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
39 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
40 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, and
41 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
42 information on the specific unit configuration files. The execution specific configuration options are configured
43 in the [Service], [Socket], [Mount], or [Swap] sections, depending on the unit type.</para>
44
45 <para>In addition, options which control resources through Linux Control Groups (cgroups) are listed in
46 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
47 Those options complement options listed here.</para>
48 </refsect1>
49
50 <refsect1>
51 <title>Implicit Dependencies</title>
52
53 <para>A few execution parameters result in additional, automatic dependencies to be added:</para>
54
55 <itemizedlist>
56 <listitem><para>Units with <varname>WorkingDirectory=</varname>, <varname>RootDirectory=</varname>,
57 <varname>RootImage=</varname>, <varname>RuntimeDirectory=</varname>, <varname>StateDirectory=</varname>,
58 <varname>CacheDirectory=</varname>, <varname>LogsDirectory=</varname> or
59 <varname>ConfigurationDirectory=</varname> set automatically gain dependencies of type
60 <varname>Requires=</varname> and <varname>After=</varname> on all mount units required to access the specified
61 paths. This is equivalent to having them listed explicitly in
62 <varname>RequiresMountsFor=</varname>.</para></listitem>
63
64 <listitem><para>Units with <varname>PrivateTmp=yes</varname> automatically gain dependencies of type
65 <varname>Wants=</varname> and <varname>After=</varname> on all mounts required to access
66 <filename>/tmp/</filename> and <filename>/var/tmp/</filename>. They will also gain an automatic
67 <varname>After=</varname> dependency on
68 <citerefentry><refentrytitle>systemd-tmpfiles-setup.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
69 </para></listitem>
70
71 <listitem><para>Units with <varname>PrivateTmp=disconnected</varname> automatically gain dependencies
72 of type <varname>Wants=</varname> and <varname>After=</varname> on the mount required to access
73 <filename>/var/</filename>, unless <varname>DefaultDependencies=no</varname> and/or
74 <varname>RootDirectory=/RootImage=</varname> are specified.</para></listitem>
75
76 <listitem><para>Units whose standard output or error output is connected to <option>journal</option> or
77 <option>kmsg</option> (or their combinations with console output, see below) automatically acquire
78 dependencies of type <varname>After=</varname> on
79 <filename>systemd-journald.socket</filename>.</para></listitem>
80
81 <listitem><para>Units using <varname>LogNamespace=</varname> will automatically gain ordering and
82 requirement dependencies on the two socket units associated with
83 <filename>systemd-journald@.service</filename> instances.</para></listitem>
84 </itemizedlist>
85 </refsect1>
86
87 <!-- We do not have any default dependency here. -->
88
89 <refsect1>
90 <title>Paths</title>
91
92 <para>The following settings may be used to change a service's view of the filesystem. Please note that the paths
93 must be absolute and must not contain a <literal>..</literal> path component.</para>
94
95 <variablelist class='unit-directives'>
96
97 <varlistentry>
98 <term><varname>ExecSearchPath=</varname></term>
99
100 <listitem><para>Takes a colon separated list of absolute paths relative to which the executable
101 used by the <varname>Exec*=</varname> (e.g. <varname>ExecStart=</varname>,
102 <varname>ExecStop=</varname>, etc.) properties can be found. <varname>ExecSearchPath=</varname>
103 overrides <varname>$PATH</varname> if <varname>$PATH</varname> is not supplied by the user through
104 <varname>Environment=</varname>, <varname>EnvironmentFile=</varname> or
105 <varname>PassEnvironment=</varname>. Assigning an empty string removes previous assignments
106 and setting <varname>ExecSearchPath=</varname> to a value multiple times will append
107 to the previous setting.
108 </para>
109
110 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
111 </varlistentry>
112
113 <varlistentry>
114 <term><varname>WorkingDirectory=</varname></term>
115
116 <listitem><para>Takes a directory path relative to the service's root directory specified by
117 <varname>RootDirectory=</varname>, or the special value <literal>~</literal>. Sets the working directory for
118 executed processes. If set to <literal>~</literal>, the home directory of the user specified in
119 <varname>User=</varname> is used. If not set, defaults to the root directory when systemd is running as a
120 system instance and the respective user's home directory if run as user. If the setting is prefixed with the
121 <literal>-</literal> character, a missing working directory is not considered fatal. If
122 <varname>RootDirectory=</varname>/<varname>RootImage=</varname> is not set, then
123 <varname>WorkingDirectory=</varname> is relative to the root of the system running the service manager. Note
124 that setting this parameter might result in additional dependencies to be added to the unit (see
125 above).</para></listitem>
126 </varlistentry>
127
128 <varlistentry>
129 <term><varname>RootDirectory=</varname></term>
130
131 <listitem><para>Takes a directory path relative to the host's root directory (i.e. the root of the system
132 running the service manager). Sets the root directory for executed processes, with the <citerefentry
133 project='man-pages'><refentrytitle>pivot_root</refentrytitle><manvolnum>2</manvolnum></citerefentry>
134 or <citerefentry project='man-pages'><refentrytitle>chroot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
135 system call. If this is used, it must be ensured that the process binary and all its auxiliary files
136 are available in the new root. Note that setting this parameter might result in additional
137 dependencies to be added to the unit (see above).</para>
138
139 <para>The <varname>MountAPIVFS=</varname> and <varname>PrivateUsers=</varname> settings are particularly useful
140 in conjunction with <varname>RootDirectory=</varname>. For details, see below.</para>
141
142 <para>If <varname>RootDirectory=</varname>/<varname>RootImage=</varname> are used together with
143 <varname>NotifyAccess=</varname> the notification socket is automatically mounted from the host into
144 the root environment, to ensure the notification interface can work correctly.</para>
145
146 <para>Note that services using <varname>RootDirectory=</varname>/<varname>RootImage=</varname> will
147 not be able to log via the syslog or journal protocols to the host logging infrastructure, unless the
148 relevant sockets are mounted from the host, specifically:</para>
149
150 <para>The host's
151 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>
152 file will be made available for the service (read-only) as
153 <filename>/run/host/os-release</filename>.
154 It will be updated automatically on soft reboot (see:
155 <citerefentry><refentrytitle>systemd-soft-reboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>),
156 in case the service is configured to survive it.</para>
157
158 <example>
159 <title>Mounting logging sockets into root environment</title>
160
161 <programlisting>BindReadOnlyPaths=/dev/log /run/systemd/journal/socket /run/systemd/journal/stdout</programlisting>
162 </example>
163
164 <xi:include href="vpick.xml" xpointer="directory"/>
165
166 <xi:include href="system-or-user-ns.xml" xpointer="singular"/></listitem>
167 </varlistentry>
168
169 <varlistentry>
170 <term><varname>RootImage=</varname></term>
171
172 <listitem><para>Takes a path to a block device node or regular file as argument. This call is similar
173 to <varname>RootDirectory=</varname> however mounts a file system hierarchy from a block device node
174 or loopback file instead of a directory. The device node or file system image file needs to contain a
175 file system without a partition table, or a file system within an MBR/MS-DOS or GPT partition table
176 with only a single Linux-compatible partition, or a set of file systems within a GPT partition table
177 that follows the
178 <ulink url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">
179 Discoverable Partitions Specification</ulink>.</para>
180
181 <para>When <varname>DevicePolicy=</varname> is set to <literal>closed</literal> or
182 <literal>strict</literal>, or set to <literal>auto</literal> and <varname>DeviceAllow=</varname> is
183 set, then this setting adds <filename>/dev/loop-control</filename> with <constant>rw</constant> mode,
184 <literal>block-loop</literal> and <literal>block-blkext</literal> with <constant>rwm</constant> mode
185 to <varname>DeviceAllow=</varname>. See
186 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
187 for the details about <varname>DevicePolicy=</varname> or <varname>DeviceAllow=</varname>. Also, see
188 <varname>PrivateDevices=</varname> below, as it may change the setting of
189 <varname>DevicePolicy=</varname>.</para>
190
191 <para>Units making use of <varname>RootImage=</varname> automatically gain an
192 <varname>After=</varname> dependency on <filename>systemd-udevd.service</filename>.</para>
193
194 <para>The host's
195 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>
196 file will be made available for the service (read-only) as
197 <filename>/run/host/os-release</filename>.
198 It will be updated automatically on soft reboot (see:
199 <citerefentry><refentrytitle>systemd-soft-reboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>),
200 in case the service is configured to survive it.</para>
201
202 <xi:include href="vpick.xml" xpointer="image"/>
203
204 <xi:include href="system-or-user-ns-mountfsd.xml" xpointer="singular"/>
205
206 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
207 </varlistentry>
208
209 <varlistentry>
210 <term><varname>RootImageOptions=</varname></term>
211
212 <listitem><para>Takes a comma-separated list of mount options that will be used on disk images specified by
213 <varname>RootImage=</varname>. Optionally a partition name can be prefixed, followed by colon, in
214 case the image has multiple partitions, otherwise partition name <literal>root</literal> is implied.
215 Options for multiple partitions can be specified in a single line with space separators. Assigning an empty
216 string removes previous assignments. Duplicated options are ignored. For a list of valid mount options, please
217 refer to
218 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
219 </para>
220
221 <para>Valid partition names follow the
222 <ulink url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">
223 Discoverable Partitions Specification</ulink>:
224 <constant>root</constant>, <constant>usr</constant>, <constant>home</constant>, <constant>srv</constant>,
225 <constant>esp</constant>, <constant>xbootldr</constant>, <constant>tmp</constant>,
226 <constant>var</constant>.</para>
227
228 <xi:include href="system-only.xml" xpointer="singular"/>
229
230 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
231 </varlistentry>
232
233 <varlistentry>
234 <term><varname>RootEphemeral=</varname></term>
235
236 <listitem><para>Takes a boolean argument. If enabled, executed processes will run in an ephemeral
237 copy of the root directory or root image. The ephemeral copy is placed in
238 <filename>/var/lib/systemd/ephemeral-trees/</filename> while the service is active and is cleaned up
239 when the service is stopped or restarted. If <varname>RootDirectory=</varname> is used and the root
240 directory is a subvolume, the ephemeral copy will be created by making a snapshot of the subvolume.
241 </para>
242
243 <para>To make sure making ephemeral copies can be made efficiently, the root directory or root image
244 should be located on the same filesystem as <filename>/var/lib/systemd/ephemeral-trees/</filename>.
245 When using <varname>RootEphemeral=</varname> with root directories,
246 <citerefentry project='url'><refentrytitle url='https://btrfs.readthedocs.io/en/latest/btrfs-man5.html'>btrfs</refentrytitle><manvolnum>5</manvolnum></citerefentry>
247 should be used as the filesystem and the root directory should ideally be a subvolume which
248 <command>systemd</command> can snapshot to make the ephemeral copy. For root images, a filesystem
249 with support for reflinks should be used to ensure an efficient ephemeral copy.</para>
250
251 <xi:include href="system-only.xml" xpointer="singular"/>
252
253 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
254 </varlistentry>
255
256 <varlistentry>
257 <term><varname>RootHash=</varname></term>
258
259 <listitem><para>Takes a data integrity (dm-verity) root hash specified in hexadecimal, or the path to a file
260 containing a root hash in ASCII hexadecimal format. This option enables data integrity checks using dm-verity,
261 if the used image contains the appropriate integrity data (see above) or if <varname>RootVerity=</varname> is used.
262 The specified hash must match the root hash of integrity data, and is usually at least 256 bits (and hence 64
263 formatted hexadecimal characters) long (in case of SHA256 for example). If this option is not specified, but
264 the image file carries the <literal>user.verity.roothash</literal> extended file attribute (see <citerefentry
265 project='man-pages'><refentrytitle>xattr</refentrytitle><manvolnum>7</manvolnum></citerefentry>), then the root
266 hash is read from it, also as formatted hexadecimal characters. If the extended file attribute is not found (or
267 is not supported by the underlying file system), but a file with the <filename>.roothash</filename> suffix is
268 found next to the image file, bearing otherwise the same name (except if the image has the
269 <filename>.raw</filename> suffix, in which case the root hash file must not have it in its name), the root hash
270 is read from it and automatically used, also as formatted hexadecimal characters.</para>
271
272 <para>If the disk image contains a separate <filename>/usr/</filename> partition it may also be
273 Verity protected, in which case the root hash may configured via an extended attribute
274 <literal>user.verity.usrhash</literal> or a <filename>.usrhash</filename> file adjacent to the disk
275 image. There's currently no option to configure the root hash for the <filename>/usr/</filename> file
276 system via the unit file directly.</para>
277
278 <xi:include href="system-or-user-ns-mountfsd.xml" xpointer="singular"/>
279
280 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
281 </varlistentry>
282
283 <varlistentry>
284 <term><varname>RootHashSignature=</varname></term>
285
286 <listitem><para>Takes a PKCS7 signature of the <varname>RootHash=</varname> option as a path to a
287 DER-encoded signature file, or as an ASCII base64 string encoding of a DER-encoded signature prefixed
288 by <literal>base64:</literal>. The dm-verity volume will only be opened if the signature of the root
289 hash is valid and signed by a public key present in the kernel keyring. If this option is not
290 specified, but a file with the <filename>.roothash.p7s</filename> suffix is found next to the image
291 file, bearing otherwise the same name (except if the image has the <filename>.raw</filename> suffix,
292 in which case the signature file must not have it in its name), the signature is read from it and
293 automatically used.</para>
294
295 <para>If the disk image contains a separate <filename>/usr/</filename> partition it may also be
296 Verity protected, in which case the signature for the root hash may configured via a
297 <filename>.usrhash.p7s</filename> file adjacent to the disk image. There's currently no option to
298 configure the root hash signature for the <filename>/usr/</filename> via the unit file
299 directly.</para>
300
301 <xi:include href="system-or-user-ns-mountfsd.xml" xpointer="singular"/>
302
303 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
304 </varlistentry>
305
306 <varlistentry>
307 <term><varname>RootVerity=</varname></term>
308
309 <listitem><para>Takes the path to a data integrity (dm-verity) file. This option enables data integrity checks
310 using dm-verity, if <varname>RootImage=</varname> is used and a root-hash is passed and if the used image itself
311 does not contain the integrity data. The integrity data must be matched by the root hash. If this option is not
312 specified, but a file with the <filename>.verity</filename> suffix is found next to the image file, bearing otherwise
313 the same name (except if the image has the <filename>.raw</filename> suffix, in which case the verity data file must
314 not have it in its name), the verity data is read from it and automatically used.</para>
315
316 <para>This option is supported only for disk images that contain a single file system, without an
317 enveloping partition table. Images that contain a GPT partition table should instead include both
318 root file system and matching Verity data in the same image, implementing the
319 <ulink url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">
320 Discoverable Partitions Specification</ulink>.</para>
321
322 <xi:include href="system-or-user-ns-mountfsd.xml" xpointer="singular"/>
323
324 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
325 </varlistentry>
326
327 <varlistentry>
328 <term><varname>RootImagePolicy=</varname></term>
329 <term><varname>MountImagePolicy=</varname></term>
330 <term><varname>ExtensionImagePolicy=</varname></term>
331
332 <listitem><para>Takes an image policy string as per
333 <citerefentry><refentrytitle>systemd.image-policy</refentrytitle><manvolnum>7</manvolnum></citerefentry>
334 to use when mounting the disk images (DDI) specified in <varname>RootImage=</varname>,
335 <varname>MountImage=</varname>, <varname>ExtensionImage=</varname>, respectively. If not specified
336 the following policy string is the default for <varname>RootImagePolicy=</varname> and <varname>MountImagePolicy</varname>:</para>
337
338 <programlisting>root=verity+signed+encrypted+unprotected+absent: \
339 usr=verity+signed+encrypted+unprotected+absent: \
340 home=encrypted+unprotected+absent: \
341 srv=encrypted+unprotected+absent: \
342 tmp=encrypted+unprotected+absent: \
343 var=encrypted+unprotected+absent</programlisting>
344
345 <para>The default policy for <varname>ExtensionImagePolicy=</varname> is:</para>
346
347 <programlisting>root=verity+signed+encrypted+unprotected+absent: \
348 usr=verity+signed+encrypted+unprotected+absent</programlisting>
349
350 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
351 </varlistentry>
352
353 <varlistentry>
354 <term><varname>MountAPIVFS=</varname></term>
355
356 <listitem><para>Takes a boolean argument. If on, a private mount namespace for the unit's processes is created
357 and the API file systems <filename>/proc/</filename>, <filename>/sys/</filename>, <filename>/dev/</filename> and
358 <filename>/run/</filename> (as an empty <literal>tmpfs</literal>) are mounted inside of it, unless they are
359 already mounted. Note that this option has no effect unless used in conjunction with
360 <varname>RootDirectory=</varname>/<varname>RootImage=</varname> as these four mounts are
361 generally mounted in the host anyway, and unless the root directory is changed, the private mount namespace
362 will be a 1:1 copy of the host's, and include these four mounts. Note that the <filename>/dev/</filename> file
363 system of the host is bind mounted if this option is used without <varname>PrivateDevices=</varname>. To run
364 the service with a private, minimal version of <filename>/dev/</filename>, combine this option with
365 <varname>PrivateDevices=</varname>.</para>
366
367 <para>In order to allow propagating mounts at runtime in a safe manner, <filename>/run/systemd/propagate/</filename>
368 on the host will be used to set up new mounts, and <filename>/run/host/incoming/</filename> in the private namespace
369 will be used as an intermediate step to store them before being moved to the final mount point.</para>
370
371 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
372 </varlistentry>
373
374 <varlistentry>
375 <term><varname>BindLogSockets=</varname></term>
376
377 <listitem><para>Takes a boolean argument. If true, sockets from <citerefentry>
378 <refentrytitle>systemd-journald.socket</refentrytitle><manvolnum>8</manvolnum></citerefentry>
379 will be bind mounted into the mount namespace. This is particularly useful when a different instance
380 of <filename>/run/</filename> is employed, to make sure processes running in the namespace
381 can still make use of <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
382 </para>
383
384 <para>This option is implied when <varname>LogNamespace=</varname> is used,
385 when <varname>MountAPIVFS=yes</varname>, or when <varname>PrivateDevices=yes</varname> is used
386 in conjunction with either <varname>RootDirectory=</varname> or <varname>RootImage=</varname>.</para>
387
388 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
389 </varlistentry>
390
391 <varlistentry>
392 <term><varname>ProtectProc=</varname></term>
393
394 <listitem><para>Takes one of <literal>noaccess</literal>, <literal>invisible</literal>,
395 <literal>ptraceable</literal> or <literal>default</literal> (which it defaults to). When set, this
396 controls the <literal>hidepid=</literal> mount option of the <literal>procfs</literal> instance for
397 the unit that controls which directories with process metainformation
398 (<filename>/proc/<replaceable>PID</replaceable></filename>) are visible and accessible: when set to
399 <literal>noaccess</literal> the ability to access most of other users' process metadata in
400 <filename>/proc/</filename> is taken away for processes of the service. When set to
401 <literal>invisible</literal> processes owned by other users are hidden from
402 <filename>/proc/</filename>. If <literal>ptraceable</literal> all processes that cannot be
403 <function>ptrace()</function>'ed by a process are hidden to it. If <literal>default</literal> no
404 restrictions on <filename>/proc/</filename> access or visibility are made. For further details see
405 <ulink url="https://docs.kernel.org/filesystems/proc.html#mount-options">The /proc
406 Filesystem</ulink>. It is generally recommended to run most system services with this option set to
407 <literal>invisible</literal>. This option is implemented via file system namespacing, and thus cannot
408 be used with services that shall be able to install mount points in the host file system
409 hierarchy. Note that the root user is unaffected by this option, so to be effective it has to be used
410 together with <varname>User=</varname> or <varname>DynamicUser=yes</varname>, and also without the
411 <literal>CAP_SYS_PTRACE</literal> capability, which also allows a process to bypass this feature. It
412 cannot be used for services that need to access metainformation about other users' processes. This
413 option implies <varname>MountAPIVFS=</varname>.</para>
414
415 <para>If the kernel does not support per-mount point <option>hidepid=</option> mount options this
416 setting remains without effect, and the unit's processes will be able to access and see other process
417 as if the option was not used.</para>
418
419 <xi:include href="system-only.xml" xpointer="singular"/>
420
421 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
422 </varlistentry>
423
424 <varlistentry>
425 <term><varname>ProcSubset=</varname></term>
426
427 <listitem><para>Takes one of <literal>all</literal> (the default) and <literal>pid</literal>. If
428 <literal>pid</literal>, all files and directories not directly associated with process management and
429 introspection are made invisible in the <filename>/proc/</filename> file system configured for the
430 unit's processes. This controls the <literal>subset=</literal> mount option of the
431 <literal>procfs</literal> instance for the unit. For further details see <ulink
432 url="https://docs.kernel.org/filesystems/proc.html#mount-options">The /proc
433 Filesystem</ulink>. Note that Linux exposes various kernel APIs via <filename>/proc/</filename>,
434 which are made unavailable with this setting. Since these APIs are used frequently this option is
435 useful only in a few, specific cases, and is not suitable for most non-trivial programs.</para>
436
437 <para>Much like <varname>ProtectProc=</varname> above, this is implemented via file system mount
438 namespacing, and hence the same restrictions apply: it is only available to system services, it
439 disables mount propagation to the host mount table, and it implies
440 <varname>MountAPIVFS=</varname>. Also, like <varname>ProtectProc=</varname> this setting is gracefully
441 disabled if the used kernel does not support the <literal>subset=</literal> mount option of
442 <literal>procfs</literal>.</para>
443
444 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
445 </varlistentry>
446
447 <varlistentry>
448 <term><varname>BindPaths=</varname></term>
449 <term><varname>BindReadOnlyPaths=</varname></term>
450
451 <listitem><para>Configures unit-specific bind mounts. A bind mount makes a particular file or directory
452 available at an additional place in the unit's view of the file system. Any bind mounts created with this
453 option are specific to the unit, and are not visible in the host's mount table. This option expects a
454 whitespace separated list of bind mount definitions. Each definition consists of a colon-separated triple of
455 source path, destination path and option string, where the latter two are optional. If only a source path is
456 specified the source and destination is taken to be the same. The option string may be either
457 <literal>rbind</literal> or <literal>norbind</literal> for configuring a recursive or non-recursive bind
458 mount. If the destination path is omitted, the option string must be omitted too.
459 Each bind mount definition may be prefixed with <literal>-</literal>, in which case it will be ignored
460 when its source path does not exist.</para>
461
462 <para><varname>BindPaths=</varname> creates regular writable bind mounts (unless the source file system mount
463 is already marked read-only), while <varname>BindReadOnlyPaths=</varname> creates read-only bind mounts. These
464 settings may be used more than once, each usage appends to the unit's list of bind mounts. If the empty string
465 is assigned to either of these two options the entire list of bind mounts defined prior to this is reset. Note
466 that, in this case, both read-only and regular bind mounts are reset, regardless which of the two settings is
467 used.</para>
468
469 <para>Using this option implies that a mount namespace is allocated for the unit, i.e. it implies the
470 effect of <varname>PrivateMounts=</varname> (see below).</para>
471
472 <para>This option is particularly useful when <varname>RootDirectory=</varname>/<varname>RootImage=</varname>
473 is used. In this case, the source path refers to a path on the host file system, while the destination path
474 refers to a path below the root directory of the unit.</para>
475
476 <para>Note that the destination directory must exist or systemd must be able to create it. Thus, it
477 is not possible to use those options for mount points nested underneath paths specified in
478 <varname>InaccessiblePaths=</varname>, or under <filename>/home/</filename> and other protected
479 directories if <varname>ProtectHome=yes</varname> is
480 specified. <varname>TemporaryFileSystem=</varname> with <literal>:ro</literal> or
481 <varname>ProtectHome=tmpfs</varname> should be used instead.</para>
482
483 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
484 </varlistentry>
485
486 <varlistentry>
487 <term><varname>MountImages=</varname></term>
488
489 <listitem><para>This setting is similar to <varname>RootImage=</varname> in that it mounts a file
490 system hierarchy from a block device node or loopback file, but the destination directory can be
491 specified as well as mount options. This option expects a whitespace separated list of mount
492 definitions. Each definition consists of a colon-separated tuple of source path and destination
493 definitions, optionally followed by another colon and a list of mount options.</para>
494
495 <para>Mount options may be defined as a single comma-separated list of options, in which case they
496 will be implicitly applied to the root partition on the image, or a series of colon-separated tuples
497 of partition name and mount options. Valid partition names and mount options are the same as for
498 <varname>RootImageOptions=</varname> setting described above.</para>
499
500 <para>Each mount definition may be prefixed with <literal>-</literal>, in which case it will be
501 ignored when its source path does not exist. The source argument is a path to a block device node or
502 regular file. If source or destination contain a <literal>:</literal>, it needs to be escaped as
503 <literal>\:</literal>. The device node or file system image file needs to follow the same rules as
504 specified for <varname>RootImage=</varname>. Any mounts created with this option are specific to the
505 unit, and are not visible in the host's mount table.</para>
506
507 <para>These settings may be used more than once, each usage appends to the unit's list of mount
508 paths. If the empty string is assigned, the entire list of mount paths defined prior to this is
509 reset.</para>
510
511 <para>Note that the destination directory must exist or systemd must be able to create it. Thus, it
512 is not possible to use those options for mount points nested underneath paths specified in
513 <varname>InaccessiblePaths=</varname>, or under <filename>/home/</filename> and other protected
514 directories if <varname>ProtectHome=yes</varname> is specified.</para>
515
516 <para>When <varname>DevicePolicy=</varname> is set to <literal>closed</literal> or
517 <literal>strict</literal>, or set to <literal>auto</literal> and <varname>DeviceAllow=</varname> is
518 set, then this setting adds <filename>/dev/loop-control</filename> with <constant>rw</constant> mode,
519 <literal>block-loop</literal> and <literal>block-blkext</literal> with <constant>rwm</constant> mode
520 to <varname>DeviceAllow=</varname>. See
521 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
522 for the details about <varname>DevicePolicy=</varname> or <varname>DeviceAllow=</varname>. Also, see
523 <varname>PrivateDevices=</varname> below, as it may change the setting of
524 <varname>DevicePolicy=</varname>.</para>
525
526 <xi:include href="system-or-user-ns-mountfsd.xml" xpointer="singular"/>
527
528 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
529 </varlistentry>
530
531 <varlistentry>
532 <term><varname>ExtensionImages=</varname></term>
533
534 <listitem><para>This setting is similar to <varname>MountImages=</varname> in that it mounts a file
535 system hierarchy from a block device node or loopback file, but instead of providing a destination
536 path, an overlay will be set up. This option expects a whitespace separated list of mount
537 definitions. Each definition consists of a source path, optionally followed by a colon and a list of
538 mount options.</para>
539
540 <para>A read-only OverlayFS will be set up on top of <filename>/usr/</filename> and
541 <filename>/opt/</filename> hierarchies for sysext images and <filename>/etc/</filename>
542 hierarchy for confext images. The order in which the images are listed will determine the
543 order in which the overlay is laid down: images specified first to last will result in overlayfs
544 layers bottom to top.</para>
545
546 <para>Mount options may be defined as a single comma-separated list of options, in which case they
547 will be implicitly applied to the root partition on the image, or a series of colon-separated tuples
548 of partition name and mount options. Valid partition names and mount options are the same as for
549 <varname>RootImageOptions=</varname> setting described above.</para>
550
551 <para>Each mount definition may be prefixed with <literal>-</literal>, in which case it will be
552 ignored when its source path does not exist. The source argument is a path to a block device node or
553 regular file. If the source path contains a <literal>:</literal>, it needs to be escaped as
554 <literal>\:</literal>. The device node or file system image file needs to follow the same rules as
555 specified for <varname>RootImage=</varname>. Any mounts created with this option are specific to the
556 unit, and are not visible in the host's mount table.</para>
557
558 <para>These settings may be used more than once, each usage appends to the unit's list of image
559 paths. If the empty string is assigned, the entire list of mount paths defined prior to this is
560 reset.</para>
561
562 <para>Each sysext image must carry a <filename>/usr/lib/extension-release.d/extension-release.IMAGE</filename>
563 file while each confext image must carry a <filename>/etc/extension-release.d/extension-release.IMAGE</filename>
564 file, with the appropriate metadata which matches <varname>RootImage=</varname>/<varname>RootDirectory=</varname>
565 or the host. See:
566 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
567 To disable the safety check that the extension-release file name matches the image file name, the
568 <varname>x-systemd.relax-extension-release-check</varname> mount option may be appended.</para>
569
570 <para>This option can be used together with a <option>notify-reload</option> service type and
571 <citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry>
572 to manage configuration updates. When such a service carrying confext images is reloaded via
573 <command>systemctl reload foo.service</command> or equivalent D-Bus method, the confext itself will
574 be reloaded to pick up any changes. This only applies to confext extensions. Note that in case a
575 service has this configuration enabled at first, and then it is subsequently removed in an update
576 followed by a daemon-reload operation, reloading the confexts will be a no-op, and a full service
577 restart is required instead. See
578 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
579 also for details.</para>
580
581 <para>When <varname>DevicePolicy=</varname> is set to <literal>closed</literal> or
582 <literal>strict</literal>, or set to <literal>auto</literal> and <varname>DeviceAllow=</varname> is
583 set, then this setting adds <filename>/dev/loop-control</filename> with <constant>rw</constant> mode,
584 <literal>block-loop</literal> and <literal>block-blkext</literal> with <constant>rwm</constant> mode
585 to <varname>DeviceAllow=</varname>. See
586 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
587 for the details about <varname>DevicePolicy=</varname> or <varname>DeviceAllow=</varname>. Also, see
588 <varname>PrivateDevices=</varname> below, as it may change the setting of
589 <varname>DevicePolicy=</varname>.</para>
590
591 <xi:include href="vpick.xml" xpointer="image"/>
592
593 <xi:include href="system-or-user-ns-mountfsd.xml" xpointer="singular"/>
594
595 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
596 </varlistentry>
597
598 <varlistentry>
599 <term><varname>ExtensionDirectories=</varname></term>
600
601 <listitem><para>This setting is similar to <varname>BindReadOnlyPaths=</varname> in that it mounts a file
602 system hierarchy from a directory, but instead of providing a destination path, an overlay will be set
603 up. This option expects a whitespace separated list of source directories.</para>
604
605 <para>A read-only OverlayFS will be set up on top of <filename>/usr/</filename> and
606 <filename>/opt/</filename> hierarchies for sysext images and <filename>/etc/</filename>
607 hierarchy for confext images. The order in which the directories are listed will determine
608 the order in which the overlay is laid down: directories specified first to last will result in overlayfs
609 layers bottom to top.</para>
610
611 <para>Each directory listed in <varname>ExtensionDirectories=</varname> may be prefixed with <literal>-</literal>,
612 in which case it will be ignored when its source path does not exist. Any mounts created with this option are
613 specific to the unit, and are not visible in the host's mount table.</para>
614
615 <para>These settings may be used more than once, each usage appends to the unit's list of directories
616 paths. If the empty string is assigned, the entire list of mount paths defined prior to this is
617 reset.</para>
618
619 <para>Each sysext directory must contain a <filename>/usr/lib/extension-release.d/extension-release.IMAGE</filename>
620 file while each confext directory must carry a <filename>/etc/extension-release.d/extension-release.IMAGE</filename>
621 file, with the appropriate metadata which matches <varname>RootImage=</varname>/<varname>RootDirectory=</varname>
622 or the host. See:
623 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
624
625 <para>This option can be used together with a <option>notify-reload</option> service type and
626 <citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry>
627 to manage configuration updates. When such a service carrying confext directories is reloaded via
628 <command>systemctl reload foo.service</command> or equivalent D-Bus method, the confext itself will
629 be reloaded to pick up any changes. This only applies to confext extensions. Note that in case a
630 service has this configuration enabled at first, and then it is subsequently removed in an update
631 followed by a daemon-reload operation, reloading the confexts will be a no-op, and a full service
632 restart is required instead. See
633 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
634 also for details.</para>
635
636 <para>Note that usage from user units requires overlayfs support in unprivileged user namespaces,
637 which was first introduced in kernel v5.11.</para>
638
639 <xi:include href="vpick.xml" xpointer="directory"/>
640
641 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
642
643 <xi:include href="version-info.xml" xpointer="v251"/></listitem>
644 </varlistentry>
645 </variablelist>
646 </refsect1>
647
648 <refsect1>
649 <title>User/Group Identity</title>
650
651 <xi:include href="system-only.xml" xpointer="plural"/>
652
653 <variablelist class='unit-directives'>
654
655 <varlistentry>
656 <term><varname>User=</varname></term>
657 <term><varname>Group=</varname></term>
658
659 <listitem><para>Set the UNIX user or group that the processes are executed as, respectively. Takes a single
660 user or group name, or a numeric ID as argument. For system services (services run by the system service
661 manager, i.e. managed by PID 1) and for user services of the root user (services managed by root's instance of
662 <command>systemd --user</command>), the default is <literal>root</literal>, but <varname>User=</varname> may be
663 used to specify a different user. For user services of any other user, switching user identity is not
664 permitted, hence the only valid setting is the same user the user's service manager is running as. If no group
665 is set, the default group of the user is used. This setting does not affect commands whose command line is
666 prefixed with <literal>+</literal>.</para>
667
668 <para>Note that this enforces only weak restrictions on the user/group name syntax, but will generate
669 warnings in many cases where user/group names do not adhere to the following rules: the specified
670 name should consist only of the characters a-z, A-Z, 0-9, <literal>_</literal> and
671 <literal>-</literal>, except for the first character which must be one of a-z, A-Z and
672 <literal>_</literal> (i.e. digits and <literal>-</literal> are not permitted as first character). The
673 user/group name must have at least one character, and at most 31. These restrictions are made in
674 order to avoid ambiguities and to ensure user/group names and unit files remain portable among Linux
675 systems. For further details on the names accepted and the names warned about see <ulink
676 url="https://systemd.io/USER_NAMES">User/Group Name Syntax</ulink>.</para>
677
678 <para>When used in conjunction with <varname>DynamicUser=</varname> the user/group name specified is
679 dynamically allocated at the time the service is started, and released at the time the service is
680 stopped — unless it is already allocated statically (see below). If <varname>DynamicUser=</varname>
681 is not used the specified user and group must have been created statically in the user database no
682 later than the moment the service is started, for example using the
683 <citerefentry><refentrytitle>sysusers.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
684 facility, which is applied at boot or package install time. If the user does not exist by then
685 program invocation will fail.</para>
686
687 <para>If the <varname>User=</varname> setting is used the supplementary group list is initialized
688 from the specified user's default group list, as defined in the system's user and group
689 database. Additional groups may be configured through the <varname>SupplementaryGroups=</varname>
690 setting (see below).</para></listitem>
691 </varlistentry>
692
693 <varlistentry>
694 <term><varname>DynamicUser=</varname></term>
695
696 <listitem><para>Takes a boolean parameter. If set, a UNIX user and group pair is allocated
697 dynamically when the unit is started, and released as soon as it is stopped. The user and group will
698 not be added to <filename>/etc/passwd</filename> or <filename>/etc/group</filename>, but are managed
699 transiently during runtime. The
700 <citerefentry><refentrytitle>nss-systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry> glibc
701 NSS module provides integration of these dynamic users/groups into the system's user and group
702 databases. The user and group name to use may be configured via <varname>User=</varname> and
703 <varname>Group=</varname> (see above). If these options are not used and dynamic user/group
704 allocation is enabled for a unit, the name of the dynamic user/group is implicitly derived from the
705 unit name. If the unit name without the type suffix qualifies as valid user name it is used directly,
706 otherwise a name incorporating a hash of it is used. If a statically allocated user or group of the
707 configured name already exists, it is used and no dynamic user/group is allocated. Note that if
708 <varname>User=</varname> is specified and the static group with the name exists, then it is required
709 that the static user with the name already exists. Similarly, if <varname>Group=</varname> is
710 specified and the static user with the name exists, then it is required that the static group with
711 the name already exists. Dynamic users/groups are allocated from the UID/GID range 61184…65519. It is
712 recommended to avoid this range for regular system or login users. At any point in time each UID/GID
713 from this range is only assigned to zero or one dynamically allocated users/groups in use. However,
714 UID/GIDs are recycled after a unit is terminated. Care should be taken that any processes running as
715 part of a unit for which dynamic users/groups are enabled do not leave files or directories owned by
716 these users/groups around, as a different unit might get the same UID/GID assigned later on, and thus
717 gain access to these files or directories. If <varname>DynamicUser=</varname> is enabled,
718 <varname>RemoveIPC=</varname> is implied (and cannot be turned off). This ensures that the lifetime
719 of IPC objects and temporary files created by the executed processes is bound to the runtime of the
720 service, and hence the lifetime of the dynamic user/group. Since <filename>/tmp/</filename> and
721 <filename>/var/tmp/</filename> are usually the only world-writable directories on a system, unless
722 <varname>PrivateTmp=</varname> is manually set to <literal>true</literal>, <literal>disconnected</literal>
723 would be implied. This ensures that a unit making use of dynamic user/group allocation cannot
724 leave files around after unit termination. Furthermore
725 <varname>NoNewPrivileges=</varname> and <varname>RestrictSUIDSGID=</varname> are implicitly enabled
726 (and cannot be disabled), to ensure that processes invoked cannot take benefit or create SUID/SGID
727 files or directories. Moreover, <varname>ProtectSystem=strict</varname> and
728 <varname>ProtectHome=read-only</varname> are implied, thus prohibiting the service to write to
729 arbitrary file system locations. In order to allow the service to write to certain directories, they
730 have to be allow-listed using <varname>ReadWritePaths=</varname>, but care must be taken so that
731 UID/GID recycling does not create security issues involving files created by the service. Use
732 <varname>RuntimeDirectory=</varname> (see below) in order to assign a writable runtime directory to a
733 service, owned by the dynamic user/group and removed automatically when the unit is terminated. Use
734 <varname>StateDirectory=</varname>, <varname>CacheDirectory=</varname> and
735 <varname>LogsDirectory=</varname> in order to assign a set of writable directories for specific
736 purposes to the service in a way that they are protected from vulnerabilities due to UID reuse (see
737 below). If this option is enabled, care should be taken that the unit's processes do not get access
738 to directories outside of these explicitly configured and managed ones. Specifically, do not use
739 <varname>BindPaths=</varname> and be careful with <constant>AF_UNIX</constant> file descriptor
740 passing for directory file descriptors, as this would permit processes to create files or directories
741 owned by the dynamic user/group that are not subject to the lifecycle and access guarantees of the
742 service. Note that this option is currently incompatible with D-Bus policies, thus a service using
743 this option may currently not allocate a D-Bus service name (note that this does not affect calling
744 into other D-Bus services). Defaults to off.</para>
745
746 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
747 </varlistentry>
748
749 <varlistentry>
750 <term><varname>SupplementaryGroups=</varname></term>
751
752 <listitem><para>Sets the supplementary Unix groups the processes are executed as. This takes a space-separated
753 list of group names or IDs. This option may be specified more than once, in which case all listed groups are
754 set as supplementary groups. When the empty string is assigned, the list of supplementary groups is reset, and
755 all assignments prior to this one will have no effect. In any way, this option does not override, but extends
756 the list of supplementary groups configured in the system group database for the user. This does not affect
757 commands prefixed with <literal>+</literal>.</para></listitem>
758 </varlistentry>
759
760 <varlistentry>
761 <term><varname>SetLoginEnvironment=</varname></term>
762
763 <listitem><para>Takes a boolean parameter that controls whether to set the <varname>$HOME</varname>,
764 <varname>$LOGNAME</varname>, and <varname>$SHELL</varname> environment variables. If not set, this
765 defaults to true if <varname>User=</varname>, <varname>DynamicUser=</varname> or
766 <varname>PAMName=</varname> are set, false otherwise. If set to true, the variables will always be
767 set for system services, i.e. even when the default user <literal>root</literal> is used. If set to
768 false, the mentioned variables are not set by the service manager, no matter whether
769 <varname>User=</varname>, <varname>DynamicUser=</varname>, or <varname>PAMName=</varname> are used or
770 not. This option normally has no effect on services of the per-user service manager, since in that
771 case these variables are typically inherited from user manager's own environment anyway.</para>
772
773 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
774 </varlistentry>
775
776 <varlistentry>
777 <term><varname>PAMName=</varname></term>
778
779 <listitem><para>Sets the PAM service name to set up a session as. If set, the executed process will be
780 registered as a PAM session under the specified service name. This is only useful in conjunction with the
781 <varname>User=</varname> setting, and is otherwise ignored. If not set, no PAM session will be opened for the
782 executed processes. See <citerefentry
783 project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
784 details.</para>
785
786 <para>Note that for each unit making use of this option a PAM session handler process will be maintained as
787 part of the unit and stays around as long as the unit is active, to ensure that appropriate actions can be
788 taken when the unit and hence the PAM session terminates. This process is named <literal>(sd-pam)</literal> and
789 is an immediate child process of the unit's main process.</para>
790
791 <para>Note that when this option is used for a unit it is very likely (depending on PAM configuration) that the
792 main unit process will be migrated to its own session scope unit when it is activated. This process will hence
793 be associated with two units: the unit it was originally started from (and for which
794 <varname>PAMName=</varname> was configured), and the session scope unit. Any child processes of that process
795 will however be associated with the session scope unit only. This has implications when used in combination
796 with <varname>NotifyAccess=</varname><option>all</option>, as these child processes will not be able to affect
797 changes in the original unit through notification messages. These messages will be considered belonging to the
798 session scope unit and not the original unit. It is hence not recommended to use <varname>PAMName=</varname> in
799 combination with <varname>NotifyAccess=</varname><option>all</option>.</para>
800
801 <para>If a PAM module interactively requests input (a password or suchlike) it will be attempted to
802 be read from a service credential (as configured via <varname>SetCredential=</varname>,
803 <varname>ImportCredential=</varname> and related calls) under the name
804 <varname>pam.authtok.<replaceable>pamservice</replaceable></varname>, where
805 <replaceable>pamservice</replaceable> is replaced by the PAM service name as configured with
806 <varname>PAMName=</varname>. (Note that the credential remains accessible for the runtime of the
807 service!) If no matching credential is set, the user is prompted for it interactively via the <ulink
808 url="https://systemd.io/PASSWORD_AGENTS">Password Agent</ulink> logic.</para>
809 </listitem>
810 </varlistentry>
811
812 </variablelist>
813 </refsect1>
814
815 <refsect1>
816 <title>Capabilities</title>
817
818 <xi:include href="system-or-user-ns.xml" xpointer="plural"/>
819
820 <variablelist class='unit-directives'>
821
822 <varlistentry>
823 <term><varname>CapabilityBoundingSet=</varname></term>
824
825 <listitem><para>Controls which capabilities to include in the capability bounding set for the
826 executed process. See <citerefentry
827 project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
828 for details. Takes a whitespace-separated list of capability names,
829 e.g. <constant>CAP_SYS_ADMIN</constant>, <constant>CAP_DAC_OVERRIDE</constant>,
830 <constant>CAP_SYS_PTRACE</constant>. Capabilities listed will be included in the bounding set, all
831 others are removed. If the list of capabilities is prefixed with <literal>~</literal>, all but the
832 listed capabilities will be included, the effect of the assignment inverted. Note that this option
833 also affects the respective capabilities in the effective, permitted and inheritable capability
834 sets. If this option is not used, the capability bounding set is not modified on process execution,
835 hence no limits on the capabilities of the process are enforced. This option may appear more than
836 once, in which case the bounding sets are merged by <constant>OR</constant>, or by
837 <constant>AND</constant> if the lines are prefixed with <literal>~</literal> (see below). If the
838 empty string is assigned to this option, the bounding set is reset to the empty capability set, and
839 all prior settings have no effect. If set to <literal>~</literal> (without any further argument),
840 the bounding set is reset to the full set of available capabilities, also undoing any previous
841 settings. This does not affect commands prefixed with <literal>+</literal>.</para>
842
843 <para>Use
844 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
845 <command>capability</command> command to retrieve a list of capabilities defined on the local
846 system.</para>
847
848 <para>Example: if a unit has the following,
849 <programlisting>CapabilityBoundingSet=CAP_A CAP_B
850CapabilityBoundingSet=CAP_B CAP_C</programlisting>
851 then <constant index='false'>CAP_A</constant>, <constant index='false'>CAP_B</constant>, and
852 <constant index='false'>CAP_C</constant> are set. If the second line is prefixed with
853 <literal>~</literal>, e.g.,
854 <programlisting>CapabilityBoundingSet=CAP_A CAP_B
855CapabilityBoundingSet=~CAP_B CAP_C</programlisting>
856 then, only <constant index='false'>CAP_A</constant> is set.</para></listitem>
857 </varlistentry>
858
859 <varlistentry>
860 <term><varname>AmbientCapabilities=</varname></term>
861
862 <listitem><para>Controls which capabilities to include in the ambient capability set for the executed
863 process. Takes a whitespace-separated list of capability names, e.g. <constant>CAP_SYS_ADMIN</constant>,
864 <constant>CAP_DAC_OVERRIDE</constant>, <constant>CAP_SYS_PTRACE</constant>. This option may appear more than
865 once, in which case the ambient capability sets are merged (see the above examples in
866 <varname>CapabilityBoundingSet=</varname>). If the list of capabilities is prefixed with <literal>~</literal>,
867 all but the listed capabilities will be included, the effect of the assignment inverted. If the empty string is
868 assigned to this option, the ambient capability set is reset to the empty capability set, and all prior
869 settings have no effect. If set to <literal>~</literal> (without any further argument), the ambient capability
870 set is reset to the full set of available capabilities, also undoing any previous settings. Note that adding
871 capabilities to the ambient capability set adds them to the process's inherited capability set.</para>
872
873 <para>Ambient capability sets are useful if you want to execute a process as a non-privileged user but
874 still want to give it some capabilities. Note that, in this case, option <constant>keep-caps</constant>
875 is automatically added to <varname>SecureBits=</varname> to retain the capabilities over the user
876 change. <varname>AmbientCapabilities=</varname> does not affect commands prefixed with
877 <literal>+</literal>.</para>
878
879 <xi:include href="version-info.xml" xpointer="v229"/></listitem>
880 </varlistentry>
881
882 </variablelist>
883 </refsect1>
884
885 <refsect1>
886 <title>Security</title>
887
888 <variablelist class='unit-directives'>
889
890 <varlistentry>
891 <term><varname>NoNewPrivileges=</varname></term>
892
893 <listitem><para>Takes a boolean argument. If true, ensures that the service process and all its
894 children can never gain new privileges through <function>execve()</function> (e.g. via setuid or
895 setgid bits, or filesystem capabilities). This is the simplest and most effective way to ensure that
896 a process and its children can never elevate privileges again. Defaults to false. In case the service
897 will be run in a new mount namespace anyway and SELinux is disabled, all file systems are mounted with
898 <constant>MS_NOSUID</constant> flag. Also see <ulink
899 url="https://docs.kernel.org/userspace-api/no_new_privs.html">No New Privileges Flag</ulink>.
900 </para>
901
902 <para>Note that this setting only has an effect on the unit's processes themselves (or any processes
903 directly or indirectly forked off them). It has no effect on processes potentially invoked on request
904 of them through tools such as <citerefentry
905 project='man-pages'><refentrytitle>at</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
906 <citerefentry
907 project='man-pages'><refentrytitle>crontab</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
908 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>, or
909 arbitrary IPC services.</para>
910
911 <xi:include href="version-info.xml" xpointer="v187"/></listitem>
912 </varlistentry>
913
914 <varlistentry>
915 <term><varname>SecureBits=</varname></term>
916
917 <listitem><para>Controls the secure bits set for the executed process. Takes a space-separated combination of
918 options from the following list: <option>keep-caps</option>, <option>keep-caps-locked</option>,
919 <option>no-setuid-fixup</option>, <option>no-setuid-fixup-locked</option>, <option>noroot</option>, and
920 <option>noroot-locked</option>. This option may appear more than once, in which case the secure bits are
921 ORed. If the empty string is assigned to this option, the bits are reset to 0. This does not affect commands
922 prefixed with <literal>+</literal>. See <citerefentry
923 project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
924 details.</para></listitem>
925 </varlistentry>
926
927 </variablelist>
928 </refsect1>
929
930 <refsect1>
931 <title>Mandatory Access Control</title>
932
933 <variablelist class='unit-directives'>
934
935 <varlistentry>
936 <term><varname>SELinuxContext=</varname></term>
937
938 <listitem><para>Set the SELinux security context of the executed process. If set, this will override the
939 automated domain transition. However, the policy still needs to authorize the transition. This directive is
940 ignored if SELinux is disabled. If prefixed by <literal>-</literal>, failing to set the SELinux
941 security context will be ignored, but it is still possible that the subsequent
942 <function>execve()</function> may fail if the policy does not allow the transition for the
943 non-overridden context. This does not affect commands prefixed with <literal>+</literal>. See
944 <citerefentry
945 project='die-net'><refentrytitle>setexeccon</refentrytitle><manvolnum>3</manvolnum></citerefentry>
946 for details.</para>
947
948 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
949 </varlistentry>
950
951 <varlistentry>
952 <term><varname>AppArmorProfile=</varname></term>
953
954 <listitem><para>Takes a profile name as argument. The process executed by the unit will switch to
955 this profile when started. Profiles must already be loaded in the kernel, or the unit will fail. If
956 prefixed by <literal>-</literal>, all errors will be ignored. This setting has no effect if AppArmor
957 is not enabled. This setting does not affect commands prefixed with <literal>+</literal>.</para>
958
959 <xi:include href="system-only.xml" xpointer="singular"/>
960
961 <xi:include href="version-info.xml" xpointer="v210"/>
962 </listitem>
963 </varlistentry>
964
965 <varlistentry>
966 <term><varname>SmackProcessLabel=</varname></term>
967
968 <listitem><para>Takes a <option>SMACK64</option> security label as argument. The process executed by the unit
969 will be started under this label and SMACK will decide whether the process is allowed to run or not, based on
970 it. The process will continue to run under the label specified here unless the executable has its own
971 <option>SMACK64EXEC</option> label, in which case the process will transition to run under that label. When not
972 specified, the label that systemd is running under is used. This directive is ignored if SMACK is
973 disabled.</para>
974
975 <para>The value may be prefixed by <literal>-</literal>, in which case all errors will be ignored. An empty
976 value may be specified to unset previous assignments. This does not affect commands prefixed with
977 <literal>+</literal>.</para>
978
979 <xi:include href="system-only.xml" xpointer="singular"/>
980
981 <xi:include href="version-info.xml" xpointer="v218"/></listitem>
982 </varlistentry>
983
984 </variablelist>
985 </refsect1>
986
987 <refsect1>
988 <title>Process Properties</title>
989
990 <variablelist class='unit-directives'>
991
992 <varlistentry>
993 <term><varname>LimitCPU=</varname></term>
994 <term><varname>LimitFSIZE=</varname></term>
995 <term><varname>LimitDATA=</varname></term>
996 <term><varname>LimitSTACK=</varname></term>
997 <term><varname>LimitCORE=</varname></term>
998 <term><varname>LimitRSS=</varname></term>
999 <term><varname>LimitNOFILE=</varname></term>
1000 <term><varname>LimitAS=</varname></term>
1001 <term><varname>LimitNPROC=</varname></term>
1002 <term><varname>LimitMEMLOCK=</varname></term>
1003 <term><varname>LimitLOCKS=</varname></term>
1004 <term><varname>LimitSIGPENDING=</varname></term>
1005 <term><varname>LimitMSGQUEUE=</varname></term>
1006 <term><varname>LimitNICE=</varname></term>
1007 <term><varname>LimitRTPRIO=</varname></term>
1008 <term><varname>LimitRTTIME=</varname></term>
1009
1010 <listitem><para>Set soft and hard limits on various resources for executed processes. See
1011 <citerefentry><refentrytitle>setrlimit</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
1012 details on the process resource limit concept. Process resource limits may be specified in two formats:
1013 either as single value to set a specific soft and hard limit to the same value, or as colon-separated
1014 pair <option>soft:hard</option> to set both limits individually
1015 (e.g. <literal>LimitAS=4G:16G</literal>). Use the string <option>infinity</option> to configure no
1016 limit on a specific resource. The multiplicative suffixes K, M, G, T, P and E (to the base 1024) may
1017 be used for resource limits measured in bytes (e.g. <literal>LimitAS=16G</literal>). For the limits
1018 referring to time values, the usual time units ms, s, min, h and so on may be used (see
1019 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
1020 details). Note that if no time unit is specified for <varname>LimitCPU=</varname> the default unit of
1021 seconds is implied, while for <varname>LimitRTTIME=</varname> the default unit of microseconds is
1022 implied. Also, note that the effective granularity of the limits might influence their
1023 enforcement. For example, time limits specified for <varname>LimitCPU=</varname> will be rounded up
1024 implicitly to multiples of 1s. For <varname>LimitNICE=</varname> the value may be specified in two
1025 syntaxes: if prefixed with <literal>+</literal> or <literal>-</literal>, the value is understood as
1026 regular Linux nice value in the range -20…19. If not prefixed like this the value is understood as
1027 raw resource limit parameter in the range 0…40 (with 0 being equivalent to 1).</para>
1028
1029 <para>Note that most process resource limits configured with these options are per-process, and
1030 processes may fork in order to acquire a new set of resources that are accounted independently of the
1031 original process, and may thus escape limits set. Also note that <varname>LimitRSS=</varname> is not
1032 implemented on Linux, and setting it has no effect. Often it is advisable to prefer the resource
1033 controls listed in
1034 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1035 over these per-process limits, as they apply to services as a whole, may be altered dynamically at
1036 runtime, and are generally more expressive. For example, <varname>MemoryMax=</varname> is a more
1037 powerful (and working) replacement for <varname>LimitRSS=</varname>.</para>
1038
1039 <para>Note that <varname>LimitNPROC=</varname> will limit the number of processes from one (real) UID and
1040 not the number of processes started (forked) by the service. Therefore the limit is cumulative for all
1041 processes running under the same UID. Please also note that the <varname>LimitNPROC=</varname> will not be
1042 enforced if the service is running as root (and not dropping privileges). Due to these limitations,
1043 <varname>TasksMax=</varname> (see <citerefentry><refentrytitle>systemd.resource-control</refentrytitle>
1044 <manvolnum>5</manvolnum></citerefentry>) is typically a better choice than <varname>LimitNPROC=</varname>.
1045 </para>
1046
1047 <para>Resource limits not configured explicitly for a unit default to the value configured in the various
1048 <varname>DefaultLimitCPU=</varname>, <varname>DefaultLimitFSIZE=</varname>, … options available in
1049 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, and –
1050 if not configured there – the kernel or per-user defaults, as defined by the OS (the latter only for user
1051 services, see below).</para>
1052
1053 <para>For system units these resource limits may be chosen freely. When these settings are configured
1054 in a user service (i.e. a service run by the per-user instance of the service manager) they cannot be
1055 used to raise the limits above those set for the user manager itself when it was first invoked, as
1056 the user's service manager generally lacks the privileges to do so. In user context these
1057 configuration options are hence only useful to lower the limits passed in or to raise the soft limit
1058 to the maximum of the hard limit as configured for the user. To raise the user's limits further, the
1059 available configuration mechanisms differ between operating systems, but typically require
1060 privileges. In most cases it is possible to configure higher per-user resource limits via PAM or by
1061 setting limits on the system service encapsulating the user's service manager, i.e. the user's
1062 instance of <filename>user@.service</filename>. After making such changes, make sure to restart the
1063 user's service manager.</para>
1064
1065 <table>
1066 <title>Resource limit directives, their equivalent <command>ulimit</command> shell commands and the unit used</title>
1067
1068 <tgroup cols='4'>
1069 <colspec colname='directive' />
1070 <colspec colname='equivalent' />
1071 <colspec colname='unit' />
1072 <colspec colname='notes' />
1073 <thead>
1074 <row>
1075 <entry>Directive</entry>
1076 <entry><command>ulimit</command> equivalent</entry>
1077 <entry>Unit</entry>
1078 <entry>Notes</entry>
1079 </row>
1080 </thead>
1081 <tbody>
1082 <row>
1083 <entry>LimitCPU=</entry>
1084 <entry>ulimit -t</entry>
1085 <entry>Seconds</entry>
1086 <entry>-</entry>
1087 </row>
1088 <row>
1089 <entry>LimitFSIZE=</entry>
1090 <entry>ulimit -f</entry>
1091 <entry>Bytes</entry>
1092 <entry>-</entry>
1093 </row>
1094 <row>
1095 <entry>LimitDATA=</entry>
1096 <entry>ulimit -d</entry>
1097 <entry>Bytes</entry>
1098 <entry>Do not use. This limits the allowed address range, not memory use! Defaults to unlimited and should not be lowered. To limit memory use, see <varname>MemoryMax=</varname> in <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</entry>
1099 </row>
1100 <row>
1101 <entry>LimitSTACK=</entry>
1102 <entry>ulimit -s</entry>
1103 <entry>Bytes</entry>
1104 <entry>-</entry>
1105 </row>
1106 <row>
1107 <entry>LimitCORE=</entry>
1108 <entry>ulimit -c</entry>
1109 <entry>Bytes</entry>
1110 <entry>-</entry>
1111 </row>
1112 <row>
1113 <entry>LimitRSS=</entry>
1114 <entry>ulimit -m</entry>
1115 <entry>Bytes</entry>
1116 <entry>Do not use. No effect on Linux.</entry>
1117 </row>
1118 <row>
1119 <entry>LimitNOFILE=</entry>
1120 <entry>ulimit -n</entry>
1121 <entry>Number of File Descriptors</entry>
1122 <entry>Do not use. Be careful when raising the soft limit above 1024, since <citerefentry project='man-pages'><refentrytitle>select</refentrytitle><manvolnum>2</manvolnum></citerefentry> cannot function with file descriptors above 1023 on Linux. Nowadays, the hard limit defaults to 524288, a very high value compared to historical defaults. Typically applications should increase their soft limit to the hard limit on their own, if they are OK with working with file descriptors above 1023, i.e. do not use <citerefentry project='man-pages'><refentrytitle>select</refentrytitle><manvolnum>2</manvolnum></citerefentry>. Note that file descriptors are nowadays accounted like any other form of memory, thus there should not be any need to lower the hard limit. Use <varname>MemoryMax=</varname> to control overall service memory use, including file descriptor memory.</entry>
1123 </row>
1124 <row>
1125 <entry>LimitAS=</entry>
1126 <entry>ulimit -v</entry>
1127 <entry>Bytes</entry>
1128 <entry>Do not use. This limits the allowed address range, not memory use! Defaults to unlimited and should not be lowered. To limit memory use, see <varname>MemoryMax=</varname> in <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</entry>
1129 </row>
1130 <row>
1131 <entry>LimitNPROC=</entry>
1132 <entry>ulimit -u</entry>
1133 <entry>Number of Processes</entry>
1134 <entry>This limit is enforced based on the number of processes belonging to the user. Typically it is better to track processes per service, i.e. use <varname>TasksMax=</varname>, see <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</entry>
1135 </row>
1136 <row>
1137 <entry>LimitMEMLOCK=</entry>
1138 <entry>ulimit -l</entry>
1139 <entry>Bytes</entry>
1140 <entry>-</entry>
1141 </row>
1142 <row>
1143 <entry>LimitLOCKS=</entry>
1144 <entry>ulimit -x</entry>
1145 <entry>Number of Locks</entry>
1146 <entry>-</entry>
1147 </row>
1148 <row>
1149 <entry>LimitSIGPENDING=</entry>
1150 <entry>ulimit -i</entry>
1151 <entry>Number of Queued Signals</entry>
1152 <entry>-</entry>
1153 </row>
1154 <row>
1155 <entry>LimitMSGQUEUE=</entry>
1156 <entry>ulimit -q</entry>
1157 <entry>Bytes</entry>
1158 <entry>-</entry>
1159 </row>
1160 <row>
1161 <entry>LimitNICE=</entry>
1162 <entry>ulimit -e</entry>
1163 <entry>Nice Level</entry>
1164 <entry>-</entry>
1165 </row>
1166 <row>
1167 <entry>LimitRTPRIO=</entry>
1168 <entry>ulimit -r</entry>
1169 <entry>Realtime Priority</entry>
1170 <entry>-</entry>
1171 </row>
1172 <row>
1173 <entry>LimitRTTIME=</entry>
1174 <entry>ulimit -R</entry>
1175 <entry>Microseconds</entry>
1176 <entry>-</entry>
1177 </row>
1178 </tbody>
1179 </tgroup>
1180 </table></listitem>
1181 </varlistentry>
1182
1183 <varlistentry>
1184 <term><varname>UMask=</varname></term>
1185
1186 <listitem><para>Controls the file mode creation mask. Takes an access mode in octal notation. See
1187 <citerefentry><refentrytitle>umask</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
1188 details. Defaults to 0022 for system units. For user units the default value is inherited from the
1189 per-user service manager (whose default is in turn inherited from the system service manager, and
1190 thus typically also is 0022 — unless overridden by a PAM module). In order to change the per-user mask
1191 for all user services, consider setting the <varname>UMask=</varname> setting of the user's
1192 <filename>user@.service</filename> system service instance. The per-user umask may also be set via
1193 the <varname>umask</varname> field of a user's <ulink url="https://systemd.io/USER_RECORD">JSON User
1194 Record</ulink> (for users managed by
1195 <citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
1196 this field may be controlled via <command>homectl --umask=</command>). It may also be set via a PAM
1197 module, such as <citerefentry
1198 project='man-pages'><refentrytitle>pam_umask</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para></listitem>
1199 </varlistentry>
1200
1201 <varlistentry>
1202 <term><varname>CoredumpFilter=</varname></term>
1203
1204 <listitem><para>Controls which types of memory mappings will be saved if the process dumps core
1205 (using the <filename>/proc/<replaceable>pid</replaceable>/coredump_filter</filename> file). Takes a
1206 whitespace-separated combination of mapping type names or numbers (with the default base 16). Mapping
1207 type names are <constant>private-anonymous</constant>, <constant>shared-anonymous</constant>,
1208 <constant>private-file-backed</constant>, <constant>shared-file-backed</constant>,
1209 <constant>elf-headers</constant>, <constant>private-huge</constant>,
1210 <constant>shared-huge</constant>, <constant>private-dax</constant>, <constant>shared-dax</constant>,
1211 and the special values <constant>all</constant> (all types) and <constant>default</constant> (the
1212 kernel default of <literal><constant>private-anonymous</constant>
1213 <constant>shared-anonymous</constant> <constant>elf-headers</constant>
1214 <constant>private-huge</constant></literal>). See
1215 <citerefentry project='man-pages'><refentrytitle>core</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1216 for the meaning of the mapping types. When specified multiple times, all specified masks are
1217 ORed. When not set, or if the empty value is assigned, the inherited value is not changed.</para>
1218
1219 <example>
1220 <title>Add DAX pages to the dump filter</title>
1221
1222 <programlisting>CoredumpFilter=default private-dax shared-dax</programlisting>
1223 </example>
1224
1225 <xi:include href="version-info.xml" xpointer="v246"/>
1226 </listitem>
1227 </varlistentry>
1228
1229 <varlistentry>
1230 <term><varname>KeyringMode=</varname></term>
1231
1232 <listitem><para>Controls how the kernel session keyring is set up for the service (see <citerefentry
1233 project='man-pages'><refentrytitle>session-keyring</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
1234 details on the session keyring). Takes one of <option>inherit</option>, <option>private</option>,
1235 <option>shared</option>. If set to <option>inherit</option> no special keyring setup is done, and the kernel's
1236 default behaviour is applied. If <option>private</option> is used a new session keyring is allocated when a
1237 service process is invoked, and it is not linked up with any user keyring. This is the recommended setting for
1238 system services, as this ensures that multiple services running under the same system user ID (in particular
1239 the root user) do not share their key material among each other. If <option>shared</option> is used a new
1240 session keyring is allocated as for <option>private</option>, but the user keyring of the user configured with
1241 <varname>User=</varname> is linked into it, so that keys assigned to the user may be requested by the unit's
1242 processes. In this mode multiple units running processes under the same user ID may share key material. Unless
1243 <option>inherit</option> is selected the unique invocation ID for the unit (see below) is added as a protected
1244 key by the name <literal>invocation_id</literal> to the newly created session keyring. Defaults to
1245 <option>private</option> for services of the system service manager and to <option>inherit</option> for
1246 non-service units and for services of the user service manager.</para>
1247
1248 <xi:include href="version-info.xml" xpointer="v235"/></listitem>
1249 </varlistentry>
1250
1251 <varlistentry>
1252 <term><varname>OOMScoreAdjust=</varname></term>
1253
1254 <listitem><para>Sets the adjustment value for the Linux kernel's Out-Of-Memory (OOM) killer score for
1255 executed processes. Takes an integer between -1000 (to disable OOM killing of processes of this unit)
1256 and 1000 (to make killing of processes of this unit under memory pressure very likely). See <ulink
1257 url="https://docs.kernel.org/filesystems/proc.html">The /proc Filesystem</ulink> for
1258 details. If not specified, defaults to the OOM score adjustment level of the service manager itself,
1259 which is normally at 0.</para>
1260
1261 <para>Use the <varname>OOMPolicy=</varname> setting of service units to configure how the service
1262 manager shall react to the kernel OOM killer or <command>systemd-oomd</command> terminating a process of the service. See
1263 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1264 for details.</para></listitem>
1265 </varlistentry>
1266
1267 <varlistentry>
1268 <term><varname>TimerSlackNSec=</varname></term>
1269 <listitem><para>Sets the timer slack in nanoseconds for the executed processes. The timer slack controls the
1270 accuracy of wake-ups triggered by timers. See
1271 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry> for more
1272 information. Note that in contrast to most other time span definitions this parameter takes an integer value in
1273 nano-seconds if no unit is specified. The usual time units are understood too.</para></listitem>
1274 </varlistentry>
1275
1276 <varlistentry>
1277 <term><varname>Personality=</varname></term>
1278
1279 <listitem><para>Controls which kernel architecture <citerefentry
1280 project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry> shall
1281 report, when invoked by unit processes. Takes one of the architecture identifiers
1282 <constant>arm64</constant>, <constant>arm64-be</constant>, <constant>arm</constant>,
1283 <constant>arm-be</constant>, <constant>x86</constant>, <constant>x86-64</constant>,
1284 <constant>ppc</constant>, <constant>ppc-le</constant>, <constant>ppc64</constant>,
1285 <constant>ppc64-le</constant>, <constant>s390</constant> or <constant>s390x</constant>. Which
1286 personality architectures are supported depends on the kernel's native architecture. Usually the
1287 64-bit versions of the various system architectures support their immediate 32-bit personality
1288 architecture counterpart, but no others. For example, <constant>x86-64</constant> systems support the
1289 <constant>x86-64</constant> and <constant>x86</constant> personalities but no others. The personality
1290 feature is useful when running 32-bit services on a 64-bit host system. If not specified, the
1291 personality is left unmodified and thus reflects the personality of the host system's kernel. This
1292 option is not useful on architectures for which only one native word width was ever available, such
1293 as <constant>m68k</constant> (32-bit only) or <constant>alpha</constant> (64-bit only).</para>
1294
1295 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
1296 </varlistentry>
1297
1298 <varlistentry>
1299 <term><varname>IgnoreSIGPIPE=</varname></term>
1300
1301 <listitem><para>Takes a boolean argument. If true, <constant>SIGPIPE</constant> is ignored in the
1302 executed process. Defaults to true since <constant>SIGPIPE</constant> is generally only useful in
1303 shell pipelines.</para></listitem>
1304 </varlistentry>
1305
1306 </variablelist>
1307 </refsect1>
1308
1309 <refsect1>
1310 <title>Scheduling</title>
1311
1312 <variablelist class='unit-directives'>
1313
1314 <varlistentry>
1315 <term><varname>Nice=</varname></term>
1316
1317 <listitem><para>Sets the default nice level (scheduling priority) for executed processes. Takes an
1318 integer between -20 (highest priority) and 19 (lowest priority). In case of resource contention,
1319 smaller values mean more resources will be made available to the unit's processes, larger values mean
1320 less resources will be made available. See
1321 <citerefentry><refentrytitle>setpriority</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
1322 details.</para></listitem>
1323 </varlistentry>
1324
1325 <varlistentry>
1326 <term><varname>CPUSchedulingPolicy=</varname></term>
1327
1328 <listitem><para>Sets the CPU scheduling policy for executed processes. Takes one of <option>other</option>,
1329 <option>batch</option>, <option>idle</option>, <option>fifo</option> or <option>rr</option>. See
1330 <citerefentry project='man-pages'><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
1331 details.</para></listitem>
1332 </varlistentry>
1333
1334 <varlistentry>
1335 <term><varname>CPUSchedulingPriority=</varname></term>
1336
1337 <listitem><para>Sets the CPU scheduling priority for executed processes. The available priority range
1338 depends on the selected CPU scheduling policy (see above). For real-time scheduling policies an
1339 integer between 1 (lowest priority) and 99 (highest priority) can be used. In case of CPU resource
1340 contention, smaller values mean less CPU time is made available to the service, larger values mean
1341 more. See <citerefentry
1342 project='man-pages'><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1343 for details. </para></listitem>
1344 </varlistentry>
1345
1346 <varlistentry>
1347 <term><varname>CPUSchedulingResetOnFork=</varname></term>
1348
1349 <listitem><para>Takes a boolean argument. If true, elevated CPU scheduling priorities and policies
1350 will be reset when the executed processes call
1351 <citerefentry project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1352 and can hence not leak into child processes. See
1353 <citerefentry project='man-pages'><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1354 for details. Defaults to false.</para></listitem>
1355 </varlistentry>
1356
1357 <varlistentry>
1358 <term><varname>CPUAffinity=</varname></term>
1359
1360 <listitem><para>Controls the CPU affinity of the executed processes. Takes a list of CPU indices or ranges
1361 separated by either whitespace or commas. Alternatively, takes a special "numa" value in which case systemd
1362 automatically derives allowed CPU range based on the value of <varname>NUMAMask=</varname> option. CPU ranges
1363 are specified by the lower and upper CPU indices separated by a dash. This option may be specified more than
1364 once, in which case the specified CPU affinity masks are merged. If the empty string is assigned, the mask
1365 is reset, all assignments prior to this will have no effect. See
1366 <citerefentry project='man-pages'><refentrytitle>sched_setaffinity</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
1367 details.</para></listitem>
1368 </varlistentry>
1369
1370 <varlistentry>
1371 <term><varname>NUMAPolicy=</varname></term>
1372
1373 <listitem><para>Controls the NUMA memory policy of the executed processes. Takes a policy type, one of:
1374 <option>default</option>, <option>preferred</option>, <option>bind</option>, <option>interleave</option> and
1375 <option>local</option>. A list of NUMA nodes that should be associated with the policy must be specified
1376 in <varname>NUMAMask=</varname>. For more details on each policy please see,
1377 <citerefentry><refentrytitle>set_mempolicy</refentrytitle><manvolnum>2</manvolnum></citerefentry>. For overall
1378 overview of NUMA support in Linux see,
1379 <citerefentry project='man-pages'><refentrytitle>numa</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
1380 </para>
1381
1382 <xi:include href="version-info.xml" xpointer="v243"/></listitem>
1383 </varlistentry>
1384
1385 <varlistentry>
1386 <term><varname>NUMAMask=</varname></term>
1387
1388 <listitem><para>Controls the NUMA node list which will be applied alongside with selected NUMA policy.
1389 Takes a list of NUMA nodes and has the same syntax as a list of CPUs for <varname>CPUAffinity=</varname>
1390 option or special "all" value which will include all available NUMA nodes in the mask. Note that the list
1391 of NUMA nodes is not required for <option>default</option> and <option>local</option>
1392 policies and for <option>preferred</option> policy we expect a single NUMA node.</para>
1393
1394 <xi:include href="version-info.xml" xpointer="v243"/></listitem>
1395 </varlistentry>
1396
1397 <varlistentry>
1398 <term><varname>IOSchedulingClass=</varname></term>
1399
1400 <listitem><para>Sets the I/O scheduling class for executed processes. Takes one of the strings
1401 <option>realtime</option>, <option>best-effort</option> or <option>idle</option>. The kernel's
1402 default scheduling class is <option>best-effort</option> at a priority of 4. If the empty string is
1403 assigned to this option, all prior assignments to both <varname>IOSchedulingClass=</varname> and
1404 <varname>IOSchedulingPriority=</varname> have no effect. See
1405 <citerefentry><refentrytitle>ioprio_set</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
1406 details.</para></listitem>
1407 </varlistentry>
1408
1409 <varlistentry>
1410 <term><varname>IOSchedulingPriority=</varname></term>
1411
1412 <listitem><para>Sets the I/O scheduling priority for executed processes. Takes an integer between 0
1413 (highest priority) and 7 (lowest priority). In case of I/O contention, smaller values mean more I/O
1414 bandwidth is made available to the unit's processes, larger values mean less bandwidth. The available
1415 priorities depend on the selected I/O scheduling class (see above). If the empty string is assigned
1416 to this option, all prior assignments to both <varname>IOSchedulingClass=</varname> and
1417 <varname>IOSchedulingPriority=</varname> have no effect. For the kernel's default scheduling class
1418 (<option>best-effort</option>) this defaults to 4. See
1419 <citerefentry><refentrytitle>ioprio_set</refentrytitle><manvolnum>2</manvolnum></citerefentry> for
1420 details.</para></listitem>
1421 </varlistentry>
1422
1423 </variablelist>
1424 </refsect1>
1425
1426 <refsect1>
1427 <title>Sandboxing</title>
1428
1429 <para>The following sandboxing options are an effective way to limit the exposure of the system towards the unit's
1430 processes. It is recommended to turn on as many of these options for each unit as is possible without negatively
1431 affecting the process' ability to operate. Note that many of these sandboxing features are gracefully turned off on
1432 systems where the underlying security mechanism is not available. For example, <varname>ProtectSystem=</varname>
1433 has no effect if the kernel is built without file system namespacing or if the service manager runs in a container
1434 manager that makes file system namespacing unavailable to its payload. Similarly,
1435 <varname>RestrictRealtime=</varname> has no effect on systems that lack support for SECCOMP system call filtering,
1436 or in containers where support for this is turned off.</para>
1437
1438 <para>Also note that some sandboxing functionality is generally not available in user services (i.e. services run
1439 by the per-user service manager). Specifically, the various settings requiring file system namespacing support
1440 (such as <varname>ProtectSystem=</varname>) are not available, as the underlying kernel functionality is only
1441 accessible to privileged processes. However, most namespacing settings, that will not work on their own in user
1442 services, will work when used in conjunction with <varname>PrivateUsers=</varname><option>true</option>.</para>
1443
1444 <para>Note that the various options that turn directories read-only (such as
1445 <varname>ProtectSystem=</varname>, <varname>ReadOnlyPaths=</varname>, …) do not affect the ability for
1446 programs to connect to and communicate with <constant>AF_UNIX</constant> sockets in these
1447 directories. These options cannot be used to lock down access to IPC services hence.</para>
1448
1449 <variablelist class='unit-directives'>
1450
1451 <varlistentry>
1452 <term><varname>ProtectSystem=</varname></term>
1453
1454 <listitem><para>Takes a boolean argument or the special values <literal>full</literal> or
1455 <literal>strict</literal>. If true, mounts the <filename>/usr/</filename> and the boot loader
1456 directories (<filename>/boot</filename> and <filename>/efi</filename>) read-only for processes
1457 invoked by this unit. If set to <literal>full</literal>, the <filename>/etc/</filename> directory is
1458 mounted read-only, too. If set to <literal>strict</literal> the entire file system hierarchy is
1459 mounted read-only, except for the API file system subtrees <filename>/dev/</filename>,
1460 <filename>/proc/</filename> and <filename>/sys/</filename> (protect these directories using
1461 <varname>PrivateDevices=</varname>, <varname>ProtectKernelTunables=</varname>,
1462 <varname>ProtectControlGroups=</varname>). This setting ensures that any modification of the
1463 vendor-supplied operating system (and optionally its configuration, and local mounts) is prohibited
1464 for the service. It is recommended to enable this setting for all long-running services, unless they
1465 are involved with system updates or need to modify the operating system in other ways. If this option
1466 is used, <varname>ReadWritePaths=</varname> may be used to exclude specific directories from being
1467 made read-only. Similar, <varname>StateDirectory=</varname>, <varname>LogsDirectory=</varname>, … and
1468 related directory settings (see below) also exclude the specific directories from the effect of
1469 <varname>ProtectSystem=</varname>. This setting is implied if <varname>DynamicUser=</varname> is
1470 set. This setting cannot ensure protection in all cases. In general it has the same limitations as
1471 <varname>ReadOnlyPaths=</varname>, see below. Defaults to off.</para>
1472
1473 <para>Note that if <varname>ProtectSystem=</varname> is set to <literal>strict</literal> and
1474 <varname>PrivateTmp=</varname> is enabled, then <filename>/tmp/</filename> and
1475 <filename>/var/tmp/</filename> will be writable.</para>
1476
1477 <xi:include href="version-info.xml" xpointer="v214"/></listitem>
1478 </varlistentry>
1479
1480 <varlistentry>
1481 <term><varname>ProtectHome=</varname></term>
1482
1483 <listitem><para>Takes a boolean argument or the special values <literal>read-only</literal> or
1484 <literal>tmpfs</literal>. If true, the directories <filename>/home/</filename>,
1485 <filename>/root</filename>, and <filename>/run/user</filename> are made inaccessible and empty for
1486 processes invoked by this unit. If set to <literal>read-only</literal>, the three directories are
1487 made read-only instead. If set to <literal>tmpfs</literal>, temporary file systems are mounted on the
1488 three directories in read-only mode. The value <literal>tmpfs</literal> is useful to hide home
1489 directories not relevant to the processes invoked by the unit, while still allowing necessary
1490 directories to be made visible when listed in <varname>BindPaths=</varname> or
1491 <varname>BindReadOnlyPaths=</varname>.</para>
1492
1493 <para>Setting this to <literal>yes</literal> is mostly equivalent to setting the three directories in
1494 <varname>InaccessiblePaths=</varname>. Similarly, <literal>read-only</literal> is mostly equivalent to
1495 <varname>ReadOnlyPaths=</varname>, and <literal>tmpfs</literal> is mostly equivalent to
1496 <varname>TemporaryFileSystem=</varname> with <literal>:ro</literal>.</para>
1497
1498 <para>It is recommended to enable this setting for all long-running services (in particular
1499 network-facing ones), to ensure they cannot get access to private user data, unless the services
1500 actually require access to the user's private data. This setting is implied if
1501 <varname>DynamicUser=</varname> is set. This setting cannot ensure protection in all cases. In
1502 general it has the same limitations as <varname>ReadOnlyPaths=</varname>, see below.</para>
1503
1504 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
1505
1506 <xi:include href="version-info.xml" xpointer="v214"/></listitem>
1507 </varlistentry>
1508
1509 <varlistentry>
1510 <term><varname>RuntimeDirectory=</varname></term>
1511 <term><varname>StateDirectory=</varname></term>
1512 <term><varname>CacheDirectory=</varname></term>
1513 <term><varname>LogsDirectory=</varname></term>
1514 <term><varname>ConfigurationDirectory=</varname></term>
1515
1516 <listitem><para>These options take a whitespace-separated list of directory names. The specified
1517 directory names must be relative, and may not include <literal>..</literal>. If set, when the unit is
1518 started, one or more directories by the specified names will be created (including their parents)
1519 below the locations defined in the following table. Also, the corresponding environment variable will
1520 be defined with the full paths of the directories. If multiple directories are set, then in the
1521 environment variable the paths are concatenated with colon (<literal>:</literal>).</para>
1522
1523 <para>If <varname>DynamicUser=</varname> is used, and if the kernel version supports
1524 <ulink url="https://lwn.net/Articles/896255/">id-mapped mounts</ulink>, the specified directories will
1525 be owned by "nobody" in the host namespace and will be mapped to (and will be owned by) the service's
1526 UID/GID in its own namespace. For backward compatibility, existing directories created without id-mapped
1527 mounts will be kept untouched.</para>
1528
1529 <table>
1530 <title>Automatic directory creation and environment variables</title>
1531 <tgroup cols='4'>
1532 <thead>
1533 <row>
1534 <entry>Directory</entry>
1535 <entry>Below path for system units</entry>
1536 <entry>Below path for user units</entry>
1537 <entry>Environment variable set</entry>
1538 </row>
1539 </thead>
1540 <tbody>
1541 <row>
1542 <entry><varname>RuntimeDirectory=</varname></entry>
1543 <entry><filename>/run/</filename></entry>
1544 <entry><varname>$XDG_RUNTIME_DIR</varname></entry>
1545 <entry><varname>$RUNTIME_DIRECTORY</varname></entry>
1546 </row>
1547 <row>
1548 <entry><varname>StateDirectory=</varname></entry>
1549 <entry><filename>/var/lib/</filename></entry>
1550 <entry><varname>$XDG_STATE_HOME</varname></entry>
1551 <entry><varname>$STATE_DIRECTORY</varname></entry>
1552 </row>
1553 <row>
1554 <entry><varname>CacheDirectory=</varname></entry>
1555 <entry><filename>/var/cache/</filename></entry>
1556 <entry><varname>$XDG_CACHE_HOME</varname></entry>
1557 <entry><varname>$CACHE_DIRECTORY</varname></entry>
1558 </row>
1559 <row>
1560 <entry><varname>LogsDirectory=</varname></entry>
1561 <entry><filename>/var/log/</filename></entry>
1562 <entry><varname>$XDG_STATE_HOME</varname><filename>/log/</filename></entry>
1563 <entry><varname>$LOGS_DIRECTORY</varname></entry>
1564 </row>
1565 <row>
1566 <entry><varname>ConfigurationDirectory=</varname></entry>
1567 <entry><filename>/etc/</filename></entry>
1568 <entry><varname>$XDG_CONFIG_HOME</varname></entry>
1569 <entry><varname>$CONFIGURATION_DIRECTORY</varname></entry>
1570 </row>
1571 </tbody>
1572 </tgroup>
1573 </table>
1574
1575 <para>In case of <varname>RuntimeDirectory=</varname> the innermost subdirectories are removed when
1576 the unit is stopped. It is possible to preserve the specified directories in this case if
1577 <varname>RuntimeDirectoryPreserve=</varname> is configured to <option>restart</option> or
1578 <option>yes</option> (see below). The directories specified with <varname>StateDirectory=</varname>,
1579 <varname>CacheDirectory=</varname>, <varname>LogsDirectory=</varname>,
1580 <varname>ConfigurationDirectory=</varname> are not removed when the unit is stopped.</para>
1581
1582 <para>Except in case of <varname>ConfigurationDirectory=</varname>, the innermost specified directories will be
1583 owned by the user and group specified in <varname>User=</varname> and <varname>Group=</varname>. If the
1584 specified directories already exist and their owning user or group do not match the configured ones, all files
1585 and directories below the specified directories as well as the directories themselves will have their file
1586 ownership recursively changed to match what is configured. As an optimization, if the specified directories are
1587 already owned by the right user and group, files and directories below of them are left as-is, even if they do
1588 not match what is requested. The innermost specified directories will have their access mode adjusted to the
1589 what is specified in <varname>RuntimeDirectoryMode=</varname>, <varname>StateDirectoryMode=</varname>,
1590 <varname>CacheDirectoryMode=</varname>, <varname>LogsDirectoryMode=</varname> and
1591 <varname>ConfigurationDirectoryMode=</varname>.</para>
1592
1593 <para>These options imply <varname>BindPaths=</varname> for the specified paths. When combined with
1594 <varname>RootDirectory=</varname> or <varname>RootImage=</varname> these paths always reside on the host and
1595 are mounted from there into the unit's file system namespace.</para>
1596
1597 <para>If <varname>DynamicUser=</varname> is used, the logic for <varname>CacheDirectory=</varname>,
1598 <varname>LogsDirectory=</varname> and <varname>StateDirectory=</varname> is slightly altered: the directories are created below
1599 <filename>/var/cache/private</filename>, <filename>/var/log/private</filename> and <filename>/var/lib/private</filename>,
1600 respectively, which are host directories made inaccessible to
1601 unprivileged users, which ensures that access to these directories cannot be gained through dynamic
1602 user ID recycling. Symbolic links are created to hide this difference in behaviour. Both from
1603 perspective of the host and from inside the unit, the relevant directories hence always appear
1604 directly below <filename>/var/cache</filename>, <filename>/var/log</filename> and
1605 <filename>/var/lib</filename>.</para>
1606
1607 <para>Use <varname>RuntimeDirectory=</varname> to manage one or more runtime directories for the unit and bind
1608 their lifetime to the daemon runtime. This is particularly useful for unprivileged daemons that cannot create
1609 runtime directories in <filename>/run/</filename> due to lack of privileges, and to make sure the runtime
1610 directory is cleaned up automatically after use. For runtime directories that require more complex or different
1611 configuration or lifetime guarantees, please consider using
1612 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
1613
1614 <para><varname>RuntimeDirectory=</varname>, <varname>StateDirectory=</varname>,
1615 <varname>CacheDirectory=</varname> and <varname>LogsDirectory=</varname> optionally support two
1616 more parameters, separated by <literal>:</literal>. The second parameter will be interpreted as a
1617 destination path that will be created as a symlink to the directory. The symlinks will be created
1618 after any <varname>BindPaths=</varname> or <varname>TemporaryFileSystem=</varname> options have been
1619 set up, to make ephemeral symlinking possible. The same source can have multiple symlinks, by using
1620 the same first parameter, but a different second parameter. The third parameter is a flags field,
1621 and since v257 can take a value of <constant>ro</constant> to make the directory read only for the
1622 service. This is also supported for <varname>ConfigurationDirectory=</varname>. If multiple symlinks
1623 are set up, the directory will be read only if at least one is configured to be read only. To pass a
1624 flag without a destination symlink, the second parameter can be empty, for example:
1625 <programlisting>ConfigurationDirectory=foo::ro</programlisting></para>
1626
1627 <para>The directories defined by these options are always created under the standard paths used by systemd
1628 (<filename>/var/</filename>, <filename>/run/</filename>, <filename>/etc/</filename>, …). If the service needs
1629 directories in a different location, a different mechanism has to be used to create them.</para>
1630
1631 <para><citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> provides
1632 functionality that overlaps with these options. Using these options is recommended, because the lifetime of
1633 the directories is tied directly to the lifetime of the unit, and it is not necessary to ensure that the
1634 <filename>tmpfiles.d</filename> configuration is executed before the unit is started.</para>
1635
1636 <para>To remove any of the directories created by these settings, use the <command>systemctl clean
1637 …</command> command on the relevant units, see
1638 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
1639 details.</para>
1640
1641 <para>Example: if a system service unit has the following,
1642 <programlisting>RuntimeDirectory=foo/bar baz</programlisting>
1643 the service manager creates <filename index='false'>/run/foo</filename> (if it does not exist),
1644
1645 <filename index='false'>/run/foo/bar</filename>, and <filename index='false'>/run/baz</filename>. The
1646 directories <filename index='false'>/run/foo/bar</filename> and
1647 <filename index='false'>/run/baz</filename> except <filename index='false'>/run/foo</filename> are
1648 owned by the user and group specified in <varname>User=</varname> and <varname>Group=</varname>, and removed
1649 when the service is stopped.</para>
1650
1651 <para>Example: if a system service unit has the following,
1652 <programlisting>RuntimeDirectory=foo/bar
1653StateDirectory=aaa/bbb ccc</programlisting>
1654 then the environment variable <literal>RUNTIME_DIRECTORY</literal> is set with <literal>/run/foo/bar</literal>, and
1655 <literal>STATE_DIRECTORY</literal> is set with <literal>/var/lib/aaa/bbb:/var/lib/ccc</literal>.</para>
1656
1657 <para>Example: if a system service unit has the following,
1658 <programlisting>RuntimeDirectory=foo:bar foo:baz</programlisting>
1659 the service manager creates <filename index='false'>/run/foo</filename> (if it does not exist), and
1660 <filename index='false'>/run/bar</filename> plus <filename index='false'>/run/baz</filename> as symlinks to
1661 <filename index='false'>/run/foo</filename>.</para>
1662
1663 <xi:include href="version-info.xml" xpointer="v211"/></listitem>
1664 </varlistentry>
1665
1666 <varlistentry>
1667 <term><varname>RuntimeDirectoryMode=</varname></term>
1668 <term><varname>StateDirectoryMode=</varname></term>
1669 <term><varname>CacheDirectoryMode=</varname></term>
1670 <term><varname>LogsDirectoryMode=</varname></term>
1671 <term><varname>ConfigurationDirectoryMode=</varname></term>
1672
1673 <listitem><para>Specifies the access mode of the directories specified in <varname>RuntimeDirectory=</varname>,
1674 <varname>StateDirectory=</varname>, <varname>CacheDirectory=</varname>, <varname>LogsDirectory=</varname>, or
1675 <varname>ConfigurationDirectory=</varname>, respectively, as an octal number. Defaults to
1676 <constant>0755</constant>. See "Permissions" in <citerefentry
1677 project='man-pages'><refentrytitle>path_resolution</refentrytitle><manvolnum>7</manvolnum></citerefentry> for a
1678 discussion of the meaning of permission bits.</para>
1679
1680 <xi:include href="version-info.xml" xpointer="v234"/></listitem>
1681 </varlistentry>
1682
1683 <varlistentry>
1684 <term><varname>StateDirectoryQuota=</varname></term>
1685 <term><varname>CacheDirectoryQuota=</varname></term>
1686 <term><varname>LogsDirectoryQuota=</varname></term>
1687
1688 <listitem><para>Specifies the storage limits for the directories specified in <varname>StateDirectory=</varname>,
1689 <varname>CacheDirectory=</varname>, or <varname>LogsDirectory=</varname> respectively.</para>
1690
1691 <para>The storage quota is defined in terms of disk blocks and inodes, as per
1692 <ulink url="https://man7.org/linux/man-pages/man2/quotactl.2.html">quotactl</ulink>. Takes an absolute size limit
1693 in bytes. If the value is suffixed with K, M, G or T, the specified size is parsed as Kilobytes, Megabytes, Gigabytes,
1694 or Terabytes (with the base 1024), respectively. If an absolute size limit is specified, only the block quota is set
1695 (rounded up to the nearest block). Alternatively, a percentage value may be specified, which applies the same percent
1696 quota to both blocks and inodes. Defaults to <constant>off</constant>, in which case no storage limits will be set.</para>
1697
1698 <para>Only hard limits are set, not soft limits. If the underlying filesystem for the specified directories does not
1699 support project quotas, the specified storage limits will not be set. In addition to enabling per-unit quotas with
1700 these settings, it is necessary to enable <constant>prjquota</constant> on the file system level as well
1701 (i.e. <command>tune2fs -Q prjquota</command>). Quotas must also be turned on with
1702 <ulink url="https://linux.die.net/man/8/quotaon">quotaon.</ulink></para>
1703
1704 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
1705 </varlistentry>
1706
1707 <varlistentry>
1708 <term><varname>StateDirectoryAccounting=</varname></term>
1709 <term><varname>CacheDirectoryAccounting=</varname></term>
1710 <term><varname>LogsDirectoryAccounting=</varname></term>
1711
1712 <listitem><para>Takes a boolean argument. If true, a project ID is assigned to the directories specified in
1713 <varname>StateDirectory=</varname>, <varname>CacheDirectory=</varname>, or <varname>LogsDirectory=</varname>
1714 respectively, which is used for tracking disk usage when disk quotas are turned on
1715 (see <ulink url="https://man7.org/linux/man-pages/man8/repquota.8.html">repquota</ulink>). Defaults to false.</para>
1716
1717 <para>To set and enforce disk quotas, <varname>StateDirectoryQuota=</varname>, <varname>CacheDirectoryQuota=</varname>,
1718 or <varname>LogsDirectoryQuota=</varname> must be specified.</para>
1719
1720 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
1721 </varlistentry>
1722
1723 <varlistentry>
1724 <term><varname>RuntimeDirectoryPreserve=</varname></term>
1725
1726 <listitem><para>Takes a boolean argument or <option>restart</option>. If set to <option>no</option> (the
1727 default), the directories specified in <varname>RuntimeDirectory=</varname> are always removed when the service
1728 stops. If set to <option>restart</option> the directories are preserved when the service is both automatically
1729 and manually restarted. Here, the automatic restart means the operation specified in
1730 <varname>Restart=</varname>, and manual restart means the one triggered by <command>systemctl restart
1731 foo.service</command>. If set to <option>yes</option>, then the directories are not removed when the service is
1732 stopped. Note that since the runtime directory <filename>/run/</filename> is a mount point of
1733 <literal>tmpfs</literal>, then for system services the directories specified in
1734 <varname>RuntimeDirectory=</varname> are removed when the system is rebooted.</para>
1735
1736 <xi:include href="version-info.xml" xpointer="v235"/></listitem>
1737 </varlistentry>
1738
1739 <varlistentry>
1740 <term><varname>TimeoutCleanSec=</varname></term>
1741 <listitem><para>Configures a timeout on the clean-up operation requested through <command>systemctl
1742 clean …</command>, see
1743 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
1744 details. Takes the usual time values and defaults to <constant>infinity</constant>, i.e. by default
1745 no timeout is applied. If a timeout is configured the clean operation will be aborted forcibly when
1746 the timeout is reached, potentially leaving resources on disk.</para>
1747
1748 <xi:include href="version-info.xml" xpointer="v244"/></listitem>
1749 </varlistentry>
1750
1751 <varlistentry>
1752 <term><varname>ReadWritePaths=</varname></term>
1753 <term><varname>ReadOnlyPaths=</varname></term>
1754 <term><varname>InaccessiblePaths=</varname></term>
1755 <term><varname>ExecPaths=</varname></term>
1756 <term><varname>NoExecPaths=</varname></term>
1757
1758 <listitem><para>Sets up a new file system namespace for executed processes. These options may be used
1759 to limit access a process has to the file system. Each setting takes a space-separated list of paths
1760 relative to the host's root directory (i.e. the system running the service manager). Note that if
1761 paths contain symlinks, they are resolved relative to the root directory set with
1762 <varname>RootDirectory=</varname>/<varname>RootImage=</varname>.</para>
1763
1764 <para>Paths listed in <varname>ReadWritePaths=</varname> are accessible from within the namespace
1765 with the same access modes as from outside of it. Paths listed in <varname>ReadOnlyPaths=</varname>
1766 are accessible for reading only, writing will be refused even if the usual file access controls would
1767 permit this. Nest <varname>ReadWritePaths=</varname> inside of <varname>ReadOnlyPaths=</varname> in
1768 order to provide writable subdirectories within read-only directories. Use
1769 <varname>ReadWritePaths=</varname> in order to allow-list specific paths for write access if
1770 <varname>ProtectSystem=strict</varname> is used. Note that <varname>ReadWritePaths=</varname> cannot
1771 be used to gain write access to a file system whose superblock is mounted read-only. On Linux, for
1772 each mount point write access is granted only if the mount point itself <emphasis>and</emphasis> the
1773 file system superblock backing it are not marked read-only. <varname>ReadWritePaths=</varname> only
1774 controls the former, not the latter, hence a read-only file system superblock remains
1775 protected.</para>
1776
1777 <para>Paths listed in <varname>InaccessiblePaths=</varname> will be made inaccessible for processes inside
1778 the namespace along with everything below them in the file system hierarchy. This may be more restrictive than
1779 desired, because it is not possible to nest <varname>ReadWritePaths=</varname>, <varname>ReadOnlyPaths=</varname>,
1780 <varname>BindPaths=</varname>, or <varname>BindReadOnlyPaths=</varname> inside it. For a more flexible option,
1781 see <varname>TemporaryFileSystem=</varname>.</para>
1782
1783 <para>Content in paths listed in <varname>NoExecPaths=</varname> are not executable even if the usual
1784 file access controls would permit this. Nest <varname>ExecPaths=</varname> inside of
1785 <varname>NoExecPaths=</varname> in order to provide executable content within non-executable
1786 directories.</para>
1787
1788 <para>Non-directory paths may be specified as well. These options may be specified more than once,
1789 in which case all paths listed will have limited access from within the namespace. If the empty string is
1790 assigned to this option, the specific list is reset, and all prior assignments have no effect.</para>
1791
1792 <para>Paths in <varname>ReadWritePaths=</varname>, <varname>ReadOnlyPaths=</varname>,
1793 <varname>InaccessiblePaths=</varname>, <varname>ExecPaths=</varname> and
1794 <varname>NoExecPaths=</varname> may be prefixed with <literal>-</literal>, in which case they will be
1795 ignored when they do not exist. If prefixed with <literal>+</literal> the paths are taken relative to the root
1796 directory of the unit, as configured with <varname>RootDirectory=</varname>/<varname>RootImage=</varname>,
1797 instead of relative to the root directory of the host (see above). When combining <literal>-</literal> and
1798 <literal>+</literal> on the same path make sure to specify <literal>-</literal> first, and <literal>+</literal>
1799 second.</para>
1800
1801 <para>Note that these settings will disconnect propagation of mounts from the unit's processes to the
1802 host. This means that this setting may not be used for services which shall be able to install mount points in
1803 the main mount namespace. For <varname>ReadWritePaths=</varname> and <varname>ReadOnlyPaths=</varname>,
1804 propagation in the other direction is not affected, i.e. mounts created on the host generally appear in the
1805 unit processes' namespace, and mounts removed on the host also disappear there too. In particular, note that
1806 mount propagation from host to unit will result in unmodified mounts to be created in the unit's namespace,
1807 i.e. writable mounts appearing on the host will be writable in the unit's namespace too, even when propagated
1808 below a path marked with <varname>ReadOnlyPaths=</varname>! Restricting access with these options hence does
1809 not extend to submounts of a directory that are created later on. This means the lock-down offered by that
1810 setting is not complete, and does not offer full protection.</para>
1811
1812 <para>Note that the effect of these settings may be undone by privileged processes. In order to set up an
1813 effective sandboxed environment for a unit it is thus recommended to combine these settings with either
1814 <varname>CapabilityBoundingSet=~CAP_SYS_ADMIN</varname> or <varname>SystemCallFilter=~@mount</varname>.</para>
1815
1816 <para>Please be extra careful when applying these options to API file systems (a list of them could be
1817 found in <varname>MountAPIVPS=</varname>), since they may be required for basic system functionalities.
1818 Moreover, <filename>/run/</filename> needs to be writable for setting up mount namespace and propagation.</para>
1819
1820 <para>Simple allow-list example using these directives:
1821 <programlisting>[Service]
1822ReadOnlyPaths=/
1823ReadWritePaths=/var /run
1824InaccessiblePaths=-/lost+found
1825NoExecPaths=/
1826ExecPaths=/usr/sbin/my_daemon /usr/lib /usr/lib64
1827</programlisting></para>
1828
1829 <xi:include href="system-or-user-ns.xml" xpointer="plural"/>
1830
1831 <xi:include href="version-info.xml" xpointer="v231"/></listitem>
1832 </varlistentry>
1833
1834 <varlistentry>
1835 <term><varname>TemporaryFileSystem=</varname></term>
1836
1837 <listitem><para>Takes a space-separated list of mount points for temporary file systems (tmpfs). If set, a new file
1838 system namespace is set up for executed processes, and a temporary file system is mounted on each mount point.
1839 This option may be specified more than once, in which case temporary file systems are mounted on all listed mount
1840 points. If the empty string is assigned to this option, the list is reset, and all prior assignments have no effect.
1841 Each mount point may optionally be suffixed with a colon (<literal>:</literal>) and mount options such as
1842 <literal>size=10%</literal> or <literal>ro</literal>. By default, each temporary file system is mounted
1843 with <literal>nodev,strictatime,mode=0755</literal>. These can be disabled by explicitly specifying the corresponding
1844 mount options, e.g., <literal>dev</literal> or <literal>nostrictatime</literal>.</para>
1845
1846 <para>This is useful to hide files or directories not relevant to the processes invoked by the unit, while necessary
1847 files or directories can be still accessed by combining with <varname>BindPaths=</varname> or
1848 <varname>BindReadOnlyPaths=</varname>:</para>
1849
1850 <para>Example: if a unit has the following,
1851 <programlisting>TemporaryFileSystem=/var:ro
1852BindReadOnlyPaths=/var/lib/systemd</programlisting>
1853 then the invoked processes by the unit cannot see any files or directories under <filename>/var/</filename> except for
1854 <filename>/var/lib/systemd</filename> or its contents.</para>
1855
1856 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
1857
1858 <xi:include href="version-info.xml" xpointer="v238"/></listitem>
1859 </varlistentry>
1860
1861 <varlistentry>
1862 <term><varname>PrivateTmp=</varname></term>
1863
1864 <listitem><para>Takes a boolean argument, or <literal>disconnected</literal>. If enabled, a new
1865 file system namespace will be set up for the executed processes, and <filename>/tmp/</filename>
1866 and <filename>/var/tmp/</filename> directories inside it are not shared with processes outside of
1867 the namespace, plus all temporary files created by a service in these directories will be removed
1868 after the service is stopped. For this setting, the same restrictions regarding mount propagation
1869 and privileges apply as for <varname>ReadOnlyPaths=</varname> and related calls, see above. This
1870 setting is useful to secure access to temporary files of the process, but makes sharing between
1871 processes via <filename>/tmp/</filename> or <filename>/var/tmp/</filename> impossible. If
1872 <varname>DynamicUser=</varname> is enabled, <literal>disconnected</literal> is implied. Otherwise,
1873 defaults to false.</para>
1874
1875 <para>If <literal>true</literal>, the backing storage of the private temporary directories will
1876 remain on the host's <filename>/tmp/</filename> and <filename>/var/tmp/</filename> directories. It is
1877 possible to run two or more units within the same private <filename>/tmp/</filename> and
1878 <filename>/var/tmp/</filename> namespace by using the <varname>JoinsNamespaceOf=</varname> directive,
1879 see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1880 for details. This has the side effect of adding <varname>Wants=</varname> and
1881 <varname>After=</varname> dependencies on all mount units necessary to access
1882 <filename>/tmp/</filename> and <filename>/var/tmp/</filename> on the host. Moreover, an implicit
1883 <varname>After=</varname> ordering on
1884 <citerefentry><refentrytitle>systemd-tmpfiles-setup.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
1885 is added.</para>
1886
1887 <para>If <literal>disconnected</literal>, the directories will be backed by a completely new tmpfs
1888 instance, meaning that the storage is fully disconnected from the host namespace. The tmpfs instance
1889 does not shared with other units even if the <varname>JoinsNamespaceOf=</varname> directive is used.
1890 If <varname>DefaultDependencies=no</varname> is specified,
1891 <varname>RequiresMountsFor=/WantsMountsFor=</varname> for <filename>/var/</filename> is not
1892 specified, and <varname>RootDirectory=/RootImage=</varname> is not specified, then a new tmpfs is
1893 mounted <emphasis>only</emphasis> on <filename>/tmp/</filename>, hence the host's
1894 <filename>/var/tmp</filename> is still accessible from the unit. In that case,
1895 <varname>$TMPDIR</varname> environment variable is set to <literal>/tmp</literal> to suggest the
1896 processes in the unit to use <filename>/tmp/</filename>. This automatically adds
1897 <varname>WantsMountsFor=/var/</varname> dependency, unless <varname>DefaultDependencies=no</varname>
1898 and/or <varname>RootDirectory=/RootImage=</varname> are specified.</para>
1899
1900 <table>
1901 <title>Summary for <varname>PrivateTmp=disconnected</varname></title>
1902 <tgroup cols='4' align='left' colsep='1' rowsep='1'>
1903 <colspec colname="other settings" />
1904 <colspec colname="tmpfs instance on /var/tmp/" />
1905 <colspec colname="$TMPVAR" />
1906 <colspec colname="implied dependencies" />
1907 <thead>
1908 <row>
1909 <entry>Other Settings</entry>
1910 <entry>tmpfs on /var/tmp/</entry>
1911 <entry>$TMPVAR</entry>
1912 <entry>implied dependencies</entry>
1913 </row>
1914 </thead>
1915 <tbody>
1916 <row>
1917 <entry>(none)</entry>
1918 <entry>yes</entry>
1919 <entry>(unset)</entry>
1920 <entry><varname>WantsMountsFor=/var/</varname></entry>
1921 </row>
1922 <row>
1923 <entry><varname>RootDirectory=/RootImage=</varname></entry>
1924 <entry>yes</entry>
1925 <entry>(unset)</entry>
1926 <entry>(none)</entry>
1927 </row>
1928 <row>
1929 <entry><varname>DefaultDependency=no</varname>, <varname>RequiresMountsFor=/var/</varname></entry>
1930 <entry>yes</entry>
1931 <entry>(unset)</entry>
1932 <entry>(none)</entry>
1933 </row>
1934 <row>
1935 <entry><varname>DefaultDependency=no</varname>, <varname>WantsMountsFor=/var/</varname></entry>
1936 <entry>yes</entry>
1937 <entry>(unset)</entry>
1938 <entry>(none)</entry>
1939 </row>
1940 <row>
1941 <entry><varname>DefaultDependency=no</varname></entry>
1942 <entry>no</entry>
1943 <entry><varname>$TMPDIR=/tmp</varname></entry>
1944 <entry>(none)</entry>
1945 </row>
1946 </tbody>
1947 </tgroup>
1948 </table>
1949
1950 <para>Note that the implementation of this setting might be impossible (for example if mount namespaces are not
1951 available), and the unit should be written in a way that does not solely rely on this setting for
1952 security.</para>
1953
1954 <xi:include href="system-or-user-ns.xml" xpointer="singular"/></listitem>
1955 </varlistentry>
1956
1957 <varlistentry>
1958 <term><varname>PrivateDevices=</varname></term>
1959
1960 <listitem><para>Takes a boolean argument. If true, sets up a new <filename>/dev/</filename> mount for
1961 the executed processes and only adds API pseudo devices such as <filename>/dev/null</filename>,
1962 <filename>/dev/zero</filename> or <filename>/dev/random</filename> (as well as the pseudo TTY
1963 subsystem) to it, but no physical devices such as <filename>/dev/sda</filename>, system memory
1964 <filename>/dev/mem</filename>, system ports <filename>/dev/port</filename> and others. This is useful
1965 to turn off physical device access by the executed process. Defaults to false.</para>
1966
1967 <para>Enabling this option will install a system call filter to block low-level I/O system calls that
1968 are grouped in the <varname>@raw-io</varname> set, remove <constant>CAP_MKNOD</constant> and
1969 <constant>CAP_SYS_RAWIO</constant> from the capability bounding set for the unit, and set
1970 <varname>DevicePolicy=closed</varname> (see
1971 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1972 for details). Note that using this setting will disconnect propagation of mounts from the service to
1973 the host (propagation in the opposite direction continues to work). This means that this setting may
1974 not be used for services which shall be able to install mount points in the main mount namespace. The
1975 new <filename>/dev/</filename> will be mounted read-only and 'noexec'. The latter may break old
1976 programs which try to set up executable memory by using
1977 <citerefentry><refentrytitle>mmap</refentrytitle><manvolnum>2</manvolnum></citerefentry> of
1978 <filename>/dev/zero</filename> instead of using <constant>MAP_ANON</constant>. For this setting the
1979 same restrictions regarding mount propagation and privileges apply as for
1980 <varname>ReadOnlyPaths=</varname> and related calls, see above.</para>
1981
1982 <para>Note that the implementation of this setting might be impossible (for example if mount
1983 namespaces are not available), and the unit should be written in a way that does not solely rely on
1984 this setting for security.</para>
1985
1986 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
1987
1988 <para>When access to some but not all devices must be possible, the <varname>DeviceAllow=</varname>
1989 setting might be used instead. See
1990 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1991 </para>
1992
1993 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
1994 </varlistentry>
1995
1996 <varlistentry>
1997 <term><varname>PrivateNetwork=</varname></term>
1998
1999 <listitem><para>Takes a boolean argument. If true, sets up a new network namespace for the executed processes
2000 and configures only the loopback network device <literal>lo</literal> inside it. No other network devices will
2001 be available to the executed process. This is useful to turn off network access by the executed process.
2002 Defaults to false. It is possible to run two or more units within the same private network namespace by using
2003 the <varname>JoinsNamespaceOf=</varname> directive, see
2004 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
2005 details. Note that this option will disconnect all socket families from the host, including
2006 <constant>AF_NETLINK</constant> and <constant>AF_UNIX</constant>. Effectively, for
2007 <constant>AF_NETLINK</constant> this means that device configuration events received from
2008 <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> are
2009 not delivered to the unit's processes. And for <constant>AF_UNIX</constant> this has the effect that
2010 <constant>AF_UNIX</constant> sockets in the abstract socket namespace of the host will become unavailable to
2011 the unit's processes (however, those located in the file system will continue to be accessible).</para>
2012
2013 <para>Note that the implementation of this setting might be impossible (for example if network namespaces are
2014 not available), and the unit should be written in a way that does not solely rely on this setting for
2015 security.</para>
2016
2017 <para>When this option is enabled, <varname>PrivateMounts=</varname> is implied unless it is
2018 explicitly disabled, and <filename>/sys</filename> will be remounted to associate it with the new
2019 network namespace.</para>
2020
2021 <para>When this option is used on a socket unit any sockets bound on behalf of this unit will be
2022 bound within a private network namespace. This may be combined with
2023 <varname>JoinsNamespaceOf=</varname> to listen on sockets inside of network namespaces of other
2024 services.</para>
2025
2026 <xi:include href="system-or-user-ns.xml" xpointer="singular"/></listitem>
2027 </varlistentry>
2028
2029 <varlistentry>
2030 <term><varname>UserNamespacePath=</varname></term>
2031
2032 <listitem><para>Takes an absolute file system path referring to a Linux user namespace
2033 pseudo-file (i.e. a file like <filename>/proc/$PID/ns/user</filename> or a bind mount or symlink to
2034 one). When set the invoked processes are added to the user namespace referenced by that path. The
2035 path has to point to a valid namespace file at the moment the processes are forked off. If this
2036 option is used <varname>PrivateUsers=</varname> has no effect.</para>
2037
2038 <para>This option is only available for system services.</para>
2039
2040 <xi:include href="version-info.xml" xpointer="v259"/></listitem>
2041 </varlistentry>
2042
2043 <varlistentry>
2044 <term><varname>NetworkNamespacePath=</varname></term>
2045
2046 <listitem><para>Takes an absolute file system path referring to a Linux network namespace
2047 pseudo-file (i.e. a file like <filename>/proc/$PID/ns/net</filename> or a bind mount or symlink to
2048 one). When set the invoked processes are added to the network namespace referenced by that path. The
2049 path has to point to a valid namespace file at the moment the processes are forked off. If this
2050 option is used <varname>PrivateNetwork=</varname> has no effect. If this option is used together with
2051 <varname>JoinsNamespaceOf=</varname> then it only has an effect if this unit is started before any of
2052 the listed units that have <varname>PrivateNetwork=</varname> or
2053 <varname>NetworkNamespacePath=</varname> configured, as otherwise the network namespace of those
2054 units is reused.</para>
2055
2056 <para>When this option is enabled, <varname>PrivateMounts=</varname> is implied unless it is
2057 explicitly disabled, and <filename>/sys</filename> will be remounted to associate it with the new
2058 network namespace.</para>
2059
2060 <para>When this option is used on a socket unit any sockets bound on behalf of this unit will be
2061 bound within the specified network namespace.</para>
2062
2063 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2064
2065 <xi:include href="version-info.xml" xpointer="v242"/></listitem>
2066 </varlistentry>
2067
2068 <varlistentry>
2069 <term><varname>PrivateIPC=</varname></term>
2070
2071 <listitem><para>Takes a boolean argument. If true, sets up a new IPC namespace for the executed processes.
2072 Each IPC namespace has its own set of System V IPC identifiers and its own POSIX message queue file system.
2073 This is useful to avoid name clash of IPC identifiers. Defaults to false. It is possible to run two or
2074 more units within the same private IPC namespace by using the <varname>JoinsNamespaceOf=</varname> directive,
2075 see <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
2076 details.</para>
2077
2078 <para>Note that IPC namespacing does not have an effect on
2079 <constant>AF_UNIX</constant> sockets, which are the most common
2080 form of IPC used on Linux. Instead, <constant>AF_UNIX</constant>
2081 sockets in the file system are subject to mount namespacing, and
2082 those in the abstract namespace are subject to network namespacing.
2083 IPC namespacing only has an effect on SysV IPC (which is mostly
2084 legacy) as well as POSIX message queues (for which
2085 <constant>AF_UNIX</constant>/<constant>SOCK_SEQPACKET</constant>
2086 sockets are typically a better replacement). IPC namespacing also
2087 has no effect on POSIX shared memory (which is subject to mount
2088 namespacing) either. See
2089 <citerefentry project='man-pages'><refentrytitle>ipc_namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
2090 the details.</para>
2091
2092 <para>Note that the implementation of this setting might be impossible (for example if IPC namespaces are
2093 not available), and the unit should be written in a way that does not solely rely on this setting for
2094 security.</para>
2095
2096 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2097
2098 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
2099 </varlistentry>
2100
2101 <varlistentry>
2102 <term><varname>IPCNamespacePath=</varname></term>
2103
2104 <listitem><para>Takes an absolute file system path referring to a Linux IPC namespace
2105 pseudo-file (i.e. a file like <filename>/proc/$PID/ns/ipc</filename> or a bind mount or symlink to
2106 one). When set the invoked processes are added to the network namespace referenced by that path. The
2107 path has to point to a valid namespace file at the moment the processes are forked off. If this
2108 option is used <varname>PrivateIPC=</varname> has no effect. If this option is used together with
2109 <varname>JoinsNamespaceOf=</varname> then it only has an effect if this unit is started before any of
2110 the listed units that have <varname>PrivateIPC=</varname> or
2111 <varname>IPCNamespacePath=</varname> configured, as otherwise the network namespace of those
2112 units is reused.</para>
2113
2114 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2115
2116 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
2117 </varlistentry>
2118
2119 <varlistentry>
2120 <term><varname>MemoryKSM=</varname></term>
2121
2122 <listitem><para>Takes a boolean argument. When set, it enables KSM (kernel samepage merging) for
2123 the processes. KSM is a memory-saving de-duplication feature. Anonymous memory pages with identical
2124 content can be replaced by a single write-protected page. This feature should only be enabled for
2125 jobs that share the same security domain. For details, see
2126 <ulink url="https://docs.kernel.org/admin-guide/mm/ksm.html">Kernel Samepage Merging</ulink> in the
2127 kernel documentation.</para>
2128
2129 <para>Note that this functionality might not be available, for example if KSM is disabled in the
2130 kernel, or the kernel does not support controlling KSM at the process level through
2131 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>.</para>
2132
2133 <xi:include href="version-info.xml" xpointer="v254"/>
2134 </listitem>
2135 </varlistentry>
2136
2137 <varlistentry>
2138 <term><varname>PrivatePIDs=</varname></term>
2139
2140 <listitem><para>Takes a boolean argument. Defaults to false. If enabled, sets up a new PID namespace
2141 for the executed processes. Each executed process is now PID 1 - the init process - in the new namespace.
2142 <filename>/proc/</filename> is mounted such that only processes in the PID namespace are visible.
2143 If <varname>PrivatePIDs=</varname> is set, <varname>MountAPIVFS=yes</varname> is implied.</para>
2144
2145 <para><varname>PrivatePIDs=</varname> is only supported for service units. This setting is not supported
2146 with <varname>Type=forking</varname> since the kernel will kill all processes in the PID namespace if
2147 the init process terminates.</para>
2148
2149 <para>This setting will be ignored if the kernel does not support PID namespaces.</para>
2150
2151 <para>Note unprivileged user services (i.e. a service run by the per-user instance of the service manager)
2152 will fail with <varname>PrivatePIDs=yes</varname> if <filename>/proc/</filename> is masked
2153 (i.e. <filename>/proc/kmsg</filename> is over-mounted with <constant>tmpfs</constant> like
2154 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> does).
2155 This is due to a kernel restriction not allowing unprivileged user namespaces to mount a less restrictive
2156 instance of <filename>/proc/</filename>.</para>
2157
2158 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
2159 </varlistentry>
2160
2161 <varlistentry>
2162 <term><varname>PrivateUsers=</varname></term>
2163
2164 <listitem><para>Takes a boolean argument or one of <literal>self</literal>, <literal>identity</literal>,
2165 or <literal>full</literal>. Defaults to false. If enabled, sets up a new user namespace for the
2166 executed processes and configures a user and group mapping. If set to a true value or
2167 <literal>self</literal>, a minimal user and group mapping is configured that maps the
2168 <literal>root</literal> user and group as well as the unit's own user and group to themselves and
2169 everything else to the <literal>nobody</literal> user and group. This is useful to securely detach
2170 the user and group databases used by the unit from the rest of the system, and thus to create an
2171 effective sandbox environment. All files, directories, processes, IPC objects and other resources
2172 owned by users/groups not equaling <literal>root</literal> or the unit's own will stay visible from
2173 within the unit but appear owned by the <literal>nobody</literal> user and group. </para>
2174
2175 <para>If the parameter is <literal>identity</literal>, user namespacing is set up with an identity
2176 mapping for the first 65536 UIDs/GIDs. Any UIDs/GIDs above 65536 will be mapped to the
2177 <literal>nobody</literal> user and group, respectively. While this does not provide UID/GID isolation,
2178 since all UIDs/GIDs are chosen identically it does provide process capability isolation, and hence is
2179 often a good choice if proper user namespacing with distinct UID maps is not appropriate.</para>
2180
2181 <para>If the parameter is <literal>full</literal>, user namespacing is set up with an identity
2182 mapping for all UIDs/GIDs. In addition, for system services, <literal>full</literal> allows the unit
2183 to call <function>setgroups()</function> system calls (by setting
2184 <filename>/proc/<replaceable>pid</replaceable>/setgroups</filename> to <literal>allow</literal>).
2185 Similar to <literal>identity</literal>, this does not provide UID/GID isolation, but it does provide
2186 process capability isolation.</para>
2187
2188 <para>If this mode is enabled, all unit processes are run without privileges in the host user
2189 namespace (regardless of whether the unit's own user/group is <literal>root</literal> or not). Specifically
2190 this means that the process will have zero process capabilities on the host's user namespace, but
2191 full capabilities within the service's user namespace. Settings such as
2192 <varname>CapabilityBoundingSet=</varname> will affect only the latter, and there's no way to acquire
2193 additional capabilities in the host's user namespace.</para>
2194
2195 <para>When this setting is set up by a per-user instance of the service manager, the mapping of the
2196 <literal>root</literal> user and group to itself is omitted (unless the user manager is root).
2197 Additionally, in the per-user instance manager case, the
2198 user namespace will be set up before most other namespaces. This means that combining
2199 <varname>PrivateUsers=</varname><option>true</option> with other namespaces will enable use of features not
2200 normally supported by the per-user instances of the service manager.</para>
2201
2202 <para>This setting is particularly useful in conjunction with
2203 <varname>RootDirectory=</varname>/<varname>RootImage=</varname>, as the need to synchronize the user and group
2204 databases in the root directory and on the host is reduced, as the only users and groups who need to be matched
2205 are <literal>root</literal>, <literal>nobody</literal> and the unit's own user and group.</para>
2206
2207 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
2208 </varlistentry>
2209
2210 <varlistentry>
2211 <term><varname>ProtectHostname=</varname></term>
2212
2213 <listitem><para>Takes a boolean argument or <literal>private</literal>. If enabled, sets up a new UTS
2214 namespace for the executed processes. If enabled, a hostname can be optionally specified following a
2215 colon (e.g. <literal>yes:foo</literal> or <literal>private:host.example.com</literal>), and the
2216 hostname is set in the new UTS namespace for the unit. If set to a true value, changing hostname or
2217 domainname via <function>sethostname()</function> and <function>setdomainname()</function> system
2218 calls is prevented. If set to <literal>private</literal>, changing hostname or domainname is allowed
2219 but only affects the unit's UTS namespace. Defaults to off.</para>
2220
2221 <para>Note that the implementation of this setting might be impossible (for example if UTS namespaces
2222 are not available), and the unit should be written in a way that does not solely rely on this setting
2223 for security.</para>
2224
2225 <para>Note that when this option is enabled for a service hostname changes no longer propagate from
2226 the system into the service, it is hence not suitable for services that need to take notice of system
2227 hostname changes dynamically.</para>
2228
2229 <para>Note that this option does not prevent changing system hostname via <command>hostnamectl</command>.
2230 However, <varname>User=</varname> and <varname>Group=</varname> may be used to run as an unprivileged user
2231 to disallow changing system hostname. See <function>SetHostname()</function> in
2232 <citerefentry project="man-pages"><refentrytitle>org.freedesktop.hostname1</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2233 for more details.</para>
2234
2235 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2236
2237 <xi:include href="version-info.xml" xpointer="v242"/></listitem>
2238 </varlistentry>
2239
2240 <varlistentry>
2241 <term><varname>ProtectClock=</varname></term>
2242
2243 <listitem><para>Takes a boolean argument. If set, writes to the hardware clock or system clock will
2244 be denied. Defaults to off. Enabling this option removes <constant>CAP_SYS_TIME</constant> and
2245 <constant>CAP_WAKE_ALARM</constant> from the capability bounding set for this unit, installs a system
2246 call filter to block calls that can set the clock, and <varname>DeviceAllow=char-rtc r</varname> is
2247 implied. Note that the system calls are blocked altogether, the filter does not take into account
2248 that some of the calls can be used to read the clock state with some parameter combinations.
2249 Effectively, <filename>/dev/rtc0</filename>, <filename>/dev/rtc1</filename>, etc. are made read-only
2250 to the service. See
2251 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2252 for the details about <varname>DeviceAllow=</varname>.</para>
2253
2254 <para>It is recommended to turn this on for most services that do not need modify the clock or check
2255 its state.</para>
2256
2257 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2258
2259 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
2260 </varlistentry>
2261
2262 <varlistentry>
2263 <term><varname>ProtectKernelTunables=</varname></term>
2264
2265 <listitem><para>Takes a boolean argument. If true, kernel variables accessible through
2266 <filename>/proc/sys/</filename>, <filename>/sys/</filename>, <filename>/proc/sysrq-trigger</filename>,
2267 <filename>/proc/latency_stats</filename>, <filename>/proc/acpi</filename>,
2268 <filename>/proc/timer_stats</filename>, <filename>/proc/fs</filename> and <filename>/proc/irq</filename> will
2269 be made read-only and <filename>/proc/kallsyms</filename> as well as <filename>/proc/kcore</filename> will be
2270 inaccessible to all processes of the unit.
2271 Usually, tunable kernel variables should be initialized only at boot-time, for example with the
2272 <citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> mechanism. Few
2273 services need to write to these at runtime; it is hence recommended to turn this on for most services. For this
2274 setting the same restrictions regarding mount propagation and privileges apply as for
2275 <varname>ReadOnlyPaths=</varname> and related calls, see above. Defaults to off.
2276 Note that this option does not prevent indirect changes to kernel tunables affected by IPC calls to
2277 other processes. However, <varname>InaccessiblePaths=</varname> may be used to make relevant IPC file system
2278 objects inaccessible. If <varname>ProtectKernelTunables=</varname> is set,
2279 <varname>MountAPIVFS=yes</varname> is implied.</para>
2280
2281 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2282
2283 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
2284 </varlistentry>
2285
2286 <varlistentry>
2287 <term><varname>ProtectKernelModules=</varname></term>
2288
2289 <listitem><para>Takes a boolean argument. If true, explicit module loading will be denied. This allows
2290 module load and unload operations to be turned off on modular kernels. It is recommended to turn this on for most services
2291 that do not need special file systems or extra kernel modules to work. Defaults to off. Enabling this option
2292 removes <constant>CAP_SYS_MODULE</constant> from the capability bounding set for the unit, and installs a
2293 system call filter to block module system calls, also <filename>/usr/lib/modules</filename> is made
2294 inaccessible. For this setting the same restrictions regarding mount propagation and privileges apply as for
2295 <varname>ReadOnlyPaths=</varname> and related calls, see above. Note that limited automatic module loading due
2296 to user configuration or kernel mapping tables might still happen as side effect of requested user operations,
2297 both privileged and unprivileged. To disable module auto-load feature please see
2298 <citerefentry><refentrytitle>sysctl.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2299 <constant>kernel.modules_disabled</constant> mechanism and
2300 <filename>/proc/sys/kernel/modules_disabled</filename> documentation.</para>
2301
2302 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2303
2304 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
2305 </varlistentry>
2306
2307 <varlistentry>
2308 <term><varname>ProtectKernelLogs=</varname></term>
2309
2310 <listitem><para>Takes a boolean argument. If true, access to the kernel log ring buffer will be denied. It is
2311 recommended to turn this on for most services that do not need to read from or write to the kernel log ring
2312 buffer. Enabling this option removes <constant>CAP_SYSLOG</constant> from the capability bounding set for this
2313 unit, and installs a system call filter to block the
2314 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>2</manvolnum></citerefentry>
2315 system call (not to be confused with the libc API
2316 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
2317 for userspace logging). The kernel exposes its log buffer to userspace via <filename>/dev/kmsg</filename> and
2318 <filename>/proc/kmsg</filename>. If enabled, these are made inaccessible to all the processes in the unit.
2319 </para>
2320
2321 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2322
2323 <xi:include href="version-info.xml" xpointer="v244"/></listitem>
2324 </varlistentry>
2325
2326 <varlistentry>
2327 <term><varname>ProtectControlGroups=</varname></term>
2328
2329 <listitem><para>Takes a boolean argument or the special values <literal>private</literal> or
2330 <literal>strict</literal>. If true, the Linux Control Groups (<citerefentry project='man-pages'>
2331 <refentrytitle>cgroups</refentrytitle><manvolnum>7</manvolnum></citerefentry>) hierarchies
2332 accessible through <filename>/sys/fs/cgroup/</filename> will be made read-only to all processes of the
2333 unit. If set to <literal>private</literal>, the unit will run in a cgroup namespace with a private
2334 writable mount of <filename>/sys/fs/cgroup/</filename>. If set to <literal>strict</literal>, the unit
2335 will run in a cgroup namespace with a private read-only mount of <filename>/sys/fs/cgroup/</filename>.
2336 Defaults to off. If <varname>ProtectControlGroups=</varname> is set, <varname>MountAPIVFS=yes</varname>
2337 is implied. Note <literal>private</literal> and <literal>strict</literal> are downgraded to false and
2338 true respectively unless the system is using the unified control group hierarchy and the kernel supports
2339 cgroup namespaces.</para>
2340
2341 <para>Except for container managers no services should require write access to the control groups hierarchies;
2342 it is hence recommended to set <varname>ProtectControlGroups=</varname> to true or <literal>strict</literal>
2343 for most services. For this setting the same restrictions regarding mount propagation and privileges apply
2344 as for <varname>ReadOnlyPaths=</varname> and related settings, see above.</para>
2345
2346 <xi:include href="system-only.xml" xpointer="singular"/>
2347
2348 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
2349 </varlistentry>
2350
2351 <varlistentry>
2352 <term><varname>RestrictAddressFamilies=</varname></term>
2353
2354 <listitem><para>Restricts the set of socket address families accessible to the processes of this
2355 unit. Takes <literal>none</literal>, or a space-separated list of address family names to
2356 allow-list, such as <constant>AF_UNIX</constant>, <constant>AF_INET</constant> or
2357 <constant>AF_INET6</constant>, see
2358 <citerefentry project='man-pages'><refentrytitle>address_families</refentrytitle><manvolnum>7</manvolnum></citerefentry>
2359 for all possible options. When <literal>none</literal> is specified, then all address
2360 families will be denied. When prefixed with <literal>~</literal> the listed address
2361 families will be applied as deny list, otherwise as allow list.</para>
2362
2363 <para>By default, no restrictions apply, all address families are accessible to processes. If
2364 assigned the empty string, any previous address family restriction changes are undone. This setting
2365 does not affect commands prefixed with <literal>+</literal>.</para>
2366
2367 <para>Use this option to limit exposure of processes to remote access, in particular via exotic and
2368 sensitive network protocols, such as <constant>AF_PACKET</constant>. Note that in most cases, the
2369 local <constant>AF_UNIX</constant> address family should be included in the configured allow list as
2370 it is frequently used for local communication, including for
2371 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>2</manvolnum></citerefentry>
2372 logging.</para>
2373
2374 <para>Note that this restricts access to the <citerefentry
2375 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum></citerefentry>
2376 system call only. Sockets passed into the process by other means (for example, by using socket
2377 activation with socket units, see
2378 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
2379 are unaffected. Also, sockets created with <function>socketpair()</function> (which creates connected
2380 AF_UNIX sockets) or the
2381 <citerefentry project='man-pages'><refentrytitle>io_uring</refentrytitle><manvolnum>7</manvolnum></citerefentry>
2382 functions, are not affected. Thus, it is recommended to combined this setting with
2383 <varname>SystemCallFilter=@service</varname>, to only allow a limited subset of system calls.</para>
2384
2385 <para>Note that this option is limited to some ABIs, in particular x86-64, but currently has no
2386 effect on 32-bit x86, s390, s390x, mips, mips-le, ppc, ppc-le, ppc64, or ppc64-le, and is ignored. On
2387 systems supporting multiple ABIs (such as x86/x86-64) it is recommended to turn off alternative ABIs
2388 for services, so that they cannot be used to circumvent the restrictions of this option.
2389 Specifically, it is recommended to combine this option with
2390 <varname>SystemCallArchitectures=native</varname> or similar. </para>
2391
2392 <xi:include href="version-info.xml" xpointer="v211"/></listitem>
2393 </varlistentry>
2394
2395 <varlistentry>
2396 <term><varname>RestrictFileSystems=</varname></term>
2397
2398 <listitem><para>Restricts the set of filesystems processes of this unit can open files on. Takes a space-separated
2399 list of filesystem names. Any filesystem listed is made accessible to the unit's processes, access to filesystem
2400 types not listed is prohibited (allow-listing). If the first character of the list is <literal>~</literal>, the
2401 effect is inverted: access to the filesystems listed is prohibited (deny-listing). If the empty string is assigned,
2402 access to filesystems is not restricted.</para>
2403
2404 <para>If you specify both types of this option (i.e. allow-listing and deny-listing), the first encountered will take
2405 precedence and will dictate the default action (allow access to the filesystem or deny it). Then the next occurrences
2406 of this option will add or delete the listed filesystems from the set of the restricted filesystems, depending on its
2407 type and the default action.</para>
2408
2409 <para>Example: if a unit has the following,
2410 <programlisting>RestrictFileSystems=ext4 tmpfs
2411RestrictFileSystems=ext2 ext4</programlisting>
2412 then access to <constant>ext4</constant>, <constant>tmpfs</constant>, and <constant>ext2</constant> is allowed
2413 and access to other filesystems is denied.</para>
2414
2415 <para>Example: if a unit has the following,
2416 <programlisting>RestrictFileSystems=ext4 tmpfs
2417RestrictFileSystems=~ext4</programlisting>
2418 then only access <constant>tmpfs</constant> is allowed.</para>
2419
2420 <para>Example: if a unit has the following,
2421 <programlisting>RestrictFileSystems=~ext4 tmpfs
2422RestrictFileSystems=ext4</programlisting>
2423 then only access to <constant>tmpfs</constant> is denied.</para>
2424
2425 <para>As the number of possible filesystems is large, predefined sets of filesystems are provided. A set
2426 starts with <literal>@</literal> character, followed by name of the set.</para>
2427
2428 <table>
2429 <title>Currently predefined filesystem sets</title>
2430
2431 <tgroup cols='2'>
2432 <colspec colname='set' />
2433 <colspec colname='description' />
2434 <thead>
2435 <row>
2436 <entry>Set</entry>
2437 <entry>Description</entry>
2438 </row>
2439 </thead>
2440 <tbody>
2441 <row>
2442 <entry>@basic-api</entry>
2443 <entry>Basic filesystem API.</entry>
2444 </row>
2445 <row>
2446 <entry>@auxiliary-api</entry>
2447 <entry>Auxiliary filesystem API.</entry>
2448 </row>
2449 <row>
2450 <entry>@common-block</entry>
2451 <entry>Common block device filesystems.</entry>
2452 </row>
2453 <row>
2454 <entry>@historical-block</entry>
2455 <entry>Historical block device filesystems.</entry>
2456 </row>
2457 <row>
2458 <entry>@network</entry>
2459 <entry>Well-known network filesystems.</entry>
2460 </row>
2461 <row>
2462 <entry>@privileged-api</entry>
2463 <entry>Privileged filesystem API.</entry>
2464 </row>
2465 <row>
2466 <entry>@temporary</entry>
2467 <entry>Temporary filesystems: tmpfs, ramfs.</entry>
2468 </row>
2469 <row>
2470 <entry>@known</entry>
2471 <entry>All known filesystems defined by the kernel. This list is defined statically in systemd based on a kernel version that was available when this systemd version was released. It will become progressively more out-of-date as the kernel is updated.</entry>
2472 </row>
2473 </tbody>
2474 </tgroup>
2475 </table>
2476
2477 <para>Use
2478 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
2479 <command>filesystems</command> command to retrieve a list of filesystems defined on the local
2480 system.</para>
2481
2482 <para>Note that this setting might not be supported on some systems (for example if the LSM eBPF hook is
2483 not enabled in the underlying kernel or if not using the unified control group hierarchy). In that case this setting
2484 has no effect.</para>
2485
2486 <xi:include href="cgroup-sandboxing.xml" xpointer="singular"/>
2487
2488 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
2489 </varlistentry>
2490
2491 <varlistentry>
2492 <term><varname>RestrictNamespaces=</varname></term>
2493
2494 <listitem><para>Restricts access to Linux namespace functionality for the processes of this unit. For details
2495 about Linux namespaces, see <citerefentry
2496 project='man-pages'><refentrytitle>namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry>. Either
2497 takes a boolean argument, or a space-separated list of namespace type identifiers. If false (the default), no
2498 restrictions on namespace creation and switching are made. If true, access to any kind of namespacing is
2499 prohibited. Otherwise, a space-separated list of namespace type identifiers must be specified, consisting of
2500 any combination of: <constant>cgroup</constant>, <constant>ipc</constant>, <constant>net</constant>,
2501 <constant>mnt</constant>, <constant>pid</constant>, <constant>user</constant>, <constant>uts</constant>, and
2502 <constant>time</constant>. Any namespace type listed is made accessible to the unit's processes, access to
2503 namespace types not listed is prohibited (allow-listing). By prepending the list with a single tilde
2504 character (<literal>~</literal>) the effect may be inverted: only the listed namespace types will be made
2505 inaccessible, all unlisted ones are permitted (deny-listing). If the empty string is assigned, the default
2506 namespace restrictions are applied, which is equivalent to false. This option may appear more than once, in
2507 which case the namespace types are merged by <constant>OR</constant>, or by <constant>AND</constant> if the
2508 lines are prefixed with <literal>~</literal> (see examples below). Internally, this setting limits access to
2509 the <citerefentry><refentrytitle>unshare</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
2510 <citerefentry><refentrytitle>clone</refentrytitle><manvolnum>2</manvolnum></citerefentry> and
2511 <citerefentry><refentrytitle>setns</refentrytitle><manvolnum>2</manvolnum></citerefentry> system calls, taking
2512 the specified flags parameters into account. Note that — if this option is used — in addition to restricting
2513 creation and switching of the specified types of namespaces (or all of them, if true) access to the
2514 <function>setns()</function> system call with a zero flags parameter is prohibited. This setting is only
2515 supported on x86, x86-64, mips, mips-le, mips64, mips64-le, mips64-n32, mips64-le-n32, ppc64, ppc64-le, s390
2516 and s390x, and enforces no restrictions on other architectures.</para>
2517
2518 <para>Example: if a unit has the following,
2519 <programlisting>RestrictNamespaces=cgroup ipc
2520RestrictNamespaces=cgroup net</programlisting>
2521 then <constant>cgroup</constant>, <constant>ipc</constant>, and <constant>net</constant> are set.
2522 If the second line is prefixed with <literal>~</literal>, e.g.,
2523 <programlisting>RestrictNamespaces=cgroup ipc
2524RestrictNamespaces=~cgroup net</programlisting>
2525 then, only <constant>ipc</constant> is set.</para>
2526
2527 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
2528 </varlistentry>
2529
2530 <varlistentry>
2531 <term><varname>DelegateNamespaces=</varname></term>
2532
2533 <listitem><para>Delegates ownership of the given namespace types to the user namespace of the
2534 processes of this unit. For details about Linux namespaces, see <citerefentry
2535 project='man-pages'><refentrytitle>namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
2536 Either takes a boolean argument, or a space-separated list of namespace type identifiers. If false
2537 (the default), the unit's processes' user namespace will not have ownership over any namespaces
2538 created during setup of the unit's sandboxed environment. If true, ownership of all namespace types
2539 (except for user namespaces, where the concept doesn't apply) created during setup of the unit's
2540 sandboxed environment is delegated to the unit's processes' user namespace. Otherwise, a
2541 space-separated list of namespace type identifiers must be specified, consisting of any combination
2542 of: <constant>cgroup</constant>, <constant>ipc</constant>, <constant>net</constant>,
2543 <constant>mnt</constant>, <constant>pid</constant>, and <constant>uts</constant>. All namespaces of
2544 the listed types will be owned by the unit's processes' user namespace if they are created during
2545 setup of the unit's sandboxed environment (allow-listing). By prepending the list with a single tilde
2546 character (<literal>~</literal>) the effect may be inverted: all namespaces of types not listed and
2547 created during setup of the unit's sandboxed environment will be owned by the unit's processes' user
2548 namespace (deny-listing). If the empty string is assigned, the default namespace ownership is
2549 applied, which is equivalent to false. This option may appear more than once, in which case the
2550 namespace types are merged by <constant>OR</constant>, or by <constant>AND</constant> if the lines
2551 are prefixed with <literal>~</literal> (see examples below). Internally, this setting controls the
2552 order in which namespaces are unshared by systemd. Namespace types that should be owned by the unit's
2553 processes' user namespace will be unshared after unsharing the user namespace. Internally, this
2554 setting controls the order in which namespaces are unshared. Delegated namespaces will be unshared
2555 after the user namespace is unshared. Other namespaces will be unshared before the user namespace is
2556 unshared.</para>
2557
2558 <para>Delegating any namespace with <varname>DelegateNamespaces=</varname> implies
2559 <varname>PrivateUsers=self</varname> unless <varname>PrivateUsers=</varname> is explicitly enabled
2560 already by the unit. Delegating a namespace does not imply that the namespace is unshared, that is
2561 done with the namespace specific unit setting such as <varname>PrivateNetwork=</varname> or
2562 <varname>PrivateMounts=</varname>.</para>
2563
2564 <para>Note that some namespace sandboxing options might entail mount namespace for private API VFS instances,
2565 such as <varname>PrivatePIDs=</varname>, <varname>ProtectControlGroups=private/strict</varname>, or
2566 <varname>PrivateNetwork=</varname>. If any of the mentioned options are enabled, mount namespace
2567 is implicitly delegated.</para>
2568
2569 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
2570 </varlistentry>
2571
2572 <varlistentry>
2573 <term><varname>PrivateBPF=</varname></term>
2574
2575 <listitem><para>Takes a boolean argument. If set, mount a private instance of the BPF filesystem
2576 on <filename>/sys/fs/bpf/</filename>, effectively hiding the host bpffs which contains information
2577 about loaded programs and maps. Otherwise, if <varname>ProtectKernelTunables=</varname> is set, the
2578 instance from the host is inherited but mounted read-only. Defaults to false.</para>
2579
2580 <para>This can be used together with the bpffs delegate feature to choose what BPF functions are
2581 available to the unit's processes. When mounting the BPF filesystem with the fsopen() API, four mount
2582 options can be specified to set a list of BPF commands, maps, programs and attachment types that are
2583 allowed to be used. Processes needs to get a file descriptor for the bpffs mountpoint and use that to
2584 get a token which will enable for that user namespace the BPF functionalities chosen upon bpffs mount.
2585 A more detailed explanation of the feature can be found in this
2586 <ulink url="https://lwn.net/Articles/947173/">LWN post</ulink>.</para>
2587
2588
2589 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
2590 </varlistentry>
2591
2592 <varlistentry>
2593 <term><varname>BPFDelegateCommands=</varname></term>
2594
2595 <listitem><para>Accepts a list of BPF commands to allow or <literal>any</literal> to allow everything.
2596 Defaults to none. The accepted values are:
2597 <xi:include href="bpf-delegate.xml" xpointer="bpf_delegate_cmd"/>
2598 This will set the <constant>delegate_cmds</constant> bpffs mount option.</para>
2599
2600 <para>Requires <varname>PrivateBPF=yes</varname> to be effective,
2601 see <varname>PrivateBPF=</varname> more details.</para>
2602
2603 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
2604 </varlistentry>
2605
2606 <varlistentry>
2607 <term><varname>BPFDelegateMaps=</varname></term>
2608
2609 <listitem><para>Accepts a list of BPF maps to allow or <literal>any</literal> to allow everything.
2610 Defaults to none. The accepted values are:
2611 <xi:include href="bpf-delegate.xml" xpointer="bpf_delegate_map_type"/>
2612 This will set the <constant>delegate_maps</constant> bpffs mount option.</para>
2613
2614 <para>Requires <varname>PrivateBPF=yes</varname> to be effective,
2615 see <varname>PrivateBPF=</varname> more details.</para>
2616
2617 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
2618 </varlistentry>
2619
2620 <varlistentry>
2621 <term><varname>BPFDelegatePrograms=</varname></term>
2622
2623 <listitem><para>Accepts a list of BPF programs to allow or <literal>any</literal> to allow everything.
2624 Defaults to none. The accepted values are:
2625 <xi:include href="bpf-delegate.xml" xpointer="bpf_delegate_prog_type"/>
2626 This will set the <constant>delegate_progs</constant> bpffs mount option.</para>
2627
2628 <para>Requires <varname>PrivateBPF=yes</varname> to be effective,
2629 see <varname>PrivateBPF=</varname> more details.</para>
2630
2631 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
2632 </varlistentry>
2633
2634 <varlistentry>
2635 <term><varname>BPFDelegateAttachments=</varname></term>
2636
2637 <listitem><para>Accepts a list of BPF attach points to allow or <literal>any</literal> to allow everything.
2638 Defaults to none. The accepted values are:
2639 <xi:include href="bpf-delegate.xml" xpointer="bpf_delegate_attach_type"/>
2640 This will set the <constant>delegate_attachs</constant> bpffs mount option.</para>
2641
2642 <para>Requires <varname>PrivateBPF=yes</varname> to be effective,
2643 see <varname>PrivateBPF=</varname> more details.</para>
2644
2645 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
2646 </varlistentry>
2647
2648 <varlistentry>
2649 <term><varname>LockPersonality=</varname></term>
2650
2651 <listitem><para>Takes a boolean argument. If set, locks down the <citerefentry
2652 project='man-pages'><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry> system
2653 call so that the kernel execution domain may not be changed from the default or the personality selected with
2654 <varname>Personality=</varname> directive. This may be useful to improve security, because odd personality
2655 emulations may be poorly tested and source of vulnerabilities.</para>
2656
2657 <xi:include href="version-info.xml" xpointer="v235"/></listitem>
2658 </varlistentry>
2659
2660 <varlistentry>
2661 <term><varname>MemoryDenyWriteExecute=</varname></term>
2662
2663 <listitem><para>Takes a boolean argument. If set, attempts to create memory mappings that are writable and
2664 executable at the same time, or to change existing memory mappings to become executable, or mapping shared
2665 memory segments as executable, are prohibited. Specifically, a system call filter is added (or
2666 preferably, an equivalent kernel check is enabled with
2667 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>) that
2668 rejects <citerefentry><refentrytitle>mmap</refentrytitle><manvolnum>2</manvolnum></citerefentry>
2669 system calls with both <constant>PROT_EXEC</constant> and <constant>PROT_WRITE</constant> set,
2670 <citerefentry><refentrytitle>mprotect</refentrytitle><manvolnum>2</manvolnum></citerefentry> or
2671 <citerefentry><refentrytitle>pkey_mprotect</refentrytitle><manvolnum>2</manvolnum></citerefentry> system calls
2672 with <constant>PROT_EXEC</constant> set and
2673 <citerefentry><refentrytitle>shmat</refentrytitle><manvolnum>2</manvolnum></citerefentry> system calls with
2674 <constant>SHM_EXEC</constant> set. Note that this option is incompatible with programs and libraries that
2675 generate program code dynamically at runtime, including JIT execution engines, executable stacks, and code
2676 "trampoline" feature of various C compilers. This option improves service security, as it makes harder for
2677 software exploits to change running code dynamically. However, the protection can be circumvented, if
2678 the service can write to a filesystem, which is not mounted with <constant>noexec</constant> (such as
2679 <filename>/dev/shm</filename>), or it can use <function>memfd_create()</function>. This can be
2680 prevented by making such file systems inaccessible to the service
2681 (e.g. <varname>InaccessiblePaths=/dev/shm</varname>) and installing further system call filters
2682 (<varname>SystemCallFilter=~memfd_create</varname>). Note that this feature is fully available on
2683 x86-64, and partially on x86. Specifically, the <function>shmat()</function> protection is not
2684 available on x86. Note that on systems supporting multiple ABIs (such as x86/x86-64) it is
2685 recommended to turn off alternative ABIs for services, so that they cannot be used to circumvent the
2686 restrictions of this option. Specifically, it is recommended to combine this option with
2687 <varname>SystemCallArchitectures=native</varname> or similar.</para>
2688
2689 <xi:include href="version-info.xml" xpointer="v231"/></listitem>
2690 </varlistentry>
2691
2692 <varlistentry>
2693 <term><varname>RestrictRealtime=</varname></term>
2694
2695 <listitem><para>Takes a boolean argument. If set, any attempts to enable realtime scheduling in a process of
2696 the unit are refused. This restricts access to realtime task scheduling policies such as
2697 <constant>SCHED_FIFO</constant>, <constant>SCHED_RR</constant> or <constant>SCHED_DEADLINE</constant>. See
2698 <citerefentry project='man-pages'><refentrytitle>sched</refentrytitle><manvolnum>7</manvolnum></citerefentry>
2699 for details about these scheduling policies. Realtime scheduling policies may be used to monopolize CPU
2700 time for longer periods of time, and may hence be used to lock up or otherwise trigger Denial-of-Service
2701 situations on the system. It is hence recommended to restrict access to realtime scheduling to the few programs
2702 that actually require them. Defaults to off.</para>
2703
2704 <xi:include href="version-info.xml" xpointer="v231"/></listitem>
2705 </varlistentry>
2706
2707 <varlistentry>
2708 <term><varname>RestrictSUIDSGID=</varname></term>
2709
2710 <listitem><para>Takes a boolean argument. If set, any attempts to set the set-user-ID (SUID) or
2711 set-group-ID (SGID) bits on files or directories will be denied (for details on these bits see
2712 <citerefentry
2713 project='man-pages'><refentrytitle>inode</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
2714 As the SUID/SGID bits are mechanisms to elevate privileges, and allow users to acquire the
2715 identity of other users, it is recommended to restrict creation of SUID/SGID files to the few
2716 programs that actually require them. Note that this restricts marking of any type of file system
2717 object with these bits, including both regular files and directories (where the SGID is a different
2718 meaning than for files, see documentation). This option is implied if <varname>DynamicUser=</varname>
2719 is enabled.</para>
2720
2721 <para>In other cases, this setting defaults to the value set with <varname>DefaultRestrictSUIDSGID=</varname> in
2722 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, which
2723 defaults to off.</para>
2724
2725 <xi:include href="version-info.xml" xpointer="v242"/></listitem>
2726 </varlistentry>
2727
2728 <varlistentry>
2729 <term><varname>RemoveIPC=</varname></term>
2730
2731 <listitem><para>Takes a boolean parameter. If set, all System V and POSIX IPC objects owned by the user and
2732 group the processes of this unit are run as are removed when the unit is stopped. This setting only has an
2733 effect if at least one of <varname>User=</varname>, <varname>Group=</varname> and
2734 <varname>DynamicUser=</varname> are used. It has no effect on IPC objects owned by the root user. Specifically,
2735 this removes System V semaphores, as well as System V and POSIX shared memory segments and message queues. If
2736 multiple units use the same user or group the IPC objects are removed when the last of these units is
2737 stopped. This setting is implied if <varname>DynamicUser=</varname> is set.</para>
2738
2739 <xi:include href="system-only.xml" xpointer="singular"/>
2740
2741 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
2742 </varlistentry>
2743
2744 <varlistentry>
2745 <term><varname>PrivateMounts=</varname></term>
2746
2747 <listitem><para>Takes a boolean parameter. If set, the processes of this unit will be run in their own private
2748 file system (mount) namespace with all mount propagation from the processes towards the host's main file system
2749 namespace turned off. This means any file system mount points established or removed by the unit's processes
2750 will be private to them and not be visible to the host. However, file system mount points established or
2751 removed on the host will be propagated to the unit's processes. See <citerefentry
2752 project='man-pages'><refentrytitle>mount_namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
2753 details on file system namespaces. Defaults to off.</para>
2754
2755 <para>When turned on, this executes three operations for each invoked process: a new
2756 <constant>CLONE_NEWNS</constant> namespace is created, after which all existing mounts are remounted to
2757 <constant>MS_SLAVE</constant> to disable propagation from the unit's processes to the host (but leaving
2758 propagation in the opposite direction in effect). Finally, the mounts are remounted again to the propagation
2759 mode configured with <varname>MountFlags=</varname>, see below.</para>
2760
2761 <para>File system namespaces are set up individually for each process forked off by the service manager. Mounts
2762 established in the namespace of the process created by <varname>ExecStartPre=</varname> will hence be cleaned
2763 up automatically as soon as that process exits and will not be available to subsequent processes forked off for
2764 <varname>ExecStart=</varname> (and similar applies to the various other commands configured for
2765 units). Similarly, <varname>JoinsNamespaceOf=</varname> does not permit sharing kernel mount namespaces between
2766 units, it only enables sharing of the <filename>/tmp/</filename> and <filename>/var/tmp/</filename>
2767 directories.</para>
2768
2769 <para>Other file system namespace unit settings — <varname>PrivateTmp=</varname>,
2770 <varname>PrivateDevices=</varname>, <varname>ProtectSystem=</varname>,
2771 <varname>ProtectHome=</varname>, <varname>ReadOnlyPaths=</varname>,
2772 <varname>InaccessiblePaths=</varname>, <varname>ReadWritePaths=</varname>,
2773 <varname>BindPaths=</varname>, <varname>BindReadOnlyPaths=</varname>, … — also enable file system
2774 namespacing in a fashion equivalent to this option. Hence it is primarily useful to explicitly
2775 request this behaviour if none of the other settings are used.</para>
2776
2777 <xi:include href="system-or-user-ns.xml" xpointer="singular"/>
2778
2779 <xi:include href="version-info.xml" xpointer="v239"/></listitem>
2780 </varlistentry>
2781
2782 <varlistentry>
2783 <term><varname>MountFlags=</varname></term>
2784
2785 <listitem><para>Takes a mount propagation setting: <option>shared</option>, <option>slave</option> or
2786 <option>private</option>, which controls whether file system mount points in the file system namespaces set up
2787 for this unit's processes will receive or propagate mounts and unmounts from other file system namespaces. See
2788 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>2</manvolnum></citerefentry>
2789 for details on mount propagation, and the three propagation flags in particular.</para>
2790
2791 <para>This setting only controls the <emphasis>final</emphasis> propagation setting in effect on all mount
2792 points of the file system namespace created for each process of this unit. Other file system namespacing unit
2793 settings (see the discussion in <varname>PrivateMounts=</varname> above) will implicitly disable mount and
2794 unmount propagation from the unit's processes towards the host by changing the propagation setting of all mount
2795 points in the unit's file system namespace to <option>slave</option> first. Setting this option to
2796 <option>shared</option> does not reestablish propagation in that case.</para>
2797
2798 <para>If not set – but file system namespaces are enabled through another file system namespace unit setting –
2799 <option>shared</option> mount propagation is used, but — as mentioned — as <option>slave</option> is applied
2800 first, propagation from the unit's processes to the host is still turned off.</para>
2801
2802 <para>It is not recommended to use <option>private</option> mount propagation for units, as this means
2803 temporary mounts (such as removable media) of the host will stay mounted and thus indefinitely busy in forked
2804 off processes, as unmount propagation events will not be received by the file system namespace of the unit.</para>
2805
2806 <para>Usually, it is best to leave this setting unmodified, and use higher level file system namespacing
2807 options instead, in particular <varname>PrivateMounts=</varname>, see above.</para>
2808
2809 <xi:include href="system-or-user-ns.xml" xpointer="singular"/></listitem>
2810 </varlistentry>
2811
2812 </variablelist>
2813 </refsect1>
2814
2815 <refsect1>
2816 <title>System Call Filtering</title>
2817 <variablelist class='unit-directives'>
2818
2819 <varlistentry>
2820 <term><varname>SystemCallFilter=</varname></term>
2821
2822 <listitem><para>Takes a space-separated list of system call names or system call groups. If this
2823 setting is used, system calls executed by the unit processes except for the listed ones will result
2824 in the system call being denied (allow-listing). If the first character of the list is
2825 <literal>~</literal>, the effect is inverted: only the listed system calls will be denied
2826 (deny-listing). This option may be specified more than once, in which case the filter masks are
2827 merged. If the empty string is assigned, the filter is reset, all prior assignments will have no
2828 effect.</para>
2829
2830 <para>Commands prefixed with <literal>+</literal> are not subject to filtering. The
2831 <function>execve()</function>, <function>exit()</function>, <function>exit_group()</function>,
2832 <function>getrlimit()</function>, <function>rt_sigreturn()</function>,
2833 <function>sigreturn()</function> system calls and the system calls for querying time and sleeping are
2834 implicitly allow-listed and do not need to be listed explicitly.</para>
2835
2836 <para>The default action when a system call is denied is to terminate the processes with a
2837 <constant>SIGSYS</constant> signal. This can changed using <varname>SystemCallErrorNumber=</varname>,
2838 see below. In addition, deny-listed system calls and system call groups may optionally be suffixed
2839 with a colon (<literal>:</literal>) and an argument in the same format as
2840 <varname>SystemCallErrorNumber=</varname>, to take this action when the matching system call is made.
2841 This takes precedence over the action specified in <varname>SystemCallErrorNumber=</varname>.</para>
2842
2843 <para>This feature makes use of the Secure Computing Mode 2 interfaces of the kernel ('seccomp
2844 filtering') and is useful for enforcing a minimal sandboxing environment.</para>
2845
2846 <para>Note that on systems supporting multiple ABIs (such as x86/x86-64) it is recommended to turn
2847 off alternative ABIs for services, so that they cannot be used to circumvent the restrictions of this
2848 option. Specifically, it is recommended to combine this option with
2849 <varname>SystemCallArchitectures=native</varname> or similar.</para>
2850
2851 <para>Note that strict system call filters may impact execution and error handling code paths of the
2852 service invocation. Specifically, access to the <function>execve()</function> system call is required
2853 for the execution of the service binary — if it is blocked service invocation will necessarily fail.
2854 Also, if execution of the service binary fails for some reason (for example: missing service
2855 executable), the error handling logic might require access to an additional set of system calls in
2856 order to process and log this failure correctly. It might be necessary to temporarily disable system
2857 call filters in order to allow debugging of such failures.</para>
2858
2859 <para>If you specify both types of this option (i.e. allow-listing and deny-listing), the first
2860 encountered will take precedence and will dictate the default action (termination or approval of a
2861 system call). Then the next occurrences of this option will add or delete the listed system calls
2862 from the set of the filtered system calls, depending of its type and the default action. (For
2863 example, if you have started with an allow list rule for <function>read()</function> and
2864 <function>write()</function>, and right after it add a deny list rule for <function>write()</function>,
2865 then <function>write()</function> will be removed from the set.)</para>
2866
2867 <para>As the number of possible system calls is large, predefined groups of system calls are
2868 provided. A group starts with <literal>@</literal> character, followed by name of the set.
2869
2870 <table>
2871 <title>Currently predefined system call sets</title>
2872
2873 <tgroup cols='2'>
2874 <colspec colname='set' />
2875 <colspec colname='description' />
2876 <thead>
2877 <row>
2878 <entry>Set</entry>
2879 <entry>Description</entry>
2880 </row>
2881 </thead>
2882 <tbody>
2883 <row>
2884 <entry>@aio</entry>
2885 <entry>Asynchronous I/O (<citerefentry project='man-pages'><refentrytitle>io_setup</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>io_submit</refentrytitle><manvolnum>2</manvolnum></citerefentry>, and related calls)</entry>
2886 </row>
2887 <row>
2888 <entry>@basic-io</entry>
2889 <entry>System calls for basic I/O: reading, writing, seeking, file descriptor duplication and closing (<citerefentry project='man-pages'><refentrytitle>read</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>write</refentrytitle><manvolnum>2</manvolnum></citerefentry>, and related calls)</entry>
2890 </row>
2891 <row>
2892 <entry>@chown</entry>
2893 <entry>Changing file ownership (<citerefentry project='man-pages'><refentrytitle>chown</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>fchownat</refentrytitle><manvolnum>2</manvolnum></citerefentry>, and related calls)</entry>
2894 </row>
2895 <row>
2896 <entry>@clock</entry>
2897 <entry>System calls for changing the system clock (<citerefentry project='man-pages'><refentrytitle>adjtimex</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>settimeofday</refentrytitle><manvolnum>2</manvolnum></citerefentry>, and related calls)</entry>
2898 </row>
2899 <row>
2900 <entry>@cpu-emulation</entry>
2901 <entry>System calls for CPU emulation functionality (<citerefentry project='man-pages'><refentrytitle>vm86</refentrytitle><manvolnum>2</manvolnum></citerefentry> and related calls)</entry>
2902 </row>
2903 <row>
2904 <entry>@debug</entry>
2905 <entry>Debugging, performance monitoring and tracing functionality (<citerefentry project='man-pages'><refentrytitle>ptrace</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>perf_event_open</refentrytitle><manvolnum>2</manvolnum></citerefentry> and related calls)</entry>
2906 </row>
2907 <row>
2908 <entry>@file-system</entry>
2909 <entry>File system operations: opening, creating files and directories for read and write, renaming and removing them, reading file properties, or creating hard and symbolic links</entry>
2910 </row>
2911 <row>
2912 <entry>@io-event</entry>
2913 <entry>Event loop system calls (<citerefentry project='man-pages'><refentrytitle>poll</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>select</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>epoll</refentrytitle><manvolnum>7</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>eventfd</refentrytitle><manvolnum>2</manvolnum></citerefentry> and related calls)</entry>
2914 </row>
2915 <row>
2916 <entry>@ipc</entry>
2917 <entry>Pipes, SysV IPC, POSIX Message Queues and other IPC (<citerefentry project='man-pages'><refentrytitle>mq_overview</refentrytitle><manvolnum>7</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>svipc</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
2918 </row>
2919 <row>
2920 <entry>@keyring</entry>
2921 <entry>Kernel keyring access (<citerefentry project='man-pages'><refentrytitle>keyctl</refentrytitle><manvolnum>2</manvolnum></citerefentry> and related calls)</entry>
2922 </row>
2923 <row>
2924 <entry>@memlock</entry>
2925 <entry>Locking of memory in RAM (<citerefentry project='man-pages'><refentrytitle>mlock</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>mlockall</refentrytitle><manvolnum>2</manvolnum></citerefentry> and related calls)</entry>
2926 </row>
2927 <row>
2928 <entry>@module</entry>
2929 <entry>Loading and unloading of kernel modules (<citerefentry project='man-pages'><refentrytitle>init_module</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>delete_module</refentrytitle><manvolnum>2</manvolnum></citerefentry> and related calls)</entry>
2930 </row>
2931 <row>
2932 <entry>@mount</entry>
2933 <entry>Mounting and unmounting of file systems (<citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>chroot</refentrytitle><manvolnum>2</manvolnum></citerefentry>, and related calls)</entry>
2934 </row>
2935 <row>
2936 <entry>@network-io</entry>
2937 <entry>Socket I/O (including local AF_UNIX): <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>unix</refentrytitle><manvolnum>7</manvolnum></citerefentry></entry>
2938 </row>
2939 <row>
2940 <entry>@obsolete</entry>
2941 <entry>Unusual, obsolete or unimplemented (<citerefentry project='man-pages'><refentrytitle>create_module</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>gtty</refentrytitle><manvolnum>2</manvolnum></citerefentry>, …)</entry>
2942 </row>
2943 <row>
2944 <entry>@pkey</entry>
2945 <entry>System calls that deal with memory protection keys (<citerefentry project='man-pages'><refentrytitle>pkeys</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
2946 </row>
2947 <row>
2948 <entry>@privileged</entry>
2949 <entry>All system calls which need super-user capabilities (<citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
2950 </row>
2951 <row>
2952 <entry>@process</entry>
2953 <entry>Process control, execution, namespacing operations (<citerefentry project='man-pages'><refentrytitle>clone</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>kill</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry>, …)</entry>
2954 </row>
2955 <row>
2956 <entry>@raw-io</entry>
2957 <entry>Raw I/O port access (<citerefentry project='man-pages'><refentrytitle>ioperm</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>iopl</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <function>pciconfig_read()</function>, …)</entry>
2958 </row>
2959 <row>
2960 <entry>@reboot</entry>
2961 <entry>System calls for rebooting and reboot preparation (<citerefentry project='man-pages'><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <function>kexec()</function>, …)</entry>
2962 </row>
2963 <row>
2964 <entry>@resources</entry>
2965 <entry>System calls for changing resource limits, memory and scheduling parameters (<citerefentry project='man-pages'><refentrytitle>setrlimit</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>setpriority</refentrytitle><manvolnum>2</manvolnum></citerefentry>, …)</entry>
2966 </row>
2967 <row>
2968 <entry>@sandbox</entry>
2969 <entry>System calls for sandboxing programs (<citerefentry project='man-pages'><refentrytitle>seccomp</refentrytitle><manvolnum>2</manvolnum></citerefentry>, Landlock system calls, …)</entry>
2970 </row>
2971 <row>
2972 <entry>@setuid</entry>
2973 <entry>System calls for changing user ID and group ID credentials, (<citerefentry project='man-pages'><refentrytitle>setuid</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>setgid</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>setresuid</refentrytitle><manvolnum>2</manvolnum></citerefentry>, …)</entry>
2974 </row>
2975 <row>
2976 <entry>@signal</entry>
2977 <entry>System calls for manipulating and handling process signals (<citerefentry project='man-pages'><refentrytitle>signal</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>sigprocmask</refentrytitle><manvolnum>2</manvolnum></citerefentry>, …)</entry>
2978 </row>
2979 <row>
2980 <entry>@swap</entry>
2981 <entry>System calls for enabling/disabling swap devices (<citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>swapoff</refentrytitle><manvolnum>2</manvolnum></citerefentry>)</entry>
2982 </row>
2983 <row>
2984 <entry>@sync</entry>
2985 <entry>Synchronizing files and memory to disk (<citerefentry project='man-pages'><refentrytitle>fsync</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>msync</refentrytitle><manvolnum>2</manvolnum></citerefentry>, and related calls)</entry>
2986 </row>
2987 <row>
2988 <entry>@system-service</entry>
2989 <entry>A reasonable set of system calls used by common system services, excluding any special purpose calls. This is the recommended starting point for allow-listing system calls for system services, as it contains what is typically needed by system services, but excludes overly specific interfaces. For example, the following APIs are excluded: <literal>@clock</literal>, <literal>@mount</literal>, <literal>@swap</literal>, <literal>@reboot</literal>.</entry>
2990 </row>
2991 <row>
2992 <entry>@timer</entry>
2993 <entry>System calls for scheduling operations by time (<citerefentry project='man-pages'><refentrytitle>alarm</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>timer_create</refentrytitle><manvolnum>2</manvolnum></citerefentry>, …)</entry>
2994 </row>
2995 <row>
2996 <entry>@known</entry>
2997 <entry>All system calls defined by the kernel. This list is defined statically in systemd based on a kernel version that was available when this systemd version was released. It will become progressively more out-of-date as the kernel is updated.</entry>
2998 </row>
2999 </tbody>
3000 </tgroup>
3001 </table>
3002
3003 Note, that as new system calls are added to the kernel, additional system calls might be added to the groups
3004 above. Contents of the sets may also change between systemd versions. In addition, the list of system calls
3005 depends on the kernel version and architecture for which systemd was compiled. Use
3006 <command>systemd-analyze syscall-filter</command> to list the actual list of system calls in each
3007 filter.</para>
3008
3009 <para>Generally, allow-listing system calls (rather than deny-listing) is the safer mode of
3010 operation. It is recommended to enforce system call allow lists for all long-running system
3011 services. Specifically, the following lines are a relatively safe basic choice for the majority of
3012 system services:</para>
3013
3014 <programlisting>[Service]
3015SystemCallFilter=@system-service
3016SystemCallErrorNumber=EPERM</programlisting>
3017
3018 <para>Note that various kernel system calls are defined redundantly: there are multiple system calls
3019 for executing the same operation. For example, the <function>pidfd_send_signal()</function> system
3020 call may be used to execute operations similar to what can be done with the older
3021 <function>kill()</function> system call, hence blocking the latter without the former only provides
3022 weak protection. Since new system calls are added regularly to the kernel as development progresses,
3023 keeping system call deny lists comprehensive requires constant work. It is thus recommended to use
3024 allow-listing instead, which offers the benefit that new system calls are by default implicitly
3025 blocked until the allow list is updated.</para>
3026
3027 <para>Also note that a number of system calls are required to be accessible for the dynamic linker to
3028 work. The dynamic linker is required for running most regular programs (specifically: all dynamic ELF
3029 binaries, which is how most distributions build packaged programs). This means that blocking these
3030 system calls (which include <function>open()</function>, <function>openat()</function> or
3031 <function>mmap()</function>) will make most programs typically shipped with generic distributions
3032 unusable.</para>
3033
3034 <para>It is recommended to combine the file system namespacing related options with
3035 <varname>SystemCallFilter=~@mount</varname>, in order to prohibit the unit's processes to undo the
3036 mappings. Specifically these are the options <varname>PrivateTmp=</varname>,
3037 <varname>PrivateDevices=</varname>, <varname>ProtectSystem=</varname>, <varname>ProtectHome=</varname>,
3038 <varname>ProtectKernelTunables=</varname>, <varname>ProtectControlGroups=</varname>,
3039 <varname>ProtectKernelLogs=</varname>, <varname>ProtectClock=</varname>, <varname>ReadOnlyPaths=</varname>,
3040 <varname>InaccessiblePaths=</varname> and <varname>ReadWritePaths=</varname>.</para>
3041
3042 <xi:include href="version-info.xml" xpointer="v187"/></listitem>
3043 </varlistentry>
3044
3045 <varlistentry>
3046 <term><varname>SystemCallErrorNumber=</varname></term>
3047
3048 <listitem><para>Takes an <literal>errno</literal> error number (between 1 and 4095) or errno name
3049 such as <constant>EPERM</constant>, <constant>EACCES</constant> or <constant>EUCLEAN</constant>, to
3050 return when the system call filter configured with <varname>SystemCallFilter=</varname> is triggered,
3051 instead of terminating the process immediately. See <citerefentry
3052 project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry> for a
3053 full list of error codes. When this setting is not used, or when the empty string or the special
3054 setting <literal>kill</literal> is assigned, the process will be terminated immediately when the
3055 filter is triggered.</para>
3056
3057 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
3058 </varlistentry>
3059
3060 <varlistentry>
3061 <term><varname>SystemCallArchitectures=</varname></term>
3062
3063 <listitem><para>Takes a space-separated list of architecture identifiers to include in the system call
3064 filter. The known architecture identifiers are the same as for <varname>ConditionArchitecture=</varname>
3065 described in <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
3066 as well as <constant>x32</constant>, <constant>mips64-n32</constant>, <constant>mips64-le-n32</constant>, and
3067 the special identifier <constant>native</constant>. The special identifier <constant>native</constant>
3068 implicitly maps to the native architecture of the system (or more precisely: to the architecture the system
3069 manager is compiled for). By default, this option is set to the empty list, i.e. no filtering is applied.</para>
3070
3071 <para>If this setting is used, processes of this unit will only be permitted to call native system calls, and
3072 system calls of the specified architectures. For the purposes of this option, the x32 architecture is treated
3073 as including x86-64 system calls. However, this setting still fulfills its purpose, as explained below, on
3074 x32.</para>
3075
3076 <para>System call filtering is not equally effective on all architectures. For example, on x86
3077 filtering of network socket-related calls is not possible, due to ABI limitations — a limitation that x86-64
3078 does not have, however. On systems supporting multiple ABIs at the same time — such as x86/x86-64 — it is hence
3079 recommended to limit the set of permitted system call architectures so that secondary ABIs may not be used to
3080 circumvent the restrictions applied to the native ABI of the system. In particular, setting
3081 <varname>SystemCallArchitectures=native</varname> is a good choice for disabling non-native ABIs.</para>
3082
3083 <para>System call architectures may also be restricted system-wide via the
3084 <varname>SystemCallArchitectures=</varname> option in the global configuration. See
3085 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
3086 details.</para>
3087
3088 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
3089 </varlistentry>
3090
3091 <varlistentry>
3092 <term><varname>SystemCallLog=</varname></term>
3093
3094 <listitem><para>Takes a space-separated list of system call names. If this setting is used, all
3095 system calls executed by the unit processes for the listed ones will be logged. If the first
3096 character of the list is <literal>~</literal>, the effect is inverted: all system calls except the
3097 listed system calls will be logged. This feature makes use of the Secure Computing Mode 2 interfaces
3098 of the kernel ('seccomp filtering') and is useful for auditing or setting up a minimal sandboxing
3099 environment. This option may be specified more than once, in which case the filter masks are merged.
3100 If the empty string is assigned, the filter is reset, all prior assignments will have no effect.
3101 This does not affect commands prefixed with <literal>+</literal>.</para>
3102
3103 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
3104 </varlistentry>
3105
3106 </variablelist>
3107 </refsect1>
3108
3109 <refsect1>
3110 <title>Environment</title>
3111
3112 <variablelist class='unit-directives'>
3113
3114 <varlistentry>
3115 <term><varname>Environment=</varname></term>
3116
3117 <listitem><para>Sets environment variables for executed processes. Each line is unquoted using the
3118 rules described in "Quoting" section in
3119 <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry>
3120 and becomes a list of variable assignments. If you need to assign a value containing spaces or the
3121 equals sign to a variable, put quotes around the whole assignment. Variable expansion is not
3122 performed inside the strings and the <literal>$</literal> character has no special meaning. Specifier
3123 expansion is performed, see the "Specifiers" section in
3124 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
3125 </para>
3126
3127 <para>This option may be specified more than once, in which case all listed variables will be set. If
3128 the same variable is listed twice, the later setting will override the earlier setting. If the empty
3129 string is assigned to this option, the list of environment variables is reset, all prior assignments
3130 have no effect.</para>
3131
3132 <para>The names of the variables can contain ASCII letters, digits, and the underscore character.
3133 Variable names cannot be empty or start with a digit. In variable values, most characters are
3134 allowed, but non-printable characters are currently rejected.</para>
3135
3136 <para>Example:
3137 <programlisting>Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"</programlisting>
3138 gives three variables <literal>VAR1</literal>,
3139 <literal>VAR2</literal>, <literal>VAR3</literal>
3140 with the values <literal>word1 word2</literal>,
3141 <literal>word3</literal>, <literal>$word 5 6</literal>.
3142 </para>
3143
3144 <para>See <citerefentry
3145 project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
3146 details about environment variables.</para>
3147
3148 <para>Note that environment variables are not suitable for passing secrets (such as passwords, key
3149 material, …) to service processes. Environment variables set for a unit are exposed to unprivileged
3150 clients via D-Bus IPC, and generally not understood as being data that requires protection. Moreover,
3151 environment variables are propagated down the process tree, including across security boundaries
3152 (such as setuid/setgid executables), and hence might leak to processes that should not have access to
3153 the secret data. Use <varname>LoadCredential=</varname>, <varname>LoadCredentialEncrypted=</varname>
3154 or <varname>SetCredentialEncrypted=</varname> (see below) to pass data to unit processes
3155 securely.</para></listitem>
3156 </varlistentry>
3157
3158 <varlistentry>
3159 <term><varname>EnvironmentFile=</varname></term>
3160
3161 <listitem><para>Similar to <varname>Environment=</varname>, but reads the environment variables from
3162 a text file. The text file should contain newline-separated variable assignments. Empty lines, lines
3163 without an <literal>=</literal> separator, or lines starting with <literal>;</literal> or
3164 <literal>#</literal> will be ignored, which may be used for commenting. The file must be encoded with
3165 UTF-8. Valid characters are
3166 <ulink url="https://www.unicode.org/glossary/#unicode_scalar_value">unicode scalar values</ulink>
3167 other than
3168 <ulink url="https://www.unicode.org/glossary/#noncharacter">unicode noncharacters</ulink>,
3169 <constant>U+0000</constant> <constant>NUL</constant>, and <constant>U+FEFF</constant>
3170 <ulink url="https://www.unicode.org/glossary/#byte_order_mark">unicode byte order mark</ulink>.
3171 Control codes other than <constant>NUL</constant> are allowed.</para>
3172
3173 <para>In the file, an unquoted value after the <literal>=</literal> is parsed with the same backslash-escape
3174 rules as <ulink
3175 url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_01">POSIX shell unquoted
3176 text</ulink>, but unlike in a shell, interior whitespace is preserved and quotes after the
3177 first non-whitespace character are preserved. Leading and trailing whitespace (space, tab, carriage return) is
3178 discarded, but interior whitespace within the line is preserved verbatim. A line ending with a backslash will be
3179 continued to the following one, with the newline itself discarded. A backslash
3180 <literal>\</literal> followed by any character other than newline will preserve the following character, so that
3181 <literal>\\</literal> will become the value <literal>\</literal>.</para>
3182
3183 <para>In the file, a <literal>'</literal>-quoted value after the <literal>=</literal> can span
3184 multiple lines and contain any character verbatim other than single quote, like <ulink
3185 url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_02">POSIX
3186 shell single-quoted text</ulink>. No backslash-escape sequences are recognized. Leading and trailing
3187 whitespace outside of the single quotes is discarded.</para>
3188
3189 <para>In the file, a <literal>"</literal>-quoted value after the <literal>=</literal> can span
3190 multiple lines, and the same escape sequences are recognized as in <ulink
3191 url="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03">POSIX
3192 shell double-quoted text</ulink>. Backslash (<literal>\</literal>) followed by any of
3193 <literal>"\`$</literal> will preserve that character. A backslash followed by newline is a line
3194 continuation, and the newline itself is discarded. A backslash followed by any other character is
3195 ignored; both the backslash and the following character are preserved verbatim. Leading and trailing
3196 whitespace outside of the double quotes is discarded.</para>
3197
3198 <para>The argument passed should be an absolute filename or wildcard expression, optionally prefixed with
3199 <literal>-</literal>, which indicates that if the file does not exist, it will not be read and no error or
3200 warning message is logged. This option may be specified more than once in which case all specified files are
3201 read. If the empty string is assigned to this option, the list of file to read is reset, all prior assignments
3202 have no effect.</para>
3203
3204 <para>The files listed with this directive will be read shortly before the process is executed (more
3205 specifically, after all processes from a previous unit state terminated. This means you can generate these
3206 files in one unit state, and read it with this option in the next. The files are read from the file
3207 system of the service manager, before any file system changes like bind mounts take place).</para>
3208
3209 <para>Settings from these files override settings made with <varname>Environment=</varname>. If the same
3210 variable is set twice from these files, the files will be read in the order they are specified and the later
3211 setting will override the earlier setting.</para></listitem>
3212 </varlistentry>
3213
3214 <varlistentry>
3215 <term><varname>PassEnvironment=</varname></term>
3216
3217 <listitem><para>Pass environment variables set for the system service manager to executed processes. Takes a
3218 space-separated list of variable names. This option may be specified more than once, in which case all listed
3219 variables will be passed. If the empty string is assigned to this option, the list of environment variables to
3220 pass is reset, all prior assignments have no effect. Variables specified that are not set for the system
3221 manager will not be passed and will be silently ignored. Note that this option is only relevant for the system
3222 service manager, as system services by default do not automatically inherit any environment variables set for
3223 the service manager itself. However, in case of the user service manager all environment variables are passed
3224 to the executed processes anyway, hence this option is without effect for the user service manager.</para>
3225
3226 <para>Variables set for invoked processes due to this setting are subject to being overridden by those
3227 configured with <varname>Environment=</varname> or <varname>EnvironmentFile=</varname>.</para>
3228
3229 <para>Example:
3230 <programlisting>PassEnvironment=VAR1 VAR2 VAR3</programlisting>
3231 passes three variables <literal>VAR1</literal>,
3232 <literal>VAR2</literal>, <literal>VAR3</literal>
3233 with the values set for those variables in PID1.</para>
3234
3235 <para>
3236 See <citerefentry
3237 project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details
3238 about environment variables.</para>
3239
3240 <xi:include href="version-info.xml" xpointer="v228"/></listitem>
3241 </varlistentry>
3242
3243 <varlistentry>
3244 <term><varname>UnsetEnvironment=</varname></term>
3245
3246 <listitem><para>Explicitly unset environment variable assignments that would normally be passed from the
3247 service manager to invoked processes of this unit. Takes a space-separated list of variable names or variable
3248 assignments. This option may be specified more than once, in which case all listed variables/assignments will
3249 be unset. If the empty string is assigned to this option, the list of environment variables/assignments to
3250 unset is reset. If a variable assignment is specified (that is: a variable name, followed by
3251 <literal>=</literal>, followed by its value), then any environment variable matching this precise assignment is
3252 removed. If a variable name is specified (that is a variable name without any following <literal>=</literal> or
3253 value), then any assignment matching the variable name, regardless of its value is removed. Note that the
3254 effect of <varname>UnsetEnvironment=</varname> is applied as final step when the environment list passed to
3255 executed processes is compiled. That means it may undo assignments from any configuration source, including
3256 assignments made through <varname>Environment=</varname> or <varname>EnvironmentFile=</varname>, inherited from
3257 the system manager's global set of environment variables, inherited via <varname>PassEnvironment=</varname>,
3258 set by the service manager itself (such as <varname>$NOTIFY_SOCKET</varname> and such), or set by a PAM module
3259 (in case <varname>PAMName=</varname> is used).</para>
3260
3261 <para>See "Environment Variables in Spawned Processes" below for a description of how those
3262 settings combine to form the inherited environment. See <citerefentry
3263 project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> for general
3264 information about environment variables.</para>
3265
3266 <xi:include href="version-info.xml" xpointer="v235"/></listitem>
3267 </varlistentry>
3268
3269 </variablelist>
3270 </refsect1>
3271
3272 <refsect1>
3273 <title>Logging and Standard Input/Output</title>
3274
3275 <variablelist class='unit-directives'>
3276 <varlistentry>
3277
3278 <term><varname>StandardInput=</varname></term>
3279
3280 <listitem><para>Controls where file descriptor 0 (STDIN) of the executed processes is connected to. Takes one
3281 of <option>null</option>, <option>tty</option>, <option>tty-force</option>, <option>tty-fail</option>,
3282 <option>data</option>, <option>file:<replaceable>path</replaceable></option>, <option>socket</option> or
3283 <option>fd:<replaceable>name</replaceable></option>.</para>
3284
3285 <para>If <option>null</option> is selected, standard input will be connected to <filename>/dev/null</filename>,
3286 i.e. all read attempts by the process will result in immediate EOF.</para>
3287
3288 <para>If <option>tty</option> is selected, standard input is connected to a TTY (as configured by
3289 <varname>TTYPath=</varname>, see below) and the executed process becomes the controlling process of the
3290 terminal. If the terminal is already being controlled by another process, the executed process waits until the
3291 current controlling process releases the terminal.</para>
3292
3293 <para><option>tty-force</option> is similar to <option>tty</option>, but the executed process is forcefully and
3294 immediately made the controlling process of the terminal, potentially removing previous controlling processes
3295 from the terminal.</para>
3296
3297 <para><option>tty-fail</option> is similar to <option>tty</option>, but if the terminal already has a
3298 controlling process start-up of the executed process fails.</para>
3299
3300 <para>The <option>data</option> option may be used to configure arbitrary textual or binary data to pass via
3301 standard input to the executed process. The data to pass is configured via
3302 <varname>StandardInputText=</varname>/<varname>StandardInputData=</varname> (see below). Note that the actual
3303 file descriptor type passed (memory file, regular file, UNIX pipe, …) might depend on the kernel and available
3304 privileges. In any case, the file descriptor is read-only, and when read returns the specified data followed by
3305 EOF.</para>
3306
3307 <para>The <option>file:<replaceable>path</replaceable></option> option may be used to connect a specific file
3308 system object to standard input. An absolute path following the <literal>:</literal> character is expected,
3309 which may refer to a regular file, a FIFO or special file. If an <constant>AF_UNIX</constant> socket in the
3310 file system is specified, a stream socket is connected to it. The latter is useful for connecting standard
3311 input of processes to arbitrary system services.</para>
3312
3313 <para>The <option>socket</option> option is valid in socket-activated services only, and requires the relevant
3314 socket unit file (see
3315 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details)
3316 to have <varname>Accept=yes</varname> set, or to specify a single socket only. If this option is set, standard
3317 input will be connected to the socket the service was activated from, which is primarily useful for
3318 compatibility with daemons designed for use with the traditional <citerefentry
3319 project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry> socket activation
3320 daemon (<varname>$LISTEN_FDS</varname> (and related) environment variables are not passed when
3321 <option>socket</option> value is configured).</para>
3322
3323 <para>The <option>fd:<replaceable>name</replaceable></option> option connects standard input to a specific,
3324 named file descriptor provided by a socket unit. The name may be specified as part of this option, following a
3325 <literal>:</literal> character (e.g. <literal>fd:foobar</literal>). If no name is specified, the name
3326 <literal>stdin</literal> is implied (i.e. <literal>fd</literal> is equivalent to <literal>fd:stdin</literal>).
3327 At least one socket unit defining the specified name must be provided via the <varname>Sockets=</varname>
3328 option, and the file descriptor name may differ from the name of its containing socket unit. If multiple
3329 matches are found, the first one will be used. See <varname>FileDescriptorName=</varname> in
3330 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
3331 details about named file descriptors and their ordering.</para>
3332
3333 <para>This setting defaults to <option>null</option>, unless
3334 <varname>StandardInputText=</varname>/<varname>StandardInputData=</varname> are set, in which case it
3335 defaults to <option>data</option>.</para></listitem>
3336 </varlistentry>
3337
3338 <varlistentry>
3339 <term><varname>StandardOutput=</varname></term>
3340
3341 <listitem><para>Controls where file descriptor 1 (stdout) of the executed processes is connected
3342 to. Takes one of <option>inherit</option>, <option>null</option>, <option>tty</option>,
3343 <option>journal</option>, <option>kmsg</option>, <option>journal+console</option>,
3344 <option>kmsg+console</option>, <option>file:<replaceable>path</replaceable></option>,
3345 <option>append:<replaceable>path</replaceable></option>, <option>truncate:<replaceable>path</replaceable></option>,
3346 <option>socket</option> or <option>fd:<replaceable>name</replaceable></option>.</para>
3347
3348 <para><option>inherit</option> duplicates the file descriptor of standard input for standard output.</para>
3349
3350 <para><option>null</option> connects standard output to <filename>/dev/null</filename>, i.e. everything written
3351 to it will be lost.</para>
3352
3353 <para><option>tty</option> connects standard output to a tty (as configured via <varname>TTYPath=</varname>,
3354 see below). If the TTY is used for output only, the executed process will not become the controlling process of
3355 the terminal, and will not fail or wait for other processes to release the terminal. Note: if a unit
3356 tries to print multiple lines to a TTY during bootup or shutdown, then there's a chance that those
3357 lines will be broken up by status messages. <function>SetShowStatus()</function> can be used to
3358 prevent this problem. See
3359 <citerefentry project="man-pages"><refentrytitle>org.freedesktop.systemd1</refentrytitle><manvolnum>5</manvolnum></citerefentry>
3360 for details.</para>
3361
3362 <para><option>journal</option> connects standard output with the journal, which is accessible via
3363 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. Note
3364 that everything that is written to kmsg (see below) is implicitly stored in the journal as well, the
3365 specific option listed below is hence a superset of this one. (Also note that any external,
3366 additional syslog daemons receive their log data from the journal, too, hence this is the option to
3367 use when logging shall be processed with such a daemon.)</para>
3368
3369 <para><option>kmsg</option> connects standard output with the kernel log buffer which is accessible via
3370 <citerefentry project='man-pages'><refentrytitle>dmesg</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
3371 in addition to the journal. The journal daemon might be configured to send all logs to kmsg anyway, in which
3372 case this option is no different from <option>journal</option>.</para>
3373
3374 <para><option>journal+console</option> and <option>kmsg+console</option> work in a similar way as the
3375 two options above but copy the output to the system console as well.</para>
3376
3377 <para>The <option>file:<replaceable>path</replaceable></option> option may be used to connect a specific file
3378 system object to standard output. The semantics are similar to the same option of
3379 <varname>StandardInput=</varname>, see above. If <replaceable>path</replaceable> refers to a regular file
3380 on the filesystem, it is opened (created if it does not exist yet using privileges of the user executing the
3381 systemd process) for writing at the beginning of the file, but without truncating it.
3382 If standard input and output are directed to the same file path, it is opened only once — for reading as well
3383 as writing — and duplicated. This is particularly useful when the specified path refers to an
3384 <constant>AF_UNIX</constant> socket in the file system, as in that case only a
3385 single stream connection is created for both input and output.</para>
3386
3387 <para><option>append:<replaceable>path</replaceable></option> is similar to
3388 <option>file:<replaceable>path</replaceable></option> above, but it opens the file in append mode.
3389 </para>
3390
3391 <para><option>truncate:<replaceable>path</replaceable></option> is similar to
3392 <option>file:<replaceable>path</replaceable></option> above, but it truncates the file when opening
3393 it. For units with multiple command lines, e.g. <varname>Type=oneshot</varname> services with
3394 multiple <varname>ExecStart=</varname>, or services with <varname>ExecCondition=</varname>,
3395 <varname>ExecStartPre=</varname> or <varname>ExecStartPost=</varname>, the output file is reopened
3396 and therefore re-truncated for each command line. If the output file is truncated while another
3397 process still has the file open, e.g. by an <varname>ExecReload=</varname> running concurrently with
3398 an <varname>ExecStart=</varname>, and the other process continues writing to the file without
3399 adjusting its offset, then the space between the file pointers of the two processes may be filled
3400 with <constant>NUL</constant> bytes, producing a sparse file. Thus,
3401 <option>truncate:<replaceable>path</replaceable></option> is typically only useful for units where
3402 only one process runs at a time, such as services with a single <varname>ExecStart=</varname> and no
3403 <varname>ExecStartPost=</varname>, <varname>ExecReload=</varname>, <varname>ExecStop=</varname> or
3404 similar.</para>
3405
3406 <para><option>socket</option> connects standard output to a socket acquired via socket activation. The
3407 semantics are similar to the same option of <varname>StandardInput=</varname>, see above.</para>
3408
3409 <para>The <option>fd:<replaceable>name</replaceable></option> option connects standard output to a
3410 specific, named file descriptor provided by a socket unit. A name may be specified as part of this
3411 option, following a <literal>:</literal> character
3412 (e.g. <literal>fd:<replaceable>foobar</replaceable></literal>). If no name is specified, the name
3413 <literal>stdout</literal> is implied (i.e. <literal>fd</literal> is equivalent to
3414 <literal>fd:stdout</literal>). At least one socket unit defining the specified name must be provided
3415 via the <varname>Sockets=</varname> option, and the file descriptor name may differ from the name of
3416 its containing socket unit. If multiple matches are found, the first one will be used. See
3417 <varname>FileDescriptorName=</varname> in
3418 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
3419 for more details about named descriptors and their ordering.</para>
3420
3421 <para>If the standard output (or error output, see below) of a unit is connected to the journal or
3422 the kernel log buffer, the unit will implicitly gain a dependency of type <varname>After=</varname>
3423 on <filename>systemd-journald.socket</filename> (also see the "Implicit Dependencies" section
3424 above). Also note that, in this case, stdout (or stderr, see below) will be an
3425 <constant>AF_UNIX</constant> stream socket, and not a pipe or FIFO that can be reopened. This means
3426 when executing shell scripts the construct <command>echo "hello" &gt; /dev/stderr</command> for
3427 writing text to stderr will not work. To mitigate this use the construct <command>echo "hello"
3428 >&amp;2</command> instead, which is mostly equivalent and avoids this pitfall.</para>
3429
3430 <para>If <varname>StandardInput=</varname> is set to one of <option>tty</option>, <option>tty-force</option>,
3431 <option>tty-fail</option>, <option>socket</option>, or <option>fd:<replaceable>name</replaceable></option>, this
3432 setting defaults to <option>inherit</option>.</para>
3433
3434 <para>In other cases, this setting defaults to the value set with <varname>DefaultStandardOutput=</varname> in
3435 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, which
3436 defaults to <option>journal</option>. Note that setting this parameter might result in additional dependencies
3437 to be added to the unit (see above).</para></listitem>
3438 </varlistentry>
3439
3440 <varlistentry>
3441 <term><varname>StandardError=</varname></term>
3442
3443 <listitem><para>Controls where file descriptor 2 (stderr) of the executed processes is connected to. The
3444 available options are identical to those of <varname>StandardOutput=</varname>, with some exceptions: if set to
3445 <option>inherit</option> the file descriptor used for standard output is duplicated for standard error, while
3446 <option>fd:<replaceable>name</replaceable></option> will use a default file descriptor name of
3447 <literal>stderr</literal>.</para>
3448
3449 <para>This setting defaults to the value set with <varname>DefaultStandardError=</varname> in
3450 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, which
3451 defaults to <option>inherit</option>. Note that setting this parameter might result in additional dependencies
3452 to be added to the unit (see above).</para></listitem>
3453 </varlistentry>
3454
3455 <varlistentry>
3456 <term><varname>StandardInputText=</varname></term>
3457 <term><varname>StandardInputData=</varname></term>
3458
3459 <listitem><para>Configures arbitrary textual or binary data to pass via file descriptor 0 (STDIN) to
3460 the executed processes. These settings have no effect unless <varname>StandardInput=</varname> is set
3461 to <option>data</option> (which is the default if <varname>StandardInput=</varname> is not set
3462 otherwise, but <varname>StandardInputText=</varname>/<varname>StandardInputData=</varname> is). Use
3463 this option to embed process input data directly in the unit file.</para>
3464
3465 <para><varname>StandardInputText=</varname> accepts arbitrary textual data. C-style escapes for special
3466 characters as well as the usual <literal>%</literal>-specifiers are resolved. Each time this setting is used
3467 the specified text is appended to the per-unit data buffer, followed by a newline character (thus every use
3468 appends a new line to the end of the buffer). Note that leading and trailing whitespace of lines configured
3469 with this option is removed. If an empty line is specified the buffer is cleared (hence, in order to insert an
3470 empty line, add an additional <literal>\n</literal> to the end or beginning of a line).</para>
3471
3472 <para><varname>StandardInputData=</varname> accepts arbitrary binary data, encoded in <ulink
3473 url="https://tools.ietf.org/html/rfc2045#section-6.8">Base64</ulink>. No escape sequences or specifiers are
3474 resolved. Any whitespace in the encoded version is ignored during decoding.</para>
3475
3476 <para>Note that <varname>StandardInputText=</varname> and <varname>StandardInputData=</varname> operate on the
3477 same data buffer, and may be mixed in order to configure both binary and textual data for the same input
3478 stream. The textual or binary data is joined strictly in the order the settings appear in the unit
3479 file. Assigning an empty string to either will reset the data buffer.</para>
3480
3481 <para>Please keep in mind that in order to maintain readability long unit file settings may be split into
3482 multiple lines, by suffixing each line (except for the last) with a <literal>\</literal> character (see
3483 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
3484 details). This is particularly useful for large data configured with these two options. Example:</para>
3485
3486 <programlisting>…
3487StandardInput=data
3488StandardInputData=V2XigLJyZSBubyBzdHJhbmdlcnMgdG8gbG92ZQpZb3Uga25vdyB0aGUgcnVsZXMgYW5kIHNvIGRv \
3489 IEkKQSBmdWxsIGNvbW1pdG1lbnQncyB3aGF0IEnigLJtIHRoaW5raW5nIG9mCllvdSB3b3VsZG4n \
3490 dCBnZXQgdGhpcyBmcm9tIGFueSBvdGhlciBndXkKSSBqdXN0IHdhbm5hIHRlbGwgeW91IGhvdyBJ \
3491 J20gZmVlbGluZwpHb3R0YSBtYWtlIHlvdSB1bmRlcnN0YW5kCgpOZXZlciBnb25uYSBnaXZlIHlv \
3492 dSB1cApOZXZlciBnb25uYSBsZXQgeW91IGRvd24KTmV2ZXIgZ29ubmEgcnVuIGFyb3VuZCBhbmQg \
3493 ZGVzZXJ0IHlvdQpOZXZlciBnb25uYSBtYWtlIHlvdSBjcnkKTmV2ZXIgZ29ubmEgc2F5IGdvb2Ri \
3494 eWUKTmV2ZXIgZ29ubmEgdGVsbCBhIGxpZSBhbmQgaHVydCB5b3UK
3495…</programlisting>
3496
3497 <xi:include href="version-info.xml" xpointer="v236"/></listitem>
3498 </varlistentry>
3499
3500 <varlistentry>
3501 <term><varname>LogLevelMax=</varname></term>
3502
3503 <listitem><para>Sets the maximum log level for log messages generated by this unit. Takes a
3504 <command>syslog</command> log level, one of <option>emerg</option> (lowest log level, only highest
3505 priority messages), <option>alert</option>, <option>crit</option>, <option>err</option>,
3506 <option>warning</option>, <option>notice</option>, <option>info</option>, <option>debug</option>
3507 (highest log level, also lowest priority messages). See <citerefentry
3508 project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
3509 details. By default, the maximum log level is not overridden.</para>
3510
3511 <para>This option can be used to configure the logging system to drop log messages of a specific
3512 service above the specified level. For example, set
3513 <varname>LogLevelMax=</varname><option>info</option> in order to turn off debug logging of a
3514 particularly chatty unit. Alternatively, this option can be used to enable extra logging about a
3515 specific unit by the system or user manager processes without changing the global log level for the
3516 system or user manager processes by setting <varname>LogLevelMax=</varname><option>debug</option>.
3517 </para>
3518
3519 <para>Note that the configured level is applied to any log messages written by any of the processes
3520 belonging to this unit, as well as any log messages written by the system or user manager processes
3521 in reference to this unit, sent via any supported logging protocol. The override is applied early in
3522 the logging pipeline, before any kind of further processing is done. Moreover, messages which pass
3523 through this filter successfully might still be dropped by filters applied at a later stage in the
3524 logging subsystem. For example, <varname>MaxLevelStore=</varname> configured in
3525 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
3526 might prohibit messages of higher log levels to be stored on disk, even though the per-unit
3527 <varname>LogLevelMax=</varname> permitted it to be processed.</para>
3528
3529 <xi:include href="version-info.xml" xpointer="v236"/></listitem>
3530 </varlistentry>
3531
3532 <varlistentry>
3533 <term><varname>LogExtraFields=</varname></term>
3534
3535 <listitem><para>Configures additional log metadata fields to include in all log records generated by
3536 processes associated with this unit, including systemd. This setting takes one or more journal field
3537 assignments in the format <literal>FIELD=VALUE</literal> separated by whitespace. See
3538 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
3539 for details on the journal field concept. Even though the underlying journal implementation permits
3540 binary field values, this setting accepts only valid UTF-8 values. To include space characters in a
3541 journal field value, enclose the assignment in double quotes ("). <!-- " fake closing quote for emacs-->
3542 The usual specifiers are expanded in all assignments (see below). Note that this setting is not only
3543 useful for attaching additional metadata to log records of a unit, but given that all fields and
3544 values are indexed may also be used to implement cross-unit log record matching. Assign an empty
3545 string to reset the list.</para>
3546
3547 <para>Note that this functionality is currently only available in system services, not in per-user
3548 services.</para>
3549
3550 <xi:include href="version-info.xml" xpointer="v236"/></listitem>
3551 </varlistentry>
3552
3553 <varlistentry>
3554 <term><varname>LogRateLimitIntervalSec=</varname></term>
3555 <term><varname>LogRateLimitBurst=</varname></term>
3556
3557 <listitem><para>Configures the rate limiting that is applied to log messages generated by this unit.
3558 If, in the time interval defined by <varname>LogRateLimitIntervalSec=</varname>, more messages than
3559 specified in <varname>LogRateLimitBurst=</varname> are logged by a service, all further messages
3560 within the interval are dropped until the interval is over. A message about the number of dropped
3561 messages is generated. The time specification for <varname>LogRateLimitIntervalSec=</varname> may be
3562 specified in the following units: "s", "min", "h", "ms", "us". See
3563 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
3564 details. The default settings are set by <varname>RateLimitIntervalSec=</varname> and
3565 <varname>RateLimitBurst=</varname> configured in
3566 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
3567 Note that this only applies to log messages that are processed by the logging subsystem, i.e. by
3568 <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
3569 This means that if you connect a service's stderr directly to a file via
3570 <varname>StandardOutput=file:…</varname> or a similar setting, the rate limiting will not be applied
3571 to messages written that way (but it will be enforced for messages generated via
3572 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
3573 and similar functions).</para>
3574
3575 <xi:include href="version-info.xml" xpointer="v240"/></listitem>
3576 </varlistentry>
3577
3578 <varlistentry>
3579 <term><varname>LogFilterPatterns=</varname></term>
3580
3581 <listitem><para>Define an extended regular expression to filter log messages based on the
3582 <varname>MESSAGE=</varname> field of the structured message. If the first character of the pattern is
3583 <literal>~</literal>, log entries matching the pattern should be discarded. This option takes a single
3584 pattern as an argument but can be used multiple times to create a list of allowed and denied patterns.
3585 If the empty string is assigned, the filter is reset, and all prior assignments will have no effect.</para>
3586
3587 <para>Because the <literal>~</literal> character is used to define denied patterns, it must be replaced
3588 with <literal>\x7e</literal> to allow a message starting with <literal>~</literal>. For example,
3589 <literal>~foobar</literal> would add a pattern matching <literal>foobar</literal> to the deny list, while
3590 <literal>\x7efoobar</literal> would add a pattern matching <literal>~foobar</literal> to the allow list.</para>
3591
3592 <para>Log messages are tested against denied patterns (if any), then against allowed patterns
3593 (if any). If a log message matches any of the denied patterns, it is discarded immediately without considering
3594 allowed patterns. Remaining log messages are tested against allowed patterns. Messages matching
3595 against none of the allowed pattern are discarded. If no allowed patterns are defined, then all
3596 messages are processed directly after going through denied filters.</para>
3597
3598 <para>Filtering is based on the unit for which <varname>LogFilterPatterns=</varname> is defined, meaning log
3599 messages coming from
3600 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> about the
3601 unit are not taken into account. Filtered log messages will not be forwarded to traditional syslog daemons,
3602 the kernel log buffer (kmsg), the systemd console, or sent as wall messages to all logged-in
3603 users.</para>
3604
3605 <para>Note that this functionality is currently only available in system services, not in per-user
3606 services.</para>
3607
3608 <xi:include href="version-info.xml" xpointer="v253"/></listitem>
3609 </varlistentry>
3610
3611 <varlistentry>
3612 <term><varname>LogNamespace=</varname></term>
3613
3614 <listitem><para>Run the unit's processes in the specified journal namespace. Expects a short
3615 user-defined string identifying the namespace. If not used the processes of the service are run in
3616 the default journal namespace, i.e. their log stream is collected and processed by
3617 <filename>systemd-journald.service</filename>. If this option is used any log data generated by
3618 processes of this unit (regardless of whether via the <function>syslog()</function>, journal native logging
3619 or stdout/stderr logging) is collected and processed by an instance of the
3620 <filename>systemd-journald@.service</filename> template unit, which manages the specified
3621 namespace. The log data is stored in a data store independent from the default log namespace's data
3622 store. See
3623 <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
3624 for details about journal namespaces.</para>
3625
3626 <para>Internally, journal namespaces are implemented through Linux mount namespacing and
3627 over-mounting the directory that contains the relevant <constant>AF_UNIX</constant> sockets used for
3628 logging in the unit's mount namespace. Since mount namespaces are used this setting disconnects
3629 propagation of mounts from the unit's processes to the host, similarly to how
3630 <varname>ReadOnlyPaths=</varname> and similar settings describe above work. Journal namespaces may hence
3631 not be used for services that need to establish mount points on the host.</para>
3632
3633 <para>When this option is used the unit will automatically gain ordering and requirement dependencies
3634 on the two socket units associated with the <filename>systemd-journald@.service</filename> instance
3635 so that they are automatically established prior to the unit starting up. Note that when this option
3636 is used log output of this service does not appear in the regular
3637 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
3638 output, unless the <option>--namespace=</option> option is used.</para>
3639
3640 <xi:include href="system-only.xml" xpointer="singular"/>
3641
3642 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
3643 </varlistentry>
3644
3645 <varlistentry>
3646 <term><varname>SyslogIdentifier=</varname></term>
3647
3648 <listitem><para>Sets the process name ("<command>syslog</command> tag") to prefix log lines sent to
3649 the logging system or the kernel log buffer with. If not set, defaults to the process name of the
3650 executed process. This option is only useful when <varname>StandardOutput=</varname> or
3651 <varname>StandardError=</varname> are set to <option>journal</option> or <option>kmsg</option> (or to
3652 the same settings in combination with <option>+console</option>) and only applies to log messages
3653 written to stdout or stderr.</para></listitem>
3654 </varlistentry>
3655
3656 <varlistentry>
3657 <term><varname>SyslogFacility=</varname></term>
3658
3659 <listitem><para>Sets the <command>syslog</command> facility identifier to use when logging. One of
3660 <option>kern</option>, <option>user</option>, <option>mail</option>, <option>daemon</option>,
3661 <option>auth</option>, <option>syslog</option>, <option>lpr</option>, <option>news</option>,
3662 <option>uucp</option>, <option>cron</option>, <option>authpriv</option>, <option>ftp</option>,
3663 <option>local0</option>, <option>local1</option>, <option>local2</option>, <option>local3</option>,
3664 <option>local4</option>, <option>local5</option>, <option>local6</option> or
3665 <option>local7</option>. See <citerefentry
3666 project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
3667 details. This option is only useful when <varname>StandardOutput=</varname> or
3668 <varname>StandardError=</varname> are set to <option>journal</option> or <option>kmsg</option> (or to
3669 the same settings in combination with <option>+console</option>), and only applies to log messages
3670 written to stdout or stderr. Defaults to <option>daemon</option>.</para></listitem>
3671 </varlistentry>
3672
3673 <varlistentry>
3674 <term><varname>SyslogLevel=</varname></term>
3675
3676 <listitem><para>The default <command>syslog</command> log level to use when logging to the logging system or
3677 the kernel log buffer. One of <option>emerg</option>, <option>alert</option>, <option>crit</option>,
3678 <option>err</option>, <option>warning</option>, <option>notice</option>, <option>info</option>,
3679 <option>debug</option>. See <citerefentry
3680 project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
3681 details. This option is only useful when <varname>StandardOutput=</varname> or
3682 <varname>StandardError=</varname> are set to <option>journal</option> or
3683 <option>kmsg</option> (or to the same settings in combination with <option>+console</option>), and only applies
3684 to log messages written to stdout or stderr. Note that individual lines output by executed processes may be
3685 prefixed with a different log level which can be used to override the default log level specified here. The
3686 interpretation of these prefixes may be disabled with <varname>SyslogLevelPrefix=</varname>, see below. For
3687 details, see <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
3688 Defaults to <option>info</option>.</para></listitem>
3689 </varlistentry>
3690
3691 <varlistentry>
3692 <term><varname>SyslogLevelPrefix=</varname></term>
3693
3694 <listitem><para>Takes a boolean argument. If true and <varname>StandardOutput=</varname> or
3695 <varname>StandardError=</varname> are set to <option>journal</option> or <option>kmsg</option> (or to
3696 the same settings in combination with <option>+console</option>), log lines written by the executed
3697 process that are prefixed with a log level will be processed with this log level set but the prefix
3698 removed. If set to false, the interpretation of these prefixes is disabled and the logged lines are
3699 passed on as-is. This only applies to log messages written to stdout or stderr. For details about
3700 this prefixing see
3701 <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
3702 Defaults to true.</para></listitem>
3703 </varlistentry>
3704
3705 <varlistentry>
3706 <term><varname>TTYPath=</varname></term>
3707
3708 <listitem><para>Sets the terminal device node to use if standard input, output, or error are connected to a TTY
3709 (see above). Defaults to <filename>/dev/console</filename>.</para></listitem>
3710 </varlistentry>
3711
3712 <varlistentry>
3713 <term><varname>TTYReset=</varname></term>
3714
3715 <listitem><para>Reset the terminal device specified with <varname>TTYPath=</varname> before and after
3716 execution. This does not erase the screen (see <varname>TTYVTDisallocate=</varname> below for
3717 that). Defaults to <literal>no</literal>.</para></listitem>
3718 </varlistentry>
3719
3720 <varlistentry>
3721 <term><varname>TTYVHangup=</varname></term>
3722
3723 <listitem><para>Disconnect all clients which have opened the terminal device specified with
3724 <varname>TTYPath=</varname> before and after execution. Defaults to <literal>no</literal>.</para></listitem>
3725 </varlistentry>
3726
3727 <varlistentry>
3728 <term><varname>TTYColumns=</varname></term>
3729 <term><varname>TTYRows=</varname></term>
3730
3731 <listitem><para>Configure the size of the TTY specified with <varname>TTYPath=</varname>. If unset or
3732 set to the empty string, it is attempted to retrieve the dimensions of the terminal screen via ANSI
3733 sequences, and if that fails the kernel defaults (typically 80x24) are used.</para>
3734
3735 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
3736 </varlistentry>
3737
3738 <varlistentry>
3739 <term><varname>TTYVTDisallocate=</varname></term>
3740
3741 <listitem><para>If the terminal device specified with <varname>TTYPath=</varname> is a virtual
3742 console terminal, try to deallocate the TTY before and after execution. This ensures that the screen
3743 and scrollback buffer is cleared. If the terminal device is of any other type of TTY an attempt is
3744 made to clear the screen via ANSI sequences. Defaults to <literal>no</literal>.</para></listitem>
3745 </varlistentry>
3746 </variablelist>
3747 </refsect1>
3748
3749 <refsect1>
3750 <title>Credentials</title>
3751
3752 <variablelist class='unit-directives'>
3753
3754 <varlistentry>
3755 <term><varname>LoadCredential=</varname><replaceable>ID</replaceable><optional>:<replaceable>PATH</replaceable></optional></term>
3756 <term><varname>LoadCredentialEncrypted=</varname><replaceable>ID</replaceable><optional>:<replaceable>PATH</replaceable></optional></term>
3757
3758 <listitem><para>Pass a credential to the unit. Credentials are limited-size binary or textual objects
3759 that may be passed to unit processes. They are primarily intended for passing cryptographic keys
3760 (both public and private) or certificates, user account information or identity information from host
3761 to services, but can be freely used to pass any kind of limited-size information to a service. The
3762 data is accessible from the unit's processes via the file system, at a read-only location that (if
3763 possible and permitted) is backed by non-swappable memory. The data is only accessible to the user
3764 associated with the unit, via the <varname>User=</varname>/<varname>DynamicUser=</varname> settings
3765 (as well as the superuser). When available, the location of credentials is exported as the
3766 <varname>$CREDENTIALS_DIRECTORY</varname> environment variable to the unit's processes.</para>
3767
3768 <para>The <varname>LoadCredential=</varname> setting takes a textual ID to use as name for a
3769 credential plus a file system path, separated by a colon. The ID must be a short ASCII string
3770 suitable as filename in the filesystem, and may be chosen freely by the user. If the specified path
3771 is absolute it is opened as regular file and the credential data is read from it. If the absolute
3772 path refers to an <constant>AF_UNIX</constant> stream socket in the file system a connection is made
3773 to it (once at process invocation) and the credential data read from the connection, providing an
3774 easy IPC integration point for dynamically transferring credentials from other services.</para>
3775
3776 <para>If the specified path is not absolute and itself qualifies as valid credential identifier it is
3777 attempted to find a credential that the service manager itself received under the specified name —
3778 which may be used to propagate credentials from an invoking environment (e.g. a container manager
3779 that invoked the service manager) into a service. If no matching passed credential is found, the
3780 system service manager will search the directories <filename>/etc/credstore/</filename>,
3781 <filename>/run/credstore/</filename> and <filename>/usr/lib/credstore/</filename> for files under the
3782 credential's name — which hence are recommended locations for credential data on disk. If
3783 <varname>LoadCredentialEncrypted=</varname> is used <filename>/run/credstore.encrypted/</filename>,
3784 <filename>/etc/credstore.encrypted/</filename>, and
3785 <filename>/usr/lib/credstore.encrypted/</filename> are searched as well. The per-user service manager
3786 will search <filename>$XDG_CONFIG_HOME/credstore/</filename>,
3787 <filename>$XDG_RUNTIME_DIR/credstore/</filename>, <filename>$HOME/.local/lib/credstore/</filename>
3788 (and the counterparts ending with <filename>…/credstore.encrypted/</filename>) instead. The
3789 <citerefentry><refentrytitle>systemd-path</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool
3790 may be used to query the precise credential store search path.</para>
3791
3792 <para>If the file system path is omitted it is chosen identical to the credential name, i.e. this is
3793 a terse way to declare credentials to inherit from the service manager or credstore directories into
3794 a service. This option may be used multiple times, each time defining an additional credential to
3795 pass to the unit.</para>
3796
3797 <para>Note that if the path is not specified or a valid credential identifier is given, i.e.
3798 in the above two cases, a missing credential is not considered fatal.</para>
3799
3800 <para>If an absolute path referring to a directory is specified, every file in that directory
3801 (recursively) will be loaded as a separate credential. The ID for each credential will be the
3802 provided ID suffixed with <literal>_$FILENAME</literal> (e.g., <literal>Key_file1</literal>). When
3803 loading from a directory, symlinks will be ignored.</para>
3804
3805 <para>The contents of the file/socket may be arbitrary binary or textual data, including newline
3806 characters and <constant>NUL</constant> bytes.</para>
3807
3808 <para>The <varname>LoadCredentialEncrypted=</varname> setting is identical to
3809 <varname>LoadCredential=</varname>, except that the credential data is decrypted and authenticated
3810 before being passed on to the executed processes. Specifically, the referenced path should refer to a
3811 file or socket with an encrypted credential, as implemented by
3812 <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>. This
3813 credential is loaded, decrypted, authenticated and then passed to the application in plaintext form,
3814 in the same way a regular credential specified via <varname>LoadCredential=</varname> would be. A
3815 credential configured this way may be symmetrically encrypted/authenticated with a secret key derived
3816 from the system's TPM2 security chip, or with a secret key stored in
3817 <filename>/var/lib/systemd/credential.secret</filename>, or with both. Using encrypted and
3818 authenticated credentials improves security as credentials are not stored in plaintext and only
3819 authenticated and decrypted into plaintext the moment a service requiring them is started. Moreover,
3820 credentials may be bound to the local hardware and installations, so that they cannot easily be
3821 analyzed offline, or be generated externally. See
3822 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
3823 for the details about <varname>DevicePolicy=</varname> or <varname>DeviceAllow=</varname>.</para>
3824
3825 <para>Note that encrypted credentials targeted for services of the per-user service manager must be
3826 encrypted with <command>systemd-creds encrypt --user</command>, and those for the system service
3827 manager without the <option>--user</option> switch. Encrypted credentials are always targeted to a
3828 specific user or the system as a whole, and it is ensured that per-user service managers cannot
3829 decrypt secrets intended for the system or for other users.</para>
3830
3831 <para>The credential files/IPC sockets must be accessible to the service manager, but do not have to
3832 be directly accessible to the unit's processes: the credential data is read and copied into separate,
3833 read-only copies for the unit that are accessible to appropriately privileged processes. This is
3834 particularly useful in combination with <varname>DynamicUser=</varname> as this way privileged data
3835 can be made available to processes running under a dynamic UID (i.e. not a previously known one)
3836 without having to open up access to all users.</para>
3837
3838 <para>In order to reference the path a credential may be read from within a
3839 <varname>ExecStart=</varname> command line use <literal>${CREDENTIALS_DIRECTORY}/mycred</literal>,
3840 e.g. <literal>ExecStart=cat ${CREDENTIALS_DIRECTORY}/mycred</literal>. In order to reference the path
3841 a credential may be read from within a <varname>Environment=</varname> line use
3842 <literal>%d/mycred</literal>, e.g. <literal>Environment=MYCREDPATH=%d/mycred</literal>. For system
3843 services the path may also be referenced as
3844 <literal>/run/credentials/<replaceable>UNITNAME</replaceable></literal> in cases where no
3845 interpolation is possible, e.g. configuration files of software that does not yet support credentials
3846 natively. <varname>$CREDENTIALS_DIRECTORY</varname> is considered the primary interface to look for
3847 credentials, though, since it also works for user services.</para>
3848
3849 <para>Currently, an accumulated credential size limit of 1 MB per unit is enforced.</para>
3850
3851 <para>The service manager itself may receive system credentials that can be propagated to services
3852 from a hosting container manager or VM hypervisor. See the <ulink
3853 url="https://systemd.io/CONTAINER_INTERFACE">Container Interface</ulink> documentation for details
3854 about the former. For the latter, pass <ulink
3855 url="https://www.dmtf.org/standards/smbios">DMI/SMBIOS</ulink> OEM string table entries (field type
3856 11) with a prefix of <literal>io.systemd.credential:</literal> or
3857 <literal>io.systemd.credential.binary:</literal>. In both cases a key/value pair separated by
3858 <literal>=</literal> is expected. In the latter case, the right-hand side is Base64 decoded when
3859 parsed (thus permitting binary data to be passed in). Example <ulink
3860 url="https://www.qemu.org/docs/master/system/index.html">qemu</ulink> switch: <literal>-smbios
3861 type=11,value=io.systemd.credential:xx=yy</literal>, or <literal>-smbios
3862 type=11,value=io.systemd.credential.binary:rick=TmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXA=</literal>. Alternatively,
3863 use the <command>qemu</command> <literal>fw_cfg</literal> node
3864 <literal>opt/io.systemd.credentials/</literal>. Example <command>qemu</command> switch:
3865 <literal>-fw_cfg name=opt/io.systemd.credentials/mycred,string=supersecret</literal>. They may also
3866 be passed from the UEFI firmware environment via
3867 <citerefentry><refentrytitle>systemd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
3868 from the initrd (see
3869 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>), or be
3870 specified on the kernel command line using the <literal>systemd.set_credential=</literal> and
3871 <literal>systemd.set_credential_binary=</literal> switches (see
3872 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> – this is
3873 not recommended since unprivileged userspace can read the kernel command line). </para>
3874
3875 <para>If referencing an <constant>AF_UNIX</constant> stream socket to connect to, the connection will
3876 originate from an abstract namespace socket, that includes information about the unit and the
3877 credential ID in its socket name. Use <citerefentry
3878 project='man-pages'><refentrytitle>getpeername</refentrytitle><manvolnum>2</manvolnum></citerefentry>
3879 to query this information. The returned socket name is formatted as <constant>NUL</constant>
3880 <replaceable>RANDOM</replaceable> <literal>/unit/</literal> <replaceable>UNIT</replaceable>
3881 <literal>/</literal> <replaceable>ID</replaceable>, i.e. a <constant>NUL</constant> byte (as required
3882 for abstract namespace socket names), followed by a random string (consisting of alphadecimal
3883 characters), followed by the literal string <literal>/unit/</literal>, followed by the requesting
3884 unit name, followed by the literal character <literal>/</literal>, followed by the textual credential
3885 ID requested. Example: <literal>\0adf9d86b6eda275e/unit/foobar.service/credx</literal> in case the
3886 credential <literal>credx</literal> is requested for a unit <literal>foobar.service</literal>. This
3887 functionality is useful for using a single listening socket to serve credentials to multiple
3888 consumers.</para>
3889
3890 <para>For further information see <ulink url="https://systemd.io/CREDENTIALS">System and Service
3891 Credentials</ulink> documentation.</para>
3892
3893 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
3894 </varlistentry>
3895
3896 <varlistentry>
3897 <term><varname>ImportCredential=</varname><replaceable>GLOB</replaceable></term>
3898
3899 <listitem><para>Pass one or more credentials to the unit. Takes a credential name for which we will
3900 attempt to find a credential that the service manager itself received under the specified name —
3901 which may be used to propagate credentials from an invoking environment (e.g. a container manager
3902 that invoked the service manager) into a service. If the credential name is a glob, all credentials
3903 matching the glob are passed to the unit. Matching credentials are searched for in the system
3904 credentials, the encrypted system credentials, and under <filename>/etc/credstore/</filename>,
3905 <filename>/run/credstore/</filename>, <filename>/usr/lib/credstore/</filename>,
3906 <filename>/run/credstore.encrypted/</filename>, <filename>/etc/credstore.encrypted/</filename>, and
3907 <filename>/usr/lib/credstore.encrypted/</filename> in that order. When multiple credentials of the
3908 same name are found, the first one found is used.</para>
3909
3910 <para>The globbing expression implements a restrictive subset of <citerefentry
3911 project='man-pages'><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>: only
3912 a single trailing <literal>*</literal> wildcard may be specified. Both <literal>?</literal> and
3913 <literal>[]</literal> wildcards are not permitted, nor are <literal>*</literal> wildcards anywhere
3914 except at the end of the glob expression.</para>
3915
3916 <para>Optionally, the credential name or glob may be followed by a colon followed by a rename pattern.
3917 If specified, all credentials matching the credential name or glob are renamed according to the given
3918 pattern. For example, if <literal>ImportCredential=my.original.cred:my.renamed.cred</literal> is
3919 specified, the service manager will read the <literal>my.original.cred</literal> credential and make
3920 it available as the <literal>my.renamed.cred</literal> credential to the service. Similarly, if
3921 <literal>ImportCredential=my.original.*:my.renamed.</literal> is specified, the service manager will
3922 read all credentials starting with <literal>my.original.</literal> and make them available as
3923 <literal>my.renamed.xxx</literal> to the service.</para>
3924
3925 <para>If <varname>ImportCredential=</varname> is specified multiple times and multiple credentials
3926 end up with the same name after renaming, the first one is kept and later ones are dropped.</para>
3927
3928 <para>When multiple credentials of the same name are found, credentials found by
3929 <varname>LoadCredential=</varname> and <varname>LoadCredentialEncrypted=</varname> take priority over
3930 credentials found by <varname>ImportCredential=</varname>.</para>
3931
3932 <para>Note that if decryption or authentication of a credential picked up as result of
3933 <varname>ImportCredential=</varname> fails it will be skipped gracefully (a warning is generated, but
3934 the credential will not be made available to the invoked service). This is different for those
3935 configured via
3936 <varname>SetCredentialEncrypted=</varname>/<varname>LoadCredentialEncrypted=</varname>, where failed
3937 decryption/authentication will result in service failure.</para>
3938
3939 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
3940 </varlistentry>
3941
3942 <varlistentry>
3943 <term><varname>SetCredential=</varname><replaceable>ID</replaceable>:<replaceable>VALUE</replaceable></term>
3944 <term><varname>SetCredentialEncrypted=</varname><replaceable>ID</replaceable>:<replaceable>VALUE</replaceable></term>
3945
3946 <listitem><para>The <varname>SetCredential=</varname> setting is similar to
3947 <varname>LoadCredential=</varname> but accepts a literal value to use as data for the credential,
3948 instead of a file system path to read the data from. Do not use this option for data that is supposed
3949 to be secret, as it is accessible to unprivileged processes via IPC. It's only safe to use this for
3950 user IDs, public key material and similar non-sensitive data. For everything else use
3951 <varname>LoadCredential=</varname>. In order to embed binary data into the credential data use
3952 C-style escaping (i.e. <literal>\n</literal> to embed a newline, or <literal>\x00</literal> to embed
3953 a <constant>NUL</constant> byte).</para>
3954
3955 <para>The <varname>SetCredentialEncrypted=</varname> setting is identical to
3956 <varname>SetCredential=</varname> but expects an encrypted credential in literal form as value. This
3957 allows embedding confidential credentials securely directly in unit files. Use
3958 <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>'
3959 <option>-p</option> switch to generate suitable <varname>SetCredentialEncrypted=</varname> lines
3960 directly from plaintext credentials. For further details see
3961 <varname>LoadCredentialEncrypted=</varname> above.</para>
3962
3963 <para>When multiple credentials of the same name are found, credentials found by
3964 <varname>LoadCredential=</varname>, <varname>LoadCredentialEncrypted=</varname> and
3965 <varname>ImportCredential=</varname> take priority over credentials found by
3966 <varname>SetCredential=</varname>. As such, <varname>SetCredential=</varname> will act as default if
3967 no credentials are found by any of the former. In this case, not being able to retrieve the credential
3968 from the path specified in <varname>LoadCredential=</varname> or
3969 <varname>LoadCredentialEncrypted=</varname> is not considered fatal.</para>
3970
3971 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
3972 </varlistentry>
3973 </variablelist>
3974 </refsect1>
3975
3976 <refsect1>
3977 <title>System V Compatibility</title>
3978 <variablelist class='unit-directives'>
3979
3980 <varlistentry>
3981 <term><varname>UtmpIdentifier=</varname></term>
3982
3983 <listitem><para>Takes a four character identifier string for an <citerefentry
3984 project='man-pages'><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry> and wtmp entry
3985 for this service. This should only be set for services such as <command>getty</command> implementations (such
3986 as <citerefentry
3987 project='die-net'><refentrytitle>agetty</refentrytitle><manvolnum>8</manvolnum></citerefentry>) where utmp/wtmp
3988 entries must be created and cleared before and after execution, or for services that shall be executed as if
3989 they were run by a <command>getty</command> process (see below). If the configured string is longer than four
3990 characters, it is truncated and the terminal four characters are used. This setting interprets %I style string
3991 replacements. This setting is unset by default, i.e. no utmp/wtmp entries are created or cleaned up for this
3992 service.</para></listitem>
3993 </varlistentry>
3994
3995 <varlistentry>
3996 <term><varname>UtmpMode=</varname></term>
3997
3998 <listitem><para>Takes one of <literal>init</literal>, <literal>login</literal> or <literal>user</literal>. If
3999 <varname>UtmpIdentifier=</varname> is set, controls which type of <citerefentry
4000 project='man-pages'><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry>/wtmp entries
4001 for this service are generated. This setting has no effect unless <varname>UtmpIdentifier=</varname> is set
4002 too. If <literal>init</literal> is set, only an <constant>INIT_PROCESS</constant> entry is generated and the
4003 invoked process must implement a <command>getty</command>-compatible utmp/wtmp logic. If
4004 <literal>login</literal> is set, first an <constant>INIT_PROCESS</constant> entry, followed by a
4005 <constant>LOGIN_PROCESS</constant> entry is generated. In this case, the invoked process must implement a
4006 <citerefentry
4007 project='die-net'><refentrytitle>login</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible
4008 utmp/wtmp logic. If <literal>user</literal> is set, first an <constant>INIT_PROCESS</constant> entry, then a
4009 <constant>LOGIN_PROCESS</constant> entry and finally a <constant>USER_PROCESS</constant> entry is
4010 generated. In this case, the invoked process may be any process that is suitable to be run as session
4011 leader. Defaults to <literal>init</literal>.</para>
4012
4013 <xi:include href="version-info.xml" xpointer="v225"/></listitem>
4014 </varlistentry>
4015
4016 </variablelist>
4017 </refsect1>
4018
4019 <refsect1>
4020 <title>Environment Variables in Spawned Processes</title>
4021
4022 <para>Processes started by the service manager are executed with an environment variable block assembled from
4023 multiple sources. Processes started by the system service manager generally do not inherit environment variables
4024 set for the service manager itself (but this may be altered via <varname>PassEnvironment=</varname>), but processes
4025 started by the user service manager instances generally do inherit all environment variables set for the service
4026 manager itself.</para>
4027
4028 <para>For each invoked process the list of environment variables set is compiled from the following sources:</para>
4029
4030 <itemizedlist>
4031 <listitem><para>Variables globally configured for the service manager, using the
4032 <varname>DefaultEnvironment=</varname> setting in
4033 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
4034 the kernel command line option <varname>systemd.setenv=</varname> understood by
4035 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, or via
4036 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
4037 <command>set-environment</command> verb.</para></listitem>
4038
4039 <listitem><para>Variables defined by the service manager itself (see the list below).</para></listitem>
4040
4041 <listitem><para>Variables set in the service manager's own environment variable block (subject to
4042 <varname>PassEnvironment=</varname> for the system service manager).</para></listitem>
4043
4044 <listitem><para>Variables set via <varname>Environment=</varname> in the unit file.</para></listitem>
4045
4046 <listitem><para>Variables read from files specified via <varname>EnvironmentFile=</varname> in the unit
4047 file.</para></listitem>
4048
4049 <listitem><para>Variables set by any PAM modules in case <varname>PAMName=</varname> is in effect,
4050 cf. <citerefentry
4051 project='man-pages'><refentrytitle>pam_env</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
4052 </para></listitem>
4053 </itemizedlist>
4054
4055 <para>If the same environment variable is set by multiple of these sources, the later source — according
4056 to the order of the list above — wins. Note that as the final step all variables listed in
4057 <varname>UnsetEnvironment=</varname> are removed from the compiled environment variable list, immediately
4058 before it is passed to the executed process.</para>
4059
4060 <para>The general philosophy is to expose a small curated list of environment variables to processes.
4061 Services started by the system manager (PID 1) will be started, without additional service-specific
4062 configuration, with just a few environment variables. The user manager inherits environment variables as
4063 any other system service, but in addition may receive additional environment variables from PAM, and,
4064 typically, additional imported variables when the user starts a graphical session. It is recommended to
4065 keep the environment blocks in both the system and user managers lean. Importing all variables
4066 inherited by the graphical session or by one of the user shells is strongly discouraged.</para>
4067
4068 <para>Hint: <command>systemd-run -P env</command> and <command>systemd-run --user -P env</command> print
4069 the effective system and user service environment blocks.</para>
4070
4071 <refsect2>
4072 <title>Environment Variables Set or Propagated by the Service Manager</title>
4073
4074 <para>The following environment variables are propagated by the service manager or generated internally
4075 for each invoked process:</para>
4076
4077 <variablelist class='environment-variables'>
4078 <varlistentry>
4079 <term><varname>$PATH</varname></term>
4080
4081 <listitem><para>Colon-separated list of directories to use when launching
4082 executables. <command>systemd</command> uses a fixed value of
4083 <literal><filename>/usr/local/sbin</filename>:<filename>/usr/local/bin</filename>:<filename>/usr/sbin</filename>:<filename>/usr/bin</filename></literal>
4084 in the system manager. In case of the user manager, a different path may be configured by the
4085 distribution. It is recommended to not rely on the order of entries, and have only one program
4086 with a given name in <varname>$PATH</varname>.</para>
4087
4088 <xi:include href="version-info.xml" xpointer="v208"/></listitem>
4089 </varlistentry>
4090
4091 <varlistentry>
4092 <term><varname>$LANG</varname></term>
4093
4094 <listitem><para>Locale. Can be set in <citerefentry
4095 project='man-pages'><refentrytitle>locale.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
4096 or on the kernel command line (see
4097 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> and
4098 <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
4099 </para>
4100
4101 <xi:include href="version-info.xml" xpointer="v208"/></listitem>
4102 </varlistentry>
4103
4104 <varlistentry>
4105 <term><varname>$USER</varname></term>
4106 <term><varname>$LOGNAME</varname></term>
4107 <term><varname>$HOME</varname></term>
4108 <term><varname>$SHELL</varname></term>
4109
4110 <listitem><para>User name (twice), home directory, and the login shell. <varname>$USER</varname> is
4111 set unconditionally, while <varname>$HOME</varname>, <varname>$LOGNAME</varname>, and <varname>$SHELL</varname>
4112 are only set for the units that have <varname>User=</varname> set and <varname>SetLoginEnvironment=</varname>
4113 unset or set to true. For user services, these variables are typically inherited from the user manager itself. See
4114 <citerefentry project='die-net'><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
4115 </para>
4116
4117 <xi:include href="version-info.xml" xpointer="v208"/></listitem>
4118 </varlistentry>
4119
4120 <varlistentry>
4121 <term><varname>$INVOCATION_ID</varname></term>
4122
4123 <listitem><para>Contains a randomized, unique 128-bit ID identifying each runtime cycle of the unit, formatted
4124 as 32 character hexadecimal string. A new ID is assigned each time the unit changes from an inactive state into
4125 an activating or active state, and may be used to identify this specific runtime cycle, in particular in data
4126 stored offline, such as the journal. The same ID is passed to all processes run as part of the
4127 unit.</para>
4128
4129 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
4130 </varlistentry>
4131
4132 <varlistentry>
4133 <term><varname>$XDG_RUNTIME_DIR</varname></term>
4134
4135 <listitem><para>The directory to use for runtime objects (such as IPC objects) and volatile state. Set for all
4136 services run by the user <command>systemd</command> instance, as well as any system services that use
4137 <varname>PAMName=</varname> with a PAM stack that includes <command>pam_systemd</command>. See below and
4138 <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry> for more
4139 information.</para>
4140
4141 <xi:include href="version-info.xml" xpointer="v208"/></listitem>
4142 </varlistentry>
4143
4144 <varlistentry>
4145 <term><varname>$RUNTIME_DIRECTORY</varname></term>
4146 <term><varname>$STATE_DIRECTORY</varname></term>
4147 <term><varname>$CACHE_DIRECTORY</varname></term>
4148 <term><varname>$LOGS_DIRECTORY</varname></term>
4149 <term><varname>$CONFIGURATION_DIRECTORY</varname></term>
4150
4151 <listitem><para>Absolute paths to the directories defined with
4152 <varname>RuntimeDirectory=</varname>, <varname>StateDirectory=</varname>,
4153 <varname>CacheDirectory=</varname>, <varname>LogsDirectory=</varname>, and
4154 <varname>ConfigurationDirectory=</varname> when those settings are used.</para>
4155
4156 <xi:include href="version-info.xml" xpointer="v244"/>
4157 </listitem>
4158 </varlistentry>
4159
4160 <varlistentry>
4161 <term><varname>$CREDENTIALS_DIRECTORY</varname></term>
4162
4163 <listitem><para>An absolute path to the per-unit directory with credentials configured via
4164 <varname>ImportCredential=</varname>/<varname>LoadCredential=</varname>/<varname>SetCredential=</varname>.
4165 The directory is marked read-only and is placed in unswappable memory (if supported and permitted),
4166 and is only accessible to the UID associated with the unit via <varname>User=</varname> or
4167 <varname>DynamicUser=</varname> (and the superuser).</para>
4168
4169 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
4170 </varlistentry>
4171
4172 <varlistentry>
4173 <term><varname>$TMPDIR</varname></term>
4174
4175 <listitem><para>The environment variable is set to <literal>/tmp</literal> when
4176 <varname>PrivateTmp=disconnected</varname> specified with <varname>DefaultDependencies=no</varname>
4177 and without <varname>RootDirectory=/RootImage=</varname> and
4178 <varname>RequiresMountsFor=/WantsMountsFor=</varname> for <filename>/var/</filename>.
4179 See explanation for <varname>PrivateTmp=</varname> above.</para>
4180
4181 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
4182 </varlistentry>
4183
4184 <varlistentry>
4185 <term><varname>$MAINPID</varname></term>
4186
4187 <listitem><para>The UNIX process ID (PID) of the unit's main process if it is known. This is only
4188 set for control processes as invoked by <varname>ExecReload=</varname> and similar.</para>
4189
4190 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
4191 </varlistentry>
4192
4193 <varlistentry>
4194 <term><varname>$MAINPIDFDID</varname></term>
4195
4196 <listitem><para>The 64bit inode ID of the file descriptor returned by <citerefentry
4197 project='man-pages'><refentrytitle>pidfd_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>
4198 for the main process (if supported). This is only set for control processes as invoked by
4199 <varname>ExecReload=</varname> and similar.</para>
4200
4201 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
4202 </varlistentry>
4203
4204 <varlistentry>
4205 <term><varname>$MANAGERPID</varname></term>
4206
4207 <listitem><para>The PID of the per-user <command>systemd</command> service manager instance, set
4208 for processes spawned by it.</para>
4209 <xi:include href="version-info.xml" xpointer="v208"/></listitem>
4210 </varlistentry>
4211
4212 <varlistentry>
4213 <term><varname>$MANAGERPIDFDID</varname></term>
4214
4215 <listitem><para>The <function>pidfd_open()</function> inode ID (see above) of the per-user
4216 <command>systemd</command> service manager instance, set for processes spawned by it.</para>
4217
4218 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
4219 </varlistentry>
4220
4221 <varlistentry>
4222 <term><varname>$LISTEN_FDS</varname></term>
4223 <term><varname>$LISTEN_PID</varname></term>
4224 <term><varname>$LISTEN_PIDFDID</varname></term>
4225 <term><varname>$LISTEN_FDNAMES</varname></term>
4226
4227 <listitem><para>Information about file descriptors passed to a
4228 service for socket activation. See
4229 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
4230 </para>
4231
4232 <xi:include href="version-info.xml" xpointer="v208"/></listitem>
4233 </varlistentry>
4234
4235 <varlistentry>
4236 <term><varname>$NOTIFY_SOCKET</varname></term>
4237
4238 <listitem><para>The socket <function>sd_notify()</function> talks to. See
4239 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
4240 </para>
4241
4242 <xi:include href="version-info.xml" xpointer="v229"/></listitem>
4243 </varlistentry>
4244
4245 <varlistentry>
4246 <term><varname>$WATCHDOG_PID</varname></term>
4247 <term><varname>$WATCHDOG_USEC</varname></term>
4248
4249 <listitem><para>Information about watchdog keep-alive notifications. See
4250 <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
4251 </para>
4252
4253 <xi:include href="version-info.xml" xpointer="v229"/></listitem>
4254 </varlistentry>
4255
4256 <varlistentry>
4257 <term><varname>$SYSTEMD_EXEC_PID</varname></term>
4258
4259 <listitem><para>The PID of the unit process (e.g. process invoked by
4260 <varname>ExecStart=</varname>). The child process can use this information to determine
4261 whether the process is directly invoked by the service manager or indirectly as a child of
4262 another process by comparing this value with the current PID (similarly to the scheme used in
4263 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>
4264 with <varname>$LISTEN_PID</varname> and <varname>$LISTEN_FDS</varname>).</para>
4265
4266 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
4267 </varlistentry>
4268
4269 <varlistentry>
4270 <term><varname>$TERM</varname></term>
4271
4272 <listitem><para>Terminal type, set only for units connected to
4273 a terminal (<varname>StandardInput=tty</varname>,
4274 <varname>StandardOutput=tty</varname>, or
4275 <varname>StandardError=tty</varname>). See
4276 <citerefentry project='man-pages'><refentrytitle>termcap</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
4277 </para>
4278
4279 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
4280 </varlistentry>
4281
4282 <varlistentry>
4283 <term><varname>$LOG_NAMESPACE</varname></term>
4284
4285 <listitem><para>Contains the name of the selected logging namespace when the
4286 <varname>LogNamespace=</varname> service setting is used.</para>
4287
4288 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
4289 </varlistentry>
4290
4291 <varlistentry>
4292 <term><varname>$JOURNAL_STREAM</varname></term>
4293
4294 <listitem><para>If the standard output or standard error output of the executed processes are connected to the
4295 journal (for example, by setting <varname>StandardError=journal</varname>) <varname>$JOURNAL_STREAM</varname>
4296 contains the device and inode numbers of the connection file descriptor, formatted in decimal, separated by a
4297 colon (<literal>:</literal>). This permits invoked processes to safely detect whether their standard output or
4298 standard error output are connected to the journal. The device and inode numbers of the file descriptors should
4299 be compared with the values set in the environment variable to determine whether the process output is still
4300 connected to the journal. Note that it is generally not sufficient to only check whether
4301 <varname>$JOURNAL_STREAM</varname> is set at all as services might invoke external processes replacing their
4302 standard output or standard error output, without unsetting the environment variable.</para>
4303
4304 <para>If both standard output and standard error of the executed processes are connected to the journal via a
4305 stream socket, this environment variable will contain information about the standard error stream, as that's
4306 usually the preferred destination for log data. (Note that typically the same stream is used for both standard
4307 output and standard error, hence very likely the environment variable contains device and inode information
4308 matching both stream file descriptors.)</para>
4309
4310 <para>This environment variable is primarily useful to allow services to optionally upgrade their used log
4311 protocol to the native journal protocol (using
4312 <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry> and other
4313 functions) if their standard output or standard error output is connected to the journal anyway, thus enabling
4314 delivery of structured metadata along with logged messages.</para>
4315
4316 <xi:include href="version-info.xml" xpointer="v231"/></listitem>
4317 </varlistentry>
4318
4319 <varlistentry>
4320 <term><varname>$SERVICE_RESULT</varname></term>
4321
4322 <listitem><para>Only used for the service unit type. This environment variable is passed to all
4323 <varname>ExecStop=</varname> and <varname>ExecStopPost=</varname> processes, and encodes the service
4324 "result". Currently, the following values are defined:</para>
4325
4326 <table>
4327 <title>Defined <varname>$SERVICE_RESULT</varname> values</title>
4328 <tgroup cols='2'>
4329 <colspec colname='result'/>
4330 <colspec colname='meaning'/>
4331 <thead>
4332 <row>
4333 <entry>Value</entry>
4334 <entry>Meaning</entry>
4335 </row>
4336 </thead>
4337
4338 <tbody>
4339 <row>
4340 <entry><literal>success</literal></entry>
4341 <entry>The service ran successfully and exited cleanly.</entry>
4342 </row>
4343 <row>
4344 <entry><literal>protocol</literal></entry>
4345 <entry>A protocol violation occurred: the service did not take the steps required by its unit configuration (specifically what is configured in its <varname>Type=</varname> setting).</entry>
4346 </row>
4347 <row>
4348 <entry><literal>timeout</literal></entry>
4349 <entry>One of the steps timed out.</entry>
4350 </row>
4351 <row>
4352 <entry><literal>exit-code</literal></entry>
4353 <entry>Service process exited with a non-zero exit code; see <varname>$EXIT_CODE</varname> below for the actual exit code returned.</entry>
4354 </row>
4355 <row>
4356 <entry><literal>signal</literal></entry>
4357 <entry>A service process was terminated abnormally by a signal, without dumping core. See <varname>$EXIT_CODE</varname> below for the actual signal causing the termination.</entry>
4358 </row>
4359 <row>
4360 <entry><literal>core-dump</literal></entry>
4361 <entry>A service process terminated abnormally with a signal and dumped core. See <varname>$EXIT_CODE</varname> below for the signal causing the termination.</entry>
4362 </row>
4363 <row>
4364 <entry><literal>watchdog</literal></entry>
4365 <entry>Watchdog keep-alive ping was enabled for the service, but the deadline was missed.</entry>
4366 </row>
4367 <row>
4368 <entry><literal>exec-condition</literal></entry>
4369 <entry>Service did not run because <varname>ExecCondition=</varname> failed (that is its command exited with an exit status of 1 through 254 (inclusive)).</entry>
4370 </row>
4371 <row>
4372 <entry><literal>oom-kill</literal></entry>
4373 <entry>A service process was terminated by the Out-Of-Memory (OOM) killer.</entry>
4374 </row>
4375 <row>
4376 <entry><literal>start-limit-hit</literal></entry>
4377 <entry>A start limit was defined for the unit and it was hit, causing the unit to fail to start. See <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>'s <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> for details.</entry>
4378 </row>
4379 <row>
4380 <entry><literal>resources</literal></entry>
4381 <entry>A catch-all condition in case a system operation failed.</entry>
4382 </row>
4383 </tbody>
4384 </tgroup>
4385 </table>
4386
4387 <para>This environment variable is useful to monitor failure or successful termination of a service. Even
4388 though this variable is available in both <varname>ExecStop=</varname> and <varname>ExecStopPost=</varname>, it
4389 is usually a better choice to place monitoring tools in the latter, as the former is only invoked for services
4390 that managed to start up correctly, and the latter covers both services that failed during their start-up and
4391 those which failed during their runtime.</para>
4392
4393 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
4394 </varlistentry>
4395
4396 <varlistentry>
4397 <term><varname>$EXIT_CODE</varname></term>
4398 <term><varname>$EXIT_STATUS</varname></term>
4399
4400 <listitem><para>Only defined for the service unit type. These environment variables are passed to all
4401 <varname>ExecStop=</varname>, <varname>ExecStopPost=</varname> processes and contain exit status/code
4402 information of the main process of the service. For the precise definition of the exit code and status, see
4403 <citerefentry><refentrytitle>wait</refentrytitle><manvolnum>2</manvolnum></citerefentry>. <varname>$EXIT_CODE</varname>
4404 is one of <literal>exited</literal>, <literal>killed</literal>,
4405 <literal>dumped</literal>. <varname>$EXIT_STATUS</varname> contains the numeric exit code formatted as string
4406 if <varname>$EXIT_CODE</varname> is <literal>exited</literal>, and the signal name in all other cases. Note
4407 that these environment variables are only set if the service manager succeeded to start and identify the main
4408 process of the service.</para>
4409
4410 <table>
4411 <title>Summary of possible service result variable values</title>
4412 <tgroup cols='3'>
4413 <colspec colname='result' />
4414 <colspec colname='code' />
4415 <colspec colname='status' />
4416 <thead>
4417 <row>
4418 <entry><varname>$SERVICE_RESULT</varname></entry>
4419 <entry><varname>$EXIT_CODE</varname></entry>
4420 <entry><varname>$EXIT_STATUS</varname></entry>
4421 </row>
4422 </thead>
4423
4424 <tbody>
4425 <row>
4426 <entry morerows="1" valign="top"><literal>success</literal></entry>
4427 <entry valign="top"><literal>killed</literal></entry>
4428 <entry><literal>HUP</literal>, <literal>INT</literal>, <literal>TERM</literal>, <literal>PIPE</literal></entry>
4429 </row>
4430 <row>
4431 <entry valign="top"><literal>exited</literal></entry>
4432 <entry><literal>0</literal></entry>
4433 </row>
4434 <row>
4435 <entry morerows="1" valign="top"><literal>protocol</literal></entry>
4436 <entry valign="top">not set</entry>
4437 <entry>not set</entry>
4438 </row>
4439 <row>
4440 <entry><literal>exited</literal></entry>
4441 <entry><literal>0</literal></entry>
4442 </row>
4443 <row>
4444 <entry morerows="1" valign="top"><literal>timeout</literal></entry>
4445 <entry valign="top"><literal>killed</literal></entry>
4446 <entry><literal>TERM</literal>, <literal>KILL</literal></entry>
4447 </row>
4448 <row>
4449 <entry valign="top"><literal>exited</literal></entry>
4450 <entry><literal>0</literal>, <literal>1</literal>, <literal>2</literal>, <literal
4451 >3</literal>, …, <literal>255</literal></entry>
4452 </row>
4453 <row>
4454 <entry valign="top"><literal>exit-code</literal></entry>
4455 <entry valign="top"><literal>exited</literal></entry>
4456 <entry><literal>1</literal>, <literal>2</literal>, <literal
4457 >3</literal>, …, <literal>255</literal></entry>
4458 </row>
4459 <row>
4460 <entry valign="top"><literal>signal</literal></entry>
4461 <entry valign="top"><literal>killed</literal></entry>
4462 <entry><literal>HUP</literal>, <literal>INT</literal>, <literal>KILL</literal>, …</entry>
4463 </row>
4464 <row>
4465 <entry valign="top"><literal>core-dump</literal></entry>
4466 <entry valign="top"><literal>dumped</literal></entry>
4467 <entry><literal>ABRT</literal>, <literal>SEGV</literal>, <literal>QUIT</literal>, …</entry>
4468 </row>
4469 <row>
4470 <entry morerows="2" valign="top"><literal>watchdog</literal></entry>
4471 <entry><literal>dumped</literal></entry>
4472 <entry><literal>ABRT</literal></entry>
4473 </row>
4474 <row>
4475 <entry><literal>killed</literal></entry>
4476 <entry><literal>TERM</literal>, <literal>KILL</literal></entry>
4477 </row>
4478 <row>
4479 <entry><literal>exited</literal></entry>
4480 <entry><literal>0</literal>, <literal>1</literal>, <literal>2</literal>, <literal
4481 >3</literal>, …, <literal>255</literal></entry>
4482 </row>
4483 <row>
4484 <entry valign="top"><literal>exec-condition</literal></entry>
4485 <entry><literal>exited</literal></entry>
4486 <entry><literal>1</literal>, <literal>2</literal>, <literal>3</literal>, <literal
4487 >4</literal>, …, <literal>254</literal></entry>
4488 </row>
4489 <row>
4490 <entry valign="top"><literal>oom-kill</literal></entry>
4491 <entry valign="top"><literal>killed</literal></entry>
4492 <entry><literal>TERM</literal>, <literal>KILL</literal></entry>
4493 </row>
4494 <row>
4495 <entry><literal>start-limit-hit</literal></entry>
4496 <entry>not set</entry>
4497 <entry>not set</entry>
4498 </row>
4499 <row>
4500 <entry><literal>resources</literal></entry>
4501 <entry>any of the above</entry>
4502 <entry>any of the above</entry>
4503 </row>
4504 <row>
4505 <entry namest="results" nameend="status">Note: the process may be also terminated by a signal not sent by systemd. In particular the process may send an arbitrary signal to itself in a handler for any of the non-maskable signals. Nevertheless, in the <literal>timeout</literal> and <literal>watchdog</literal> rows above only the signals that systemd sends have been included. Moreover, using <varname>SuccessExitStatus=</varname> additional exit statuses may be declared to indicate clean termination, which is not reflected by this table.</entry>
4506 </row>
4507 </tbody>
4508 </tgroup>
4509 </table>
4510
4511 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
4512 </varlistentry>
4513
4514 <varlistentry>
4515 <term><varname>$MONITOR_SERVICE_RESULT</varname></term>
4516 <term><varname>$MONITOR_EXIT_CODE</varname></term>
4517 <term><varname>$MONITOR_EXIT_STATUS</varname></term>
4518 <term><varname>$MONITOR_INVOCATION_ID</varname></term>
4519 <term><varname>$MONITOR_UNIT</varname></term>
4520
4521 <listitem><para>Only defined for the service unit type. Those environment variables are passed to
4522 all <varname>ExecStart=</varname> and <varname>ExecStartPre=</varname> processes which run in
4523 services triggered by <varname>OnFailure=</varname> or <varname>OnSuccess=</varname> dependencies.
4524 </para>
4525
4526 <para>Variables <varname>$MONITOR_SERVICE_RESULT</varname>, <varname>$MONITOR_EXIT_CODE</varname>
4527 and <varname>$MONITOR_EXIT_STATUS</varname> take the same values as for
4528 <varname>ExecStop=</varname> and <varname>ExecStopPost=</varname> processes. Variables
4529 <varname>$MONITOR_INVOCATION_ID</varname> and <varname>$MONITOR_UNIT</varname> are set to the
4530 invocation id and unit name of the service which triggered the dependency.</para>
4531
4532 <para>Note that when multiple services specify the same unit as their
4533 <varname>OnFailure=</varname> or <varname>OnSuccess=</varname> handler, those variables will
4534 <emphasis>not</emphasis> be passed. Consider using a template handler unit for that case instead:
4535 <literal>OnFailure=<replaceable>handler</replaceable>@%n.service</literal> for non-templated units,
4536 or <literal>OnFailure=<replaceable>handler</replaceable>@%p-%i.service</literal> for templated
4537 units.</para>
4538
4539 <xi:include href="version-info.xml" xpointer="v251"/></listitem>
4540 </varlistentry>
4541
4542 <varlistentry>
4543 <term><varname>$PIDFILE</varname></term>
4544
4545 <listitem><para>The path to the configured PID file, in case the process is forked off on behalf of
4546 a service that uses the <varname>PIDFile=</varname> setting, see
4547 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
4548 for details. Service code may use this environment variable to automatically generate a PID file at
4549 the location configured in the unit file. This field is set to an absolute path in the file
4550 system.</para>
4551
4552 <xi:include href="version-info.xml" xpointer="v242"/></listitem>
4553 </varlistentry>
4554
4555 <varlistentry>
4556 <term><varname>$REMOTE_ADDR</varname></term>
4557 <term><varname>$REMOTE_PORT</varname></term>
4558
4559 <listitem><para>If this is a unit started via per-connection socket activation (i.e. via a socket
4560 unit with <varname>Accept=yes</varname>), these environment variables contain information about the
4561 remote peer of the socket connection.</para>
4562
4563 <para>For IPv4 and IPv6 connections, <varname>$REMOTE_ADDR</varname> contains the IP address, and
4564 <varname>$REMOTE_PORT</varname> contains the port number of the remote peer.</para>
4565
4566 <para>For <constant>AF_UNIX</constant> socket connections, <varname>$REMOTE_ADDR</varname> contains
4567 either the remote socket's file system path starting with a slash (<literal>/</literal>), its
4568 address in the abstract namespace starting with an at symbol (<literal>@</literal>), or is unset
4569 in case of an unnamed socket. <varname>$REMOTE_PORT</varname> is not set for <constant>AF_UNIX</constant>
4570 sockets.</para>
4571
4572 <xi:include href="version-info.xml" xpointer="v220"/></listitem>
4573 </varlistentry>
4574
4575 <varlistentry>
4576 <term><varname>$SO_COOKIE</varname></term>
4577
4578 <listitem><para>If this is a unit started via per-connection socket activation (i.e. via a socket
4579 unit with <varname>Accept=yes</varname>), this environment variable contains the Linux socket
4580 cookie, formatted as decimal integer. The socket cookie can otherwise be acquired via <citerefentry
4581 project='man-pages'><refentrytitle>getsockopt</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
4582
4583 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
4584 </varlistentry>
4585
4586 <varlistentry>
4587 <term><varname>$TRIGGER_UNIT</varname></term>
4588 <term><varname>$TRIGGER_PATH</varname></term>
4589 <term><varname>$TRIGGER_TIMER_REALTIME_USEC</varname></term>
4590 <term><varname>$TRIGGER_TIMER_MONOTONIC_USEC</varname></term>
4591
4592 <listitem><para>If the unit was activated dynamically (e.g.: a corresponding path unit or timer unit), the
4593 unit that triggered it and other type-dependent information will be passed via these variables. Note that
4594 this information is provided in a best-effort way. For example, multiple triggers happening one after
4595 another will be coalesced and only one will be reported, with no guarantee as to which one it will be.
4596 Because of this, in most cases this variable will be primarily informational, i.e. useful for debugging
4597 purposes, is lossy, and should not be relied upon to propagate a comprehensive reason for activation.
4598 </para>
4599
4600 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
4601 </varlistentry>
4602
4603 <varlistentry>
4604 <term><varname>$MEMORY_PRESSURE_WATCH</varname></term>
4605 <term><varname>$MEMORY_PRESSURE_WRITE</varname></term>
4606
4607 <listitem><para>If memory pressure monitoring is enabled for this service unit, the path to watch
4608 and the data to write into it. See <ulink url="https://systemd.io/MEMORY_PRESSURE">Memory Pressure
4609 Handling</ulink> for details about these variables and the service protocol data they
4610 convey.</para>
4611
4612 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
4613 </varlistentry>
4614
4615 <varlistentry>
4616 <term><varname>$FDSTORE</varname></term>
4617
4618 <listitem><para>The maximum number of file descriptors that may be stored in the manager for the
4619 service. This variable is set when the file descriptor store is enabled for the service, i.e.
4620 <varname>FileDescriptorStoreMax=</varname> is set to a non-zero value (see
4621 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
4622 for details). Applications may check this environment variable before sending file descriptors to
4623 the service manager via
4624 <citerefentry><refentrytitle>sd_pid_notify_with_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
4625 </para>
4626
4627 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
4628 </varlistentry>
4629
4630 <varlistentry>
4631 <term><varname>$DEBUG_INVOCATION</varname></term>
4632
4633 <listitem><para>If <varname>RestartMode=debug</varname> is set, and a previous attempt at starting
4634 the unit failed, this variable will be passed to the service to indicate that additional logging
4635 should be enabled at startup. See
4636 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
4637 for more details.</para>
4638
4639 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
4640 </varlistentry>
4641
4642 </variablelist>
4643
4644 <para>For system services, when <varname>PAMName=</varname> is enabled and <command>pam_systemd</command> is part
4645 of the selected PAM stack, additional environment variables defined by systemd may be set for
4646 services. Specifically, these are <varname>$XDG_SEAT</varname>, <varname>$XDG_VTNR</varname>, see
4647 <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry> for details.</para>
4648 </refsect2>
4649
4650 </refsect1>
4651
4652 <refsect1>
4653 <title>Process Exit Codes</title>
4654
4655 <para>When invoking a unit process the service manager possibly fails to apply the execution parameters configured
4656 with the settings above. In that case the already created service process will exit with a non-zero exit code
4657 before the configured command line is executed. (Or in other words, the child process possibly exits with these
4658 error codes, after having been created by the <citerefentry
4659 project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, but
4660 before the matching <citerefentry
4661 project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call is
4662 called.) Specifically, exit codes defined by the C library, by the LSB specification and by the systemd service
4663 manager itself are used.</para>
4664
4665 <para>The following basic service exit codes are defined by the C library.</para>
4666
4667 <table>
4668 <title>Basic C library exit codes</title>
4669 <tgroup cols='3'>
4670 <thead>
4671 <row>
4672 <entry>Exit Code</entry>
4673 <entry>Symbolic Name</entry>
4674 <entry>Description</entry>
4675 </row>
4676 </thead>
4677 <tbody>
4678 <row>
4679 <entry>0</entry>
4680 <entry><constant>EXIT_SUCCESS</constant></entry>
4681 <entry>Generic success code.</entry>
4682 </row>
4683 <row>
4684 <entry>1</entry>
4685 <entry><constant>EXIT_FAILURE</constant></entry>
4686 <entry>Generic failure or unspecified error.</entry>
4687 </row>
4688 </tbody>
4689 </tgroup>
4690 </table>
4691
4692 <para>The following service exit codes are defined by the <ulink
4693 url="https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html">LSB specification</ulink>.
4694 </para>
4695
4696 <table>
4697 <title>LSB service exit codes</title>
4698 <tgroup cols='3'>
4699 <thead>
4700 <row>
4701 <entry>Exit Code</entry>
4702 <entry>Symbolic Name</entry>
4703 <entry>Description</entry>
4704 </row>
4705 </thead>
4706 <tbody>
4707 <row>
4708 <entry>2</entry>
4709 <entry><constant>EXIT_INVALIDARGUMENT</constant></entry>
4710 <entry>Invalid or excess arguments.</entry>
4711 </row>
4712 <row>
4713 <entry>3</entry>
4714 <entry><constant>EXIT_NOTIMPLEMENTED</constant></entry>
4715 <entry>Unimplemented feature.</entry>
4716 </row>
4717 <row>
4718 <entry>4</entry>
4719 <entry><constant>EXIT_NOPERMISSION</constant></entry>
4720 <entry>The user has insufficient privileges.</entry>
4721 </row>
4722 <row>
4723 <entry>5</entry>
4724 <entry><constant>EXIT_NOTINSTALLED</constant></entry>
4725 <entry>The program is not installed.</entry>
4726 </row>
4727 <row>
4728 <entry>6</entry>
4729 <entry><constant>EXIT_NOTCONFIGURED</constant></entry>
4730 <entry>The program is not configured.</entry>
4731 </row>
4732 <row>
4733 <entry>7</entry>
4734 <entry><constant>EXIT_NOTRUNNING</constant></entry>
4735 <entry>The program is not running.</entry>
4736 </row>
4737 </tbody>
4738 </tgroup>
4739 </table>
4740
4741 <para>
4742 The LSB specification suggests that error codes 200 and above are reserved for implementations. Some of them are
4743 used by the service manager to indicate problems during process invocation:
4744 </para>
4745 <table>
4746 <title>systemd-specific exit codes</title>
4747 <tgroup cols='3'>
4748 <thead>
4749 <row>
4750 <entry>Exit Code</entry>
4751 <entry>Symbolic Name</entry>
4752 <entry>Description</entry>
4753 </row>
4754 </thead>
4755 <tbody>
4756 <row>
4757 <entry>200</entry>
4758 <entry><constant>EXIT_CHDIR</constant></entry>
4759 <entry>Changing to the requested working directory failed. See <varname>WorkingDirectory=</varname> above.</entry>
4760 </row>
4761 <row>
4762 <entry>201</entry>
4763 <entry><constant>EXIT_NICE</constant></entry>
4764 <entry>Failed to set up process scheduling priority (nice level). See <varname>Nice=</varname> above.</entry>
4765 </row>
4766 <row>
4767 <entry>202</entry>
4768 <entry><constant>EXIT_FDS</constant></entry>
4769 <entry>Failed to close unwanted file descriptors, or to adjust passed file descriptors.</entry>
4770 </row>
4771 <row>
4772 <entry>203</entry>
4773 <entry><constant>EXIT_EXEC</constant></entry>
4774 <entry>The actual process execution failed (specifically, the <citerefentry project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call). Most likely this is caused by a missing or non-accessible executable file.</entry>
4775 </row>
4776 <row>
4777 <entry>204</entry>
4778 <entry><constant>EXIT_MEMORY</constant></entry>
4779 <entry>Failed to perform an action due to memory shortage.</entry>
4780 </row>
4781 <row>
4782 <entry>205</entry>
4783 <entry><constant>EXIT_LIMITS</constant></entry>
4784 <entry>Failed to adjust resource limits. See <varname>LimitCPU=</varname> and related settings above.</entry>
4785 </row>
4786 <row>
4787 <entry>206</entry>
4788 <entry><constant>EXIT_OOM_ADJUST</constant></entry>
4789 <entry>Failed to adjust the OOM setting. See <varname>OOMScoreAdjust=</varname> above.</entry>
4790 </row>
4791 <row>
4792 <entry>207</entry>
4793 <entry><constant>EXIT_SIGNAL_MASK</constant></entry>
4794 <entry>Failed to set process signal mask.</entry>
4795 </row>
4796 <row>
4797 <entry>208</entry>
4798 <entry><constant>EXIT_STDIN</constant></entry>
4799 <entry>Failed to set up standard input. See <varname>StandardInput=</varname> above.</entry>
4800 </row>
4801 <row>
4802 <entry>209</entry>
4803 <entry><constant>EXIT_STDOUT</constant></entry>
4804 <entry>Failed to set up standard output. See <varname>StandardOutput=</varname> above.</entry>
4805 </row>
4806 <row>
4807 <entry>210</entry>
4808 <entry><constant>EXIT_CHROOT</constant></entry>
4809 <entry>Failed to change root directory (<citerefentry project='man-pages'><refentrytitle>chroot</refentrytitle><manvolnum>2</manvolnum></citerefentry>). See <varname>RootDirectory=</varname>/<varname>RootImage=</varname> above.</entry>
4810 </row>
4811 <row>
4812 <entry>211</entry>
4813 <entry><constant>EXIT_IOPRIO</constant></entry>
4814 <entry>Failed to set up IO scheduling priority. See <varname>IOSchedulingClass=</varname>/<varname>IOSchedulingPriority=</varname> above.</entry>
4815 </row>
4816 <row>
4817 <entry>212</entry>
4818 <entry><constant>EXIT_TIMERSLACK</constant></entry>
4819 <entry>Failed to set up timer slack. See <varname>TimerSlackNSec=</varname> above.</entry>
4820 </row>
4821 <row>
4822 <entry>213</entry>
4823 <entry><constant>EXIT_SECUREBITS</constant></entry>
4824 <entry>Failed to set process secure bits. See <varname>SecureBits=</varname> above.</entry>
4825 </row>
4826 <row>
4827 <entry>214</entry>
4828 <entry><constant>EXIT_SETSCHEDULER</constant></entry>
4829 <entry>Failed to set up CPU scheduling. See <varname>CPUSchedulingPolicy=</varname>/<varname>CPUSchedulingPriority=</varname> above.</entry>
4830 </row>
4831 <row>
4832 <entry>215</entry>
4833 <entry><constant>EXIT_CPUAFFINITY</constant></entry>
4834 <entry>Failed to set up CPU affinity. See <varname>CPUAffinity=</varname> above.</entry>
4835 </row>
4836 <row>
4837 <entry>216</entry>
4838 <entry><constant>EXIT_GROUP</constant></entry>
4839 <entry>Failed to determine or change group credentials. See <varname>Group=</varname>/<varname>SupplementaryGroups=</varname> above.</entry>
4840 </row>
4841 <row>
4842 <entry>217</entry>
4843 <entry><constant>EXIT_USER</constant></entry>
4844 <entry>Failed to determine or change user credentials, or to set up user namespacing. See <varname>User=</varname>/<varname>PrivateUsers=</varname> above.</entry>
4845 </row>
4846 <row>
4847 <entry>218</entry>
4848 <entry><constant>EXIT_CAPABILITIES</constant></entry>
4849 <entry>Failed to drop capabilities, or apply ambient capabilities. See <varname>CapabilityBoundingSet=</varname>/<varname>AmbientCapabilities=</varname> above.</entry>
4850 </row>
4851 <row>
4852 <entry>219</entry>
4853 <entry><constant>EXIT_CGROUP</constant></entry>
4854 <entry>Setting up the service control group failed.</entry>
4855 </row>
4856 <row>
4857 <entry>220</entry>
4858 <entry><constant>EXIT_SETSID</constant></entry>
4859 <entry>Failed to create new process session.</entry>
4860 </row>
4861 <row>
4862 <entry>221</entry>
4863 <entry><constant>EXIT_CONFIRM</constant></entry>
4864 <entry>Execution has been cancelled by the user. See the <varname>systemd.confirm_spawn=</varname> kernel command line setting on <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details.</entry>
4865 </row>
4866 <row>
4867 <entry>222</entry>
4868 <entry><constant>EXIT_STDERR</constant></entry>
4869 <entry>Failed to set up standard error output. See <varname>StandardError=</varname> above.</entry>
4870 </row>
4871 <row>
4872 <entry>224</entry>
4873 <entry><constant>EXIT_PAM</constant></entry>
4874 <entry>Failed to set up PAM session. See <varname>PAMName=</varname> above.</entry>
4875 </row>
4876 <row>
4877 <entry>225</entry>
4878 <entry><constant>EXIT_NETWORK</constant></entry>
4879 <entry>Failed to set up network namespacing. See <varname>PrivateNetwork=</varname> above.</entry>
4880 </row>
4881 <row>
4882 <entry>226</entry>
4883 <entry><constant>EXIT_NAMESPACE</constant></entry>
4884 <entry>Failed to set up mount, UTS, or IPC namespacing. See <varname>ReadOnlyPaths=</varname>, <varname>ProtectHostname=</varname>, <varname>PrivateIPC=</varname>, and related settings above.</entry>
4885 </row>
4886 <row>
4887 <entry>227</entry>
4888 <entry><constant>EXIT_NO_NEW_PRIVILEGES</constant></entry>
4889 <entry>Failed to disable new privileges. See <varname>NoNewPrivileges=yes</varname> above.</entry>
4890 </row>
4891 <row>
4892 <entry>228</entry>
4893 <entry><constant>EXIT_SECCOMP</constant></entry>
4894 <entry>Failed to apply system call filters. See <varname>SystemCallFilter=</varname> and related settings above.</entry>
4895 </row>
4896 <row>
4897 <entry>229</entry>
4898 <entry><constant>EXIT_SELINUX_CONTEXT</constant></entry>
4899 <entry>Determining or changing SELinux context failed. See <varname>SELinuxContext=</varname> above.</entry>
4900 </row>
4901 <row>
4902 <entry>230</entry>
4903 <entry><constant>EXIT_PERSONALITY</constant></entry>
4904 <entry>Failed to set up an execution domain (personality). See <varname>Personality=</varname> above.</entry>
4905 </row>
4906 <row>
4907 <entry>231</entry>
4908 <entry><constant>EXIT_APPARMOR_PROFILE</constant></entry>
4909 <entry>Failed to prepare changing AppArmor profile. See <varname>AppArmorProfile=</varname> above.</entry>
4910 </row>
4911 <row>
4912 <entry>232</entry>
4913 <entry><constant>EXIT_ADDRESS_FAMILIES</constant></entry>
4914 <entry>Failed to restrict address families. See <varname>RestrictAddressFamilies=</varname> above.</entry>
4915 </row>
4916 <row>
4917 <entry>233</entry>
4918 <entry><constant>EXIT_RUNTIME_DIRECTORY</constant></entry>
4919 <entry>Setting up runtime directory failed. See <varname>RuntimeDirectory=</varname> and related settings above.</entry>
4920 </row>
4921 <row>
4922 <entry>235</entry>
4923 <entry><constant>EXIT_CHOWN</constant></entry>
4924 <entry>Failed to adjust socket ownership. Used for socket units only.</entry>
4925 </row>
4926 <row>
4927 <entry>236</entry>
4928 <entry><constant>EXIT_SMACK_PROCESS_LABEL</constant></entry>
4929 <entry>Failed to set SMACK label. See <varname>SmackProcessLabel=</varname> above.</entry>
4930 </row>
4931 <row>
4932 <entry>237</entry>
4933 <entry><constant>EXIT_KEYRING</constant></entry>
4934 <entry>Failed to set up kernel keyring.</entry>
4935 </row>
4936 <row>
4937 <entry>238</entry>
4938 <entry><constant>EXIT_STATE_DIRECTORY</constant></entry>
4939 <entry>Failed to set up unit's state directory. See <varname>StateDirectory=</varname> above.</entry>
4940 </row>
4941 <row>
4942 <entry>239</entry>
4943 <entry><constant>EXIT_CACHE_DIRECTORY</constant></entry>
4944 <entry>Failed to set up unit's cache directory. See <varname>CacheDirectory=</varname> above.</entry>
4945 </row>
4946 <row>
4947 <entry>240</entry>
4948 <entry><constant>EXIT_LOGS_DIRECTORY</constant></entry>
4949 <entry>Failed to set up unit's logging directory. See <varname>LogsDirectory=</varname> above.</entry>
4950 </row>
4951 <row>
4952 <entry>241</entry>
4953 <entry><constant>EXIT_CONFIGURATION_DIRECTORY</constant></entry>
4954 <entry>Failed to set up unit's configuration directory. See <varname>ConfigurationDirectory=</varname> above.</entry>
4955 </row>
4956 <row>
4957 <entry>242</entry>
4958 <entry><constant>EXIT_NUMA_POLICY</constant></entry>
4959 <entry>Failed to set up unit's NUMA memory policy. See <varname>NUMAPolicy=</varname> and <varname>NUMAMask=</varname> above.</entry>
4960 </row>
4961 <row>
4962 <entry>243</entry>
4963 <entry><constant>EXIT_CREDENTIALS</constant></entry>
4964 <entry>Failed to set up unit's credentials. See <varname>ImportCredential=</varname>, <varname>LoadCredential=</varname> and <varname>SetCredential=</varname> above.</entry>
4965 </row>
4966 <row>
4967 <entry>245</entry>
4968 <entry><constant>EXIT_BPF</constant></entry>
4969 <entry>Failed to apply BPF restrictions. See <varname>RestrictFileSystems=</varname> above.</entry>
4970 </row>
4971 </tbody>
4972 </tgroup>
4973 </table>
4974
4975 <para>Finally, the BSD operating systems define a set of exit codes, typically defined on Linux systems too:</para>
4976
4977 <table>
4978 <title>BSD exit codes</title>
4979 <tgroup cols='3'>
4980 <thead>
4981 <row>
4982 <entry>Exit Code</entry>
4983 <entry>Symbolic Name</entry>
4984 <entry>Description</entry>
4985 </row>
4986 </thead>
4987 <tbody>
4988 <row>
4989 <entry>64</entry>
4990 <entry><constant>EX_USAGE</constant></entry>
4991 <entry>Command line usage error</entry>
4992 </row>
4993 <row>
4994 <entry>65</entry>
4995 <entry><constant>EX_DATAERR</constant></entry>
4996 <entry>Data format error</entry>
4997 </row>
4998 <row>
4999 <entry>66</entry>
5000 <entry><constant>EX_NOINPUT</constant></entry>
5001 <entry>Cannot open input</entry>
5002 </row>
5003 <row>
5004 <entry>67</entry>
5005 <entry><constant>EX_NOUSER</constant></entry>
5006 <entry>Addressee unknown</entry>
5007 </row>
5008 <row>
5009 <entry>68</entry>
5010 <entry><constant>EX_NOHOST</constant></entry>
5011 <entry>Host name unknown</entry>
5012 </row>
5013 <row>
5014 <entry>69</entry>
5015 <entry><constant>EX_UNAVAILABLE</constant></entry>
5016 <entry>Service unavailable</entry>
5017 </row>
5018 <row>
5019 <entry>70</entry>
5020 <entry><constant>EX_SOFTWARE</constant></entry>
5021 <entry>internal software error</entry>
5022 </row>
5023 <row>
5024 <entry>71</entry>
5025 <entry><constant>EX_OSERR</constant></entry>
5026 <entry>System error (e.g., cannot fork)</entry>
5027 </row>
5028 <row>
5029 <entry>72</entry>
5030 <entry><constant>EX_OSFILE</constant></entry>
5031 <entry>Critical OS file missing</entry>
5032 </row>
5033 <row>
5034 <entry>73</entry>
5035 <entry><constant>EX_CANTCREAT</constant></entry>
5036 <entry>Cannot create (user) output file</entry>
5037 </row>
5038 <row>
5039 <entry>74</entry>
5040 <entry><constant>EX_IOERR</constant></entry>
5041 <entry>Input/output error</entry>
5042 </row>
5043 <row>
5044 <entry>75</entry>
5045 <entry><constant>EX_TEMPFAIL</constant></entry>
5046 <entry>Temporary failure; user is invited to retry</entry>
5047 </row>
5048 <row>
5049 <entry>76</entry>
5050 <entry><constant>EX_PROTOCOL</constant></entry>
5051 <entry>Remote error in protocol</entry>
5052 </row>
5053 <row>
5054 <entry>77</entry>
5055 <entry><constant>EX_NOPERM</constant></entry>
5056 <entry>Permission denied</entry>
5057 </row>
5058 <row>
5059 <entry>78</entry>
5060 <entry><constant>EX_CONFIG</constant></entry>
5061 <entry>Configuration error</entry>
5062 </row>
5063 </tbody>
5064 </tgroup>
5065 </table>
5066 </refsect1>
5067
5068 <refsect1>
5069 <title>Examples</title>
5070
5071 <example>
5072 <title><varname>$MONITOR_<replaceable>*</replaceable></varname> usage</title>
5073
5074 <para>A service <filename index="false">myfailer.service</filename> which can trigger an
5075 <varname>OnFailure=</varname> dependency.</para>
5076
5077 <programlisting>
5078[Unit]
5079Description=Service which can trigger an OnFailure= dependency
5080OnFailure=myhandler.service
5081
5082[Service]
5083ExecStart=/bin/myprogram
5084</programlisting>
5085
5086 <para>A service <filename index="false">mysuccess.service</filename> which can trigger an
5087 <varname>OnSuccess=</varname> dependency.</para>
5088
5089 <programlisting>
5090[Unit]
5091Description=Service which can trigger an OnSuccess= dependency
5092OnSuccess=myhandler.service
5093
5094[Service]
5095ExecStart=/bin/mysecondprogram
5096</programlisting>
5097
5098 <para>A service <filename index="false">myhandler.service</filename> which can be triggered
5099 by any of the above services.</para>
5100
5101 <programlisting>
5102[Unit]
5103Description=Acts on service failing or succeeding
5104
5105[Service]
5106ExecStart=/bin/bash -c "echo $MONITOR_SERVICE_RESULT $MONITOR_EXIT_CODE $MONITOR_EXIT_STATUS $MONITOR_INVOCATION_ID $MONITOR_UNIT"
5107</programlisting>
5108
5109 <para>If <filename index="false">myfailer.service</filename> were to run and exit in failure,
5110 then <filename index="false">myhandler.service</filename> would be triggered and the
5111 monitor variables would be set as follows:</para>
5112
5113 <programlisting>
5114MONITOR_SERVICE_RESULT=exit-code
5115MONITOR_EXIT_CODE=exited
5116MONITOR_EXIT_STATUS=1
5117MONITOR_INVOCATION_ID=cc8fdc149b2b4ca698d4f259f4054236
5118MONITOR_UNIT=myfailer.service
5119</programlisting>
5120
5121 <para>If <filename index="false">mysuccess.service</filename> were to run and exit in success,
5122 then <filename index="false">myhandler.service</filename> would be triggered and the
5123 monitor variables would be set as follows:</para>
5124
5125 <programlisting>
5126MONITOR_SERVICE_RESULT=success
5127MONITOR_EXIT_CODE=exited
5128MONITOR_EXIT_STATUS=0
5129MONITOR_INVOCATION_ID=6ab9af147b8c4a3ebe36e7a5f8611697
5130MONITOR_UNIT=mysuccess.service
5131</programlisting>
5132
5133 </example>
5134
5135 </refsect1>
5136
5137 <refsect1>
5138 <title>See Also</title>
5139 <para><simplelist type="inline">
5140 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
5141 <member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
5142 <member><citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
5143 <member><citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
5144 <member><citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5145 <member><citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5146 <member><citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5147 <member><citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5148 <member><citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5149 <member><citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5150 <member><citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5151 <member><citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5152 <member><citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
5153 <member><citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
5154 <member><citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
5155 <member><citerefentry project='man-pages'><refentrytitle>exec</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
5156 <member><citerefentry project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry></member>
5157 </simplelist></para>
5158 </refsect1>
5159
5160</refentry>