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