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