chiark / gitweb /
sd-daemon: Add sd_is_special for special file descriptors
[elogind.git] / man / pam_systemd.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3         "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
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
11   under the terms of the GNU General Public License as published by
12   the Free Software Foundation; either version 2 of the License, or
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
18   General Public License for more details.
19
20   You should have received a copy of the GNU General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="pam_systemd">
25
26         <refentryinfo>
27                 <title>pam_systemd</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Lennart</firstname>
34                                 <surname>Poettering</surname>
35                                 <email>lennart@poettering.net</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>pam_systemd</refentrytitle>
42                 <manvolnum>8</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>pam_systemd</refname>
47                 <refpurpose>Register user sessions in the systemd control group hierarchy</refpurpose>
48         </refnamediv>
49
50         <refsynopsisdiv>
51                 <cmdsynopsis>
52                         <command>pam_systemd.so</command>
53                 </cmdsynopsis>
54         </refsynopsisdiv>
55
56         <refsect1>
57                 <title>Description</title>
58
59                 <para><command>pam_systemd</command> registers user
60                 sessions in the systemd control group
61                 hierarchy.</para>
62
63                 <para>On login, this module ensures the following:</para>
64
65                 <orderedlist>
66                         <listitem><para>If it does not exist yet, the
67                         user runtime directory
68                         <filename>/run/user/$USER</filename> is
69                         created and its ownership changed to the user
70                         that is logging in.</para></listitem>
71
72                         <listitem><para>If
73                         <option>create-session=1</option> is set, the
74                         <varname>$XDG_SESSION_ID</varname> environment
75                         variable is initialized. If auditing is
76                         available and
77                         <command>pam_loginuid.so</command> run before
78                         this module (which is highly recommended), the
79                         variable is initialized from the auditing
80                         session id
81                         (<filename>/proc/self/sessionid</filename>). Otherwise
82                         an independent session counter is
83                         used.</para></listitem>
84
85                         <listitem><para>If
86                         <option>create-session=1</option> is set, a new
87                         control group
88                         <filename>/user/$USER/$XDG_SESSION_ID</filename>
89                         is created and the login process moved into
90                         it.</para></listitem>
91
92                         <listitem><para>If
93                         <option>create-session=0</option> is set, a new
94                         control group
95                         <filename>/user/$USER/user</filename>
96                         is created and the login process moved into
97                         it.</para></listitem>
98
99                 </orderedlist>
100
101                 <para>On logout, this module ensures the following:</para>
102
103                 <orderedlist>
104                         <listitem><para>If
105                         <varname>$XDG_SESSION_ID</varname> is set and
106                         <option>kill-session=1</option> specified, all
107                         remaining processes in the
108                         <filename>/user/$USER/$XDG_SESSION_ID</filename>
109                         control group are killed and the control group
110                         is removed.</para></listitem>
111
112                         <listitem><para>If
113                         <varname>$XDG_SESSION_ID</varname> is set and
114                         <option>kill-session=0</option> specified, all
115                         remaining processes in the
116                         <filename>/user/$USER/$XDG_SESSION_ID</filename>
117                         control group are migrated to
118                         <filename>/user/$USER/user</filename> and
119                         the original control group is
120                         removed.</para></listitem>
121
122                         <listitem><para>If
123                         <option>kill-user=1</option> is specified, and
124                         no other user session control group remains,
125                         except
126                         <filename>/user/$USER/user</filename>,
127                         all remaining processes in the
128                         <filename>/user/$USER</filename> hierarchy
129                         are killed and the control group is removed.</para></listitem>
130
131                         <listitem><para>If
132                         <option>kill-user=0</option> is specified, and
133                         no process remains in the
134                         <filename>/user/$USER</filename> hierarchy the
135                         control group is removed.</para></listitem>
136
137                         <listitem><para>If the
138                         <filename>/user/$USER</filename> control group
139                         was removed the
140                         <varname>$XDG_RUNTIME_DIR</varname> directory
141                         and all its contents are
142                         removed, too.</para></listitem>
143                 </orderedlist>
144
145                 <para>If the system was not booted up with systemd as
146                 init system, this module does nothing and immediately
147                 returns PAM_SUCCESS.</para>
148
149         </refsect1>
150
151         <refsect1>
152                 <title>Options</title>
153
154                 <para>The following options are understood:</para>
155
156                 <variablelist>
157                         <varlistentry>
158                                 <term><option>create-session=</option></term>
159
160                                 <listitem><para>Takes a boolean
161                                 argument. If true, a new session is
162                                 created: the
163                                 <varname>$XDG_SESSION_ID</varname>
164                                 environment variable is set and the
165                                 login process moved to the
166                                 <filename>/user/$USER/$XDG_SESSION_ID</filename>
167                                 control group. It is recommended that
168                                 all services which are directly created
169                                 on the user's behalf set this
170                                 option. Only for services that shall
171                                 automatically be terminated when the
172                                 user logs out completely, otherwise
173                                 <varname>create-session=0</varname>
174                                 should be set.</para></listitem>
175                         </varlistentry>
176
177                         <varlistentry>
178                                 <term><option>kill-session=</option></term>
179
180                                 <listitem><para>Takes a boolean
181                                 argument. If true, all processes
182                                 created by the user during his session
183                                 and from his session will be
184                                 terminated when he logs out from his
185                                 session.</para></listitem>
186                         </varlistentry>
187
188                         <varlistentry>
189                                 <term><option>kill-user=</option></term>
190
191                                 <listitem><para>Takes a boolean
192                                 argument. If true, all processes
193                                 created by the user during his session
194                                 and from his session will be
195                                 terminated after he logged out
196                                 completely. This is a weaker version
197                                 of <option>kill-session=1</option> and is
198                                 more friendly for users logged in more
199                                 than once, as their processes are
200                                 terminated only on their complete
201                                 logout.</para></listitem>
202                         </varlistentry>
203
204                         <varlistentry>
205                                 <term><option>kill-only-users=</option></term>
206
207                                 <listitem><para>Takes a comma
208                                 separated list of user names or
209                                 numeric user ids as argument. If this
210                                 option is used the effect of the
211                                 <option>kill-session=</option> and
212                                 <option>kill-user=</option> options
213                                 will apply only to the listed
214                                 users. If this option is not used the
215                                 option applies to all local
216                                 users. Note that
217                                 <option>kill-exclude-users=</option>
218                                 takes precedence over this list and is
219                                 hence subtracted from the list
220                                 specified here.</para></listitem>
221                         </varlistentry>
222
223                         <varlistentry>
224                                 <term><option>kill-exclude-users=</option></term>
225
226                                 <listitem><para>Takes a comma
227                                 separated list of user names or
228                                 numeric user ids as argument. Users
229                                 listed in this argument will not be
230                                 subject to the effect of
231                                 <option>kill-session=</option> or
232                                 <option>kill-user=</option>.  Note
233                                 that that this option takes precedence
234                                 over
235                                 <option>kill-only-users=</option>, and
236                                 hence whatever is listed for
237                                 <option>kill-exclude-users=</option>
238                                 is guaranteed to never be killed by
239                                 this PAM module, independent of any
240                                 other configuration
241                                 setting.</para></listitem>
242                         </varlistentry>
243
244                         <varlistentry>
245                                 <term><option>controllers=</option></term>
246
247                                 <listitem><para>Takes a comma
248                                 separated list of cgroup controllers
249                                 in which hierarchies a user/session
250                                 cgroup will be created by default for
251                                 each user logging in, in addition to
252                                 the cgroup in the named 'name=systemd'
253                                 hierarchy. If ommited, defaults to an
254                                 empty list. This may be used to move
255                                 user sessions into their own groups in
256                                 the 'cpu' hierarchy which ensures that
257                                 every logged in user gets an equal
258                                 amount of CPU time regardless how many
259                                 processes he has
260                                 started.</para></listitem>
261                         </varlistentry>
262
263                         <varlistentry>
264                                 <term><option>reset-controllers=</option></term>
265
266                                 <listitem><para>Takes a comma
267                                 separated list of cgroup controllers
268                                 in which hierarchies the logged in
269                                 processes will be reset to the root
270                                 cgroup. If ommited, defaults to 'cpu',
271                                 meaning that a 'cpu' cgroup grouping
272                                 inherited from the login manager will
273                                 be reset for the processes of the
274                                 logged in user.</para></listitem>
275                         </varlistentry>
276
277                         <varlistentry>
278                                 <term><option>debug=</option></term>
279
280                                 <listitem><para>Takes a boolean
281                                 argument. If true, logs debugging
282                                 information.</para></listitem>
283                         </varlistentry>
284                 </variablelist>
285
286                 <para>Note that setting <varname>kill-user=1</varname>
287                 or even <varname>kill-session=1</varname> will break
288                 tools like
289                 <citerefentry><refentrytitle>screen</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
290
291                 <para>If the options are omitted they default to
292                 <option>create-session=1</option>,
293                 <option>kill-session=0</option>,
294                 <option>kill-user=0</option>,
295                 <option>reset-controllers=cpu</option>,
296                 <option>kill-only-users=</option>,
297                 <option>kill-exclude-users=root</option>.</para>
298         </refsect1>
299
300         <refsect1>
301                 <title>Module Types Provided</title>
302
303                 <para>Only <option>session</option> is provided.</para>
304         </refsect1>
305
306         <refsect1>
307                 <title>Environment</title>
308
309                 <para>The following environment variables are set for the processes of the user's session:</para>
310
311                 <variablelist>
312                         <varlistentry>
313                                 <term><varname>$XDG_SESSION_ID</varname></term>
314
315                                 <listitem><para>A session identifier,
316                                 suitable to be used in file names. The
317                                 string itself should be considered
318                                 opaque, although often it is just the
319                                 audit session ID as reported by
320                                 <filename>/proc/self/sessionid</filename>. Each
321                                 ID will be assigned only once during
322                                 machine uptime. It may hence be used
323                                 to uniquely label files or other
324                                 resources of this
325                                 session.</para></listitem>
326                         </varlistentry>
327
328                         <varlistentry>
329                                 <term><varname>$XDG_RUNTIME_DIR</varname></term>
330
331                                 <listitem><para>Path to a user-private
332                                 user-writable directory that is bound
333                                 to the user login time on the
334                                 machine. It is automatically created
335                                 the first time a user logs in and
336                                 removed on his final logout. If a user
337                                 logs in twice at the same time, both
338                                 sessions will see the same
339                                 <varname>$XDG_RUNTIME_DIR</varname>
340                                 and the same contents. If a user logs
341                                 in once, then logs out again, and logs
342                                 in again, the directory contents will
343                                 have been lost in between, but
344                                 applications should not rely on this
345                                 behaviour and must be able to deal with
346                                 stale files. To store session-private
347                                 data in this directory the user should
348                                 include the value of <varname>$XDG_SESSION_ID</varname>
349                                 in the filename. This directory shall
350                                 be used for runtime file system
351                                 objects such as AF_UNIX sockets,
352                                 FIFOs, PID files and similar. It is
353                                 guaranteed that this directory is
354                                 local and offers the greatest possible
355                                 file system feature set the
356                                 operating system
357                                 provides.</para></listitem>
358                         </varlistentry>
359                 </variablelist>
360         </refsect1>
361
362         <refsect1>
363                 <title>Example</title>
364
365                 <programlisting>#%PAM-1.0
366 auth       required     pam_unix.so
367 auth       required     pam_nologin.so
368 account    required     pam_unix.so
369 password   required     pam_unix.so
370 session    required     pam_unix.so
371 session    required     pam_loginuid.so
372 session    required     pam_systemd.so kill-user=1</programlisting>
373         </refsect1>
374
375         <refsect1>
376                 <title>See Also</title>
377                 <para>
378                         <citerefentry><refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
379                         <citerefentry><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
380                         <citerefentry><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
381                         <citerefentry><refentrytitle>pam_loginuid</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
382                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
383                 </para>
384         </refsect1>
385
386 </refentry>