]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/pam_systemd.xml
grypt-util: drop two emacs modelines
[thirdparty/systemd.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 SPDX-License-Identifier: LGPL-2.1+
7
8 Copyright 2010 Lennart Poettering
9 -->
10
11 <refentry id="pam_systemd" conditional='HAVE_PAM'>
12
13 <refentryinfo>
14 <title>pam_systemd</title>
15 <productname>systemd</productname>
16
17 <authorgroup>
18 <author>
19 <contrib>Developer</contrib>
20 <firstname>Lennart</firstname>
21 <surname>Poettering</surname>
22 <email>lennart@poettering.net</email>
23 </author>
24 </authorgroup>
25 </refentryinfo>
26
27 <refmeta>
28 <refentrytitle>pam_systemd</refentrytitle>
29 <manvolnum>8</manvolnum>
30 </refmeta>
31
32 <refnamediv>
33 <refname>pam_systemd</refname>
34 <refpurpose>Register user sessions in the systemd login manager</refpurpose>
35 </refnamediv>
36
37 <refsynopsisdiv>
38 <para><filename>pam_systemd.so</filename></para>
39 </refsynopsisdiv>
40
41 <refsect1>
42 <title>Description</title>
43
44 <para><command>pam_systemd</command> registers user sessions with
45 the systemd login manager
46 <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
47 and hence the systemd control group hierarchy.</para>
48
49 <para>On login, this module — in conjunction with <filename>systemd-logind.service</filename> — ensures the
50 following:</para>
51
52 <orderedlist>
53 <listitem><para>If it does not exist yet, the user runtime directory <filename>/run/user/$UID</filename> is
54 either created or mounted as new <literal>tmpfs</literal> file system with quota applied, and its ownership
55 changed to the user that is logging in.</para></listitem>
56
57 <listitem><para>The <varname>$XDG_SESSION_ID</varname> environment variable is initialized. If auditing is
58 available and <command>pam_loginuid.so</command> was run before this module (which is highly recommended), the
59 variable is initialized from the auditing session id (<filename>/proc/self/sessionid</filename>). Otherwise, an
60 independent session counter is used.</para></listitem>
61
62 <listitem><para>A new systemd scope unit is created for the session. If this is the first concurrent session of
63 the user, an implicit per-user slice unit below <filename>user.slice</filename> is automatically created and the
64 scope placed into it. An instance of the system service <filename>user@.service</filename>, which runs the
65 systemd user manager instance, is started. </para></listitem>
66 </orderedlist>
67
68 <para>On logout, this module ensures the following:</para>
69
70 <orderedlist>
71 <listitem><para>If enabled in
72 <citerefentry><refentrytitle>logind.conf</refentrytitle>
73 <manvolnum>5</manvolnum></citerefentry> (<varname>KillUserProcesses=</varname>), all processes of the session are
74 terminated. If the last concurrent session of a user ends, the user's systemd instance will be terminated too,
75 and so will the user's slice unit.</para></listitem>
76
77 <listitem><para>If the last concurrent session of a user ends,
78 the user runtime directory <filename>/run/user/$UID</filename> and all its
79 contents are removed, too.</para></listitem>
80 </orderedlist>
81
82 <para>If the system was not booted up with systemd as init system,
83 this module does nothing and immediately returns
84 <constant>PAM_SUCCESS</constant>.</para>
85
86 </refsect1>
87
88 <refsect1>
89 <title>Options</title>
90
91 <para>The following options are understood:</para>
92
93 <variablelist class='pam-directives'>
94
95 <varlistentry>
96 <term><option>class=</option></term>
97
98 <listitem><para>Takes a string argument which sets the session
99 class. The XDG_SESSION_CLASS environmental variable takes
100 precedence. One of
101 <literal>user</literal>,
102 <literal>greeter</literal>,
103 <literal>lock-screen</literal> or
104 <literal>background</literal>. See
105 <citerefentry><refentrytitle>sd_session_get_class</refentrytitle><manvolnum>3</manvolnum></citerefentry>
106 for details about the session class.</para></listitem>
107 </varlistentry>
108
109 <varlistentry>
110 <term><option>type=</option></term>
111
112 <listitem><para>Takes a string argument which sets the session
113 type. The XDG_SESSION_TYPE environmental variable takes
114 precedence. One of
115 <literal>unspecified</literal>,
116 <literal>tty</literal>,
117 <literal>x11</literal>,
118 <literal>wayland</literal> or
119 <literal>mir</literal>. See
120 <citerefentry><refentrytitle>sd_session_get_type</refentrytitle><manvolnum>3</manvolnum></citerefentry>
121 for details about the session type.</para></listitem>
122 </varlistentry>
123
124 <varlistentry>
125 <term><option>debug<optional>=</optional></option></term>
126
127 <listitem><para>Takes an optional
128 boolean argument. If yes or without
129 the argument, the module will log
130 debugging information as it
131 operates.</para></listitem>
132 </varlistentry>
133 </variablelist>
134 </refsect1>
135
136 <refsect1>
137 <title>Module Types Provided</title>
138
139 <para>Only <option>session</option> is provided.</para>
140 </refsect1>
141
142 <refsect1>
143 <title>Environment</title>
144
145 <para>The following environment variables are set for the
146 processes of the user's session:</para>
147
148 <variablelist class='environment-variables'>
149 <varlistentry>
150 <term><varname>$XDG_SESSION_ID</varname></term>
151
152 <listitem><para>A session identifier, suitable to be used in
153 filenames. The string itself should be considered opaque,
154 although often it is just the audit session ID as reported by
155 <filename>/proc/self/sessionid</filename>. Each ID will be
156 assigned only once during machine uptime. It may hence be used
157 to uniquely label files or other resources of this
158 session.</para></listitem>
159 </varlistentry>
160
161 <varlistentry>
162 <term><varname>$XDG_RUNTIME_DIR</varname></term>
163
164 <listitem><para>Path to a user-private user-writable directory
165 that is bound to the user login time on the machine. It is
166 automatically created the first time a user logs in and
167 removed on the user's final logout. If a user logs in twice at
168 the same time, both sessions will see the same
169 <varname>$XDG_RUNTIME_DIR</varname> and the same contents. If
170 a user logs in once, then logs out again, and logs in again,
171 the directory contents will have been lost in between, but
172 applications should not rely on this behavior and must be able
173 to deal with stale files. To store session-private data in
174 this directory, the user should include the value of
175 <varname>$XDG_SESSION_ID</varname> in the filename. This
176 directory shall be used for runtime file system objects such
177 as <constant>AF_UNIX</constant> sockets, FIFOs, PID files and
178 similar. It is guaranteed that this directory is local and
179 offers the greatest possible file system feature set the
180 operating system provides. For further details, see the <ulink
181 url="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG
182 Base Directory Specification</ulink>. <varname>$XDG_RUNTIME_DIR</varname>
183 is not set if the current user is not the original user of the session.</para></listitem>
184 </varlistentry>
185
186 </variablelist>
187
188 <para>The following environment variables are read by the module
189 and may be used by the PAM service to pass metadata to the
190 module:</para>
191
192 <variablelist class='environment-variables'>
193 <varlistentry>
194 <term><varname>$XDG_SESSION_TYPE</varname></term>
195
196 <listitem><para>The session type. This may be used instead of
197 <option>session=</option> on the module parameter line, and is
198 usually preferred.</para></listitem>
199 </varlistentry>
200
201 <varlistentry>
202 <term><varname>$XDG_SESSION_CLASS</varname></term>
203
204 <listitem><para>The session class. This may be used instead of
205 <option>class=</option> on the module parameter line, and is
206 usually preferred.</para></listitem>
207 </varlistentry>
208
209 <varlistentry>
210 <term><varname>$XDG_SESSION_DESKTOP</varname></term>
211
212 <listitem><para>A single, short identifier string for the
213 desktop environment. This may be used to indicate the session
214 desktop used, where this applies and if this information is
215 available. For example: <literal>GNOME</literal>, or
216 <literal>KDE</literal>. It is recommended to use the same
217 identifiers and capitalization as for
218 <varname>$XDG_CURRENT_DESKTOP</varname>, as defined by the
219 <ulink
220 url="http://standards.freedesktop.org/desktop-entry-spec/latest/">Desktop
221 Entry Specification</ulink>. (However, note that
222 <varname>$XDG_SESSION_DESKTOP</varname> only takes a single
223 item, and not a colon-separated list like
224 <varname>$XDG_CURRENT_DESKTOP</varname>.) See
225 <citerefentry><refentrytitle>sd_session_get_desktop</refentrytitle><manvolnum>3</manvolnum></citerefentry>
226 for more details.</para></listitem>
227 </varlistentry>
228
229 <varlistentry>
230 <term><varname>$XDG_SEAT</varname></term>
231
232 <listitem><para>The seat name the session shall be registered
233 for, if any.</para></listitem>
234 </varlistentry>
235
236 <varlistentry>
237 <term><varname>$XDG_VTNR</varname></term>
238
239 <listitem><para>The VT number the session shall be registered
240 for, if any. (Only applies to seats with a VT available, such
241 as <literal>seat0</literal>)</para></listitem>
242 </varlistentry>
243 </variablelist>
244
245 <para>If not set, <command>pam_systemd</command> will determine the
246 values for <varname>$XDG_SEAT</varname> and <varname>$XDG_VTNR</varname>
247 based on the <varname>$DISPLAY</varname> variable.</para>
248 </refsect1>
249
250 <refsect1>
251 <title>Session limits</title>
252
253 <para>PAM modules earlier in the stack, that is those that come before <command>pam_systemd.so</command>,
254 can set session scope limits using the PAM context objects. The data for these objects is provided as NUL-terminated C strings
255 and maps directly to the respective unit resource control directives. Note that these limits apply to individual sessions of the user,
256 they do not apply to all user processes as a combined whole. In particular, the per-user <command>user@.service</command> unit instance,
257 which runs the <command>systemd --user</command> manager process and its children, and is tracked outside of any session, being shared
258 by all the user's sessions, is not covered by these limits.
259 </para>
260
261 <para> See
262 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information about the resources.
263 Also, see <citerefentry><refentrytitle>pam_set_data</refentrytitle><manvolnum>3</manvolnum></citerefentry> for additional information about how to set
264 the context objects.
265 </para>
266
267 <variablelist>
268 <varlistentry>
269 <term><varname>systemd.memory_max</varname></term>
270
271 <listitem><para>Sets unit <varname>MemoryMax=</varname>.</para></listitem>
272 </varlistentry>
273
274 <varlistentry>
275 <term><varname>systemd.tasks_max</varname></term>
276
277 <listitem><para>Sets unit <varname>TasksMax=</varname>.</para></listitem>
278 </varlistentry>
279
280 <varlistentry>
281 <term><varname>systemd.cpu_weight</varname></term>
282
283 <listitem><para>Sets unit <varname>CPUWeight=</varname>.</para></listitem>
284 </varlistentry>
285
286 <varlistentry>
287 <term><varname>systemd.io_weight</varname></term>
288
289 <listitem><para>Sets unit <varname>IOWeight=</varname>.</para></listitem>
290 </varlistentry>
291 </variablelist>
292
293 <para>Example data as can be provided from an another PAM module:
294 <programlisting>
295 pam_set_data(handle, "systemd.memory_max", (void *)"200M", cleanup);
296 pam_set_data(handle, "systemd.tasks_max", (void *)"50", cleanup);
297 pam_set_data(handle, "systemd.cpu_weight", (void *)"100", cleanup);
298 pam_set_data(handle, "systemd.io_weight", (void *)"340", cleanup);
299 </programlisting>
300 </para>
301
302 </refsect1>
303
304 <refsect1>
305 <title>Example</title>
306
307 <programlisting>#%PAM-1.0
308 auth required pam_unix.so
309 auth required pam_nologin.so
310 account required pam_unix.so
311 password required pam_unix.so
312 session required pam_unix.so
313 session required pam_loginuid.so
314 session required pam_systemd.so</programlisting>
315 </refsect1>
316
317 <refsect1>
318 <title>See Also</title>
319 <para>
320 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
321 <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
322 <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
323 <citerefentry><refentrytitle>loginctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
324 <citerefentry project='man-pages'><refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
325 <citerefentry project='man-pages'><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
326 <citerefentry project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
327 <citerefentry project='man-pages'><refentrytitle>pam_loginuid</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
328 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
329 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
330 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
331 </para>
332 </refsect1>
333
334 </refentry>