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