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 · Similar, 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 WorkingDirectory=
59 Takes a directory path relative to the service's root directory
60 specified by RootDirectory=, or the special value "~". Sets the
61 working directory for executed processes. If set to "~", the home
62 directory of the user specified in User= is used. If not set,
63 defaults to the root directory when systemd is running as a system
64 instance and the respective user's home directory if run as user.
65 If the setting is prefixed with the "-" character, a missing
66 working directory is not considered fatal. If
67 RootDirectory=/RootImage= is not set, then WorkingDirectory= is
68 relative to the root of the system running the service manager.
69 Note that setting this parameter might result in additional
70 dependencies to be added to the unit (see above).
71
72 RootDirectory=
73 Takes a directory path relative to the host's root directory (i.e.
74 the root of the system running the service manager). Sets the root
75 directory for executed processes, with the chroot(2) system call.
76 If this is used, it must be ensured that the process binary and all
77 its auxiliary files are available in the chroot() jail. Note that
78 setting this parameter might result in additional dependencies to
79 be added to the unit (see above).
80
81 The MountAPIVFS= and PrivateUsers= settings are particularly useful
82 in conjunction with RootDirectory=. For details, see below.
83
84 This option is only available for system services and is not
85 supported for services running in per-user instances of the service
86 manager.
87
88 RootImage=
89 Takes a path to a block device node or regular file as argument.
90 This call is similar to RootDirectory= however mounts a file system
91 hierarchy from a block device node or loopback file instead of a
92 directory. The device node or file system image file needs to
93 contain a file system without a partition table, or a file system
94 within an MBR/MS-DOS or GPT partition table with only a single
95 Linux-compatible partition, or a set of file systems within a GPT
96 partition table that follows the Discoverable Partitions
97 Specification[1].
98
99 When DevicePolicy= is set to "closed" or "strict", or set to "auto"
100 and DeviceAllow= is set, then this setting adds /dev/loop-control
101 with rw mode, "block-loop" and "block-blkext" with rwm mode to
102 DeviceAllow=. See systemd.resource-control(5) for the details about
103 DevicePolicy= or DeviceAllow=. Also, see PrivateDevices= below, as
104 it may change the setting of DevicePolicy=.
105
106 Units making use of RootImage= automatically gain an After=
107 dependency on systemd-udevd.service.
108
109 This option is only available for system services and is not
110 supported for services running in per-user instances of the service
111 manager.
112
113 RootHash=
114 Takes a data integrity (dm-verity) root hash specified in
115 hexadecimal, or the path to a file containing a root hash in ASCII
116 hexadecimal format. This option enables data integrity checks using
117 dm-verity, if the used image contains the appropriate integrity
118 data (see above) or if RootVerity= is used. The specified hash must
119 match the root hash of integrity data, and is usually at least 256
120 bits (and hence 64 formatted hexadecimal characters) long (in case
121 of SHA256 for example). If this option is not specified, but the
122 image file carries the "user.verity.roothash" extended file
123 attribute (see xattr(7)), then the root hash is read from it, also
124 as formatted hexadecimal characters. If the extended file attribute
125 is not found (or is not supported by the underlying file system),
126 but a file with the .roothash suffix is found next to the image
127 file, bearing otherwise the same name (except if the image has the
128 .raw suffix, in which case the root hash file must not have it in
129 its name), the root hash is read from it and automatically used,
130 also as formatted hexadecimal characters.
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 RootHashSignature=
137 Takes a PKCS7 formatted binary signature of the RootHash= option as
138 a path to a DER encoded signature file or as an ASCII base64 string
139 encoding of the DER encoded signature, prefixed by "base64:". The
140 dm-verity volume will only be opened if the signature of the root
141 hash signature is valid and created by a public key present in the
142 kernel keyring. If this option is not specified, but a file with
143 the .roothash.p7s suffix is found next to the image file, bearing
144 otherwise the same name (except if the image has the .raw suffix,
145 in which case the signature file must not have it in its name), the
146 signature is read from it and automatically used.
147
148 This option is only available for system services and is not
149 supported for services running in per-user instances of the service
150 manager.
151
152 RootVerity=
153 Takes the path to a data integrity (dm-verity) file. This option
154 enables data integrity checks using dm-verity, if RootImage= is
155 used and a root-hash is passed and if the used image itself does
156 not contains the integrity data. The integrity data must be matched
157 by the root hash. If this option is not specified, but a file with
158 the .verity suffix is found next to the image file, bearing
159 otherwise the same name (except if the image has the .raw suffix,
160 in which case the verity data file must not have it in its name),
161 the verity data is read from it and automatically used.
162
163 This option is supported only for disk images that contain a single
164 file system, without an enveloping partition table. Images that
165 contain a GPT partition table should instead include both root file
166 system and matching Verity data in the same image, implementing the
167 Discoverable Partition Specification[1].
168
169 This option is only available for system services and is not
170 supported for services running in per-user instances of the service
171 manager.
172
173 MountAPIVFS=
174 Takes a boolean argument. If on, a private mount namespace for the
175 unit's processes is created and the API file systems /proc, /sys,
176 and /dev are mounted inside of it, unless they are already mounted.
177 Note that this option has no effect unless used in conjunction with
178 RootDirectory=/RootImage= as these three mounts are generally
179 mounted in the host anyway, and unless the root directory is
180 changed, the private mount namespace will be a 1:1 copy of the
181 host's, and include these three mounts. Note that the /dev file
182 system of the host is bind mounted if this option is used without
183 PrivateDevices=. To run the service with a private, minimal version
184 of /dev/, combine this option with PrivateDevices=.
185
186 This option is only available for system services and is not
187 supported for services running in per-user instances of the service
188 manager.
189
190 BindPaths=, BindReadOnlyPaths=
191 Configures unit-specific bind mounts. A bind mount makes a
192 particular file or directory available at an additional place in
193 the unit's view of the file system. Any bind mounts created with
194 this option are specific to the unit, and are not visible in the
195 host's mount table. This option expects a whitespace separated list
196 of bind mount definitions. Each definition consists of a
197 colon-separated triple of source path, destination path and option
198 string, where the latter two are optional. If only a source path is
199 specified the source and destination is taken to be the same. The
200 option string may be either "rbind" or "norbind" for configuring a
201 recursive or non-recursive bind mount. If the destination path is
202 omitted, the option string must be omitted too. Each bind mount
203 definition may be prefixed with "-", in which case it will be
204 ignored when its source path does not exist.
205
206 BindPaths= creates regular writable bind mounts (unless the source
207 file system mount is already marked read-only), while
208 BindReadOnlyPaths= creates read-only bind mounts. These settings
209 may be used more than once, each usage appends to the unit's list
210 of bind mounts. If the empty string is assigned to either of these
211 two options the entire list of bind mounts defined prior to this is
212 reset. Note that in this case both read-only and regular bind
213 mounts are reset, regardless which of the two settings is used.
214
215 This option is particularly useful when RootDirectory=/RootImage=
216 is used. In this case the source path refers to a path on the host
217 file system, while the destination path refers to a path below the
218 root directory of the unit.
219
220 Note that the destination directory must exist or systemd must be
221 able to create it. Thus, it is not possible to use those options
222 for mount points nested underneath paths specified in
223 InaccessiblePaths=, or under /home/ and other protected directories
224 if ProtectHome=yes is specified. TemporaryFileSystem= with ":ro"
225 or ProtectHome=tmpfs should be used instead.
226
227 This option is only available for system services and is not
228 supported for services running in per-user instances of the service
229 manager.
230
232 These options are only available for system services and are not
233 supported for services running in per-user instances of the service
234 manager.
235
236 User=, Group=
237 Set the UNIX user or group that the processes are executed as,
238 respectively. Takes a single user or group name, or a numeric ID as
239 argument. For system services (services run by the system service
240 manager, i.e. managed by PID 1) and for user services of the root
241 user (services managed by root's instance of systemd --user), the
242 default is "root", but User= may be used to specify a different
243 user. For user services of any other user, switching user identity
244 is not permitted, hence the only valid setting is the same user the
245 user's service manager is running as. If no group is set, the
246 default group of the user is used. This setting does not affect
247 commands whose command line is prefixed with "+".
248
249 Note that this enforces only weak restrictions on the user/group
250 name syntax, but will generate warnings in many cases where
251 user/group names do not adhere to the following rules: the
252 specified name should consist only of the characters a-z, A-Z, 0-9,
253 "_" and "-", except for the first character which must be one of
254 a-z, A-Z and "_" (i.e. digits and "-" are not permitted as first
255 character). The user/group name must have at least one character,
256 and at most 31. These restrictions are made in order to avoid
257 ambiguities and to ensure user/group names and unit files remain
258 portable among Linux systems. For further details on the names
259 accepted and the names warned about see User/Group Name Syntax[2].
260
261 When used in conjunction with DynamicUser= the user/group name
262 specified is dynamically allocated at the time the service is
263 started, and released at the time the service is stopped — unless
264 it is already allocated statically (see below). If DynamicUser= is
265 not used the specified user and group must have been created
266 statically in the user database no later than the moment the
267 service is started, for example using the sysusers.d(5) facility,
268 which is applied at boot or package install time. If the user does
269 not exist by then program invocation will fail.
270
271 If the User= setting is used the supplementary group list is
272 initialized from the specified user's default group list, as
273 defined in the system's user and group database. Additional groups
274 may be configured through the SupplementaryGroups= setting (see
275 below).
276
277 DynamicUser=
278 Takes a boolean parameter. If set, a UNIX user and group pair is
279 allocated dynamically when the unit is started, and released as
280 soon as it is stopped. The user and group will not be added to
281 /etc/passwd or /etc/group, but are managed transiently during
282 runtime. The nss-systemd(8) glibc NSS module provides integration
283 of these dynamic users/groups into the system's user and group
284 databases. The user and group name to use may be configured via
285 User= and Group= (see above). If these options are not used and
286 dynamic user/group allocation is enabled for a unit, the name of
287 the dynamic user/group is implicitly derived from the unit name. If
288 the unit name without the type suffix qualifies as valid user name
289 it is used directly, otherwise a name incorporating a hash of it is
290 used. If a statically allocated user or group of the configured
291 name already exists, it is used and no dynamic user/group is
292 allocated. Note that if User= is specified and the static group
293 with the name exists, then it is required that the static user with
294 the name already exists. Similarly, if Group= is specified and the
295 static user with the name exists, then it is required that the
296 static group with the name already exists. Dynamic users/groups are
297 allocated from the UID/GID range 61184...65519. It is recommended
298 to avoid this range for regular system or login users. At any point
299 in time each UID/GID from this range is only assigned to zero or
300 one dynamically allocated users/groups in use. However, UID/GIDs
301 are recycled after a unit is terminated. Care should be taken that
302 any processes running as part of a unit for which dynamic
303 users/groups are enabled do not leave files or directories owned by
304 these users/groups around, as a different unit might get the same
305 UID/GID assigned later on, and thus gain access to these files or
306 directories. If DynamicUser= is enabled, RemoveIPC= and PrivateTmp=
307 are implied (and cannot be turned off). This ensures that the
308 lifetime of IPC objects and temporary files created by the executed
309 processes is bound to the runtime of the service, and hence the
310 lifetime of the dynamic user/group. Since /tmp/ and /var/tmp/ are
311 usually the only world-writable directories on a system this
312 ensures that a unit making use of dynamic user/group allocation
313 cannot leave files around after unit termination. Furthermore
314 NoNewPrivileges= and RestrictSUIDSGID= are implicitly enabled (and
315 cannot be disabled), to ensure that processes invoked cannot take
316 benefit or create SUID/SGID files or directories. Moreover
317 ProtectSystem=strict and ProtectHome=read-only are implied, thus
318 prohibiting the service to write to arbitrary file system
319 locations. In order to allow the service to write to certain
320 directories, they have to be allow-listed using ReadWritePaths=,
321 but care must be taken so that UID/GID recycling doesn't create
322 security issues involving files created by the service. Use
323 RuntimeDirectory= (see below) in order to assign a writable runtime
324 directory to a service, owned by the dynamic user/group and removed
325 automatically when the unit is terminated. Use StateDirectory=,
326 CacheDirectory= and LogsDirectory= in order to assign a set of
327 writable directories for specific purposes to the service in a way
328 that they are protected from vulnerabilities due to UID reuse (see
329 below). If this option is enabled, care should be taken that the
330 unit's processes do not get access to directories outside of these
331 explicitly configured and managed ones. Specifically, do not use
332 BindPaths= and be careful with AF_UNIX file descriptor passing for
333 directory file descriptors, as this would permit processes to
334 create files or directories owned by the dynamic user/group that
335 are not subject to the lifecycle and access guarantees of the
336 service. Defaults to off.
337
338 SupplementaryGroups=
339 Sets the supplementary Unix groups the processes are executed as.
340 This takes a space-separated list of group names or IDs. This
341 option may be specified more than once, in which case all listed
342 groups are set as supplementary groups. When the empty string is
343 assigned, the list of supplementary groups is reset, and all
344 assignments prior to this one will have no effect. In any way, this
345 option does not override, but extends the list of supplementary
346 groups configured in the system group database for the user. This
347 does not affect commands prefixed with "+".
348
349 PAMName=
350 Sets the PAM service name to set up a session as. If set, the
351 executed process will be registered as a PAM session under the
352 specified service name. This is only useful in conjunction with the
353 User= setting, and is otherwise ignored. If not set, no PAM session
354 will be opened for the executed processes. See pam(8) for details.
355
356 Note that for each unit making use of this option a PAM session
357 handler process will be maintained as part of the unit and stays
358 around as long as the unit is active, to ensure that appropriate
359 actions can be taken when the unit and hence the PAM session
360 terminates. This process is named "(sd-pam)" and is an immediate
361 child process of the unit's main process.
362
363 Note that when this option is used for a unit it is very likely
364 (depending on PAM configuration) that the main unit process will be
365 migrated to its own session scope unit when it is activated. This
366 process will hence be associated with two units: the unit it was
367 originally started from (and for which PAMName= was configured),
368 and the session scope unit. Any child processes of that process
369 will however be associated with the session scope unit only. This
370 has implications when used in combination with NotifyAccess=all, as
371 these child processes will not be able to affect changes in the
372 original unit through notification messages. These messages will be
373 considered belonging to the session scope unit and not the original
374 unit. It is hence not recommended to use PAMName= in combination
375 with NotifyAccess=all.
376
378 These options are only available for system services and are not
379 supported for services running in per-user instances of the service
380 manager.
381
382 CapabilityBoundingSet=
383 Controls which capabilities to include in the capability bounding
384 set for the executed process. See capabilities(7) for details.
385 Takes a whitespace-separated list of capability names, e.g.
386 CAP_SYS_ADMIN, CAP_DAC_OVERRIDE, CAP_SYS_PTRACE. Capabilities
387 listed will be included in the bounding set, all others are
388 removed. If the list of capabilities is prefixed with "~", all but
389 the listed capabilities will be included, the effect of the
390 assignment inverted. Note that this option also affects the
391 respective capabilities in the effective, permitted and inheritable
392 capability sets. If this option is not used, the capability
393 bounding set is not modified on process execution, hence no limits
394 on the capabilities of the process are enforced. This option may
395 appear more than once, in which case the bounding sets are merged
396 by OR, or by AND if the lines are prefixed with "~" (see below). If
397 the empty string is assigned to this option, the bounding set is
398 reset to the empty capability set, and all prior settings have no
399 effect. If set to "~" (without any further argument), the bounding
400 set is reset to the full set of available capabilities, also
401 undoing any previous settings. This does not affect commands
402 prefixed with "+".
403
404 Example: if a unit has the following,
405
406 CapabilityBoundingSet=CAP_A CAP_B
407 CapabilityBoundingSet=CAP_B CAP_C
408
409 then CAP_A, CAP_B, and CAP_C are set. If the second line is
410 prefixed with "~", e.g.,
411
412 CapabilityBoundingSet=CAP_A CAP_B
413 CapabilityBoundingSet=~CAP_B CAP_C
414
415 then, only CAP_A is set.
416
417 AmbientCapabilities=
418 Controls which capabilities to include in the ambient capability
419 set for the executed process. Takes a whitespace-separated list of
420 capability names, e.g. CAP_SYS_ADMIN, CAP_DAC_OVERRIDE,
421 CAP_SYS_PTRACE. This option may appear more than once in which case
422 the ambient capability sets are merged (see the above examples in
423 CapabilityBoundingSet=). If the list of capabilities is prefixed
424 with "~", all but the listed capabilities will be included, the
425 effect of the assignment inverted. If the empty string is assigned
426 to this option, the ambient capability set is reset to the empty
427 capability set, and all prior settings have no effect. If set to
428 "~" (without any further argument), the ambient capability set is
429 reset to the full set of available capabilities, also undoing any
430 previous settings. Note that adding capabilities to ambient
431 capability set adds them to the process's inherited capability set.
432
433 Ambient capability sets are useful if you want to execute a process
434 as a non-privileged user but still want to give it some
435 capabilities. Note that in this case option keep-caps is
436 automatically added to SecureBits= to retain the capabilities over
437 the user change. AmbientCapabilities= does not affect commands
438 prefixed with "+".
439
441 NoNewPrivileges=
442 Takes a boolean argument. If true, ensures that the service process
443 and all its children can never gain new privileges through execve()
444 (e.g. via setuid or setgid bits, or filesystem capabilities). This
445 is the simplest and most effective way to ensure that a process and
446 its children can never elevate privileges again. Defaults to false,
447 but certain settings override this and ignore the value of this
448 setting. This is the case when SystemCallFilter=,
449 SystemCallArchitectures=, RestrictAddressFamilies=,
450 RestrictNamespaces=, PrivateDevices=, ProtectKernelTunables=,
451 ProtectKernelModules=, ProtectKernelLogs=, ProtectClock=,
452 MemoryDenyWriteExecute=, RestrictRealtime=, RestrictSUIDSGID=,
453 DynamicUser= or LockPersonality= are specified. Note that even if
454 this setting is overridden by them, systemctl show shows the
455 original value of this setting. Also see No New Privileges Flag[3].
456
457 SecureBits=
458 Controls the secure bits set for the executed process. Takes a
459 space-separated combination of options from the following list:
460 keep-caps, keep-caps-locked, no-setuid-fixup,
461 no-setuid-fixup-locked, noroot, and noroot-locked. This option may
462 appear more than once, in which case the secure bits are ORed. If
463 the empty string is assigned to this option, the bits are reset to
464 0. This does not affect commands prefixed with "+". See
465 capabilities(7) for details.
466
468 These options are only available for system services and are not
469 supported for services running in per-user instances of the service
470 manager.
471
472 SELinuxContext=
473 Set the SELinux security context of the executed process. If set,
474 this will override the automated domain transition. However, the
475 policy still needs to authorize the transition. This directive is
476 ignored if SELinux is disabled. If prefixed by "-", all errors will
477 be ignored. This does not affect commands prefixed with "+". See
478 setexeccon(3) for details.
479
480 AppArmorProfile=
481 Takes a profile name as argument. The process executed by the unit
482 will switch to this profile when started. Profiles must already be
483 loaded in the kernel, or the unit will fail. If prefixed by "-",
484 all errors will be ignored. This setting has no effect if AppArmor
485 is not enabled. This setting not affect commands prefixed with "+".
486
487 SmackProcessLabel=
488 Takes a SMACK64 security label as argument. The process executed by
489 the unit will be started under this label and SMACK will decide
490 whether the process is allowed to run or not, based on it. The
491 process will continue to run under the label specified here unless
492 the executable has its own SMACK64EXEC label, in which case the
493 process will transition to run under that label. When not
494 specified, the label that systemd is running under is used. This
495 directive is ignored if SMACK is disabled.
496
497 The value may be prefixed by "-", in which case all errors will be
498 ignored. An empty value may be specified to unset previous
499 assignments. This does not affect commands prefixed with "+".
500
502 LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=,
503 LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=,
504 LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=,
505 LimitRTTIME=
506 Set soft and hard limits on various resources for executed
507 processes. See setrlimit(2) for details on the resource limit
508 concept. Resource limits may be specified in two formats: either as
509 single value to set a specific soft and hard limit to the same
510 value, or as colon-separated pair soft:hard to set both limits
511 individually (e.g. "LimitAS=4G:16G"). Use the string infinity to
512 configure no limit on a specific resource. The multiplicative
513 suffixes K, M, G, T, P and E (to the base 1024) may be used for
514 resource limits measured in bytes (e.g. "LimitAS=16G"). For the
515 limits referring to time values, the usual time units ms, s, min, h
516 and so on may be used (see systemd.time(7) for details). Note that
517 if no time unit is specified for LimitCPU= the default unit of
518 seconds is implied, while for LimitRTTIME= the default unit of
519 microseconds is implied. Also, note that the effective granularity
520 of the limits might influence their enforcement. For example, time
521 limits specified for LimitCPU= will be rounded up implicitly to
522 multiples of 1s. For LimitNICE= the value may be specified in two
523 syntaxes: if prefixed with "+" or "-", the value is understood as
524 regular Linux nice value in the range -20..19. If not prefixed like
525 this the value is understood as raw resource limit parameter in the
526 range 0..40 (with 0 being equivalent to 1).
527
528 Note that most process resource limits configured with these
529 options are per-process, and processes may fork in order to acquire
530 a new set of resources that are accounted independently of the
531 original process, and may thus escape limits set. Also note that
532 LimitRSS= is not implemented on Linux, and setting it has no
533 effect. Often it is advisable to prefer the resource controls
534 listed in systemd.resource-control(5) over these per-process
535 limits, as they apply to services as a whole, may be altered
536 dynamically at runtime, and are generally more expressive. For
537 example, MemoryMax= is a more powerful (and working) replacement
538 for LimitRSS=.
539
540 Resource limits not configured explicitly for a unit default to the
541 value configured in the various DefaultLimitCPU=,
542 DefaultLimitFSIZE=, ... options available in systemd-
543 system.conf(5), and – if not configured there – the kernel or
544 per-user defaults, as defined by the OS (the latter only for user
545 services, see below).
546
547 For system units these resource limits may be chosen freely. When
548 these settings are configured in a user service (i.e. a service run
549 by the per-user instance of the service manager) they cannot be
550 used to raise the limits above those set for the user manager
551 itself when it was first invoked, as the user's service manager
552 generally lacks the privileges to do so. In user context these
553 configuration options are hence only useful to lower the limits
554 passed in or to raise the soft limit to the maximum of the hard
555 limit as configured for the user. To raise the user's limits
556 further, the available configuration mechanisms differ between
557 operating systems, but typically require privileges. In most cases
558 it is possible to configure higher per-user resource limits via PAM
559 or by setting limits on the system service encapsulating the user's
560 service manager, i.e. the user's instance of user@.service. After
561 making such changes, make sure to restart the user's service
562 manager.
563
564 Table 1. Resource limit directives, their equivalent ulimit shell
565 commands and the unit used
566 ┌─────────────────┬───────────────────┬─────────────────────┐
567 │Directive │ ulimit equivalent │ Unit │
568 ├─────────────────┼───────────────────┼─────────────────────┤
569 │LimitCPU= │ ulimit -t │ Seconds │
570 ├─────────────────┼───────────────────┼─────────────────────┤
571 │LimitFSIZE= │ ulimit -f │ Bytes │
572 ├─────────────────┼───────────────────┼─────────────────────┤
573 │LimitDATA= │ ulimit -d │ Bytes │
574 ├─────────────────┼───────────────────┼─────────────────────┤
575 │LimitSTACK= │ ulimit -s │ Bytes │
576 ├─────────────────┼───────────────────┼─────────────────────┤
577 │LimitCORE= │ ulimit -c │ Bytes │
578 ├─────────────────┼───────────────────┼─────────────────────┤
579 │LimitRSS= │ ulimit -m │ Bytes │
580 ├─────────────────┼───────────────────┼─────────────────────┤
581 │LimitNOFILE= │ ulimit -n │ Number of File │
582 │ │ │ Descriptors │
583 ├─────────────────┼───────────────────┼─────────────────────┤
584 │LimitAS= │ ulimit -v │ Bytes │
585 ├─────────────────┼───────────────────┼─────────────────────┤
586 │LimitNPROC= │ ulimit -u │ Number of Processes │
587 ├─────────────────┼───────────────────┼─────────────────────┤
588 │LimitMEMLOCK= │ ulimit -l │ Bytes │
589 ├─────────────────┼───────────────────┼─────────────────────┤
590 │LimitLOCKS= │ ulimit -x │ Number of Locks │
591 ├─────────────────┼───────────────────┼─────────────────────┤
592 │LimitSIGPENDING= │ ulimit -i │ Number of Queued │
593 │ │ │ Signals │
594 ├─────────────────┼───────────────────┼─────────────────────┤
595 │LimitMSGQUEUE= │ ulimit -q │ Bytes │
596 ├─────────────────┼───────────────────┼─────────────────────┤
597 │LimitNICE= │ ulimit -e │ Nice Level │
598 ├─────────────────┼───────────────────┼─────────────────────┤
599 │LimitRTPRIO= │ ulimit -r │ Realtime Priority │
600 ├─────────────────┼───────────────────┼─────────────────────┤
601 │LimitRTTIME= │ No equivalent │ Microseconds │
602 └─────────────────┴───────────────────┴─────────────────────┘
603
604 UMask=
605 Controls the file mode creation mask. Takes an access mode in octal
606 notation. See umask(2) for details. Defaults to 0022 for system
607 units. For units of the user service manager the default value is
608 inherited from the user instance (whose default is inherited from
609 the system service manager, and thus also is 0022). Hence changing
610 the default value of a user instance, either via UMask= or via a
611 PAM module, will affect the user instance itself and all user units
612 started by the user instance unless a user unit has specified its
613 own UMask=.
614
615 CoredumpFilter=
616 Controls which types of memory mappings will be saved if the
617 process dumps core (using the /proc/pid/coredump_filter file).
618 Takes a whitespace-separated combination of mapping type names or
619 numbers (with the default base 16). Mapping type names are
620 private-anonymous, shared-anonymous, private-file-backed,
621 shared-file-backed, elf-headers, private-huge, shared-huge,
622 private-dax, shared-dax, and the special values all (all types) and
623 default (the kernel default of "private-anonymous shared-anonymous
624 elf-headers private-huge"). See core(5) for the meaning of the
625 mapping types. When specified multiple times, all specified masks
626 are ORed. When not set, or if the empty value is assigned, the
627 inherited value is not changed.
628
629 Example 1. Add DAX pages to the dump filter
630
631 CoredumpFilter=default private-dax shared-dax
632
633 KeyringMode=
634 Controls how the kernel session keyring is set up for the service
635 (see session-keyring(7) for details on the session keyring). Takes
636 one of inherit, private, shared. If set to inherit no special
637 keyring setup is done, and the kernel's default behaviour is
638 applied. If private is used a new session keyring is allocated when
639 a service process is invoked, and it is not linked up with any user
640 keyring. This is the recommended setting for system services, as
641 this ensures that multiple services running under the same system
642 user ID (in particular the root user) do not share their key
643 material among each other. If shared is used a new session keyring
644 is allocated as for private, but the user keyring of the user
645 configured with User= is linked into it, so that keys assigned to
646 the user may be requested by the unit's processes. In this modes
647 multiple units running processes under the same user ID may share
648 key material. Unless inherit is selected the unique invocation ID
649 for the unit (see below) is added as a protected key by the name
650 "invocation_id" to the newly created session keyring. Defaults to
651 private for services of the system service manager and to inherit
652 for non-service units and for services of the user service manager.
653
654 OOMScoreAdjust=
655 Sets the adjustment value for the Linux kernel's Out-Of-Memory
656 (OOM) killer score for executed processes. Takes an integer between
657 -1000 (to disable OOM killing of processes of this unit) and 1000
658 (to make killing of processes of this unit under memory pressure
659 very likely). See proc.txt[4] for details. If not specified
660 defaults to the OOM score adjustment level of the service manager
661 itself, which is normally at 0.
662
663 Use the OOMPolicy= setting of service units to configure how the
664 service manager shall react to the kernel OOM killer terminating a
665 process of the service. See systemd.service(5) for details.
666
667 TimerSlackNSec=
668 Sets the timer slack in nanoseconds for the executed processes. The
669 timer slack controls the accuracy of wake-ups triggered by timers.
670 See prctl(2) for more information. Note that in contrast to most
671 other time span definitions this parameter takes an integer value
672 in nano-seconds if no unit is specified. The usual time units are
673 understood too.
674
675 Personality=
676 Controls which kernel architecture uname(2) shall report, when
677 invoked by unit processes. Takes one of the architecture
678 identifiers x86, x86-64, ppc, ppc-le, ppc64, ppc64-le, s390 or
679 s390x. Which personality architectures are supported depends on the
680 system architecture. Usually the 64bit versions of the various
681 system architectures support their immediate 32bit personality
682 architecture counterpart, but no others. For example, x86-64
683 systems support the x86-64 and x86 personalities but no others. The
684 personality feature is useful when running 32-bit services on a
685 64-bit host system. If not specified, the personality is left
686 unmodified and thus reflects the personality of the host system's
687 kernel.
688
689 IgnoreSIGPIPE=
690 Takes a boolean argument. If true, causes SIGPIPE to be ignored in
691 the executed process. Defaults to true because SIGPIPE generally is
692 useful only in shell pipelines.
693
695 Nice=
696 Sets the default nice level (scheduling priority) for executed
697 processes. Takes an integer between -20 (highest priority) and 19
698 (lowest priority). See setpriority(2) for details.
699
700 CPUSchedulingPolicy=
701 Sets the CPU scheduling policy for executed processes. Takes one of
702 other, batch, idle, fifo or rr. See sched_setscheduler(2) for
703 details.
704
705 CPUSchedulingPriority=
706 Sets the CPU scheduling priority for executed processes. The
707 available priority range depends on the selected CPU scheduling
708 policy (see above). For real-time scheduling policies an integer
709 between 1 (lowest priority) and 99 (highest priority) can be used.
710 See sched_setscheduler(2) for details.
711
712 CPUSchedulingResetOnFork=
713 Takes a boolean argument. If true, elevated CPU scheduling
714 priorities and policies will be reset when the executed processes
715 fork, and can hence not leak into child processes. See
716 sched_setscheduler(2) for details. Defaults to false.
717
718 CPUAffinity=
719 Controls the CPU affinity of the executed processes. Takes a list
720 of CPU indices or ranges separated by either whitespace or commas.
721 Alternatively, takes a special "numa" value in which case systemd
722 automatically derives allowed CPU range based on the value of
723 NUMAMask= option. CPU ranges are specified by the lower and upper
724 CPU indices separated by a dash. This option may be specified more
725 than once, in which case the specified CPU affinity masks are
726 merged. If the empty string is assigned, the mask is reset, all
727 assignments prior to this will have no effect. See
728 sched_setaffinity(2) for details.
729
730 NUMAPolicy=
731 Controls the NUMA memory policy of the executed processes. Takes a
732 policy type, one of: default, preferred, bind, interleave and
733 local. A list of NUMA nodes that should be associated with the
734 policy must be specified in NUMAMask=. For more details on each
735 policy please see, set_mempolicy(2). For overall overview of NUMA
736 support in Linux see, numa(7).
737
738 NUMAMask=
739 Controls the NUMA node list which will be applied alongside with
740 selected NUMA policy. Takes a list of NUMA nodes and has the same
741 syntax as a list of CPUs for CPUAffinity= option. Note that the
742 list of NUMA nodes is not required for default and local policies
743 and for preferred policy we expect a single NUMA node.
744
745 IOSchedulingClass=
746 Sets the I/O scheduling class for executed processes. Takes an
747 integer between 0 and 3 or one of the strings none, realtime,
748 best-effort or idle. If the empty string is assigned to this
749 option, all prior assignments to both IOSchedulingClass= and
750 IOSchedulingPriority= have no effect. See ioprio_set(2) for
751 details.
752
753 IOSchedulingPriority=
754 Sets the I/O scheduling priority for executed processes. Takes an
755 integer between 0 (highest priority) and 7 (lowest priority). The
756 available priorities depend on the selected I/O scheduling class
757 (see above). If the empty string is assigned to this option, all
758 prior assignments to both IOSchedulingClass= and
759 IOSchedulingPriority= have no effect. See ioprio_set(2) for
760 details.
761
763 The following sandboxing options are an effective way to limit the
764 exposure of the system towards the unit's processes. It is recommended
765 to turn on as many of these options for each unit as is possible
766 without negatively affecting the process' ability to operate. Note that
767 many of these sandboxing features are gracefully turned off on systems
768 where the underlying security mechanism is not available. For example,
769 ProtectSystem= has no effect if the kernel is built without file system
770 namespacing or if the service manager runs in a container manager that
771 makes file system namespacing unavailable to its payload. Similar,
772 RestrictRealtime= has no effect on systems that lack support for
773 SECCOMP system call filtering, or in containers where support for this
774 is turned off.
775
776 Also note that some sandboxing functionality is generally not available
777 in user services (i.e. services run by the per-user service manager).
778 Specifically, the various settings requiring file system namespacing
779 support (such as ProtectSystem=) are not available, as the underlying
780 kernel functionality is only accessible to privileged processes.
781 However, most namespacing settings, that will not work on their own in
782 user services, will work when used in conjunction with
783 PrivateUsers=true.
784
785 ProtectSystem=
786 Takes a boolean argument or the special values "full" or "strict".
787 If true, mounts the /usr and the boot loader directories (/boot and
788 /efi) read-only for processes invoked by this unit. If set to
789 "full", the /etc directory is mounted read-only, too. If set to
790 "strict" the entire file system hierarchy is mounted read-only,
791 except for the API file system subtrees /dev, /proc and /sys
792 (protect these directories using PrivateDevices=,
793 ProtectKernelTunables=, ProtectControlGroups=). This setting
794 ensures that any modification of the vendor-supplied operating
795 system (and optionally its configuration, and local mounts) is
796 prohibited for the service. It is recommended to enable this
797 setting for all long-running services, unless they are involved
798 with system updates or need to modify the operating system in other
799 ways. If this option is used, ReadWritePaths= may be used to
800 exclude specific directories from being made read-only. This
801 setting is implied if DynamicUser= is set. This setting cannot
802 ensure protection in all cases. In general it has the same
803 limitations as ReadOnlyPaths=, see below. Defaults to off.
804
805 ProtectHome=
806 Takes a boolean argument or the special values "read-only" or
807 "tmpfs". If true, the directories /home, /root, and /run/user are
808 made inaccessible and empty for processes invoked by this unit. If
809 set to "read-only", the three directories are made read-only
810 instead. If set to "tmpfs", temporary file systems are mounted on
811 the three directories in read-only mode. The value "tmpfs" is
812 useful to hide home directories not relevant to the processes
813 invoked by the unit, while still allowing necessary directories to
814 be made visible when listed in BindPaths= or BindReadOnlyPaths=.
815
816 Setting this to "yes" is mostly equivalent to set the three
817 directories in InaccessiblePaths=. Similarly, "read-only" is mostly
818 equivalent to ReadOnlyPaths=, and "tmpfs" is mostly equivalent to
819 TemporaryFileSystem= with ":ro".
820
821 It is recommended to enable this setting for all long-running
822 services (in particular network-facing ones), to ensure they cannot
823 get access to private user data, unless the services actually
824 require access to the user's private data. This setting is implied
825 if DynamicUser= is set. This setting cannot ensure protection in
826 all cases. In general it has the same limitations as
827 ReadOnlyPaths=, see below.
828
829 This option is only available for system services and is not
830 supported for services running in per-user instances of the service
831 manager.
832
833 RuntimeDirectory=, StateDirectory=, CacheDirectory=, LogsDirectory=,
834 ConfigurationDirectory=
835 These options take a whitespace-separated list of directory names.
836 The specified directory names must be relative, and may not include
837 "..". If set, one or more directories by the specified names will
838 be created (including their parents) below the locations defined in
839 the following table, when the unit is started. Also, the
840 corresponding environment variable is defined with the full path of
841 directories. If multiple directories are set, then in the
842 environment variable the paths are concatenated with colon (":").
843
844 Table 2. Automatic directory creation and environment variables
845 ┌────────────────────────┬────────────────┬───────────────────────┬──────────────────────────┐
846 │Directory │ Below path for │ Below path for │ Environment │
847 │ │ system units │ user units │ variable set │
848 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
849 │RuntimeDirectory= │ /run/ │ $XDG_RUNTIME_DIR │ $RUNTIME_DIRECTORY │
850 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
851 │StateDirectory= │ /var/lib/ │ $XDG_CONFIG_HOME │ $STATE_DIRECTORY │
852 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
853 │CacheDirectory= │ /var/cache/ │ $XDG_CACHE_HOME │ $CACHE_DIRECTORY │
854 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
855 │LogsDirectory= │ /var/log/ │ $XDG_CONFIG_HOME/log/ │ $LOGS_DIRECTORY │
856 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
857 │ConfigurationDirectory= │ /etc/ │ $XDG_CONFIG_HOME │ $CONFIGURATION_DIRECTORY │
858 └────────────────────────┴────────────────┴───────────────────────┴──────────────────────────┘
859 In case of RuntimeDirectory= the innermost subdirectories are
860 removed when the unit is stopped. It is possible to preserve the
861 specified directories in this case if RuntimeDirectoryPreserve= is
862 configured to restart or yes (see below). The directories specified
863 with StateDirectory=, CacheDirectory=, LogsDirectory=,
864 ConfigurationDirectory= are not removed when the unit is stopped.
865
866 Except in case of ConfigurationDirectory=, the innermost specified
867 directories will be owned by the user and group specified in User=
868 and Group=. If the specified directories already exist and their
869 owning user or group do not match the configured ones, all files
870 and directories below the specified directories as well as the
871 directories themselves will have their file ownership recursively
872 changed to match what is configured. As an optimization, if the
873 specified directories are already owned by the right user and
874 group, files and directories below of them are left as-is, even if
875 they do not match what is requested. The innermost specified
876 directories will have their access mode adjusted to the what is
877 specified in RuntimeDirectoryMode=, StateDirectoryMode=,
878 CacheDirectoryMode=, LogsDirectoryMode= and
879 ConfigurationDirectoryMode=.
880
881 These options imply BindPaths= for the specified paths. When
882 combined with RootDirectory= or RootImage= these paths always
883 reside on the host and are mounted from there into the unit's file
884 system namespace.
885
886 If DynamicUser= is used in conjunction with StateDirectory=, the
887 logic for CacheDirectory= and LogsDirectory= is slightly altered:
888 the directories are created below /var/lib/private,
889 /var/cache/private and /var/log/private, respectively, which are
890 host directories made inaccessible to unprivileged users, which
891 ensures that access to these directories cannot be gained through
892 dynamic user ID recycling. Symbolic links are created to hide this
893 difference in behaviour. Both from perspective of the host and from
894 inside the unit, the relevant directories hence always appear
895 directly below /var/lib, /var/cache and /var/log.
896
897 Use RuntimeDirectory= to manage one or more runtime directories for
898 the unit and bind their lifetime to the daemon runtime. This is
899 particularly useful for unprivileged daemons that cannot create
900 runtime directories in /run due to lack of privileges, and to make
901 sure the runtime directory is cleaned up automatically after use.
902 For runtime directories that require more complex or different
903 configuration or lifetime guarantees, please consider using
904 tmpfiles.d(5).
905
906 The directories defined by these options are always created under
907 the standard paths used by systemd (/var, /run, /etc, ...). If the
908 service needs directories in a different location, a different
909 mechanism has to be used to create them.
910
911 tmpfiles.d(5) provides functionality that overlaps with these
912 options. Using these options is recommended, because the lifetime
913 of the directories is tied directly to the lifetime of the unit,
914 and it is not necessary to ensure that the tmpfiles.d configuration
915 is executed before the unit is started.
916
917 To remove any of the directories created by these settings, use the
918 systemctl clean ... command on the relevant units, see
919 systemctl(1) for details.
920
921 Example: if a system service unit has the following,
922
923 RuntimeDirectory=foo/bar baz
924
925 the service manager creates /run/foo (if it does not exist),
926 /run/foo/bar, and /run/baz. The directories /run/foo/bar and
927 /run/baz except /run/foo are owned by the user and group specified
928 in User= and Group=, and removed when the service is stopped.
929
930 Example: if a system service unit has the following,
931
932 RuntimeDirectory=foo/bar
933 StateDirectory=aaa/bbb ccc
934
935 then the environment variable "RUNTIME_DIRECTORY" is set with
936 "/run/foo/bar", and "STATE_DIRECTORY" is set with
937 "/var/lib/aaa/bbb:/var/lib/ccc".
938
939 RuntimeDirectoryMode=, StateDirectoryMode=, CacheDirectoryMode=,
940 LogsDirectoryMode=, ConfigurationDirectoryMode=
941 Specifies the access mode of the directories specified in
942 RuntimeDirectory=, StateDirectory=, CacheDirectory=,
943 LogsDirectory=, or ConfigurationDirectory=, respectively, as an
944 octal number. Defaults to 0755. See "Permissions" in
945 path_resolution(7) for a discussion of the meaning of permission
946 bits.
947
948 RuntimeDirectoryPreserve=
949 Takes a boolean argument or restart. If set to no (the default),
950 the directories specified in RuntimeDirectory= are always removed
951 when the service stops. If set to restart the directories are
952 preserved when the service is both automatically and manually
953 restarted. Here, the automatic restart means the operation
954 specified in Restart=, and manual restart means the one triggered
955 by systemctl restart foo.service. If set to yes, then the
956 directories are not removed when the service is stopped. Note that
957 since the runtime directory /run is a mount point of "tmpfs", then
958 for system services the directories specified in RuntimeDirectory=
959 are removed when the system is rebooted.
960
961 TimeoutCleanSec=
962 Configures a timeout on the clean-up operation requested through
963 systemctl clean ..., see systemctl(1) for details. Takes the usual
964 time values and defaults to infinity, i.e. by default no timeout is
965 applied. If a timeout is configured the clean operation will be
966 aborted forcibly when the timeout is reached, potentially leaving
967 resources on disk.
968
969 ReadWritePaths=, ReadOnlyPaths=, InaccessiblePaths=
970 Sets up a new file system namespace for executed processes. These
971 options may be used to limit access a process might have to the
972 file system hierarchy. Each setting takes a space-separated list of
973 paths relative to the host's root directory (i.e. the system
974 running the service manager). Note that if paths contain symlinks,
975 they are resolved relative to the root directory set with
976 RootDirectory=/RootImage=.
977
978 Paths listed in ReadWritePaths= are accessible from within the
979 namespace with the same access modes as from outside of it. Paths
980 listed in ReadOnlyPaths= are accessible for reading only, writing
981 will be refused even if the usual file access controls would permit
982 this. Nest ReadWritePaths= inside of ReadOnlyPaths= in order to
983 provide writable subdirectories within read-only directories. Use
984 ReadWritePaths= in order to allow-list specific paths for write
985 access if ProtectSystem=strict is used.
986
987 Paths listed in InaccessiblePaths= will be made inaccessible for
988 processes inside the namespace along with everything below them in
989 the file system hierarchy. This may be more restrictive than
990 desired, because it is not possible to nest ReadWritePaths=,
991 ReadOnlyPaths=, BindPaths=, or BindReadOnlyPaths= inside it. For a
992 more flexible option, see TemporaryFileSystem=.
993
994 Non-directory paths may be specified as well. These options may be
995 specified more than once, in which case all paths listed will have
996 limited access from within the namespace. If the empty string is
997 assigned to this option, the specific list is reset, and all prior
998 assignments have no effect.
999
1000 Paths in ReadWritePaths=, ReadOnlyPaths= and InaccessiblePaths= may
1001 be prefixed with "-", in which case they will be ignored when they
1002 do not exist. If prefixed with "+" the paths are taken relative to
1003 the root directory of the unit, as configured with
1004 RootDirectory=/RootImage=, instead of relative to the root
1005 directory of the host (see above). When combining "-" and "+" on
1006 the same path make sure to specify "-" first, and "+" second.
1007
1008 Note that these settings will disconnect propagation of mounts from
1009 the unit's processes to the host. This means that this setting may
1010 not be used for services which shall be able to install mount
1011 points in the main mount namespace. For ReadWritePaths= and
1012 ReadOnlyPaths= propagation in the other direction is not affected,
1013 i.e. mounts created on the host generally appear in the unit
1014 processes' namespace, and mounts removed on the host also disappear
1015 there too. In particular, note that mount propagation from host to
1016 unit will result in unmodified mounts to be created in the unit's
1017 namespace, i.e. writable mounts appearing on the host will be
1018 writable in the unit's namespace too, even when propagated below a
1019 path marked with ReadOnlyPaths=! Restricting access with these
1020 options hence does not extend to submounts of a directory that are
1021 created later on. This means the lock-down offered by that setting
1022 is not complete, and does not offer full protection.
1023
1024 Note that the effect of these settings may be undone by privileged
1025 processes. In order to set up an effective sandboxed environment
1026 for a unit it is thus recommended to combine these settings with
1027 either CapabilityBoundingSet=~CAP_SYS_ADMIN or
1028 SystemCallFilter=~@mount.
1029
1030 These options are only available for system services and are not
1031 supported for services running in per-user instances of the service
1032 manager.
1033
1034 TemporaryFileSystem=
1035 Takes a space-separated list of mount points for temporary file
1036 systems (tmpfs). If set, a new file system namespace is set up for
1037 executed processes, and a temporary file system is mounted on each
1038 mount point. This option may be specified more than once, in which
1039 case temporary file systems are mounted on all listed mount points.
1040 If the empty string is assigned to this option, the list is reset,
1041 and all prior assignments have no effect. Each mount point may
1042 optionally be suffixed with a colon (":") and mount options such as
1043 "size=10%" or "ro". By default, each temporary file system is
1044 mounted with "nodev,strictatime,mode=0755". These can be disabled
1045 by explicitly specifying the corresponding mount options, e.g.,
1046 "dev" or "nostrictatime".
1047
1048 This is useful to hide files or directories not relevant to the
1049 processes invoked by the unit, while necessary files or directories
1050 can be still accessed by combining with BindPaths= or
1051 BindReadOnlyPaths=:
1052
1053 Example: if a unit has the following,
1054
1055 TemporaryFileSystem=/var:ro
1056 BindReadOnlyPaths=/var/lib/systemd
1057
1058 then the invoked processes by the unit cannot see any files or
1059 directories under /var except for /var/lib/systemd or its contents.
1060
1061 This option is only available for system services and is not
1062 supported for services running in per-user instances of the service
1063 manager.
1064
1065 PrivateTmp=
1066 Takes a boolean argument. If true, sets up a new file system
1067 namespace for the executed processes and mounts private /tmp/ and
1068 /var/tmp/ directories inside it that are not shared by processes
1069 outside of the namespace. This is useful to secure access to
1070 temporary files of the process, but makes sharing between processes
1071 via /tmp or /var/tmp impossible. If this is enabled, all temporary
1072 files created by a service in these directories will be removed
1073 after the service is stopped. Defaults to false. It is possible to
1074 run two or more units within the same private /tmp and /var/tmp
1075 namespace by using the JoinsNamespaceOf= directive, see
1076 systemd.unit(5) for details. This setting is implied if
1077 DynamicUser= is set. For this setting the same restrictions
1078 regarding mount propagation and privileges apply as for
1079 ReadOnlyPaths= and related calls, see above. Enabling this setting
1080 has the side effect of adding Requires= and After= dependencies on
1081 all mount units necessary to access /tmp and /var/tmp. Moreover an
1082 implicitly After= ordering on systemd-tmpfiles-setup.service(8) is
1083 added.
1084
1085 Note that the implementation of this setting might be impossible
1086 (for example if mount namespaces are not available), and the unit
1087 should be written in a way that does not solely rely on this
1088 setting for security.
1089
1090 This option is only available for system services and is not
1091 supported for services running in per-user instances of the service
1092 manager.
1093
1094 PrivateDevices=
1095 Takes a boolean argument. If true, sets up a new /dev mount for the
1096 executed processes and only adds API pseudo devices such as
1097 /dev/null, /dev/zero or /dev/random (as well as the pseudo TTY
1098 subsystem) to it, but no physical devices such as /dev/sda, system
1099 memory /dev/mem, system ports /dev/port and others. This is useful
1100 to securely turn off physical device access by the executed
1101 process. Defaults to false. Enabling this option will install a
1102 system call filter to block low-level I/O system calls that are
1103 grouped in the @raw-io set, will also remove CAP_MKNOD and
1104 CAP_SYS_RAWIO from the capability bounding set for the unit (see
1105 above), and set DevicePolicy=closed (see systemd.resource-
1106 control(5) for details). Note that using this setting will
1107 disconnect propagation of mounts from the service to the host
1108 (propagation in the opposite direction continues to work). This
1109 means that this setting may not be used for services which shall be
1110 able to install mount points in the main mount namespace. The new
1111 /dev will be mounted read-only and 'noexec'. The latter may break
1112 old programs which try to set up executable memory by using mmap(2)
1113 of /dev/zero instead of using MAP_ANON. For this setting the same
1114 restrictions regarding mount propagation and privileges apply as
1115 for ReadOnlyPaths= and related calls, see above. If turned on and
1116 if running in user mode, or in system mode, but without the
1117 CAP_SYS_ADMIN capability (e.g. setting User=), NoNewPrivileges=yes
1118 is implied.
1119
1120 Note that the implementation of this setting might be impossible
1121 (for example if mount namespaces are not available), and the unit
1122 should be written in a way that does not solely rely on this
1123 setting for security.
1124
1125 This option is only available for system services and is not
1126 supported for services running in per-user instances of the service
1127 manager.
1128
1129 PrivateNetwork=
1130 Takes a boolean argument. If true, sets up a new network namespace
1131 for the executed processes and configures only the loopback network
1132 device "lo" inside it. No other network devices will be available
1133 to the executed process. This is useful to turn off network access
1134 by the executed process. Defaults to false. It is possible to run
1135 two or more units within the same private network namespace by
1136 using the JoinsNamespaceOf= directive, see systemd.unit(5) for
1137 details. Note that this option will disconnect all socket families
1138 from the host, including AF_NETLINK and AF_UNIX. Effectively, for
1139 AF_NETLINK this means that device configuration events received
1140 from systemd-udevd.service(8) are not delivered to the unit's
1141 processes. And for AF_UNIX this has the effect that AF_UNIX sockets
1142 in the abstract socket namespace of the host will become
1143 unavailable to the unit's processes (however, those located in the
1144 file system will continue to be accessible).
1145
1146 Note that the implementation of this setting might be impossible
1147 (for example if network namespaces are not available), and the unit
1148 should be written in a way that does not solely rely on this
1149 setting for security.
1150
1151 When this option is used on a socket unit any sockets bound on
1152 behalf of this unit will be bound within a private network
1153 namespace. This may be combined with JoinsNamespaceOf= to listen on
1154 sockets inside of network namespaces of other services.
1155
1156 This option is only available for system services and is not
1157 supported for services running in per-user instances of the service
1158 manager.
1159
1160 NetworkNamespacePath=
1161 Takes an absolute file system path refererring to a Linux network
1162 namespace pseudo-file (i.e. a file like /proc/$PID/ns/net or a bind
1163 mount or symlink to one). When set the invoked processes are added
1164 to the network namespace referenced by that path. The path has to
1165 point to a valid namespace file at the moment the processes are
1166 forked off. If this option is used PrivateNetwork= has no effect.
1167 If this option is used together with JoinsNamespaceOf= then it only
1168 has an effect if this unit is started before any of the listed
1169 units that have PrivateNetwork= or NetworkNamespacePath=
1170 configured, as otherwise the network namespace of those units is
1171 reused.
1172
1173 When this option is used on a socket unit any sockets bound on
1174 behalf of this unit will be bound within the specified network
1175 namespace.
1176
1177 This option is only available for system services and is not
1178 supported for services running in per-user instances of the service
1179 manager.
1180
1181 PrivateUsers=
1182 Takes a boolean argument. If true, sets up a new user namespace for
1183 the executed processes and configures a minimal user and group
1184 mapping, that maps the "root" user and group as well as the unit's
1185 own user and group to themselves and everything else to the
1186 "nobody" user and group. This is useful to securely detach the user
1187 and group databases used by the unit from the rest of the system,
1188 and thus to create an effective sandbox environment. All files,
1189 directories, processes, IPC objects and other resources owned by
1190 users/groups not equaling "root" or the unit's own will stay
1191 visible from within the unit but appear owned by the "nobody" user
1192 and group. If this mode is enabled, all unit processes are run
1193 without privileges in the host user namespace (regardless if the
1194 unit's own user/group is "root" or not). Specifically this means
1195 that the process will have zero process capabilities on the host's
1196 user namespace, but full capabilities within the service's user
1197 namespace. Settings such as CapabilityBoundingSet= will affect only
1198 the latter, and there's no way to acquire additional capabilities
1199 in the host's user namespace. Defaults to off.
1200
1201 When this setting is set up by a per-user instance of the service
1202 manager, the mapping of the "root" user and group to itself is
1203 omitted (unless the user manager is root). Additionally, in the
1204 per-user instance manager case, the user namespace will be set up
1205 before most other namespaces. This means that combining
1206 PrivateUsers=true with other namespaces will enable use of features
1207 not normally supported by the per-user instances of the service
1208 manager.
1209
1210 This setting is particularly useful in conjunction with
1211 RootDirectory=/RootImage=, as the need to synchronize the user and
1212 group databases in the root directory and on the host is reduced,
1213 as the only users and groups who need to be matched are "root",
1214 "nobody" and the unit's own user and group.
1215
1216 Note that the implementation of this setting might be impossible
1217 (for example if user namespaces are not available), and the unit
1218 should be written in a way that does not solely rely on this
1219 setting for security.
1220
1221 ProtectHostname=
1222 Takes a boolean argument. When set, sets up a new UTS namespace for
1223 the executed processes. In addition, changing hostname or
1224 domainname is prevented. Defaults to off.
1225
1226 Note that the implementation of this setting might be impossible
1227 (for example if UTS namespaces are not available), and the unit
1228 should be written in a way that does not solely rely on this
1229 setting for security.
1230
1231 Note that when this option is enabled for a service hostname
1232 changes no longer propagate from the system into the service, it is
1233 hence not suitable for services that need to take notice of system
1234 hostname changes dynamically.
1235
1236 This option is only available for system services and is not
1237 supported for services running in per-user instances of the service
1238 manager.
1239
1240 ProtectClock=
1241 Takes a boolean argument. If set, writes to the hardware clock or
1242 system clock will be denied. It is recommended to turn this on for
1243 most services that do not need modify the clock. Defaults to off.
1244 Enabling this option removes CAP_SYS_TIME and CAP_WAKE_ALARM from
1245 the capability bounding set for this unit, installs a system call
1246 filter to block calls that can set the clock, and
1247 DeviceAllow=char-rtc r is implied. This ensures /dev/rtc0,
1248 /dev/rtc1, etc. are made read-only to the service. See
1249 systemd.resource-control(5) for the details about DeviceAllow=.
1250
1251 This option is only available for system services and is not
1252 supported for services running in per-user instances of the service
1253 manager.
1254
1255 ProtectKernelTunables=
1256 Takes a boolean argument. If true, kernel variables accessible
1257 through /proc/sys, /sys, /proc/sysrq-trigger, /proc/latency_stats,
1258 /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq will be made
1259 read-only to all processes of the unit. Usually, tunable kernel
1260 variables should be initialized only at boot-time, for example with
1261 the sysctl.d(5) mechanism. Few services need to write to these at
1262 runtime; it is hence recommended to turn this on for most services.
1263 For this setting the same restrictions regarding mount propagation
1264 and privileges apply as for ReadOnlyPaths= and related calls, see
1265 above. Defaults to off. If turned on and if running in user mode,
1266 or in system mode, but without the CAP_SYS_ADMIN capability (e.g.
1267 services for which User= is set), NoNewPrivileges=yes is implied.
1268 Note that this option does not prevent indirect changes to kernel
1269 tunables effected by IPC calls to other processes. However,
1270 InaccessiblePaths= may be used to make relevant IPC file system
1271 objects inaccessible. If ProtectKernelTunables= is set,
1272 MountAPIVFS=yes is implied.
1273
1274 This option is only available for system services and is not
1275 supported for services running in per-user instances of the service
1276 manager.
1277
1278 ProtectKernelModules=
1279 Takes a boolean argument. If true, explicit module loading will be
1280 denied. This allows module load and unload operations to be turned
1281 off on modular kernels. It is recommended to turn this on for most
1282 services that do not need special file systems or extra kernel
1283 modules to work. Defaults to off. Enabling this option removes
1284 CAP_SYS_MODULE from the capability bounding set for the unit, and
1285 installs a system call filter to block module system calls, also
1286 /usr/lib/modules is made inaccessible. For this setting the same
1287 restrictions regarding mount propagation and privileges apply as
1288 for ReadOnlyPaths= and related calls, see above. Note that limited
1289 automatic module loading due to user configuration or kernel
1290 mapping tables might still happen as side effect of requested user
1291 operations, both privileged and unprivileged. To disable module
1292 auto-load feature please see sysctl.d(5) kernel.modules_disabled
1293 mechanism and /proc/sys/kernel/modules_disabled documentation. If
1294 turned on and if running in user mode, or in system mode, but
1295 without the CAP_SYS_ADMIN capability (e.g. setting User=),
1296 NoNewPrivileges=yes is implied.
1297
1298 This option is only available for system services and is not
1299 supported for services running in per-user instances of the service
1300 manager.
1301
1302 ProtectKernelLogs=
1303 Takes a boolean argument. If true, access to the kernel log ring
1304 buffer will be denied. It is recommended to turn this on for most
1305 services that do not need to read from or write to the kernel log
1306 ring buffer. Enabling this option removes CAP_SYSLOG from the
1307 capability bounding set for this unit, and installs a system call
1308 filter to block the syslog(2) system call (not to be confused with
1309 the libc API syslog(3) for userspace logging). The kernel exposes
1310 its log buffer to userspace via /dev/kmsg and /proc/kmsg. If
1311 enabled, these are made inaccessible to all the processes in the
1312 unit.
1313
1314 This option is only available for system services and is not
1315 supported for services running in per-user instances of the service
1316 manager.
1317
1318 ProtectControlGroups=
1319 Takes a boolean argument. If true, the Linux Control Groups
1320 (cgroups(7)) hierarchies accessible through /sys/fs/cgroup will be
1321 made read-only to all processes of the unit. Except for container
1322 managers no services should require write access to the control
1323 groups hierarchies; it is hence recommended to turn this on for
1324 most services. For this setting the same restrictions regarding
1325 mount propagation and privileges apply as for ReadOnlyPaths= and
1326 related calls, see above. Defaults to off. If ProtectControlGroups=
1327 is set, MountAPIVFS=yes is implied.
1328
1329 This option is only available for system services and is not
1330 supported for services running in per-user instances of the service
1331 manager.
1332
1333 RestrictAddressFamilies=
1334 Restricts the set of socket address families accessible to the
1335 processes of this unit. Takes a space-separated list of address
1336 family names to allow-list, such as AF_UNIX, AF_INET or AF_INET6.
1337 When prefixed with ~ the listed address families will be applied as
1338 deny list, otherwise as allow list. Note that this restricts access
1339 to the socket(2) system call only. Sockets passed into the process
1340 by other means (for example, by using socket activation with socket
1341 units, see systemd.socket(5)) are unaffected. Also, sockets created
1342 with socketpair() (which creates connected AF_UNIX sockets only)
1343 are unaffected. Note that this option has no effect on 32-bit x86,
1344 s390, s390x, mips, mips-le, ppc, ppc-le, ppc64, ppc64-le and is
1345 ignored (but works correctly on other ABIs, including x86-64). Note
1346 that on systems supporting multiple ABIs (such as x86/x86-64) it is
1347 recommended to turn off alternative ABIs for services, so that they
1348 cannot be used to circumvent the restrictions of this option.
1349 Specifically, it is recommended to combine this option with
1350 SystemCallArchitectures=native or similar. If running in user mode,
1351 or in system mode, but without the CAP_SYS_ADMIN capability (e.g.
1352 setting User=nobody), NoNewPrivileges=yes is implied. By default,
1353 no restrictions apply, all address families are accessible to
1354 processes. If assigned the empty string, any previous address
1355 family restriction changes are undone. This setting does not affect
1356 commands prefixed with "+".
1357
1358 Use this option to limit exposure of processes to remote access, in
1359 particular via exotic and sensitive network protocols, such as
1360 AF_PACKET. Note that in most cases, the local AF_UNIX address
1361 family should be included in the configured allow list as it is
1362 frequently used for local communication, including for syslog(2)
1363 logging.
1364
1365 RestrictNamespaces=
1366 Restricts access to Linux namespace functionality for the processes
1367 of this unit. For details about Linux namespaces, see
1368 namespaces(7). Either takes a boolean argument, or a
1369 space-separated list of namespace type identifiers. If false (the
1370 default), no restrictions on namespace creation and switching are
1371 made. If true, access to any kind of namespacing is prohibited.
1372 Otherwise, a space-separated list of namespace type identifiers
1373 must be specified, consisting of any combination of: cgroup, ipc,
1374 net, mnt, pid, user and uts. Any namespace type listed is made
1375 accessible to the unit's processes, access to namespace types not
1376 listed is prohibited (allow-listing). By prepending the list with a
1377 single tilde character ("~") the effect may be inverted: only the
1378 listed namespace types will be made inaccessible, all unlisted ones
1379 are permitted (deny-listing). If the empty string is assigned, the
1380 default namespace restrictions are applied, which is equivalent to
1381 false. This option may appear more than once, in which case the
1382 namespace types are merged by OR, or by AND if the lines are
1383 prefixed with "~" (see examples below). Internally, this setting
1384 limits access to the unshare(2), clone(2) and setns(2) system
1385 calls, taking the specified flags parameters into account. Note
1386 that — if this option is used — in addition to restricting creation
1387 and switching of the specified types of namespaces (or all of them,
1388 if true) access to the setns() system call with a zero flags
1389 parameter is prohibited. This setting is only supported on x86,
1390 x86-64, mips, mips-le, mips64, mips64-le, mips64-n32,
1391 mips64-le-n32, ppc64, ppc64-le, s390 and s390x, and enforces no
1392 restrictions on other architectures. If running in user mode, or in
1393 system mode, but without the CAP_SYS_ADMIN capability (e.g. setting
1394 User=), NoNewPrivileges=yes is implied.
1395
1396 Example: if a unit has the following,
1397
1398 RestrictNamespaces=cgroup ipc
1399 RestrictNamespaces=cgroup net
1400
1401 then cgroup, ipc, and net are set. If the second line is prefixed
1402 with "~", e.g.,
1403
1404 RestrictNamespaces=cgroup ipc
1405 RestrictNamespaces=~cgroup net
1406
1407 then, only ipc is set.
1408
1409 LockPersonality=
1410 Takes a boolean argument. If set, locks down the personality(2)
1411 system call so that the kernel execution domain may not be changed
1412 from the default or the personality selected with Personality=
1413 directive. This may be useful to improve security, because odd
1414 personality emulations may be poorly tested and source of
1415 vulnerabilities. If running in user mode, or in system mode, but
1416 without the CAP_SYS_ADMIN capability (e.g. setting User=),
1417 NoNewPrivileges=yes is implied.
1418
1419 MemoryDenyWriteExecute=
1420 Takes a boolean argument. If set, attempts to create memory
1421 mappings that are writable and executable at the same time, or to
1422 change existing memory mappings to become executable, or mapping
1423 shared memory segments as executable are prohibited. Specifically,
1424 a system call filter is added that rejects mmap(2) system calls
1425 with both PROT_EXEC and PROT_WRITE set, mprotect(2) or
1426 pkey_mprotect(2) system calls with PROT_EXEC set and shmat(2)
1427 system calls with SHM_EXEC set. Note that this option is
1428 incompatible with programs and libraries that generate program code
1429 dynamically at runtime, including JIT execution engines, executable
1430 stacks, and code "trampoline" feature of various C compilers. This
1431 option improves service security, as it makes harder for software
1432 exploits to change running code dynamically. However, the
1433 protection can be circumvented, if the service can write to a
1434 filesystem, which is not mounted with noexec (such as /dev/shm), or
1435 it can use memfd_create(). This can be prevented by making such
1436 file systems inaccessible to the service (e.g.
1437 InaccessiblePaths=/dev/shm) and installing further system call
1438 filters (SystemCallFilter=~memfd_create). Note that this feature is
1439 fully available on x86-64, and partially on x86. Specifically, the
1440 shmat() protection is not available on x86. Note that on systems
1441 supporting multiple ABIs (such as x86/x86-64) it is recommended to
1442 turn off alternative ABIs for services, so that they cannot be used
1443 to circumvent the restrictions of this option. Specifically, it is
1444 recommended to combine this option with
1445 SystemCallArchitectures=native or similar. If running in user mode,
1446 or in system mode, but without the CAP_SYS_ADMIN capability (e.g.
1447 setting User=), NoNewPrivileges=yes is implied.
1448
1449 RestrictRealtime=
1450 Takes a boolean argument. If set, any attempts to enable realtime
1451 scheduling in a process of the unit are refused. This restricts
1452 access to realtime task scheduling policies such as SCHED_FIFO,
1453 SCHED_RR or SCHED_DEADLINE. See sched(7) for details about these
1454 scheduling policies. If running in user mode, or in system mode,
1455 but without the CAP_SYS_ADMIN capability (e.g. setting User=),
1456 NoNewPrivileges=yes is implied. Realtime scheduling policies may be
1457 used to monopolize CPU time for longer periods of time, and may
1458 hence be used to lock up or otherwise trigger Denial-of-Service
1459 situations on the system. It is hence recommended to restrict
1460 access to realtime scheduling to the few programs that actually
1461 require them. Defaults to off.
1462
1463 RestrictSUIDSGID=
1464 Takes a boolean argument. If set, any attempts to set the
1465 set-user-ID (SUID) or set-group-ID (SGID) bits on files or
1466 directories will be denied (for details on these bits see
1467 inode(7)). If running in user mode, or in system mode, but without
1468 the CAP_SYS_ADMIN capability (e.g. setting User=),
1469 NoNewPrivileges=yes is implied. As the SUID/SGID bits are
1470 mechanisms to elevate privileges, and allows users to acquire the
1471 identity of other users, it is recommended to restrict creation of
1472 SUID/SGID files to the few programs that actually require them.
1473 Note that this restricts marking of any type of file system object
1474 with these bits, including both regular files and directories
1475 (where the SGID is a different meaning than for files, see
1476 documentation). This option is implied if DynamicUser= is enabled.
1477 Defaults to off.
1478
1479 RemoveIPC=
1480 Takes a boolean parameter. If set, all System V and POSIX IPC
1481 objects owned by the user and group the processes of this unit are
1482 run as are removed when the unit is stopped. This setting only has
1483 an effect if at least one of User=, Group= and DynamicUser= are
1484 used. It has no effect on IPC objects owned by the root user.
1485 Specifically, this removes System V semaphores, as well as System V
1486 and POSIX shared memory segments and message queues. If multiple
1487 units use the same user or group the IPC objects are removed when
1488 the last of these units is stopped. This setting is implied if
1489 DynamicUser= is set.
1490
1491 This option is only available for system services and is not
1492 supported for services running in per-user instances of the service
1493 manager.
1494
1495 PrivateMounts=
1496 Takes a boolean parameter. If set, the processes of this unit will
1497 be run in their own private file system (mount) namespace with all
1498 mount propagation from the processes towards the host's main file
1499 system namespace turned off. This means any file system mount
1500 points established or removed by the unit's processes will be
1501 private to them and not be visible to the host. However, file
1502 system mount points established or removed on the host will be
1503 propagated to the unit's processes. See mount_namespaces(7) for
1504 details on file system namespaces. Defaults to off.
1505
1506 When turned on, this executes three operations for each invoked
1507 process: a new CLONE_NEWNS namespace is created, after which all
1508 existing mounts are remounted to MS_SLAVE to disable propagation
1509 from the unit's processes to the host (but leaving propagation in
1510 the opposite direction in effect). Finally, the mounts are
1511 remounted again to the propagation mode configured with
1512 MountFlags=, see below.
1513
1514 File system namespaces are set up individually for each process
1515 forked off by the service manager. Mounts established in the
1516 namespace of the process created by ExecStartPre= will hence be
1517 cleaned up automatically as soon as that process exits and will not
1518 be available to subsequent processes forked off for ExecStart= (and
1519 similar applies to the various other commands configured for
1520 units). Similarly, JoinsNamespaceOf= does not permit sharing kernel
1521 mount namespaces between units, it only enables sharing of the
1522 /tmp/ and /var/tmp/ directories.
1523
1524 Other file system namespace unit settings — PrivateMounts=,
1525 PrivateTmp=, PrivateDevices=, ProtectSystem=, ProtectHome=,
1526 ReadOnlyPaths=, InaccessiblePaths=, ReadWritePaths=, ... — also
1527 enable file system namespacing in a fashion equivalent to this
1528 option. Hence it is primarily useful to explicitly request this
1529 behaviour if none of the other settings are used.
1530
1531 This option is only available for system services and is not
1532 supported for services running in per-user instances of the service
1533 manager.
1534
1535 MountFlags=
1536 Takes a mount propagation setting: shared, slave or private, which
1537 controls whether file system mount points in the file system
1538 namespaces set up for this unit's processes will receive or
1539 propagate mounts and unmounts from other file system namespaces.
1540 See mount(2) for details on mount propagation, and the three
1541 propagation flags in particular.
1542
1543 This setting only controls the final propagation setting in effect
1544 on all mount points of the file system namespace created for each
1545 process of this unit. Other file system namespacing unit settings
1546 (see the discussion in PrivateMounts= above) will implicitly
1547 disable mount and unmount propagation from the unit's processes
1548 towards the host by changing the propagation setting of all mount
1549 points in the unit's file system namespace to slave first. Setting
1550 this option to shared does not reestablish propagation in that
1551 case.
1552
1553 If not set – but file system namespaces are enabled through another
1554 file system namespace unit setting – shared mount propagation is
1555 used, but — as mentioned — as slave is applied first, propagation
1556 from the unit's processes to the host is still turned off.
1557
1558 It is not recommended to use private mount propagation for units,
1559 as this means temporary mounts (such as removable media) of the
1560 host will stay mounted and thus indefinitely busy in forked off
1561 processes, as unmount propagation events won't be received by the
1562 file system namespace of the unit.
1563
1564 Usually, it is best to leave this setting unmodified, and use
1565 higher level file system namespacing options instead, in particular
1566 PrivateMounts=, see above.
1567
1568 This option is only available for system services and is not
1569 supported for services running in per-user instances of the service
1570 manager.
1571
1573 SystemCallFilter=
1574 Takes a space-separated list of system call names. If this setting
1575 is used, all system calls executed by the unit processes except for
1576 the listed ones will result in immediate process termination with
1577 the SIGSYS signal (allow-listing). (See SystemCallErrorNumber=
1578 below for changing the default action). If the first character of
1579 the list is "~", the effect is inverted: only the listed system
1580 calls will result in immediate process termination (deny-listing).
1581 Deny-listed system calls and system call groups may optionally be
1582 suffixed with a colon (":") and "errno" error number (between 0 and
1583 4095) or errno name such as EPERM, EACCES or EUCLEAN (see errno(3)
1584 for a full list). This value will be returned when a deny-listed
1585 system call is triggered, instead of terminating the processes
1586 immediately. This value takes precedence over the one given in
1587 SystemCallErrorNumber=, see below. If running in user mode, or in
1588 system mode, but without the CAP_SYS_ADMIN capability (e.g. setting
1589 User=nobody), NoNewPrivileges=yes is implied. This feature makes
1590 use of the Secure Computing Mode 2 interfaces of the kernel
1591 ('seccomp filtering') and is useful for enforcing a minimal
1592 sandboxing environment. Note that the execve, exit, exit_group,
1593 getrlimit, rt_sigreturn, sigreturn system calls and the system
1594 calls for querying time and sleeping are implicitly allow-listed
1595 and do not need to be listed explicitly. This option may be
1596 specified more than once, in which case the filter masks are
1597 merged. If the empty string is assigned, the filter is reset, all
1598 prior assignments will have no effect. This does not affect
1599 commands prefixed with "+".
1600
1601 Note that on systems supporting multiple ABIs (such as x86/x86-64)
1602 it is recommended to turn off alternative ABIs for services, so
1603 that they cannot be used to circumvent the restrictions of this
1604 option. Specifically, it is recommended to combine this option with
1605 SystemCallArchitectures=native or similar.
1606
1607 Note that strict system call filters may impact execution and error
1608 handling code paths of the service invocation. Specifically, access
1609 to the execve system call is required for the execution of the
1610 service binary — if it is blocked service invocation will
1611 necessarily fail. Also, if execution of the service binary fails
1612 for some reason (for example: missing service executable), the
1613 error handling logic might require access to an additional set of
1614 system calls in order to process and log this failure correctly. It
1615 might be necessary to temporarily disable system call filters in
1616 order to simplify debugging of such failures.
1617
1618 If you specify both types of this option (i.e. allow-listing and
1619 deny-listing), the first encountered will take precedence and will
1620 dictate the default action (termination or approval of a system
1621 call). Then the next occurrences of this option will add or delete
1622 the listed system calls from the set of the filtered system calls,
1623 depending of its type and the default action. (For example, if you
1624 have started with an allow list rule for read and write, and right
1625 after it add a deny list rule for write, then write will be removed
1626 from the set.)
1627
1628 As the number of possible system calls is large, predefined sets of
1629 system calls are provided. A set starts with "@" character,
1630 followed by name of the set.
1631
1632 Table 3. Currently predefined system call sets
1633 ┌────────────────┬────────────────────────────┐
1634 │Set │ Description │
1635 ├────────────────┼────────────────────────────┤
1636 │@aio │ Asynchronous I/O │
1637 │ │ (io_setup(2), │
1638 │ │ io_submit(2), and related │
1639 │ │ calls) │
1640 ├────────────────┼────────────────────────────┤
1641 │@basic-io │ System calls for basic │
1642 │ │ I/O: reading, writing, │
1643 │ │ seeking, file descriptor │
1644 │ │ duplication and closing │
1645 │ │ (read(2), write(2), and │
1646 │ │ related calls) │
1647 ├────────────────┼────────────────────────────┤
1648 │@chown │ Changing file ownership │
1649 │ │ (chown(2), fchownat(2), │
1650 │ │ and related calls) │
1651 ├────────────────┼────────────────────────────┤
1652 │@clock │ System calls for changing │
1653 │ │ the system clock │
1654 │ │ (adjtimex(2), │
1655 │ │ settimeofday(2), and │
1656 │ │ related calls) │
1657 ├────────────────┼────────────────────────────┤
1658 │@cpu-emulation │ System calls for CPU │
1659 │ │ emulation functionality │
1660 │ │ (vm86(2) and related │
1661 │ │ calls) │
1662 ├────────────────┼────────────────────────────┤
1663 │@debug │ Debugging, performance │
1664 │ │ monitoring and tracing │
1665 │ │ functionality (ptrace(2), │
1666 │ │ perf_event_open(2) and │
1667 │ │ related calls) │
1668 ├────────────────┼────────────────────────────┤
1669 │@file-system │ File system operations: │
1670 │ │ opening, creating files │
1671 │ │ and directories for read │
1672 │ │ and write, renaming and │
1673 │ │ removing them, reading │
1674 │ │ file properties, or │
1675 │ │ creating hard and symbolic │
1676 │ │ links │
1677 ├────────────────┼────────────────────────────┤
1678 │@io-event │ Event loop system calls │
1679 │ │ (poll(2), select(2), │
1680 │ │ epoll(7), eventfd(2) and │
1681 │ │ related calls) │
1682 ├────────────────┼────────────────────────────┤
1683 │@ipc │ Pipes, SysV IPC, POSIX │
1684 │ │ Message Queues and other │
1685 │ │ IPC (mq_overview(7), │
1686 │ │ svipc(7)) │
1687 ├────────────────┼────────────────────────────┤
1688 │@keyring │ Kernel keyring access │
1689 │ │ (keyctl(2) and related │
1690 │ │ calls) │
1691 ├────────────────┼────────────────────────────┤
1692 │@memlock │ Locking of memory in RAM │
1693 │ │ (mlock(2), mlockall(2) and │
1694 │ │ related calls) │
1695 ├────────────────┼────────────────────────────┤
1696 │@module │ Loading and unloading of │
1697 │ │ kernel modules │
1698 │ │ (init_module(2), │
1699 │ │ delete_module(2) and │
1700 │ │ related calls) │
1701 ├────────────────┼────────────────────────────┤
1702 │@mount │ Mounting and unmounting of │
1703 │ │ file systems (mount(2), │
1704 │ │ chroot(2), and related │
1705 │ │ calls) │
1706 ├────────────────┼────────────────────────────┤
1707 │@network-io │ Socket I/O (including │
1708 │ │ local AF_UNIX): socket(7), │
1709 │ │ unix(7) │
1710 ├────────────────┼────────────────────────────┤
1711 │@obsolete │ Unusual, obsolete or │
1712 │ │ unimplemented │
1713 │ │ (create_module(2), │
1714 │ │ gtty(2), ...) │
1715 ├────────────────┼────────────────────────────┤
1716 │@privileged │ All system calls which │
1717 │ │ need super-user │
1718 │ │ capabilities │
1719 │ │ (capabilities(7)) │
1720 ├────────────────┼────────────────────────────┤
1721 │@process │ Process control, │
1722 │ │ execution, namespaceing │
1723 │ │ operations (clone(2), │
1724 │ │ kill(2), namespaces(7), │
1725 │ │ ...) │
1726 ├────────────────┼────────────────────────────┤
1727 │@raw-io │ Raw I/O port access │
1728 │ │ (ioperm(2), iopl(2), │
1729 │ │ pciconfig_read(), ...) │
1730 ├────────────────┼────────────────────────────┤
1731 │@reboot │ System calls for rebooting │
1732 │ │ and reboot preparation │
1733 │ │ (reboot(2), kexec(), ...) │
1734 ├────────────────┼────────────────────────────┤
1735 │@resources │ System calls for changing │
1736 │ │ resource limits, memory │
1737 │ │ and scheduling parameters │
1738 │ │ (setrlimit(2), │
1739 │ │ setpriority(2), ...) │
1740 ├────────────────┼────────────────────────────┤
1741 │@setuid │ System calls for changing │
1742 │ │ user ID and group ID │
1743 │ │ credentials, (setuid(2), │
1744 │ │ setgid(2), setresuid(2), │
1745 │ │ ...) │
1746 ├────────────────┼────────────────────────────┤
1747 │@signal │ System calls for │
1748 │ │ manipulating and handling │
1749 │ │ process signals │
1750 │ │ (signal(2), │
1751 │ │ sigprocmask(2), ...) │
1752 ├────────────────┼────────────────────────────┤
1753 │@swap │ System calls for │
1754 │ │ enabling/disabling swap │
1755 │ │ devices (swapon(2), │
1756 │ │ swapoff(2)) │
1757 ├────────────────┼────────────────────────────┤
1758 │@sync │ Synchronizing files and │
1759 │ │ memory to disk (fsync(2), │
1760 │ │ msync(2), and related │
1761 │ │ calls) │
1762 ├────────────────┼────────────────────────────┤
1763 │@system-service │ A reasonable set of system │
1764 │ │ calls used by common │
1765 │ │ system services, excluding │
1766 │ │ any special purpose calls. │
1767 │ │ This is the recommended │
1768 │ │ starting point for │
1769 │ │ allow-listing system calls │
1770 │ │ for system services, as it │
1771 │ │ contains what is typically │
1772 │ │ needed by system services, │
1773 │ │ but excludes overly │
1774 │ │ specific interfaces. For │
1775 │ │ example, the following │
1776 │ │ APIs are excluded: │
1777 │ │ "@clock", "@mount", │
1778 │ │ "@swap", "@reboot". │
1779 ├────────────────┼────────────────────────────┤
1780 │@timer │ System calls for │
1781 │ │ scheduling operations by │
1782 │ │ time (alarm(2), │
1783 │ │ timer_create(2), ...) │
1784 └────────────────┴────────────────────────────┘
1785 Note, that as new system calls are added to the kernel, additional
1786 system calls might be added to the groups above. Contents of the
1787 sets may also change between systemd versions. In addition, the
1788 list of system calls depends on the kernel version and architecture
1789 for which systemd was compiled. Use systemd-analyze syscall-filter
1790 to list the actual list of system calls in each filter.
1791
1792 Generally, allow-listing system calls (rather than deny-listing) is
1793 the safer mode of operation. It is recommended to enforce system
1794 call allow lists for all long-running system services.
1795 Specifically, the following lines are a relatively safe basic
1796 choice for the majority of system services:
1797
1798 [Service]
1799 SystemCallFilter=@system-service
1800 SystemCallErrorNumber=EPERM
1801
1802 Note that various kernel system calls are defined redundantly:
1803 there are multiple system calls for executing the same operation.
1804 For example, the pidfd_send_signal() system call may be used to
1805 execute operations similar to what can be done with the older
1806 kill() system call, hence blocking the latter without the former
1807 only provides weak protection. Since new system calls are added
1808 regularly to the kernel as development progresses, keeping system
1809 call deny lists comprehensive requires constant work. It is thus
1810 recommended to use allow-listing instead, which offers the benefit
1811 that new system calls are by default implicitly blocked until the
1812 allow list is updated.
1813
1814 Also note that a number of system calls are required to be
1815 accessible for the dynamic linker to work. The dynamic linker is
1816 required for running most regular programs (specifically: all
1817 dynamic ELF binaries, which is how most distributions build
1818 packaged programs). This means that blocking these system calls
1819 (which include open(), openat() or mmap()) will make most programs
1820 typically shipped with generic distributions unusable.
1821
1822 It is recommended to combine the file system namespacing related
1823 options with SystemCallFilter=~@mount, in order to prohibit the
1824 unit's processes to undo the mappings. Specifically these are the
1825 options PrivateTmp=, PrivateDevices=, ProtectSystem=, ProtectHome=,
1826 ProtectKernelTunables=, ProtectControlGroups=, ProtectKernelLogs=,
1827 ProtectClock=, ReadOnlyPaths=, InaccessiblePaths= and
1828 ReadWritePaths=.
1829
1830 SystemCallErrorNumber=
1831 Takes an "errno" error number (between 1 and 4095) or errno name
1832 such as EPERM, EACCES or EUCLEAN, to return when the system call
1833 filter configured with SystemCallFilter= is triggered, instead of
1834 terminating the process immediately. See errno(3) for a full list
1835 of error codes. When this setting is not used, or when the empty
1836 string is assigned, the process will be terminated immediately when
1837 the filter is triggered.
1838
1839 SystemCallArchitectures=
1840 Takes a space-separated list of architecture identifiers to include
1841 in the system call filter. The known architecture identifiers are
1842 the same as for ConditionArchitecture= described in
1843 systemd.unit(5), as well as x32, mips64-n32, mips64-le-n32, and the
1844 special identifier native. The special identifier native implicitly
1845 maps to the native architecture of the system (or more precisely:
1846 to the architecture the system manager is compiled for). If running
1847 in user mode, or in system mode, but without the CAP_SYS_ADMIN
1848 capability (e.g. setting User=nobody), NoNewPrivileges=yes is
1849 implied. By default, this option is set to the empty list, i.e. no
1850 filtering is applied.
1851
1852 If this setting is used, processes of this unit will only be
1853 permitted to call native system calls, and system calls of the
1854 specified architectures. For the purposes of this option, the x32
1855 architecture is treated as including x86-64 system calls. However,
1856 this setting still fulfills its purpose, as explained below, on
1857 x32.
1858
1859 System call filtering is not equally effective on all
1860 architectures. For example, on x86 filtering of network
1861 socket-related calls is not possible, due to ABI limitations — a
1862 limitation that x86-64 does not have, however. On systems
1863 supporting multiple ABIs at the same time — such as x86/x86-64 — it
1864 is hence recommended to limit the set of permitted system call
1865 architectures so that secondary ABIs may not be used to circumvent
1866 the restrictions applied to the native ABI of the system. In
1867 particular, setting SystemCallArchitectures=native is a good choice
1868 for disabling non-native ABIs.
1869
1870 System call architectures may also be restricted system-wide via
1871 the SystemCallArchitectures= option in the global configuration.
1872 See systemd-system.conf(5) for details.
1873
1875 Environment=
1876 Sets environment variables for executed processes. Takes a
1877 space-separated list of variable assignments. This option may be
1878 specified more than once, in which case all listed variables will
1879 be set. If the same variable is set twice, the later setting will
1880 override the earlier setting. If the empty string is assigned to
1881 this option, the list of environment variables is reset, all prior
1882 assignments have no effect. Variable expansion is not performed
1883 inside the strings, however, specifier expansion is possible. The
1884 "$" character has no special meaning. If you need to assign a value
1885 containing spaces or the equals sign to a variable, use double
1886 quotes (") for the assignment.
1887
1888 The names of the variables can contain ASCII letters, digits, and
1889 the underscore character. Variable names cannot be empty or start
1890 with a digit. In variable values, most characters are allowed, but
1891 non-printable characters are currently rejected.
1892
1893 Example:
1894
1895 Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
1896
1897 gives three variables "VAR1", "VAR2", "VAR3" with the values "word1
1898 word2", "word3", "$word 5 6".
1899
1900 See environ(7) for details about environment variables.
1901
1902 Note that environment variables are not suitable for passing
1903 secrets (such as passwords, key material, ...) to service
1904 processes. Environment variables set for a unit are exposed to
1905 unprivileged clients via D-Bus IPC, and generally not understood as
1906 being data that requires protection. Moreover, environment
1907 variables are propagated down the process tree, including across
1908 security boundaries (such as setuid/setgid executables), and hence
1909 might leak to processes that should not have access to the secret
1910 data.
1911
1912 EnvironmentFile=
1913 Similar to Environment= but reads the environment variables from a
1914 text file. The text file should contain new-line-separated variable
1915 assignments. Empty lines, lines without an "=" separator, or lines
1916 starting with ; or # will be ignored, which may be used for
1917 commenting. A line ending with a backslash will be concatenated
1918 with the following one, allowing multiline variable definitions.
1919 The parser strips leading and trailing whitespace from the values
1920 of assignments, unless you use double quotes (").
1921
1922 C escapes[5] are supported, but not most control characters[6].
1923 "\t" and "\n" can be used to insert tabs and newlines within
1924 EnvironmentFile=.
1925
1926 The argument passed should be an absolute filename or wildcard
1927 expression, optionally prefixed with "-", which indicates that if
1928 the file does not exist, it will not be read and no error or
1929 warning message is logged. This option may be specified more than
1930 once in which case all specified files are read. If the empty
1931 string is assigned to this option, the list of file to read is
1932 reset, all prior assignments have no effect.
1933
1934 The files listed with this directive will be read shortly before
1935 the process is executed (more specifically, after all processes
1936 from a previous unit state terminated. This means you can generate
1937 these files in one unit state, and read it with this option in the
1938 next. The files are read from the file system of the service
1939 manager, before any file system changes like bind mounts take
1940 place).
1941
1942 Settings from these files override settings made with Environment=.
1943 If the same variable is set twice from these files, the files will
1944 be read in the order they are specified and the later setting will
1945 override the earlier setting.
1946
1947 PassEnvironment=
1948 Pass environment variables set for the system service manager to
1949 executed processes. Takes a space-separated list of variable names.
1950 This option may be specified more than once, in which case all
1951 listed variables will be passed. If the empty string is assigned to
1952 this option, the list of environment variables to pass is reset,
1953 all prior assignments have no effect. Variables specified that are
1954 not set for the system manager will not be passed and will be
1955 silently ignored. Note that this option is only relevant for the
1956 system service manager, as system services by default do not
1957 automatically inherit any environment variables set for the service
1958 manager itself. However, in case of the user service manager all
1959 environment variables are passed to the executed processes anyway,
1960 hence this option is without effect for the user service manager.
1961
1962 Variables set for invoked processes due to this setting are subject
1963 to being overridden by those configured with Environment= or
1964 EnvironmentFile=.
1965
1966 C escapes[5] are supported, but not most control characters[6].
1967 "\t" and "\n" can be used to insert tabs and newlines within
1968 EnvironmentFile=.
1969
1970 Example:
1971
1972 PassEnvironment=VAR1 VAR2 VAR3
1973
1974 passes three variables "VAR1", "VAR2", "VAR3" with the values set
1975 for those variables in PID1.
1976
1977 See environ(7) for details about environment variables.
1978
1979 UnsetEnvironment=
1980 Explicitly unset environment variable assignments that would
1981 normally be passed from the service manager to invoked processes of
1982 this unit. Takes a space-separated list of variable names or
1983 variable assignments. This option may be specified more than once,
1984 in which case all listed variables/assignments will be unset. If
1985 the empty string is assigned to this option, the list of
1986 environment variables/assignments to unset is reset. If a variable
1987 assignment is specified (that is: a variable name, followed by "=",
1988 followed by its value), then any environment variable matching this
1989 precise assignment is removed. If a variable name is specified
1990 (that is a variable name without any following "=" or value), then
1991 any assignment matching the variable name, regardless of its value
1992 is removed. Note that the effect of UnsetEnvironment= is applied as
1993 final step when the environment list passed to executed processes
1994 is compiled. That means it may undo assignments from any
1995 configuration source, including assignments made through
1996 Environment= or EnvironmentFile=, inherited from the system
1997 manager's global set of environment variables, inherited via
1998 PassEnvironment=, set by the service manager itself (such as
1999 $NOTIFY_SOCKET and such), or set by a PAM module (in case PAMName=
2000 is used).
2001
2002 See environ(7) for details about environment variables.
2003
2005 StandardInput=
2006 Controls where file descriptor 0 (STDIN) of the executed processes
2007 is connected to. Takes one of null, tty, tty-force, tty-fail, data,
2008 file:path, socket or fd:name.
2009
2010 If null is selected, standard input will be connected to /dev/null,
2011 i.e. all read attempts by the process will result in immediate EOF.
2012
2013 If tty is selected, standard input is connected to a TTY (as
2014 configured by TTYPath=, see below) and the executed process becomes
2015 the controlling process of the terminal. If the terminal is already
2016 being controlled by another process, the executed process waits
2017 until the current controlling process releases the terminal.
2018
2019 tty-force is similar to tty, but the executed process is forcefully
2020 and immediately made the controlling process of the terminal,
2021 potentially removing previous controlling processes from the
2022 terminal.
2023
2024 tty-fail is similar to tty, but if the terminal already has a
2025 controlling process start-up of the executed process fails.
2026
2027 The data option may be used to configure arbitrary textual or
2028 binary data to pass via standard input to the executed process. The
2029 data to pass is configured via
2030 StandardInputText=/StandardInputData= (see below). Note that the
2031 actual file descriptor type passed (memory file, regular file, UNIX
2032 pipe, ...) might depend on the kernel and available privileges. In
2033 any case, the file descriptor is read-only, and when read returns
2034 the specified data followed by EOF.
2035
2036 The file:path option may be used to connect a specific file system
2037 object to standard input. An absolute path following the ":"
2038 character is expected, which may refer to a regular file, a FIFO or
2039 special file. If an AF_UNIX socket in the file system is specified,
2040 a stream socket is connected to it. The latter is useful for
2041 connecting standard input of processes to arbitrary system
2042 services.
2043
2044 The socket option is valid in socket-activated services only, and
2045 requires the relevant socket unit file (see systemd.socket(5) for
2046 details) to have Accept=yes set, or to specify a single socket
2047 only. If this option is set, standard input will be connected to
2048 the socket the service was activated from, which is primarily
2049 useful for compatibility with daemons designed for use with the
2050 traditional inetd(8) socket activation daemon.
2051
2052 The fd:name option connects standard input to a specific, named
2053 file descriptor provided by a socket unit. The name may be
2054 specified as part of this option, following a ":" character (e.g.
2055 "fd:foobar"). If no name is specified, the name "stdin" is implied
2056 (i.e. "fd" is equivalent to "fd:stdin"). At least one socket unit
2057 defining the specified name must be provided via the Sockets=
2058 option, and the file descriptor name may differ from the name of
2059 its containing socket unit. If multiple matches are found, the
2060 first one will be used. See FileDescriptorName= in
2061 systemd.socket(5) for more details about named file descriptors and
2062 their ordering.
2063
2064 This setting defaults to null.
2065
2066 StandardOutput=
2067 Controls where file descriptor 1 (stdout) of the executed processes
2068 is connected to. Takes one of inherit, null, tty, journal, kmsg,
2069 journal+console, kmsg+console, file:path, append:path, socket or
2070 fd:name.
2071
2072 inherit duplicates the file descriptor of standard input for
2073 standard output.
2074
2075 null connects standard output to /dev/null, i.e. everything written
2076 to it will be lost.
2077
2078 tty connects standard output to a tty (as configured via TTYPath=,
2079 see below). If the TTY is used for output only, the executed
2080 process will not become the controlling process of the terminal,
2081 and will not fail or wait for other processes to release the
2082 terminal.
2083
2084 journal connects standard output with the journal, which is
2085 accessible via journalctl(1). Note that everything that is written
2086 to kmsg (see below) is implicitly stored in the journal as well,
2087 the specific option listed below is hence a superset of this one.
2088 (Also note that any external, additional syslog daemons receive
2089 their log data from the journal, too, hence this is the option to
2090 use when logging shall be processed with such a daemon.)
2091
2092 kmsg connects standard output with the kernel log buffer which is
2093 accessible via dmesg(1), in addition to the journal. The journal
2094 daemon might be configured to send all logs to kmsg anyway, in
2095 which case this option is no different from journal.
2096
2097 journal+console and kmsg+console work in a similar way as the two
2098 options above but copy the output to the system console as well.
2099
2100 The file:path option may be used to connect a specific file system
2101 object to standard output. The semantics are similar to the same
2102 option of StandardInput=, see above. If path refers to a regular
2103 file on the filesystem, it is opened (created if it doesn't exist
2104 yet) for writing at the beginning of the file, but without
2105 truncating it. If standard input and output are directed to the
2106 same file path, it is opened only once, for reading as well as
2107 writing and duplicated. This is particularly useful when the
2108 specified path refers to an AF_UNIX socket in the file system, as
2109 in that case only a single stream connection is created for both
2110 input and output.
2111
2112 append:path is similar to file:path above, but it opens the file in
2113 append mode.
2114
2115 socket connects standard output to a socket acquired via socket
2116 activation. The semantics are similar to the same option of
2117 StandardInput=, see above.
2118
2119 The fd:name option connects standard output to a specific, named
2120 file descriptor provided by a socket unit. A name may be specified
2121 as part of this option, following a ":" character (e.g.
2122 "fd:foobar"). If no name is specified, the name "stdout" is implied
2123 (i.e. "fd" is equivalent to "fd:stdout"). At least one socket unit
2124 defining the specified name must be provided via the Sockets=
2125 option, and the file descriptor name may differ from the name of
2126 its containing socket unit. If multiple matches are found, the
2127 first one will be used. See FileDescriptorName= in
2128 systemd.socket(5) for more details about named descriptors and
2129 their ordering.
2130
2131 If the standard output (or error output, see below) of a unit is
2132 connected to the journal or the kernel log buffer, the unit will
2133 implicitly gain a dependency of type After= on
2134 systemd-journald.socket (also see the "Implicit Dependencies"
2135 section above). Also note that in this case stdout (or stderr, see
2136 below) will be an AF_UNIX stream socket, and not a pipe or FIFO
2137 that can be re-opened. This means when executing shell scripts the
2138 construct echo "hello" > /dev/stderr for writing text to stderr
2139 will not work. To mitigate this use the construct echo "hello" >&2
2140 instead, which is mostly equivalent and avoids this pitfall.
2141
2142 This setting defaults to the value set with DefaultStandardOutput=
2143 in systemd-system.conf(5), which defaults to journal. Note that
2144 setting this parameter might result in additional dependencies to
2145 be added to the unit (see above).
2146
2147 StandardError=
2148 Controls where file descriptor 2 (stderr) of the executed processes
2149 is connected to. The available options are identical to those of
2150 StandardOutput=, with some exceptions: if set to inherit the file
2151 descriptor used for standard output is duplicated for standard
2152 error, while fd:name will use a default file descriptor name of
2153 "stderr".
2154
2155 This setting defaults to the value set with DefaultStandardError=
2156 in systemd-system.conf(5), which defaults to inherit. Note that
2157 setting this parameter might result in additional dependencies to
2158 be added to the unit (see above).
2159
2160 StandardInputText=, StandardInputData=
2161 Configures arbitrary textual or binary data to pass via file
2162 descriptor 0 (STDIN) to the executed processes. These settings have
2163 no effect unless StandardInput= is set to data. Use this option to
2164 embed process input data directly in the unit file.
2165
2166 StandardInputText= accepts arbitrary textual data. C-style escapes
2167 for special characters as well as the usual "%"-specifiers are
2168 resolved. Each time this setting is used the specified text is
2169 appended to the per-unit data buffer, followed by a newline
2170 character (thus every use appends a new line to the end of the
2171 buffer). Note that leading and trailing whitespace of lines
2172 configured with this option is removed. If an empty line is
2173 specified the buffer is cleared (hence, in order to insert an empty
2174 line, add an additional "\n" to the end or beginning of a line).
2175
2176 StandardInputData= accepts arbitrary binary data, encoded in
2177 Base64[7]. No escape sequences or specifiers are resolved. Any
2178 whitespace in the encoded version is ignored during decoding.
2179
2180 Note that StandardInputText= and StandardInputData= operate on the
2181 same data buffer, and may be mixed in order to configure both
2182 binary and textual data for the same input stream. The textual or
2183 binary data is joined strictly in the order the settings appear in
2184 the unit file. Assigning an empty string to either will reset the
2185 data buffer.
2186
2187 Please keep in mind that in order to maintain readability long unit
2188 file settings may be split into multiple lines, by suffixing each
2189 line (except for the last) with a "\" character (see
2190 systemd.unit(5) for details). This is particularly useful for large
2191 data configured with these two options. Example:
2192
2193 ...
2194 StandardInput=data
2195 StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy4KSWNrIGtpZWtl \
2196 LCBzdGF1bmUsIHd1bmRyZSBtaXIsCnVmZiBlZW1hbCBqZWh0IHNlIHVmZiBkaWUgVMO8ci4KTmFu \
2197 dSwgZGVuayBpY2ssIGljayBkZW5rIG5hbnUhCkpldHogaXNzZSB1ZmYsIGVyc2NodCB3YXIgc2Ug \
2198 enUhCkljayBqZWhlIHJhdXMgdW5kIGJsaWNrZSDigJQKdW5kIHdlciBzdGVodCBkcmF1w59lbj8g \
2199 SWNrZSEK
2200 ...
2201
2202 LogLevelMax=
2203 Configures filtering by log level of log messages generated by this
2204 unit. Takes a syslog log level, one of emerg (lowest log level,
2205 only highest priority messages), alert, crit, err, warning, notice,
2206 info, debug (highest log level, also lowest priority messages). See
2207 syslog(3) for details. By default no filtering is applied (i.e. the
2208 default maximum log level is debug). Use this option to configure
2209 the logging system to drop log messages of a specific service above
2210 the specified level. For example, set LogLevelMax=info in order to
2211 turn off debug logging of a particularly chatty unit. Note that the
2212 configured level is applied to any log messages written by any of
2213 the processes belonging to this unit, sent via any supported
2214 logging protocol. The filtering is applied early in the logging
2215 pipeline, before any kind of further processing is done. Moreover,
2216 messages which pass through this filter successfully might still be
2217 dropped by filters applied at a later stage in the logging
2218 subsystem. For example, MaxLevelStore= configured in
2219 journald.conf(5) might prohibit messages of higher log levels to be
2220 stored on disk, even though the per-unit LogLevelMax= permitted it
2221 to be processed.
2222
2223 LogExtraFields=
2224 Configures additional log metadata fields to include in all log
2225 records generated by processes associated with this unit. This
2226 setting takes one or more journal field assignments in the format
2227 "FIELD=VALUE" separated by whitespace. See systemd.journal-
2228 fields(7) for details on the journal field concept. Even though the
2229 underlying journal implementation permits binary field values, this
2230 setting accepts only valid UTF-8 values. To include space
2231 characters in a journal field value, enclose the assignment in
2232 double quotes ("). The usual specifiers are expanded in all
2233 assignments (see below). Note that this setting is not only useful
2234 for attaching additional metadata to log records of a unit, but
2235 given that all fields and values are indexed may also be used to
2236 implement cross-unit log record matching. Assign an empty string to
2237 reset the list.
2238
2239 LogRateLimitIntervalSec=, LogRateLimitBurst=
2240 Configures the rate limiting that is applied to messages generated
2241 by this unit. If, in the time interval defined by
2242 LogRateLimitIntervalSec=, more messages than specified in
2243 LogRateLimitBurst= are logged by a service, all further messages
2244 within the interval are dropped until the interval is over. A
2245 message about the number of dropped messages is generated. The time
2246 specification for LogRateLimitIntervalSec= may be specified in the
2247 following units: "s", "min", "h", "ms", "us" (see systemd.time(7)
2248 for details). The default settings are set by RateLimitIntervalSec=
2249 and RateLimitBurst= configured in journald.conf(5).
2250
2251 LogNamespace=
2252 Run the unit's processes in the specified journal namespace.
2253 Expects a short user-defined string identifying the namespace. If
2254 not used the processes of the service are run in the default
2255 journal namespace, i.e. their log stream is collected and processed
2256 by systemd-journald.service. If this option is used any log data
2257 generated by processes of this unit (regardless if via the
2258 syslog(), journal native logging or stdout/stderr logging) is
2259 collected and processed by an instance of the
2260 systemd-journald@.service template unit, which manages the
2261 specified namespace. The log data is stored in a data store
2262 independent from the default log namespace's data store. See
2263 systemd-journald.service(8) for details about journal namespaces.
2264
2265 Internally, journal namespaces are implemented through Linux mount
2266 namespacing and over-mounting the directory that contains the
2267 relevant AF_UNIX sockets used for logging in the unit's mount
2268 namespace. Since mount namespaces are used this setting disconnects
2269 propagation of mounts from the unit's processes to the host,
2270 similar to how ReadOnlyPaths= and similar settings (see above)
2271 work. Journal namespaces may hence not be used for services that
2272 need to establish mount points on the host.
2273
2274 When this option is used the unit will automatically gain ordering
2275 and requirement dependencies on the two socket units associated
2276 with the systemd-journald@.service instance so that they are
2277 automatically established prior to the unit starting up. Note that
2278 when this option is used log output of this service does not appear
2279 in the regular journalctl(1) output, unless the --namespace= option
2280 is used.
2281
2282 This option is only available for system services and is not
2283 supported for services running in per-user instances of the service
2284 manager.
2285
2286 SyslogIdentifier=
2287 Sets the process name ("syslog tag") to prefix log lines sent to
2288 the logging system or the kernel log buffer with. If not set,
2289 defaults to the process name of the executed process. This option
2290 is only useful when StandardOutput= or StandardError= are set to
2291 journal or kmsg (or to the same settings in combination with
2292 +console) and only applies to log messages written to stdout or
2293 stderr.
2294
2295 SyslogFacility=
2296 Sets the syslog facility identifier to use when logging. One of
2297 kern, user, mail, daemon, auth, syslog, lpr, news, uucp, cron,
2298 authpriv, ftp, local0, local1, local2, local3, local4, local5,
2299 local6 or local7. See syslog(3) for details. This option is only
2300 useful when StandardOutput= or StandardError= are set to journal or
2301 kmsg (or to the same settings in combination with +console), and
2302 only applies to log messages written to stdout or stderr. Defaults
2303 to daemon.
2304
2305 SyslogLevel=
2306 The default syslog log level to use when logging to the logging
2307 system or the kernel log buffer. One of emerg, alert, crit, err,
2308 warning, notice, info, debug. See syslog(3) for details. This
2309 option is only useful when StandardOutput= or StandardError= are
2310 set to journal or kmsg (or to the same settings in combination with
2311 +console), and only applies to log messages written to stdout or
2312 stderr. Note that individual lines output by executed processes may
2313 be prefixed with a different log level which can be used to
2314 override the default log level specified here. The interpretation
2315 of these prefixes may be disabled with SyslogLevelPrefix=, see
2316 below. For details, see sd-daemon(3). Defaults to info.
2317
2318 SyslogLevelPrefix=
2319 Takes a boolean argument. If true and StandardOutput= or
2320 StandardError= are set to journal or kmsg (or to the same settings
2321 in combination with +console), log lines written by the executed
2322 process that are prefixed with a log level will be processed with
2323 this log level set but the prefix removed. If set to false, the
2324 interpretation of these prefixes is disabled and the logged lines
2325 are passed on as-is. This only applies to log messages written to
2326 stdout or stderr. For details about this prefixing see sd-
2327 daemon(3). Defaults to true.
2328
2329 TTYPath=
2330 Sets the terminal device node to use if standard input, output, or
2331 error are connected to a TTY (see above). Defaults to /dev/console.
2332
2333 TTYReset=
2334 Reset the terminal device specified with TTYPath= before and after
2335 execution. Defaults to "no".
2336
2337 TTYVHangup=
2338 Disconnect all clients which have opened the terminal device
2339 specified with TTYPath= before and after execution. Defaults to
2340 "no".
2341
2342 TTYVTDisallocate=
2343 If the terminal device specified with TTYPath= is a virtual console
2344 terminal, try to deallocate the TTY before and after execution.
2345 This ensures that the screen and scrollback buffer is cleared.
2346 Defaults to "no".
2347
2349 UtmpIdentifier=
2350 Takes a four character identifier string for an utmp(5) and wtmp
2351 entry for this service. This should only be set for services such
2352 as getty implementations (such as agetty(8)) where utmp/wtmp
2353 entries must be created and cleared before and after execution, or
2354 for services that shall be executed as if they were run by a getty
2355 process (see below). If the configured string is longer than four
2356 characters, it is truncated and the terminal four characters are
2357 used. This setting interprets %I style string replacements. This
2358 setting is unset by default, i.e. no utmp/wtmp entries are created
2359 or cleaned up for this service.
2360
2361 UtmpMode=
2362 Takes one of "init", "login" or "user". If UtmpIdentifier= is set,
2363 controls which type of utmp(5)/wtmp entries for this service are
2364 generated. This setting has no effect unless UtmpIdentifier= is set
2365 too. If "init" is set, only an INIT_PROCESS entry is generated and
2366 the invoked process must implement a getty-compatible utmp/wtmp
2367 logic. If "login" is set, first an INIT_PROCESS entry, followed by
2368 a LOGIN_PROCESS entry is generated. In this case, the invoked
2369 process must implement a login(1)-compatible utmp/wtmp logic. If
2370 "user" is set, first an INIT_PROCESS entry, then a LOGIN_PROCESS
2371 entry and finally a USER_PROCESS entry is generated. In this case,
2372 the invoked process may be any process that is suitable to be run
2373 as session leader. Defaults to "init".
2374
2376 Processes started by the service manager are executed with an
2377 environment variable block assembled from multiple sources. Processes
2378 started by the system service manager generally do not inherit
2379 environment variables set for the service manager itself (but this may
2380 be altered via PassEnvironment=), but processes started by the user
2381 service manager instances generally do inherit all environment
2382 variables set for the service manager itself.
2383
2384 For each invoked process the list of environment variables set is
2385 compiled from the following sources:
2386
2387 · Variables globally configured for the service manager, using the
2388 DefaultEnvironment= setting in systemd-system.conf(5), the kernel
2389 command line option systemd.setenv= (see systemd(1)) or via
2390 systemctl set-environment (see systemctl(1)).
2391
2392 · Variables defined by the service manager itself (see the list
2393 below)
2394
2395 · Variables set in the service manager's own environment variable
2396 block (subject to PassEnvironment= for the system service manager)
2397
2398 · Variables set via Environment= in the unit file
2399
2400 · Variables read from files specified via EnvironmentFile= in the
2401 unit file
2402
2403 · Variables set by any PAM modules in case PAMName= is in effect,
2404 cf. pam_env(8)
2405
2406 If the same environment variables are set by multiple of these sources,
2407 the later source — according to the order of the list above — wins.
2408 Note that as final step all variables listed in UnsetEnvironment= are
2409 removed again from the compiled environment variable list, immediately
2410 before it is passed to the executed process.
2411
2412 The following environment variables are set or propagated by the
2413 service manager for each invoked process:
2414
2415 $PATH
2416 Colon-separated list of directories to use when launching
2417 executables. systemd uses a fixed value of
2418 "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" in the system
2419 manager. When compiled for systems with "unmerged /usr" (/bin is
2420 not a symlink to /usr/bin), ":/sbin:/bin" is appended. In case of
2421 the the user manager, a different path may be configured by the
2422 distribution. It is recommended to not rely on the order of
2423 entries, and have only one program with a given name in $PATH.
2424
2425 $LANG
2426 Locale. Can be set in locale.conf(5) or on the kernel command line
2427 (see systemd(1) and kernel-command-line(7)).
2428
2429 $USER, $LOGNAME, $HOME, $SHELL
2430 User name (twice), home directory, and the login shell. The
2431 variables are set for the units that have User= set, which includes
2432 user systemd instances. See passwd(5).
2433
2434 $INVOCATION_ID
2435 Contains a randomized, unique 128bit ID identifying each runtime
2436 cycle of the unit, formatted as 32 character hexadecimal string. A
2437 new ID is assigned each time the unit changes from an inactive
2438 state into an activating or active state, and may be used to
2439 identify this specific runtime cycle, in particular in data stored
2440 offline, such as the journal. The same ID is passed to all
2441 processes run as part of the unit.
2442
2443 $XDG_RUNTIME_DIR
2444 The directory to use for runtime objects (such as IPC objects) and
2445 volatile state. Set for all services run by the user systemd
2446 instance, as well as any system services that use PAMName= with a
2447 PAM stack that includes pam_systemd. See below and pam_systemd(8)
2448 for more information.
2449
2450 $RUNTIME_DIRECTORY, $STATE_DIRECTORY, $CACHE_DIRECTORY,
2451 $LOGS_DIRECTORY, $CONFIGURATION_DIRECTORY
2452 Absolute paths to the directories defined with RuntimeDirectory=,
2453 StateDirectory=, CacheDirectory=, LogsDirectory=, and
2454 ConfigurationDirectory= when those settings are used.
2455
2456 $MAINPID
2457 The PID of the unit's main process if it is known. This is only set
2458 for control processes as invoked by ExecReload= and similar.
2459
2460 $MANAGERPID
2461 The PID of the user systemd instance, set for processes spawned by
2462 it.
2463
2464 $LISTEN_FDS, $LISTEN_PID, $LISTEN_FDNAMES
2465 Information about file descriptors passed to a service for socket
2466 activation. See sd_listen_fds(3).
2467
2468 $NOTIFY_SOCKET
2469 The socket sd_notify() talks to. See sd_notify(3).
2470
2471 $WATCHDOG_PID, $WATCHDOG_USEC
2472 Information about watchdog keep-alive notifications. See
2473 sd_watchdog_enabled(3).
2474
2475 $TERM
2476 Terminal type, set only for units connected to a terminal
2477 (StandardInput=tty, StandardOutput=tty, or StandardError=tty). See
2478 termcap(5).
2479
2480 $LOG_NAMESPACE
2481 If the LogNamespace= service setting is used, contains name of the
2482 selected logging namespace.
2483
2484 $JOURNAL_STREAM
2485 If the standard output or standard error output of the executed
2486 processes are connected to the journal (for example, by setting
2487 StandardError=journal) $JOURNAL_STREAM contains the device and
2488 inode numbers of the connection file descriptor, formatted in
2489 decimal, separated by a colon (":"). This permits invoked processes
2490 to safely detect whether their standard output or standard error
2491 output are connected to the journal. The device and inode numbers
2492 of the file descriptors should be compared with the values set in
2493 the environment variable to determine whether the process output is
2494 still connected to the journal. Note that it is generally not
2495 sufficient to only check whether $JOURNAL_STREAM is set at all as
2496 services might invoke external processes replacing their standard
2497 output or standard error output, without unsetting the environment
2498 variable.
2499
2500 If both standard output and standard error of the executed
2501 processes are connected to the journal via a stream socket, this
2502 environment variable will contain information about the standard
2503 error stream, as that's usually the preferred destination for log
2504 data. (Note that typically the same stream is used for both
2505 standard output and standard error, hence very likely the
2506 environment variable contains device and inode information matching
2507 both stream file descriptors.)
2508
2509 This environment variable is primarily useful to allow services to
2510 optionally upgrade their used log protocol to the native journal
2511 protocol (using sd_journal_print(3) and other functions) if their
2512 standard output or standard error output is connected to the
2513 journal anyway, thus enabling delivery of structured metadata along
2514 with logged messages.
2515
2516 $SERVICE_RESULT
2517 Only defined for the service unit type, this environment variable
2518 is passed to all ExecStop= and ExecStopPost= processes, and encodes
2519 the service "result". Currently, the following values are defined:
2520
2521 Table 4. Defined $SERVICE_RESULT values
2522 ┌──────────────────┬────────────────────────────┐
2523 │Value │ Meaning │
2524 ├──────────────────┼────────────────────────────┤
2525 │"success" │ The service ran │
2526 │ │ successfully and exited │
2527 │ │ cleanly. │
2528 ├──────────────────┼────────────────────────────┤
2529 │"protocol" │ A protocol violation │
2530 │ │ occurred: the service did │
2531 │ │ not take the steps │
2532 │ │ required by its unit │
2533 │ │ configuration │
2534 │ │ (specifically what is │
2535 │ │ configured in its Type= │
2536 │ │ setting). │
2537 ├──────────────────┼────────────────────────────┤
2538 │"timeout" │ One of the steps timed │
2539 │ │ out. │
2540 ├──────────────────┼────────────────────────────┤
2541 │"exit-code" │ Service process exited │
2542 │ │ with a non-zero exit code; │
2543 │ │ see $EXIT_CODE below for │
2544 │ │ the actual exit code │
2545 │ │ returned. │
2546 ├──────────────────┼────────────────────────────┤
2547 │"signal" │ A service process was │
2548 │ │ terminated abnormally by a │
2549 │ │ signal, without dumping │
2550 │ │ core. See $EXIT_CODE below │
2551 │ │ for the actual signal │
2552 │ │ causing the termination. │
2553 ├──────────────────┼────────────────────────────┤
2554 │"core-dump" │ A service process │
2555 │ │ terminated abnormally with │
2556 │ │ a signal and dumped core. │
2557 │ │ See $EXIT_CODE below for │
2558 │ │ the signal causing the │
2559 │ │ termination. │
2560 ├──────────────────┼────────────────────────────┤
2561 │"watchdog" │ Watchdog keep-alive ping │
2562 │ │ was enabled for the │
2563 │ │ service, but the deadline │
2564 │ │ was missed. │
2565 ├──────────────────┼────────────────────────────┤
2566 │"start-limit-hit" │ A start limit was defined │
2567 │ │ for the unit and it was │
2568 │ │ hit, causing the unit to │
2569 │ │ fail to start. See │
2570 │ │ systemd.unit(5)'s │
2571 │ │ StartLimitIntervalSec= and │
2572 │ │ StartLimitBurst= for │
2573 │ │ details. │
2574 ├──────────────────┼────────────────────────────┤
2575 │"resources" │ A catch-all condition in │
2576 │ │ case a system operation │
2577 │ │ failed. │
2578 └──────────────────┴────────────────────────────┘
2579 This environment variable is useful to monitor failure or
2580 successful termination of a service. Even though this variable is
2581 available in both ExecStop= and ExecStopPost=, it is usually a
2582 better choice to place monitoring tools in the latter, as the
2583 former is only invoked for services that managed to start up
2584 correctly, and the latter covers both services that failed during
2585 their start-up and those which failed during their runtime.
2586
2587 $EXIT_CODE, $EXIT_STATUS
2588 Only defined for the service unit type, these environment variables
2589 are passed to all ExecStop=, ExecStopPost= processes and contain
2590 exit status/code information of the main process of the service.
2591 For the precise definition of the exit code and status, see
2592 wait(2). $EXIT_CODE is one of "exited", "killed", "dumped".
2593 $EXIT_STATUS contains the numeric exit code formatted as string if
2594 $EXIT_CODE is "exited", and the signal name in all other cases.
2595 Note that these environment variables are only set if the service
2596 manager succeeded to start and identify the main process of the
2597 service.
2598
2599 Table 5. Summary of possible service result variable values
2600 ┌──────────────────┬──────────────────┬─────────────────────┐
2601 │$SERVICE_RESULT │ $EXIT_CODE │ $EXIT_STATUS │
2602 ├──────────────────┼──────────────────┼─────────────────────┤
2603 │"success" │ "killed" │ "HUP", "INT", │
2604 │ │ │ "TERM", "PIPE" │
2605 │ ├──────────────────┼─────────────────────┤
2606 │ │ "exited" │ "0" │
2607 ├──────────────────┼──────────────────┼─────────────────────┤
2608 │"protocol" │ not set │ not set │
2609 │ ├──────────────────┼─────────────────────┤
2610 │ │ "exited" │ "0" │
2611 ├──────────────────┼──────────────────┼─────────────────────┤
2612 │"timeout" │ "killed" │ "TERM", "KILL" │
2613 │ ├──────────────────┼─────────────────────┤
2614 │ │ "exited" │ "0", "1", "2", "3", │
2615 │ │ │ ..., "255" │
2616 ├──────────────────┼──────────────────┼─────────────────────┤
2617 │"exit-code" │ "exited" │ "1", "2", "3", ..., │
2618 │ │ │ "255" │
2619 ├──────────────────┼──────────────────┼─────────────────────┤
2620 │"signal" │ "killed" │ "HUP", "INT", │
2621 │ │ │ "KILL", ... │
2622 ├──────────────────┼──────────────────┼─────────────────────┤
2623 │"core-dump" │ "dumped" │ "ABRT", "SEGV", │
2624 │ │ │ "QUIT", ... │
2625 ├──────────────────┼──────────────────┼─────────────────────┤
2626 │"watchdog" │ "dumped" │ "ABRT" │
2627 │ ├──────────────────┼─────────────────────┤
2628 │ │ "killed" │ "TERM", "KILL" │
2629 │ ├──────────────────┼─────────────────────┤
2630 │ │ "exited" │ "0", "1", "2", "3", │
2631 │ │ │ ..., "255" │
2632 ├──────────────────┼──────────────────┼─────────────────────┤
2633 │"exec-condition" │ "exited" │ "1", "2", "3", "4", │
2634 │ │ │ ..., "254" │
2635 ├──────────────────┼──────────────────┼─────────────────────┤
2636 │"oom-kill" │ "killed" │ "TERM", "KILL" │
2637 ├──────────────────┼──────────────────┼─────────────────────┤
2638 │"start-limit-hit" │ not set │ not set │
2639 ├──────────────────┼──────────────────┼─────────────────────┤
2640 │"resources" │ any of the above │ any of the above │
2641 ├──────────────────┴──────────────────┴─────────────────────┤
2642 │Note: the process may be also terminated by a signal not │
2643 │sent by systemd. In particular the process may send an │
2644 │arbitrary signal to itself in a handler for any of the │
2645 │non-maskable signals. Nevertheless, in the "timeout" and │
2646 │"watchdog" rows above only the signals that systemd sends │
2647 │have been included. Moreover, using SuccessExitStatus= │
2648 │additional exit statuses may be declared to indicate clean │
2649 │termination, which is not reflected by this table. │
2650 └───────────────────────────────────────────────────────────┘
2651
2652 $PIDFILE
2653 The path to the configured PID file, in case the process is forked
2654 off on behalf of a service that uses the PIDFile= setting, see
2655 systemd.service(5) for details. Service code may use this
2656 environment variable to automatically generate a PID file at the
2657 location configured in the unit file. This field is set to an
2658 absolute path in the file system.
2659
2660 For system services, when PAMName= is enabled and pam_systemd is part
2661 of the selected PAM stack, additional environment variables defined by
2662 systemd may be set for services. Specifically, these are $XDG_SEAT,
2663 $XDG_VTNR, see pam_systemd(8) for details.
2664
2666 When invoking a unit process the service manager possibly fails to
2667 apply the execution parameters configured with the settings above. In
2668 that case the already created service process will exit with a non-zero
2669 exit code before the configured command line is executed. (Or in other
2670 words, the child process possibly exits with these error codes, after
2671 having been created by the fork(2) system call, but before the matching
2672 execve(2) system call is called.) Specifically, exit codes defined by
2673 the C library, by the LSB specification and by the systemd service
2674 manager itself are used.
2675
2676 The following basic service exit codes are defined by the C library.
2677
2678 Table 6. Basic C library exit codes
2679 ┌──────────┬───────────────┬────────────────────┐
2680 │Exit Code │ Symbolic Name │ Description │
2681 ├──────────┼───────────────┼────────────────────┤
2682 │0 │ EXIT_SUCCESS │ Generic success │
2683 │ │ │ code. │
2684 ├──────────┼───────────────┼────────────────────┤
2685 │1 │ EXIT_FAILURE │ Generic failure or │
2686 │ │ │ unspecified error. │
2687 └──────────┴───────────────┴────────────────────┘
2688
2689 The following service exit codes are defined by the LSB
2690 specification[8].
2691
2692 Table 7. LSB service exit codes
2693 ┌──────────┬──────────────────────┬────────────────────┐
2694 │Exit Code │ Symbolic Name │ Description │
2695 ├──────────┼──────────────────────┼────────────────────┤
2696 │2 │ EXIT_INVALIDARGUMENT │ Invalid or excess │
2697 │ │ │ arguments. │
2698 ├──────────┼──────────────────────┼────────────────────┤
2699 │3 │ EXIT_NOTIMPLEMENTED │ Unimplemented │
2700 │ │ │ feature. │
2701 ├──────────┼──────────────────────┼────────────────────┤
2702 │4 │ EXIT_NOPERMISSION │ The user has │
2703 │ │ │ insufficient │
2704 │ │ │ privileges. │
2705 ├──────────┼──────────────────────┼────────────────────┤
2706 │5 │ EXIT_NOTINSTALLED │ The program is not │
2707 │ │ │ installed. │
2708 ├──────────┼──────────────────────┼────────────────────┤
2709 │6 │ EXIT_NOTCONFIGURED │ The program is not │
2710 │ │ │ configured. │
2711 ├──────────┼──────────────────────┼────────────────────┤
2712 │7 │ EXIT_NOTRUNNING │ The program is not │
2713 │ │ │ running. │
2714 └──────────┴──────────────────────┴────────────────────┘
2715
2716 The LSB specification suggests that error codes 200 and above are
2717 reserved for implementations. Some of them are used by the service
2718 manager to indicate problems during process invocation:
2719
2720 Table 8. systemd-specific exit codes
2721 ┌──────────┬──────────────────────────────┬─────────────────────────────────────────────┐
2722 │Exit Code │ Symbolic Name │ Description │
2723 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2724 │200 │ EXIT_CHDIR │ Changing to the │
2725 │ │ │ requested working │
2726 │ │ │ directory failed. │
2727 │ │ │ See │
2728 │ │ │ WorkingDirectory= │
2729 │ │ │ above. │
2730 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2731 │201 │ EXIT_NICE │ Failed to set up │
2732 │ │ │ process scheduling │
2733 │ │ │ priority (nice │
2734 │ │ │ level). See Nice= │
2735 │ │ │ above. │
2736 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2737 │202 │ EXIT_FDS │ Failed to close │
2738 │ │ │ unwanted file │
2739 │ │ │ descriptors, or to │
2740 │ │ │ adjust passed file │
2741 │ │ │ descriptors. │
2742 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2743 │203 │ EXIT_EXEC │ The actual process │
2744 │ │ │ execution failed │
2745 │ │ │ (specifically, the │
2746 │ │ │ execve(2) system │
2747 │ │ │ call). Most likely │
2748 │ │ │ this is caused by a │
2749 │ │ │ missing or │
2750 │ │ │ non-accessible │
2751 │ │ │ executable file. │
2752 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2753 │204 │ EXIT_MEMORY │ Failed to perform │
2754 │ │ │ an action due to │
2755 │ │ │ memory shortage. │
2756 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2757 │205 │ EXIT_LIMITS │ Failed to adjust │
2758 │ │ │ resource limits. │
2759 │ │ │ See LimitCPU= and │
2760 │ │ │ related settings │
2761 │ │ │ above. │
2762 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2763 │206 │ EXIT_OOM_ADJUST │ Failed to adjust │
2764 │ │ │ the OOM setting. │
2765 │ │ │ See OOMScoreAdjust= │
2766 │ │ │ above. │
2767 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2768 │207 │ EXIT_SIGNAL_MASK │ Failed to set │
2769 │ │ │ process signal │
2770 │ │ │ mask. │
2771 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2772 │208 │ EXIT_STDIN │ Failed to set up │
2773 │ │ │ standard input. See │
2774 │ │ │ StandardInput= │
2775 │ │ │ above. │
2776 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2777 │209 │ EXIT_STDOUT │ Failed to set up │
2778 │ │ │ standard output. │
2779 │ │ │ See StandardOutput= │
2780 │ │ │ above. │
2781 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2782 │210 │ EXIT_CHROOT │ Failed to change │
2783 │ │ │ root directory │
2784 │ │ │ (chroot(2)). See │
2785 │ │ │ RootDirectory=/RootImage= │
2786 │ │ │ above. │
2787 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2788 │211 │ EXIT_IOPRIO │ Failed to set up IO │
2789 │ │ │ scheduling priority. See │
2790 │ │ │ IOSchedulingClass=/IOSchedulingPriority= │
2791 │ │ │ above. │
2792 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2793 │212 │ EXIT_TIMERSLACK │ Failed to set up timer slack. See │
2794 │ │ │ TimerSlackNSec= above. │
2795 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2796 │213 │ EXIT_SECUREBITS │ Failed to set process secure bits. See │
2797 │ │ │ SecureBits= above. │
2798 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2799 │214 │ EXIT_SETSCHEDULER │ Failed to set up CPU scheduling. See │
2800 │ │ │ CPUSchedulingPolicy=/CPUSchedulingPriority= │
2801 │ │ │ above. │
2802 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2803 │215 │ EXIT_CPUAFFINITY │ Failed to set up CPU affinity. See │
2804 │ │ │ CPUAffinity= above. │
2805 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2806 │216 │ EXIT_GROUP │ Failed to determine or change group │
2807 │ │ │ credentials. See │
2808 │ │ │ Group=/SupplementaryGroups= above. │
2809 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2810 │217 │ EXIT_USER │ Failed to determine or change user │
2811 │ │ │ credentials, or to set up user namespacing. │
2812 │ │ │ See User=/PrivateUsers= above. │
2813 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2814 │218 │ EXIT_CAPABILITIES │ Failed to drop capabilities, or apply │
2815 │ │ │ ambient capabilities. See │
2816 │ │ │ CapabilityBoundingSet=/AmbientCapabilities= │
2817 │ │ │ above. │
2818 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2819 │219 │ EXIT_CGROUP │ Setting up the service control group │
2820 │ │ │ failed. │
2821 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2822 │220 │ EXIT_SETSID │ Failed to create new process session. │
2823 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2824 │221 │ EXIT_CONFIRM │ Execution has been cancelled by the user. │
2825 │ │ │ See the systemd.confirm_spawn= kernel │
2826 │ │ │ command line setting on kernel-command- │
2827 │ │ │ line(7) for details. │
2828 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2829 │222 │ EXIT_STDERR │ Failed to set up standard error output. See │
2830 │ │ │ StandardError= above. │
2831 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2832 │224 │ EXIT_PAM │ Failed to set up PAM session. See PAMName= │
2833 │ │ │ above. │
2834 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2835 │225 │ EXIT_NETWORK │ Failed to set up network namespacing. See │
2836 │ │ │ PrivateNetwork= above. │
2837 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2838 │226 │ EXIT_NAMESPACE │ Failed to set up mount namespacing. See │
2839 │ │ │ ReadOnlyPaths= and related settings above. │
2840 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2841 │227 │ EXIT_NO_NEW_PRIVILEGES │ Failed to disable new privileges. See │
2842 │ │ │ NoNewPrivileges=yes above. │
2843 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2844 │228 │ EXIT_SECCOMP │ Failed to apply system call filters. See │
2845 │ │ │ SystemCallFilter= and related settings │
2846 │ │ │ above. │
2847 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2848 │229 │ EXIT_SELINUX_CONTEXT │ Determining or changing SELinux context │
2849 │ │ │ failed. See SELinuxContext= above. │
2850 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2851 │230 │ EXIT_PERSONALITY │ Failed to set up an execution domain │
2852 │ │ │ (personality). See Personality= above. │
2853 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2854 │231 │ EXIT_APPARMOR_PROFILE │ Failed to prepare changing AppArmor │
2855 │ │ │ profile. See AppArmorProfile= above. │
2856 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2857 │232 │ EXIT_ADDRESS_FAMILIES │ Failed to restrict address families. See │
2858 │ │ │ RestrictAddressFamilies= above. │
2859 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2860 │233 │ EXIT_RUNTIME_DIRECTORY │ Setting up runtime directory failed. See │
2861 │ │ │ RuntimeDirectory= and related settings │
2862 │ │ │ above. │
2863 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2864 │235 │ EXIT_CHOWN │ Failed to adjust socket ownership. Used for │
2865 │ │ │ socket units only. │
2866 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2867 │236 │ EXIT_SMACK_PROCESS_LABEL │ Failed to set SMACK label. See │
2868 │ │ │ SmackProcessLabel= above. │
2869 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2870 │237 │ EXIT_KEYRING │ Failed to set up kernel keyring. │
2871 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2872 │238 │ EXIT_STATE_DIRECTORY │ Failed to set up unit's state directory. │
2873 │ │ │ See StateDirectory= above. │
2874 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2875 │239 │ EXIT_CACHE_DIRECTORY │ Failed to set up unit's cache directory. │
2876 │ │ │ See CacheDirectory= above. │
2877 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2878 │240 │ EXIT_LOGS_DIRECTORY │ Failed to set up unit's logging directory. │
2879 │ │ │ See LogsDirectory= above. │
2880 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2881 │241 │ EXIT_CONFIGURATION_DIRECTORY │ Failed to set up unit's configuration │
2882 │ │ │ directory. See ConfigurationDirectory= │
2883 │ │ │ above. │
2884 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
2885 │242 │ EXIT_NUMA_POLICY │ Failed to set up unit's NUMA memory policy. │
2886 │ │ │ See NUMAPolicy= and NUMAMask= above. │
2887 └──────────┴──────────────────────────────┴─────────────────────────────────────────────┘
2888
2889 Finally, the BSD operating systems define a set of exit codes,
2890 typically defined on Linux systems too:
2891
2892 Table 9. BSD exit codes
2893 ┌──────────┬────────────────┬─────────────────────┐
2894 │Exit Code │ Symbolic Name │ Description │
2895 ├──────────┼────────────────┼─────────────────────┤
2896 │64 │ EX_USAGE │ Command line usage │
2897 │ │ │ error │
2898 ├──────────┼────────────────┼─────────────────────┤
2899 │65 │ EX_DATAERR │ Data format error │
2900 ├──────────┼────────────────┼─────────────────────┤
2901 │66 │ EX_NOINPUT │ Cannot open input │
2902 ├──────────┼────────────────┼─────────────────────┤
2903 │67 │ EX_NOUSER │ Addressee unknown │
2904 ├──────────┼────────────────┼─────────────────────┤
2905 │68 │ EX_NOHOST │ Host name unknown │
2906 ├──────────┼────────────────┼─────────────────────┤
2907 │69 │ EX_UNAVAILABLE │ Service unavailable │
2908 ├──────────┼────────────────┼─────────────────────┤
2909 │70 │ EX_SOFTWARE │ internal software │
2910 │ │ │ error │
2911 ├──────────┼────────────────┼─────────────────────┤
2912 │71 │ EX_OSERR │ System error (e.g., │
2913 │ │ │ can't fork) │
2914 ├──────────┼────────────────┼─────────────────────┤
2915 │72 │ EX_OSFILE │ Critical OS file │
2916 │ │ │ missing │
2917 ├──────────┼────────────────┼─────────────────────┤
2918 │73 │ EX_CANTCREAT │ Can't create (user) │
2919 │ │ │ output file │
2920 ├──────────┼────────────────┼─────────────────────┤
2921 │74 │ EX_IOERR │ Input/output error │
2922 ├──────────┼────────────────┼─────────────────────┤
2923 │75 │ EX_TEMPFAIL │ Temporary failure; │
2924 │ │ │ user is invited to │
2925 │ │ │ retry │
2926 ├──────────┼────────────────┼─────────────────────┤
2927 │76 │ EX_PROTOCOL │ Remote error in │
2928 │ │ │ protocol │
2929 ├──────────┼────────────────┼─────────────────────┤
2930 │77 │ EX_NOPERM │ Permission denied │
2931 ├──────────┼────────────────┼─────────────────────┤
2932 │78 │ EX_CONFIG │ Configuration error │
2933 └──────────┴────────────────┴─────────────────────┘
2934
2936 systemd(1), systemctl(1), systemd-analyze(1), journalctl(1), systemd-
2937 system.conf(5), systemd.unit(5), systemd.service(5), systemd.socket(5),
2938 systemd.swap(5), systemd.mount(5), systemd.kill(5), systemd.resource-
2939 control(5), systemd.time(7), systemd.directives(7), tmpfiles.d(5),
2940 exec(3)
2941
2943 1. Discoverable Partitions Specification
2944 https://systemd.io/DISCOVERABLE_PARTITIONS
2945
2946 2. User/Group Name Syntax
2947 https://systemd.io/USER_NAMES
2948
2949 3. No New Privileges Flag
2950 https://www.kernel.org/doc/html/latest/userspace-api/no_new_privs.html
2951
2952 4. proc.txt
2953 https://www.kernel.org/doc/Documentation/filesystems/proc.txt
2954
2955 5. C escapes
2956 https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences
2957
2958 6. most control characters
2959 https://en.wikipedia.org/wiki/Control_character#In_ASCII
2960
2961 7. Base64
2962 https://tools.ietf.org/html/rfc2045#section-6.8
2963
2964 8. LSB specification
2965 https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
2966
2967
2968
2969systemd 246 SYSTEMD.EXEC(5)