]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.exec.xml
Merge pull request #2147 from vcaputo/sd-event-measure-latencies
[thirdparty/systemd.git] / man / systemd.exec.xml
CommitLineData
023a4f67 1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
dd1eb43b 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
dd1eb43b
LP
4
5<!--
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
dd1eb43b
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
dd1eb43b 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
dd1eb43b
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
24<refentry id="systemd.exec">
798d3a52
ZJS
25 <refentryinfo>
26 <title>systemd.exec</title>
27 <productname>systemd</productname>
28
29 <authorgroup>
30 <author>
31 <contrib>Developer</contrib>
32 <firstname>Lennart</firstname>
33 <surname>Poettering</surname>
34 <email>lennart@poettering.net</email>
35 </author>
36 </authorgroup>
37 </refentryinfo>
38
39 <refmeta>
40 <refentrytitle>systemd.exec</refentrytitle>
41 <manvolnum>5</manvolnum>
42 </refmeta>
43
44 <refnamediv>
45 <refname>systemd.exec</refname>
46 <refpurpose>Execution environment configuration</refpurpose>
47 </refnamediv>
48
49 <refsynopsisdiv>
50 <para><filename><replaceable>service</replaceable>.service</filename>,
51 <filename><replaceable>socket</replaceable>.socket</filename>,
52 <filename><replaceable>mount</replaceable>.mount</filename>,
53 <filename><replaceable>swap</replaceable>.swap</filename></para>
54 </refsynopsisdiv>
55
56 <refsect1>
57 <title>Description</title>
58
59 <para>Unit configuration files for services, sockets, mount
60 points, and swap devices share a subset of configuration options
61 which define the execution environment of spawned
62 processes.</para>
63
64 <para>This man page lists the configuration options shared by
65 these four unit types. See
66 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
67 for the common options of all unit configuration files, and
68 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
69 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
70 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
71 and
72 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
73 for more information on the specific unit configuration files. The
74 execution specific configuration options are configured in the
75 [Service], [Socket], [Mount], or [Swap] sections, depending on the
76 unit type.</para>
77 </refsect1>
78
c129bd5d
LP
79 <refsect1>
80 <title>Automatic Dependencies</title>
81
82 <para>A few execution parameters result in additional, automatic
83 dependencies to be added.</para>
84
85 <para>Units with <varname>WorkingDirectory=</varname> or
86 <varname>RootDirectory=</varname> set automatically gain
87 dependencies of type <varname>Requires=</varname> and
88 <varname>After=</varname> on all mount units required to access
89 the specified paths. This is equivalent to having them listed
90 explicitly in <varname>RequiresMountsFor=</varname>.</para>
91
92 <para>Similar, units with <varname>PrivateTmp=</varname> enabled
93 automatically get mount unit dependencies for all mounts
94 required to access <filename>/tmp</filename> and
95 <filename>/var/tmp</filename>.</para>
96
97 <para>Units whose output standard output or error output is
98 connected to any other sink but <option>null</option>,
99 <option>tty</option> and <option>socket</option> automatically
100 acquire dependencies of type <varname>After=</varname> on
101 <filename>journald.socket</filename>.</para>
102 </refsect1>
103
798d3a52
ZJS
104 <refsect1>
105 <title>Options</title>
106
107 <variablelist class='unit-directives'>
108
109 <varlistentry>
110 <term><varname>WorkingDirectory=</varname></term>
111
5f5d8eab
LP
112 <listitem><para>Takes an absolute directory path, or the
113 special value <literal>~</literal>. Sets the working directory
b938cb90 114 for executed processes. If set to <literal>~</literal>, the
5f5d8eab
LP
115 home directory of the user specified in
116 <varname>User=</varname> is used. If not set, defaults to the
117 root directory when systemd is running as a system instance
118 and the respective user's home directory if run as user. If
119 the setting is prefixed with the <literal>-</literal>
120 character, a missing working directory is not considered
c129bd5d
LP
121 fatal. Note that setting this parameter might result in
122 additional dependencies to be added to the unit (see
123 above).</para></listitem>
798d3a52
ZJS
124 </varlistentry>
125
126 <varlistentry>
127 <term><varname>RootDirectory=</varname></term>
128
129 <listitem><para>Takes an absolute directory path. Sets the
5f5d8eab
LP
130 root directory for executed processes, with the <citerefentry
131 project='man-pages'><refentrytitle>chroot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
798d3a52 132 system call. If this is used, it must be ensured that the
5f5d8eab 133 process binary and all its auxiliary files are available in
c129bd5d
LP
134 the <function>chroot()</function> jail. Note that setting this
135 parameter might result in additional dependencies to be added
136 to the unit (see above).</para></listitem>
798d3a52
ZJS
137 </varlistentry>
138
139 <varlistentry>
140 <term><varname>User=</varname></term>
141 <term><varname>Group=</varname></term>
142
143 <listitem><para>Sets the Unix user or group that the processes
144 are executed as, respectively. Takes a single user or group
145 name or ID as argument. If no group is set, the default group
146 of the user is chosen.</para></listitem>
147 </varlistentry>
148
149 <varlistentry>
150 <term><varname>SupplementaryGroups=</varname></term>
151
152 <listitem><para>Sets the supplementary Unix groups the
153 processes are executed as. This takes a space-separated list
154 of group names or IDs. This option may be specified more than
b938cb90
JE
155 once, in which case all listed groups are set as supplementary
156 groups. When the empty string is assigned, the list of
798d3a52
ZJS
157 supplementary groups is reset, and all assignments prior to
158 this one will have no effect. In any way, this option does not
159 override, but extends the list of supplementary groups
160 configured in the system group database for the
161 user.</para></listitem>
162 </varlistentry>
163
164 <varlistentry>
165 <term><varname>Nice=</varname></term>
166
167 <listitem><para>Sets the default nice level (scheduling
168 priority) for executed processes. Takes an integer between -20
169 (highest priority) and 19 (lowest priority). See
170 <citerefentry><refentrytitle>setpriority</refentrytitle><manvolnum>2</manvolnum></citerefentry>
171 for details.</para></listitem>
172 </varlistentry>
173
174 <varlistentry>
175 <term><varname>OOMScoreAdjust=</varname></term>
176
177 <listitem><para>Sets the adjustment level for the
178 Out-Of-Memory killer for executed processes. Takes an integer
179 between -1000 (to disable OOM killing for this process) and
180 1000 (to make killing of this process under memory pressure
181 very likely). See <ulink
182 url="https://www.kernel.org/doc/Documentation/filesystems/proc.txt">proc.txt</ulink>
183 for details.</para></listitem>
184 </varlistentry>
185
186 <varlistentry>
187 <term><varname>IOSchedulingClass=</varname></term>
188
b938cb90 189 <listitem><para>Sets the I/O scheduling class for executed
798d3a52
ZJS
190 processes. Takes an integer between 0 and 3 or one of the
191 strings <option>none</option>, <option>realtime</option>,
192 <option>best-effort</option> or <option>idle</option>. See
193 <citerefentry><refentrytitle>ioprio_set</refentrytitle><manvolnum>2</manvolnum></citerefentry>
194 for details.</para></listitem>
195 </varlistentry>
196
197 <varlistentry>
198 <term><varname>IOSchedulingPriority=</varname></term>
199
b938cb90 200 <listitem><para>Sets the I/O scheduling priority for executed
798d3a52
ZJS
201 processes. Takes an integer between 0 (highest priority) and 7
202 (lowest priority). The available priorities depend on the
b938cb90 203 selected I/O scheduling class (see above). See
798d3a52
ZJS
204 <citerefentry><refentrytitle>ioprio_set</refentrytitle><manvolnum>2</manvolnum></citerefentry>
205 for details.</para></listitem>
206 </varlistentry>
207
208 <varlistentry>
209 <term><varname>CPUSchedulingPolicy=</varname></term>
210
211 <listitem><para>Sets the CPU scheduling policy for executed
212 processes. Takes one of
213 <option>other</option>,
214 <option>batch</option>,
215 <option>idle</option>,
216 <option>fifo</option> or
217 <option>rr</option>. See
218 <citerefentry><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
219 for details.</para></listitem>
220 </varlistentry>
221
222 <varlistentry>
223 <term><varname>CPUSchedulingPriority=</varname></term>
224
225 <listitem><para>Sets the CPU scheduling priority for executed
226 processes. The available priority range depends on the
227 selected CPU scheduling policy (see above). For real-time
228 scheduling policies an integer between 1 (lowest priority) and
229 99 (highest priority) can be used. See
230 <citerefentry><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
231 for details. </para></listitem>
232 </varlistentry>
233
234 <varlistentry>
235 <term><varname>CPUSchedulingResetOnFork=</varname></term>
236
237 <listitem><para>Takes a boolean argument. If true, elevated
238 CPU scheduling priorities and policies will be reset when the
239 executed processes fork, and can hence not leak into child
240 processes. See
241 <citerefentry><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
242 for details. Defaults to false.</para></listitem>
243 </varlistentry>
244
245 <varlistentry>
246 <term><varname>CPUAffinity=</varname></term>
247
248 <listitem><para>Controls the CPU affinity of the executed
71b1c27a
FB
249 processes. Takes a list of CPU indices or ranges separated by
250 either whitespace or commas. CPU ranges are specified by the
251 lower and upper CPU indices separated by a dash.
b938cb90 252 This option may be specified more than once, in which case the
798d3a52
ZJS
253 specified CPU affinity masks are merged. If the empty string
254 is assigned, the mask is reset, all assignments prior to this
255 will have no effect. See
256 <citerefentry><refentrytitle>sched_setaffinity</refentrytitle><manvolnum>2</manvolnum></citerefentry>
257 for details.</para></listitem>
258 </varlistentry>
259
260 <varlistentry>
261 <term><varname>UMask=</varname></term>
262
263 <listitem><para>Controls the file mode creation mask. Takes an
264 access mode in octal notation. See
265 <citerefentry><refentrytitle>umask</refentrytitle><manvolnum>2</manvolnum></citerefentry>
266 for details. Defaults to 0022.</para></listitem>
267 </varlistentry>
268
269 <varlistentry>
270 <term><varname>Environment=</varname></term>
271
272 <listitem><para>Sets environment variables for executed
273 processes. Takes a space-separated list of variable
b938cb90 274 assignments. This option may be specified more than once, in
798d3a52
ZJS
275 which case all listed variables will be set. If the same
276 variable is set twice, the later setting will override the
277 earlier setting. If the empty string is assigned to this
278 option, the list of environment variables is reset, all prior
279 assignments have no effect. Variable expansion is not
280 performed inside the strings, however, specifier expansion is
281 possible. The $ character has no special meaning. If you need
282 to assign a value containing spaces to a variable, use double
283 quotes (") for the assignment.</para>
284
285 <para>Example:
286 <programlisting>Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"</programlisting>
287 gives three variables <literal>VAR1</literal>,
288 <literal>VAR2</literal>, <literal>VAR3</literal>
289 with the values <literal>word1 word2</literal>,
290 <literal>word3</literal>, <literal>$word 5 6</literal>.
291 </para>
292
293 <para>
294 See
295 <citerefentry project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry>
296 for details about environment variables.</para></listitem>
297 </varlistentry>
298 <varlistentry>
299 <term><varname>EnvironmentFile=</varname></term>
300 <listitem><para>Similar to <varname>Environment=</varname> but
301 reads the environment variables from a text file. The text
302 file should contain new-line-separated variable assignments.
8f0d2981
RM
303 Empty lines, lines without an <literal>=</literal> separator,
304 or lines starting with ; or # will be ignored,
798d3a52
ZJS
305 which may be used for commenting. A line ending with a
306 backslash will be concatenated with the following one,
307 allowing multiline variable definitions. The parser strips
308 leading and trailing whitespace from the values of
309 assignments, unless you use double quotes (").</para>
310
311 <para>The argument passed should be an absolute filename or
312 wildcard expression, optionally prefixed with
313 <literal>-</literal>, which indicates that if the file does
314 not exist, it will not be read and no error or warning message
315 is logged. This option may be specified more than once in
316 which case all specified files are read. If the empty string
317 is assigned to this option, the list of file to read is reset,
318 all prior assignments have no effect.</para>
319
320 <para>The files listed with this directive will be read
321 shortly before the process is executed (more specifically,
322 after all processes from a previous unit state terminated.
323 This means you can generate these files in one unit state, and
f407824d
DH
324 read it with this option in the next).</para>
325
326 <para>Settings from these
798d3a52
ZJS
327 files override settings made with
328 <varname>Environment=</varname>. If the same variable is set
329 twice from these files, the files will be read in the order
330 they are specified and the later setting will override the
331 earlier setting.</para></listitem>
332 </varlistentry>
333
b4c14404
FB
334 <varlistentry>
335 <term><varname>PassEnvironment=</varname></term>
336
337 <listitem><para>Pass environment variables from the systemd system
338 manager to executed processes. Takes a space-separated list of variable
339 names. This option may be specified more than once, in which case all
340 listed variables will be set. If the empty string is assigned to this
341 option, the list of environment variables is reset, all prior
342 assignments have no effect. Variables that are not set in the system
343 manager will not be passed and will be silently ignored.</para>
344
345 <para>Variables passed from this setting are overridden by those passed
346 from <varname>Environment=</varname> or
347 <varname>EnvironmentFile=</varname>.</para>
348
349 <para>Example:
350 <programlisting>PassEnvironment=VAR1 VAR2 VAR3</programlisting>
351 passes three variables <literal>VAR1</literal>,
352 <literal>VAR2</literal>, <literal>VAR3</literal>
353 with the values set for those variables in PID1.</para>
354
355 <para>
356 See
357 <citerefentry project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry>
358 for details about environment variables.</para></listitem>
359 </varlistentry>
360
798d3a52
ZJS
361 <varlistentry>
362 <term><varname>StandardInput=</varname></term>
363 <listitem><para>Controls where file descriptor 0 (STDIN) of
364 the executed processes is connected to. Takes one of
365 <option>null</option>,
366 <option>tty</option>,
367 <option>tty-force</option>,
368 <option>tty-fail</option> or
369 <option>socket</option>.</para>
370
371 <para>If <option>null</option> is selected, standard input
372 will be connected to <filename>/dev/null</filename>, i.e. all
373 read attempts by the process will result in immediate
374 EOF.</para>
375
376 <para>If <option>tty</option> is selected, standard input is
377 connected to a TTY (as configured by
378 <varname>TTYPath=</varname>, see below) and the executed
379 process becomes the controlling process of the terminal. If
380 the terminal is already being controlled by another process,
381 the executed process waits until the current controlling
382 process releases the terminal.</para>
383
384 <para><option>tty-force</option> is similar to
385 <option>tty</option>, but the executed process is forcefully
386 and immediately made the controlling process of the terminal,
387 potentially removing previous controlling processes from the
388 terminal.</para>
389
390 <para><option>tty-fail</option> is similar to
391 <option>tty</option> but if the terminal already has a
392 controlling process start-up of the executed process
393 fails.</para>
394
395 <para>The <option>socket</option> option is only valid in
396 socket-activated services, and only when the socket
397 configuration file (see
398 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
399 for details) specifies a single socket only. If this option is
400 set, standard input will be connected to the socket the
401 service was activated from, which is primarily useful for
402 compatibility with daemons designed for use with the
403 traditional
b5c7d097 404 <citerefentry project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
405 daemon.</para>
406
407 <para>This setting defaults to
408 <option>null</option>.</para></listitem>
409 </varlistentry>
c129bd5d 410
798d3a52
ZJS
411 <varlistentry>
412 <term><varname>StandardOutput=</varname></term>
413 <listitem><para>Controls where file descriptor 1 (STDOUT) of
414 the executed processes is connected to. Takes one of
415 <option>inherit</option>,
416 <option>null</option>,
417 <option>tty</option>,
418 <option>journal</option>,
419 <option>syslog</option>,
420 <option>kmsg</option>,
421 <option>journal+console</option>,
422 <option>syslog+console</option>,
423 <option>kmsg+console</option> or
424 <option>socket</option>.</para>
425
426 <para><option>inherit</option> duplicates the file descriptor
427 of standard input for standard output.</para>
428
429 <para><option>null</option> connects standard output to
430 <filename>/dev/null</filename>, i.e. everything written to it
431 will be lost.</para>
432
433 <para><option>tty</option> connects standard output to a tty
434 (as configured via <varname>TTYPath=</varname>, see below). If
435 the TTY is used for output only, the executed process will not
436 become the controlling process of the terminal, and will not
437 fail or wait for other processes to release the
438 terminal.</para>
439
440 <para><option>journal</option> connects standard output with
441 the journal which is accessible via
442 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
443 Note that everything that is written to syslog or kmsg (see
444 below) is implicitly stored in the journal as well, the
445 specific two options listed below are hence supersets of this
446 one.</para>
447
448 <para><option>syslog</option> connects standard output to the
449 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
450 system syslog service, in addition to the journal. Note that
451 the journal daemon is usually configured to forward everything
452 it receives to syslog anyway, in which case this option is no
453 different from <option>journal</option>.</para>
454
455 <para><option>kmsg</option> connects standard output with the
456 kernel log buffer which is accessible via
457 <citerefentry project='man-pages'><refentrytitle>dmesg</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
458 in addition to the journal. The journal daemon might be
459 configured to send all logs to kmsg anyway, in which case this
460 option is no different from <option>journal</option>.</para>
461
462 <para><option>journal+console</option>,
463 <option>syslog+console</option> and
464 <option>kmsg+console</option> work in a similar way as the
465 three options above but copy the output to the system console
466 as well.</para>
467
468 <para><option>socket</option> connects standard output to a
469 socket acquired via socket activation. The semantics are
470 similar to the same option of
471 <varname>StandardInput=</varname>.</para>
472
473 <para>This setting defaults to the value set with
474 <option>DefaultStandardOutput=</option> in
475 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
c129bd5d
LP
476 which defaults to <option>journal</option>. Note that setting
477 this parameter might result in additional dependencies to be
478 added to the unit (see above).</para></listitem>
798d3a52 479 </varlistentry>
c129bd5d 480
798d3a52
ZJS
481 <varlistentry>
482 <term><varname>StandardError=</varname></term>
483 <listitem><para>Controls where file descriptor 2 (STDERR) of
484 the executed processes is connected to. The available options
485 are identical to those of <varname>StandardOutput=</varname>,
486 with one exception: if set to <option>inherit</option> the
487 file descriptor used for standard output is duplicated for
488 standard error. This setting defaults to the value set with
489 <option>DefaultStandardError=</option> in
490 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
c129bd5d
LP
491 which defaults to <option>inherit</option>. Note that setting
492 this parameter might result in additional dependencies to be
493 added to the unit (see above).</para></listitem>
798d3a52 494 </varlistentry>
c129bd5d 495
798d3a52
ZJS
496 <varlistentry>
497 <term><varname>TTYPath=</varname></term>
498 <listitem><para>Sets the terminal device node to use if
499 standard input, output, or error are connected to a TTY (see
500 above). Defaults to
501 <filename>/dev/console</filename>.</para></listitem>
502 </varlistentry>
503 <varlistentry>
504 <term><varname>TTYReset=</varname></term>
505 <listitem><para>Reset the terminal device specified with
506 <varname>TTYPath=</varname> before and after execution.
507 Defaults to <literal>no</literal>.</para></listitem>
508 </varlistentry>
509 <varlistentry>
510 <term><varname>TTYVHangup=</varname></term>
511 <listitem><para>Disconnect all clients which have opened the
512 terminal device specified with <varname>TTYPath=</varname>
513 before and after execution. Defaults to
514 <literal>no</literal>.</para></listitem>
515 </varlistentry>
516 <varlistentry>
517 <term><varname>TTYVTDisallocate=</varname></term>
518 <listitem><para>If the terminal device specified with
519 <varname>TTYPath=</varname> is a virtual console terminal, try
520 to deallocate the TTY before and after execution. This ensures
521 that the screen and scrollback buffer is cleared. Defaults to
522 <literal>no</literal>.</para></listitem>
523 </varlistentry>
524 <varlistentry>
525 <term><varname>SyslogIdentifier=</varname></term>
526 <listitem><para>Sets the process name to prefix log lines sent
527 to the logging system or the kernel log buffer with. If not
528 set, defaults to the process name of the executed process.
529 This option is only useful when
530 <varname>StandardOutput=</varname> or
531 <varname>StandardError=</varname> are set to
532 <option>syslog</option>, <option>journal</option> or
533 <option>kmsg</option> (or to the same settings in combination
534 with <option>+console</option>).</para></listitem>
535 </varlistentry>
536 <varlistentry>
537 <term><varname>SyslogFacility=</varname></term>
538 <listitem><para>Sets the syslog facility to use when logging
539 to syslog. One of <option>kern</option>,
540 <option>user</option>, <option>mail</option>,
541 <option>daemon</option>, <option>auth</option>,
542 <option>syslog</option>, <option>lpr</option>,
543 <option>news</option>, <option>uucp</option>,
544 <option>cron</option>, <option>authpriv</option>,
545 <option>ftp</option>, <option>local0</option>,
546 <option>local1</option>, <option>local2</option>,
547 <option>local3</option>, <option>local4</option>,
548 <option>local5</option>, <option>local6</option> or
549 <option>local7</option>. See
550 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
551 for details. This option is only useful when
552 <varname>StandardOutput=</varname> or
553 <varname>StandardError=</varname> are set to
554 <option>syslog</option>. Defaults to
555 <option>daemon</option>.</para></listitem>
556 </varlistentry>
557 <varlistentry>
558 <term><varname>SyslogLevel=</varname></term>
a8eaaee7 559 <listitem><para>The default syslog level to use when logging to
798d3a52
ZJS
560 syslog or the kernel log buffer. One of
561 <option>emerg</option>,
562 <option>alert</option>,
563 <option>crit</option>,
564 <option>err</option>,
565 <option>warning</option>,
566 <option>notice</option>,
567 <option>info</option>,
568 <option>debug</option>. See
569 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
570 for details. This option is only useful when
571 <varname>StandardOutput=</varname> or
572 <varname>StandardError=</varname> are set to
573 <option>syslog</option> or <option>kmsg</option>. Note that
574 individual lines output by the daemon might be prefixed with a
575 different log level which can be used to override the default
576 log level specified here. The interpretation of these prefixes
577 may be disabled with <varname>SyslogLevelPrefix=</varname>,
b938cb90 578 see below. For details, see
798d3a52
ZJS
579 <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
580
581 Defaults to
582 <option>info</option>.</para></listitem>
583 </varlistentry>
584
585 <varlistentry>
586 <term><varname>SyslogLevelPrefix=</varname></term>
587 <listitem><para>Takes a boolean argument. If true and
588 <varname>StandardOutput=</varname> or
589 <varname>StandardError=</varname> are set to
590 <option>syslog</option>, <option>kmsg</option> or
591 <option>journal</option>, log lines written by the executed
592 process that are prefixed with a log level will be passed on
593 to syslog with this log level set but the prefix removed. If
594 set to false, the interpretation of these prefixes is disabled
595 and the logged lines are passed on as-is. For details about
596 this prefixing see
597 <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
598 Defaults to true.</para></listitem>
599 </varlistentry>
600
601 <varlistentry>
602 <term><varname>TimerSlackNSec=</varname></term>
603 <listitem><para>Sets the timer slack in nanoseconds for the
604 executed processes. The timer slack controls the accuracy of
605 wake-ups triggered by timers. See
606 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
607 for more information. Note that in contrast to most other time
608 span definitions this parameter takes an integer value in
609 nano-seconds if no unit is specified. The usual time units are
610 understood too.</para></listitem>
611 </varlistentry>
612
613 <varlistentry>
614 <term><varname>LimitCPU=</varname></term>
615 <term><varname>LimitFSIZE=</varname></term>
616 <term><varname>LimitDATA=</varname></term>
617 <term><varname>LimitSTACK=</varname></term>
618 <term><varname>LimitCORE=</varname></term>
619 <term><varname>LimitRSS=</varname></term>
620 <term><varname>LimitNOFILE=</varname></term>
621 <term><varname>LimitAS=</varname></term>
622 <term><varname>LimitNPROC=</varname></term>
623 <term><varname>LimitMEMLOCK=</varname></term>
624 <term><varname>LimitLOCKS=</varname></term>
625 <term><varname>LimitSIGPENDING=</varname></term>
626 <term><varname>LimitMSGQUEUE=</varname></term>
627 <term><varname>LimitNICE=</varname></term>
628 <term><varname>LimitRTPRIO=</varname></term>
629 <term><varname>LimitRTTIME=</varname></term>
630 <listitem><para>These settings set both soft and hard limits
631 of various resources for executed processes. See
632 <citerefentry><refentrytitle>setrlimit</refentrytitle><manvolnum>2</manvolnum></citerefentry>
91518d20
KZ
633 for details. The resource limit is possible to specify in two formats,
634 <option>value</option> to set soft and hard limits to the same value,
635 or <option>soft:hard</option> to set both limits individually (e.g. LimitAS=4G:16G).
636 Use the string <varname>infinity</varname> to
a4c18002
LP
637 configure no limit on a specific resource. The multiplicative
638 suffixes K (=1024), M (=1024*1024) and so on for G, T, P and E
639 may be used for resource limits measured in bytes
640 (e.g. LimitAS=16G). For the limits referring to time values,
641 the usual time units ms, s, min, h and so on may be used (see
642 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>
643 for details). Note that if no time unit is specified for
644 <varname>LimitCPU=</varname> the default unit of seconds is
645 implied, while for <varname>LimitRTTIME=</varname> the default
646 unit of microseconds is implied. Also, note that the effective
647 granularity of the limits might influence their
648 enforcement. For example, time limits specified for
649 <varname>LimitCPU=</varname> will be rounded up implicitly to
650 multiples of 1s.</para>
651
652 <para>Note that most process resource limits configured with
653 these options are per-process, and processes may fork in order
654 to acquire a new set of resources that are accounted
655 independently of the original process, and may thus escape
656 limits set. Also note that <varname>LimitRSS=</varname> is not
657 implemented on Linux, and setting it has no effect. Often it
658 is advisable to prefer the resource controls listed in
659 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
660 over these per-process limits, as they apply to services as a
661 whole, may be altered dynamically at runtime, and are
662 generally more expressive. For example,
663 <varname>MemoryLimit=</varname> is a more powerful (and
664 working) replacement for <varname>LimitRSS=</varname>.</para>
798d3a52
ZJS
665
666 <table>
667 <title>Limit directives and their equivalent with ulimit</title>
668
a4c18002 669 <tgroup cols='3'>
798d3a52
ZJS
670 <colspec colname='directive' />
671 <colspec colname='equivalent' />
a4c18002 672 <colspec colname='unit' />
798d3a52
ZJS
673 <thead>
674 <row>
675 <entry>Directive</entry>
676 <entry>ulimit equivalent</entry>
a4c18002 677 <entry>Unit</entry>
798d3a52
ZJS
678 </row>
679 </thead>
680 <tbody>
681 <row>
a4c18002 682 <entry>LimitCPU=</entry>
798d3a52 683 <entry>ulimit -t</entry>
a4c18002 684 <entry>Seconds</entry>
798d3a52
ZJS
685 </row>
686 <row>
a4c18002 687 <entry>LimitFSIZE=</entry>
798d3a52 688 <entry>ulimit -f</entry>
a4c18002 689 <entry>Bytes</entry>
798d3a52
ZJS
690 </row>
691 <row>
a4c18002 692 <entry>LimitDATA=</entry>
798d3a52 693 <entry>ulimit -d</entry>
a4c18002 694 <entry>Bytes</entry>
798d3a52
ZJS
695 </row>
696 <row>
a4c18002 697 <entry>LimitSTACK=</entry>
798d3a52 698 <entry>ulimit -s</entry>
a4c18002 699 <entry>Bytes</entry>
798d3a52
ZJS
700 </row>
701 <row>
a4c18002 702 <entry>LimitCORE=</entry>
798d3a52 703 <entry>ulimit -c</entry>
a4c18002 704 <entry>Bytes</entry>
798d3a52
ZJS
705 </row>
706 <row>
a4c18002 707 <entry>LimitRSS=</entry>
798d3a52 708 <entry>ulimit -m</entry>
a4c18002 709 <entry>Bytes</entry>
798d3a52
ZJS
710 </row>
711 <row>
a4c18002 712 <entry>LimitNOFILE=</entry>
798d3a52 713 <entry>ulimit -n</entry>
a4c18002 714 <entry>Number of File Descriptors</entry>
798d3a52
ZJS
715 </row>
716 <row>
a4c18002 717 <entry>LimitAS=</entry>
798d3a52 718 <entry>ulimit -v</entry>
a4c18002 719 <entry>Bytes</entry>
798d3a52
ZJS
720 </row>
721 <row>
a4c18002 722 <entry>LimitNPROC=</entry>
798d3a52 723 <entry>ulimit -u</entry>
a4c18002 724 <entry>Number of Processes</entry>
798d3a52
ZJS
725 </row>
726 <row>
a4c18002 727 <entry>LimitMEMLOCK=</entry>
798d3a52 728 <entry>ulimit -l</entry>
a4c18002 729 <entry>Bytes</entry>
798d3a52
ZJS
730 </row>
731 <row>
a4c18002 732 <entry>LimitLOCKS=</entry>
798d3a52 733 <entry>ulimit -x</entry>
a4c18002 734 <entry>Number of Locks</entry>
798d3a52
ZJS
735 </row>
736 <row>
a4c18002 737 <entry>LimitSIGPENDING=</entry>
798d3a52 738 <entry>ulimit -i</entry>
a4c18002 739 <entry>Number of Queued Signals</entry>
798d3a52
ZJS
740 </row>
741 <row>
a4c18002 742 <entry>LimitMSGQUEUE=</entry>
798d3a52 743 <entry>ulimit -q</entry>
a4c18002 744 <entry>Bytes</entry>
798d3a52
ZJS
745 </row>
746 <row>
a4c18002 747 <entry>LimitNICE=</entry>
798d3a52 748 <entry>ulimit -e</entry>
a4c18002 749 <entry>Nice Level</entry>
798d3a52
ZJS
750 </row>
751 <row>
a4c18002 752 <entry>LimitRTPRIO=</entry>
798d3a52 753 <entry>ulimit -r</entry>
a4c18002 754 <entry>Realtime Priority</entry>
798d3a52
ZJS
755 </row>
756 <row>
a4c18002 757 <entry>LimitRTTIME=</entry>
798d3a52 758 <entry>No equivalent</entry>
a4c18002 759 <entry>Microseconds</entry>
798d3a52
ZJS
760 </row>
761 </tbody>
762 </tgroup>
a4c18002 763 </table></listitem>
798d3a52
ZJS
764 </varlistentry>
765
766 <varlistentry>
767 <term><varname>PAMName=</varname></term>
768 <listitem><para>Sets the PAM service name to set up a session
769 as. If set, the executed process will be registered as a PAM
770 session under the specified service name. This is only useful
771 in conjunction with the <varname>User=</varname> setting. If
772 not set, no PAM session will be opened for the executed
773 processes. See
774 <citerefentry project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>
775 for details.</para></listitem>
776 </varlistentry>
777
778 <varlistentry>
779 <term><varname>CapabilityBoundingSet=</varname></term>
780
781 <listitem><para>Controls which capabilities to include in the
782 capability bounding set for the executed process. See
783 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
784 for details. Takes a whitespace-separated list of capability
785 names as read by
3ba3a79d 786 <citerefentry project='mankier'><refentrytitle>cap_from_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
798d3a52
ZJS
787 e.g. <constant>CAP_SYS_ADMIN</constant>,
788 <constant>CAP_DAC_OVERRIDE</constant>,
789 <constant>CAP_SYS_PTRACE</constant>. Capabilities listed will
790 be included in the bounding set, all others are removed. If
791 the list of capabilities is prefixed with
792 <literal>~</literal>, all but the listed capabilities will be
793 included, the effect of the assignment inverted. Note that
794 this option also affects the respective capabilities in the
795 effective, permitted and inheritable capability sets, on top
796 of what <varname>Capabilities=</varname> does. If this option
797 is not used, the capability bounding set is not modified on
798 process execution, hence no limits on the capabilities of the
b938cb90 799 process are enforced. This option may appear more than once, in
798d3a52
ZJS
800 which case the bounding sets are merged. If the empty string
801 is assigned to this option, the bounding set is reset to the
802 empty capability set, and all prior settings have no effect.
803 If set to <literal>~</literal> (without any further argument),
804 the bounding set is reset to the full set of available
805 capabilities, also undoing any previous
806 settings.</para></listitem>
807 </varlistentry>
808
ece87975
IP
809 <varlistentry>
810 <term><varname>AmbientCapabilities=</varname></term>
811
812 <listitem><para>Controls which capabilities to include in the
813 ambient capability set for the executed process. Takes a
814 whitespace-separated list of capability names as read by
815 <citerefentry project='mankier'><refentrytitle>cap_from_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
816 e.g. <constant>CAP_SYS_ADMIN</constant>,
817 <constant>CAP_DAC_OVERRIDE</constant>,
818 <constant>CAP_SYS_PTRACE</constant>. This option may appear more than
819 once in which case the ambient capability sets are merged.
820 If the list of capabilities is prefixed with <literal>~</literal>, all
821 but the listed capabilities will be included, the effect of the
822 assignment inverted. If the empty string is
823 assigned to this option, the ambient capability set is reset to
824 the empty capability set, and all prior settings have no effect.
825 If set to <literal>~</literal> (without any further argument), the
826 ambient capability set is reset to the full set of available
827 capabilities, also undoing any previous settings. Note that adding
828 capabilities to ambient capability set adds them to the process's
829 inherited capability set.
830 </para><para>
831 Ambient capability sets are useful if you want to execute a process
832 as a non-privileged user but still want to give it some capabilities.
833 Note that in this case option <constant>keep-caps</constant> is
834 automatically added to <varname>SecureBits=</varname> to retain the
835 capabilities over the user change.</para></listitem>
836 </varlistentry>
837
798d3a52
ZJS
838 <varlistentry>
839 <term><varname>SecureBits=</varname></term>
840 <listitem><para>Controls the secure bits set for the executed
841 process. Takes a space-separated combination of options from
842 the following list:
843 <option>keep-caps</option>,
844 <option>keep-caps-locked</option>,
845 <option>no-setuid-fixup</option>,
846 <option>no-setuid-fixup-locked</option>,
847 <option>noroot</option>, and
848 <option>noroot-locked</option>.
b938cb90 849 This option may appear more than once, in which case the secure
798d3a52
ZJS
850 bits are ORed. If the empty string is assigned to this option,
851 the bits are reset to 0. See
852 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
853 for details.</para></listitem>
854 </varlistentry>
855
856 <varlistentry>
857 <term><varname>Capabilities=</varname></term>
858 <listitem><para>Controls the
859 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
860 set for the executed process. Take a capability string
861 describing the effective, permitted and inherited capability
862 sets as documented in
3ba3a79d 863 <citerefentry project='mankier'><refentrytitle>cap_from_text</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
798d3a52
ZJS
864 Note that these capability sets are usually influenced (and
865 filtered) by the capabilities attached to the executed file.
866 Due to that <varname>CapabilityBoundingSet=</varname> is
867 probably a much more useful setting.</para></listitem>
868 </varlistentry>
869
870 <varlistentry>
871 <term><varname>ReadWriteDirectories=</varname></term>
872 <term><varname>ReadOnlyDirectories=</varname></term>
873 <term><varname>InaccessibleDirectories=</varname></term>
874
875 <listitem><para>Sets up a new file system namespace for
876 executed processes. These options may be used to limit access
877 a process might have to the main file system hierarchy. Each
878 setting takes a space-separated list of absolute directory
879 paths. Directories listed in
880 <varname>ReadWriteDirectories=</varname> are accessible from
881 within the namespace with the same access rights as from
882 outside. Directories listed in
883 <varname>ReadOnlyDirectories=</varname> are accessible for
884 reading only, writing will be refused even if the usual file
885 access controls would permit this. Directories listed in
886 <varname>InaccessibleDirectories=</varname> will be made
887 inaccessible for processes inside the namespace. Note that
888 restricting access with these options does not extend to
889 submounts of a directory that are created later on. These
b938cb90 890 options may be specified more than once, in which case all
798d3a52
ZJS
891 directories listed will have limited access from within the
892 namespace. If the empty string is assigned to this option, the
893 specific list is reset, and all prior assignments have no
894 effect.</para>
895 <para>Paths in
896 <varname>ReadOnlyDirectories=</varname>
897 and
898 <varname>InaccessibleDirectories=</varname>
899 may be prefixed with
900 <literal>-</literal>, in which case
901 they will be ignored when they do not
902 exist. Note that using this
903 setting will disconnect propagation of
904 mounts from the service to the host
905 (propagation in the opposite direction
906 continues to work). This means that
907 this setting may not be used for
908 services which shall be able to
909 install mount points in the main mount
910 namespace.</para></listitem>
911 </varlistentry>
912
913 <varlistentry>
914 <term><varname>PrivateTmp=</varname></term>
915
916 <listitem><para>Takes a boolean argument. If true, sets up a
917 new file system namespace for the executed processes and
918 mounts private <filename>/tmp</filename> and
919 <filename>/var/tmp</filename> directories inside it that is
920 not shared by processes outside of the namespace. This is
921 useful to secure access to temporary files of the process, but
922 makes sharing between processes via <filename>/tmp</filename>
923 or <filename>/var/tmp</filename> impossible. If this is
924 enabled, all temporary files created by a service in these
925 directories will be removed after the service is stopped.
926 Defaults to false. It is possible to run two or more units
927 within the same private <filename>/tmp</filename> and
928 <filename>/var/tmp</filename> namespace by using the
929 <varname>JoinsNamespaceOf=</varname> directive, see
930 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
931 for details. Note that using this setting will disconnect
932 propagation of mounts from the service to the host
933 (propagation in the opposite direction continues to work).
934 This means that this setting may not be used for services
935 which shall be able to install mount points in the main mount
936 namespace.</para></listitem>
937 </varlistentry>
938
939 <varlistentry>
940 <term><varname>PrivateDevices=</varname></term>
941
942 <listitem><para>Takes a boolean argument. If true, sets up a
943 new /dev namespace for the executed processes and only adds
944 API pseudo devices such as <filename>/dev/null</filename>,
945 <filename>/dev/zero</filename> or
946 <filename>/dev/random</filename> (as well as the pseudo TTY
947 subsystem) to it, but no physical devices such as
948 <filename>/dev/sda</filename>. This is useful to securely turn
949 off physical device access by the executed process. Defaults
950 to false. Enabling this option will also remove
951 <constant>CAP_MKNOD</constant> from the capability bounding
952 set for the unit (see above), and set
953 <varname>DevicePolicy=closed</varname> (see
954 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
955 for details). Note that using this setting will disconnect
956 propagation of mounts from the service to the host
957 (propagation in the opposite direction continues to work).
958 This means that this setting may not be used for services
959 which shall be able to install mount points in the main mount
960 namespace.</para></listitem>
961 </varlistentry>
962
963 <varlistentry>
964 <term><varname>PrivateNetwork=</varname></term>
965
966 <listitem><para>Takes a boolean argument. If true, sets up a
967 new network namespace for the executed processes and
968 configures only the loopback network device
969 <literal>lo</literal> inside it. No other network devices will
970 be available to the executed process. This is useful to
971 securely turn off network access by the executed process.
972 Defaults to false. It is possible to run two or more units
973 within the same private network namespace by using the
974 <varname>JoinsNamespaceOf=</varname> directive, see
975 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
976 for details. Note that this option will disconnect all socket
977 families from the host, this includes AF_NETLINK and AF_UNIX.
978 The latter has the effect that AF_UNIX sockets in the abstract
979 socket namespace will become unavailable to the processes
980 (however, those located in the file system will continue to be
981 accessible).</para></listitem>
982 </varlistentry>
983
984 <varlistentry>
985 <term><varname>ProtectSystem=</varname></term>
986
987 <listitem><para>Takes a boolean argument or
988 <literal>full</literal>. If true, mounts the
989 <filename>/usr</filename> and <filename>/boot</filename>
990 directories read-only for processes invoked by this unit. If
991 set to <literal>full</literal>, the <filename>/etc</filename>
992 directory is mounted read-only, too. This setting ensures that
b938cb90 993 any modification of the vendor-supplied operating system (and
798d3a52
ZJS
994 optionally its configuration) is prohibited for the service.
995 It is recommended to enable this setting for all long-running
996 services, unless they are involved with system updates or need
997 to modify the operating system in other ways. Note however
998 that processes retaining the CAP_SYS_ADMIN capability can undo
999 the effect of this setting. This setting is hence particularly
1000 useful for daemons which have this capability removed, for
1001 example with <varname>CapabilityBoundingSet=</varname>.
1002 Defaults to off.</para></listitem>
1003 </varlistentry>
1004
1005 <varlistentry>
1006 <term><varname>ProtectHome=</varname></term>
1007
1008 <listitem><para>Takes a boolean argument or
1009 <literal>read-only</literal>. If true, the directories
58331437
CH
1010 <filename>/home</filename>, <filename>/root</filename> and
1011 <filename>/run/user</filename>
798d3a52 1012 are made inaccessible and empty for processes invoked by this
58331437 1013 unit. If set to <literal>read-only</literal>, the three
798d3a52
ZJS
1014 directories are made read-only instead. It is recommended to
1015 enable this setting for all long-running services (in
1016 particular network-facing ones), to ensure they cannot get
1017 access to private user data, unless the services actually
1018 require access to the user's private data. Note however that
1019 processes retaining the CAP_SYS_ADMIN capability can undo the
1020 effect of this setting. This setting is hence particularly
1021 useful for daemons which have this capability removed, for
1022 example with <varname>CapabilityBoundingSet=</varname>.
1023 Defaults to off.</para></listitem>
1024 </varlistentry>
1025
1026 <varlistentry>
1027 <term><varname>MountFlags=</varname></term>
1028
1029 <listitem><para>Takes a mount propagation flag:
1030 <option>shared</option>, <option>slave</option> or
1031 <option>private</option>, which control whether mounts in the
1032 file system namespace set up for this unit's processes will
1033 receive or propagate mounts or unmounts. See
3ba3a79d 1034 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>2</manvolnum></citerefentry>
798d3a52
ZJS
1035 for details. Defaults to <option>shared</option>. Use
1036 <option>shared</option> to ensure that mounts and unmounts are
1037 propagated from the host to the container and vice versa. Use
1038 <option>slave</option> to run processes so that none of their
1039 mounts and unmounts will propagate to the host. Use
1040 <option>private</option> to also ensure that no mounts and
1041 unmounts from the host will propagate into the unit processes'
1042 namespace. Note that <option>slave</option> means that file
1043 systems mounted on the host might stay mounted continuously in
1044 the unit's namespace, and thus keep the device busy. Note that
1045 the file system namespace related options
1046 (<varname>PrivateTmp=</varname>,
1047 <varname>PrivateDevices=</varname>,
1048 <varname>ProtectSystem=</varname>,
1049 <varname>ProtectHome=</varname>,
1050 <varname>ReadOnlyDirectories=</varname>,
1051 <varname>InaccessibleDirectories=</varname> and
1052 <varname>ReadWriteDirectories=</varname>) require that mount
1053 and unmount propagation from the unit's file system namespace
1054 is disabled, and hence downgrade <option>shared</option> to
1055 <option>slave</option>. </para></listitem>
1056 </varlistentry>
1057
1058 <varlistentry>
1059 <term><varname>UtmpIdentifier=</varname></term>
1060
1061 <listitem><para>Takes a four character identifier string for
023a4f67
LP
1062 an <citerefentry
1063 project='man-pages'><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1064 and wtmp entry for this service. This should only be
1065 set for services such as <command>getty</command>
1066 implementations (such as <citerefentry
1067 project='die-net'><refentrytitle>agetty</refentrytitle><manvolnum>8</manvolnum></citerefentry>)
798d3a52 1068 where utmp/wtmp entries must be created and cleared before and
023a4f67
LP
1069 after execution, or for services that shall be executed as if
1070 they were run by a <command>getty</command> process (see
1071 below). If the configured string is longer than four
798d3a52
ZJS
1072 characters, it is truncated and the terminal four characters
1073 are used. This setting interprets %I style string
1074 replacements. This setting is unset by default, i.e. no
1075 utmp/wtmp entries are created or cleaned up for this
1076 service.</para></listitem>
1077 </varlistentry>
1078
023a4f67
LP
1079 <varlistentry>
1080 <term><varname>UtmpMode=</varname></term>
1081
1082 <listitem><para>Takes one of <literal>init</literal>,
1083 <literal>login</literal> or <literal>user</literal>. If
1084 <varname>UtmpIdentifier=</varname> is set, controls which
1085 type of <citerefentry
1086 project='man-pages'><refentrytitle>utmp</refentrytitle><manvolnum>5</manvolnum></citerefentry>/wtmp
1087 entries for this service are generated. This setting has no
1088 effect unless <varname>UtmpIdentifier=</varname> is set
1089 too. If <literal>init</literal> is set, only an
1090 <constant>INIT_PROCESS</constant> entry is generated and the
6cd16034
LP
1091 invoked process must implement a
1092 <command>getty</command>-compatible utmp/wtmp logic. If
1093 <literal>login</literal> is set, first an
a8eaaee7 1094 <constant>INIT_PROCESS</constant> entry, followed by a
6cd16034 1095 <constant>LOGIN_PROCESS</constant> entry is generated. In
b938cb90 1096 this case, the invoked process must implement a <citerefentry
023a4f67
LP
1097 project='die-net'><refentrytitle>login</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible
1098 utmp/wtmp logic. If <literal>user</literal> is set, first an
1099 <constant>INIT_PROCESS</constant> entry, then a
a8eaaee7 1100 <constant>LOGIN_PROCESS</constant> entry and finally a
023a4f67 1101 <constant>USER_PROCESS</constant> entry is generated. In this
b938cb90 1102 case, the invoked process may be any process that is suitable
023a4f67
LP
1103 to be run as session leader. Defaults to
1104 <literal>init</literal>.</para></listitem>
1105 </varlistentry>
1106
798d3a52
ZJS
1107 <varlistentry>
1108 <term><varname>SELinuxContext=</varname></term>
1109
1110 <listitem><para>Set the SELinux security context of the
1111 executed process. If set, this will override the automated
1112 domain transition. However, the policy still needs to
1113 authorize the transition. This directive is ignored if SELinux
1114 is disabled. If prefixed by <literal>-</literal>, all errors
1115 will be ignored. See
3ba3a79d 1116 <citerefentry project='die-net'><refentrytitle>setexeccon</refentrytitle><manvolnum>3</manvolnum></citerefentry>
798d3a52
ZJS
1117 for details.</para></listitem>
1118 </varlistentry>
1119
1120 <varlistentry>
1121 <term><varname>AppArmorProfile=</varname></term>
1122
1123 <listitem><para>Takes a profile name as argument. The process
1124 executed by the unit will switch to this profile when started.
1125 Profiles must already be loaded in the kernel, or the unit
1126 will fail. This result in a non operation if AppArmor is not
1127 enabled. If prefixed by <literal>-</literal>, all errors will
1128 be ignored. </para></listitem>
1129 </varlistentry>
1130
1131 <varlistentry>
1132 <term><varname>SmackProcessLabel=</varname></term>
1133
1134 <listitem><para>Takes a <option>SMACK64</option> security
1135 label as argument. The process executed by the unit will be
1136 started under this label and SMACK will decide whether the
b938cb90 1137 process is allowed to run or not, based on it. The process
798d3a52
ZJS
1138 will continue to run under the label specified here unless the
1139 executable has its own <option>SMACK64EXEC</option> label, in
1140 which case the process will transition to run under that
1141 label. When not specified, the label that systemd is running
1142 under is used. This directive is ignored if SMACK is
1143 disabled.</para>
1144
1145 <para>The value may be prefixed by <literal>-</literal>, in
1146 which case all errors will be ignored. An empty value may be
1147 specified to unset previous assignments.</para>
1148 </listitem>
1149 </varlistentry>
1150
1151 <varlistentry>
1152 <term><varname>IgnoreSIGPIPE=</varname></term>
1153
1154 <listitem><para>Takes a boolean argument. If true, causes
1155 <constant>SIGPIPE</constant> to be ignored in the executed
1156 process. Defaults to true because <constant>SIGPIPE</constant>
1157 generally is useful only in shell pipelines.</para></listitem>
1158 </varlistentry>
1159
1160 <varlistentry>
1161 <term><varname>NoNewPrivileges=</varname></term>
1162
1163 <listitem><para>Takes a boolean argument. If true, ensures
1164 that the service process and all its children can never gain
1165 new privileges. This option is more powerful than the
1166 respective secure bits flags (see above), as it also prohibits
1167 UID changes of any kind. This is the simplest, most effective
1168 way to ensure that a process and its children can never
1169 elevate privileges again.</para></listitem>
1170 </varlistentry>
1171
1172 <varlistentry>
1173 <term><varname>SystemCallFilter=</varname></term>
1174
1175 <listitem><para>Takes a space-separated list of system call
1176 names. If this setting is used, all system calls executed by
1177 the unit processes except for the listed ones will result in
1178 immediate process termination with the
1179 <constant>SIGSYS</constant> signal (whitelisting). If the
1180 first character of the list is <literal>~</literal>, the
1181 effect is inverted: only the listed system calls will result
1182 in immediate process termination (blacklisting). If running in
1183 user mode and this option is used,
1184 <varname>NoNewPrivileges=yes</varname> is implied. This
1185 feature makes use of the Secure Computing Mode 2 interfaces of
1186 the kernel ('seccomp filtering') and is useful for enforcing a
1187 minimal sandboxing environment. Note that the
1188 <function>execve</function>,
1189 <function>rt_sigreturn</function>,
1190 <function>sigreturn</function>,
1191 <function>exit_group</function>, <function>exit</function>
1192 system calls are implicitly whitelisted and do not need to be
b938cb90 1193 listed explicitly. This option may be specified more than once,
798d3a52
ZJS
1194 in which case the filter masks are merged. If the empty string
1195 is assigned, the filter is reset, all prior assignments will
1196 have no effect.</para>
1197
1198 <para>If you specify both types of this option (i.e.
1199 whitelisting and blacklisting), the first encountered will
1200 take precedence and will dictate the default action
1201 (termination or approval of a system call). Then the next
1202 occurrences of this option will add or delete the listed
1203 system calls from the set of the filtered system calls,
1204 depending of its type and the default action. (For example, if
1205 you have started with a whitelisting of
1206 <function>read</function> and <function>write</function>, and
1207 right after it add a blacklisting of
1208 <function>write</function>, then <function>write</function>
1209 will be removed from the set.) </para></listitem>
1210 </varlistentry>
1211
1212 <varlistentry>
1213 <term><varname>SystemCallErrorNumber=</varname></term>
1214
1215 <listitem><para>Takes an <literal>errno</literal> error number
1216 name to return when the system call filter configured with
1217 <varname>SystemCallFilter=</varname> is triggered, instead of
1218 terminating the process immediately. Takes an error name such
1219 as <constant>EPERM</constant>, <constant>EACCES</constant> or
1220 <constant>EUCLEAN</constant>. When this setting is not used,
1221 or when the empty string is assigned, the process will be
1222 terminated immediately when the filter is
1223 triggered.</para></listitem>
1224 </varlistentry>
1225
1226 <varlistentry>
1227 <term><varname>SystemCallArchitectures=</varname></term>
1228
b938cb90 1229 <listitem><para>Takes a space-separated list of architecture
798d3a52
ZJS
1230 identifiers to include in the system call filter. The known
1231 architecture identifiers are <constant>x86</constant>,
1232 <constant>x86-64</constant>, <constant>x32</constant>,
1233 <constant>arm</constant> as well as the special identifier
1234 <constant>native</constant>. Only system calls of the
1235 specified architectures will be permitted to processes of this
1236 unit. This is an effective way to disable compatibility with
1237 non-native architectures for processes, for example to
1238 prohibit execution of 32-bit x86 binaries on 64-bit x86-64
1239 systems. The special <constant>native</constant> identifier
1240 implicitly maps to the native architecture of the system (or
1241 more strictly: to the architecture the system manager is
1242 compiled for). If running in user mode and this option is
1243 used, <varname>NoNewPrivileges=yes</varname> is implied. Note
1244 that setting this option to a non-empty list implies that
1245 <constant>native</constant> is included too. By default, this
1246 option is set to the empty list, i.e. no architecture system
1247 call filtering is applied.</para></listitem>
1248 </varlistentry>
1249
1250 <varlistentry>
1251 <term><varname>RestrictAddressFamilies=</varname></term>
1252
1253 <listitem><para>Restricts the set of socket address families
1254 accessible to the processes of this unit. Takes a
1255 space-separated list of address family names to whitelist,
1256 such as
1257 <constant>AF_UNIX</constant>,
1258 <constant>AF_INET</constant> or
1259 <constant>AF_INET6</constant>. When
1260 prefixed with <constant>~</constant> the listed address
1261 families will be applied as blacklist, otherwise as whitelist.
1262 Note that this restricts access to the
3ba3a79d 1263 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum></citerefentry>
798d3a52
ZJS
1264 system call only. Sockets passed into the process by other
1265 means (for example, by using socket activation with socket
1266 units, see
1267 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
1268 are unaffected. Also, sockets created with
1269 <function>socketpair()</function> (which creates connected
1270 AF_UNIX sockets only) are unaffected. Note that this option
1271 has no effect on 32-bit x86 and is ignored (but works
1272 correctly on x86-64). If running in user mode and this option
1273 is used, <varname>NoNewPrivileges=yes</varname> is implied. By
1274 default, no restriction applies, all address families are
1275 accessible to processes. If assigned the empty string, any
1276 previous list changes are undone.</para>
1277
1278 <para>Use this option to limit exposure of processes to remote
1279 systems, in particular via exotic network protocols. Note that
1280 in most cases, the local <constant>AF_UNIX</constant> address
1281 family should be included in the configured whitelist as it is
1282 frequently used for local communication, including for
1283 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1284 logging.</para></listitem>
1285 </varlistentry>
1286
1287 <varlistentry>
1288 <term><varname>Personality=</varname></term>
1289
1290 <listitem><para>Controls which kernel architecture
3ba3a79d 1291 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
798d3a52
ZJS
1292 shall report, when invoked by unit processes. Takes one of
1293 <constant>x86</constant> and <constant>x86-64</constant>. This
1294 is useful when running 32-bit services on a 64-bit host
1295 system. If not specified, the personality is left unmodified
1296 and thus reflects the personality of the host system's
1297 kernel.</para></listitem>
1298 </varlistentry>
1299
1300 <varlistentry>
1301 <term><varname>RuntimeDirectory=</varname></term>
1302 <term><varname>RuntimeDirectoryMode=</varname></term>
1303
1304 <listitem><para>Takes a list of directory names. If set, one
1305 or more directories by the specified names will be created
1306 below <filename>/run</filename> (for system services) or below
1307 <varname>$XDG_RUNTIME_DIR</varname> (for user services) when
1308 the unit is started, and removed when the unit is stopped. The
1309 directories will have the access mode specified in
1310 <varname>RuntimeDirectoryMode=</varname>, and will be owned by
1311 the user and group specified in <varname>User=</varname> and
1312 <varname>Group=</varname>. Use this to manage one or more
1313 runtime directories of the unit and bind their lifetime to the
1314 daemon runtime. The specified directory names must be
1315 relative, and may not include a <literal>/</literal>, i.e.
1316 must refer to simple directories to create or remove. This is
1317 particularly useful for unprivileged daemons that cannot
1318 create runtime directories in <filename>/run</filename> due to
1319 lack of privileges, and to make sure the runtime directory is
1320 cleaned up automatically after use. For runtime directories
1321 that require more complex or different configuration or
1322 lifetime guarantees, please consider using
1323 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para></listitem>
1324 </varlistentry>
1325
1326 </variablelist>
1327 </refsect1>
1328
1329 <refsect1>
1330 <title>Environment variables in spawned processes</title>
1331
1332 <para>Processes started by the system are executed in a clean
1333 environment in which select variables listed below are set. System
1334 processes started by systemd do not inherit variables from PID 1,
1335 but processes started by user systemd instances inherit all
1336 environment variables from the user systemd instance.
1337 </para>
1338
1339 <variablelist class='environment-variables'>
1340 <varlistentry>
1341 <term><varname>$PATH</varname></term>
1342
1343 <listitem><para>Colon-separated list of directories to use
1344 when launching executables. Systemd uses a fixed value of
1345 <filename>/usr/local/sbin</filename>:<filename>/usr/local/bin</filename>:<filename>/usr/sbin</filename>:<filename>/usr/bin</filename>:<filename>/sbin</filename>:<filename>/bin</filename>.
1346 </para></listitem>
1347 </varlistentry>
1348
1349 <varlistentry>
1350 <term><varname>$LANG</varname></term>
1351
1352 <listitem><para>Locale. Can be set in
3ba3a79d 1353 <citerefentry project='man-pages'><refentrytitle>locale.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
798d3a52
ZJS
1354 or on the kernel command line (see
1355 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1356 and
1357 <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
1358 </para></listitem>
1359 </varlistentry>
1360
1361 <varlistentry>
1362 <term><varname>$USER</varname></term>
1363 <term><varname>$LOGNAME</varname></term>
1364 <term><varname>$HOME</varname></term>
1365 <term><varname>$SHELL</varname></term>
1366
1367 <listitem><para>User name (twice), home directory, and the
1368 login shell. The variables are set for the units that have
1369 <varname>User=</varname> set, which includes user
1370 <command>systemd</command> instances. See
3ba3a79d 1371 <citerefentry project='die-net'><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
798d3a52
ZJS
1372 </para></listitem>
1373 </varlistentry>
1374
1375 <varlistentry>
1376 <term><varname>$XDG_RUNTIME_DIR</varname></term>
1377
1378 <listitem><para>The directory for volatile state. Set for the
1379 user <command>systemd</command> instance, and also in user
1380 sessions. See
1381 <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
1382 </para></listitem>
1383 </varlistentry>
1384
1385 <varlistentry>
1386 <term><varname>$XDG_SESSION_ID</varname></term>
1387 <term><varname>$XDG_SEAT</varname></term>
1388 <term><varname>$XDG_VTNR</varname></term>
1389
1390 <listitem><para>The identifier of the session, the seat name,
1391 and virtual terminal of the session. Set by
1392 <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
1393 for login sessions. <varname>$XDG_SEAT</varname> and
1394 <varname>$XDG_VTNR</varname> will only be set when attached to
1395 a seat and a tty.</para></listitem>
1396 </varlistentry>
1397
1398 <varlistentry>
1399 <term><varname>$MAINPID</varname></term>
1400
1401 <listitem><para>The PID of the units main process if it is
1402 known. This is only set for control processes as invoked by
1403 <varname>ExecReload=</varname> and similar. </para></listitem>
1404 </varlistentry>
1405
1406 <varlistentry>
1407 <term><varname>$MANAGERPID</varname></term>
1408
1409 <listitem><para>The PID of the user <command>systemd</command>
1410 instance, set for processes spawned by it. </para></listitem>
1411 </varlistentry>
1412
1413 <varlistentry>
1414 <term><varname>$LISTEN_FDS</varname></term>
1415 <term><varname>$LISTEN_PID</varname></term>
5c019cf2 1416 <term><varname>$LISTEN_FDNAMES</varname></term>
798d3a52
ZJS
1417
1418 <listitem><para>Information about file descriptors passed to a
1419 service for socket activation. See
1420 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
1421 </para></listitem>
1422 </varlistentry>
1423
5c019cf2
EV
1424 <varlistentry>
1425 <term><varname>$NOTIFY_SOCKET</varname></term>
1426
1427 <listitem><para>The socket
1428 <function>sd_notify()</function> talks to. See
1429 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
1430 </para></listitem>
1431 </varlistentry>
1432
1433 <varlistentry>
1434 <term><varname>$WATCHDOG_PID</varname></term>
1435 <term><varname>$WATCHDOG_USEC</varname></term>
1436
1437 <listitem><para>Information about watchdog keep-alive notifications. See
1438 <citerefentry><refentrytitle>sd_watchdog_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
1439 </para></listitem>
1440 </varlistentry>
1441
798d3a52
ZJS
1442 <varlistentry>
1443 <term><varname>$TERM</varname></term>
1444
1445 <listitem><para>Terminal type, set only for units connected to
1446 a terminal (<varname>StandardInput=tty</varname>,
1447 <varname>StandardOutput=tty</varname>, or
1448 <varname>StandardError=tty</varname>). See
1449 <citerefentry project='man-pages'><refentrytitle>termcap</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1450 </para></listitem>
1451 </varlistentry>
1452 </variablelist>
1453
1454 <para>Additional variables may be configured by the following
1455 means: for processes spawned in specific units, use the
5c019cf2
EV
1456 <varname>Environment=</varname>, <varname>EnvironmentFile=</varname>
1457 and <varname>PassEnvironment=</varname> options above; to specify
798d3a52
ZJS
1458 variables globally, use <varname>DefaultEnvironment=</varname>
1459 (see
1460 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
1461 or the kernel option <varname>systemd.setenv=</varname> (see
1462 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>).
1463 Additional variables may also be set through PAM,
1464 cf. <citerefentry project='man-pages'><refentrytitle>pam_env</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
1465 </refsect1>
1466
1467 <refsect1>
1468 <title>See Also</title>
1469 <para>
1470 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1471 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1472 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1473 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1474 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1475 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1476 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1477 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1478 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1479 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
a4c18002 1480 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
798d3a52
ZJS
1481 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1482 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1483 <citerefentry project='man-pages'><refentrytitle>exec</refentrytitle><manvolnum>3</manvolnum></citerefentry>
1484 </para>
1485 </refsect1>
dd1eb43b
LP
1486
1487</refentry>