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