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