Debian Codegraph @

upstream/debian-trixie/man8/pam_systemd.8

raw
1 '\" t
2 .TH "PAM_SYSTEMD" "8" "" "systemd 257.13" "pam_systemd"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 pam_systemd \- Register user sessions in the systemd login manager
24 .SH "SYNOPSIS"
25 .PP
26 pam_systemd\&.so
27 .SH "DESCRIPTION"
28 .PP
29 \fBpam_systemd\fR
30 registers user sessions with the systemd login manager
31 \fBsystemd-logind.service\fR(8), and hence the systemd control group hierarchy\&.
32 .PP
33 The module also applies various resource management and runtime parameters to the new session, as configured in the
34 \m[blue]\fBJSON User Records\fR\m[]\&\s-2\u[1]\d\s+2
35 of the user, when one is defined\&.
36 .PP
37 On login, this module \(em in conjunction with
38 systemd\-logind\&.service
39 \(em ensures the following:
40 .sp
41 .RS 4
42 .ie n \{\
43 \h'-04' 1.\h'+01'\c
44 .\}
45 .el \{\
46 .sp -1
47 .IP " 1." 4.2
48 .\}
49 If it does not exist yet, the user runtime directory
50 /run/user/$UID
51 is either created or mounted as new
52 "tmpfs"
53 file system with quota applied, and its ownership changed to the user that is logging in\&.
54 .RE
55 .sp
56 .RS 4
57 .ie n \{\
58 \h'-04' 2.\h'+01'\c
59 .\}
60 .el \{\
61 .sp -1
62 .IP " 2." 4.2
63 .\}
64 The
65 \fI$XDG_SESSION_ID\fR
66 environment variable is initialized\&. If auditing is available and
67 \fBpam_loginuid\&.so\fR
68 was run before this module (which is highly recommended), the variable is initialized from the auditing session id (/proc/self/sessionid)\&. Otherwise, an independent session counter is used\&.
69 .RE
70 .sp
71 .RS 4
72 .ie n \{\
73 \h'-04' 3.\h'+01'\c
74 .\}
75 .el \{\
76 .sp -1
77 .IP " 3." 4.2
78 .\}
79 A new systemd scope unit is created for the session\&. If this is the first concurrent session of the user, an implicit per\-user slice unit below
80 user\&.slice
81 is automatically created and the scope placed into it\&. An instance of the system service
82 user@\&.service, which runs the systemd user manager instance, is started\&.
83 .RE
84 .sp
85 .RS 4
86 .ie n \{\
87 \h'-04' 4.\h'+01'\c
88 .\}
89 .el \{\
90 .sp -1
91 .IP " 4." 4.2
92 .\}
93 The
94 "$TZ",
95 "$EMAIL"
96 and
97 "$LANG"
98 environment variables are configured for the user, based on the respective data from the user\*(Aqs JSON record (if it is defined)\&. Moreover, any environment variables explicitly configured in the user record are imported, and the umask, nice level, and resource limits initialized\&.
99 .RE
100 .PP
101 On logout, this module ensures the following:
102 .sp
103 .RS 4
104 .ie n \{\
105 \h'-04' 1.\h'+01'\c
106 .\}
107 .el \{\
108 .sp -1
109 .IP " 1." 4.2
110 .\}
111 If enabled in
112 \fBlogind.conf\fR(5)
113 (\fIKillUserProcesses=\fR), all processes of the session are terminated\&. If the last concurrent session of a user ends, the user\*(Aqs systemd instance will be terminated too, and so will the user\*(Aqs slice unit\&.
114 .RE
115 .sp
116 .RS 4
117 .ie n \{\
118 \h'-04' 2.\h'+01'\c
119 .\}
120 .el \{\
121 .sp -1
122 .IP " 2." 4.2
123 .\}
124 If the last concurrent session of a user ends, the user runtime directory
125 /run/user/$UID
126 and all its contents are removed, too\&.
127 .RE
128 .PP
129 If the system was not booted up with systemd as init system, this module does nothing and immediately returns
130 \fBPAM_SUCCESS\fR\&.
131 .SH "OPTIONS"
132 .PP
133 The following options are understood:
134 .PP
135 \fIclass=\fR
136 .RS 4
137 Takes a string argument which sets the session class\&. The
138 \fIXDG_SESSION_CLASS\fR
139 environment variable (see below) takes precedence\&. See
140 \fBsd_session_get_class\fR(3)
141 for a way to query the class of a session\&. The following session classes are defined:
142 .sp
143 .it 1 an-trap
144 .nr an-no-space-flag 1
145 .nr an-break-flag 1
146 .br
147 .B Table\ \&1.\ \&Session Classes
148 .TS
149 allbox tab(:);
150 lB lB.
151 T{
152 Name
153 T}:T{
154 Explanation
155 T}
156 .T&
157 l l
158 l l
159 l l
160 l l
161 l l
162 l l
163 l l
164 l l
165 l l.
166 T{
167 \fBuser\fR
168 T}:T{
169 A regular interactive user session\&. This is the default class for sessions for which a TTY or X display is known at session registration time\&.
170 T}
171 T{
172 \fBuser\-early\fR
173 T}:T{
174 Similar to \fBuser\fR but sessions of this class are not ordered after \fBsystemd-user-sessions.service\fR(8), i\&.e\&. may be started before regular sessions are allowed to be established\&. This session class is the default for sessions of the root user that would otherwise qualify for the \fBuser\fR class, see above\&. (Added in v256\&.)
175 T}
176 T{
177 \fBuser\-incomplete\fR
178 T}:T{
179 Similar to \fBuser\fR but for sessions which are not fully set up yet, i\&.e\&. have no home directory mounted or similar\&. This is used by \fBsystemd-homed.service\fR(8) to allow users to log in via \fBssh\fR(1) before their home directory is mounted, delaying the mount until the user provided the unlock password\&. Sessions of this class are upgraded to the regular \fBuser\fR class once the home directory is activated\&.
180 T}
181 T{
182 \fBgreeter\fR
183 T}:T{
184 Similar to \fBuser\fR but for sessions that are spawned by a display manager ephemerally and which prompt the user for login credentials\&.
185 T}
186 T{
187 \fBlock\-screen\fR
188 T}:T{
189 Similar to \fBuser\fR but for sessions that are spawned by a display manager ephemerally and which show a lock screen that can be used to unlock locked user accounts or sessions\&.
190 T}
191 T{
192 \fBbackground\fR
193 T}:T{
194 Used for background sessions, such as those invoked by \fBcron\fR(8) and similar tools\&. This is the default class for sessions for which no TTY or X display is known at session registration time\&.
195 T}
196 T{
197 \fBbackground\-light\fR
198 T}:T{
199 Similar to \fBbackground\fR, but sessions of this class will not pull in the \[email protected]\fR(5) of the user, and thus possibly have no services of the user running\&. (Added in v256\&.)
200 T}
201 T{
202 \fBmanager\fR
203 T}:T{
204 The \[email protected]\fR(5) service of the user is registered under this session class\&. (Added in v256\&.)
205 T}
206 T{
207 \fBmanager\-early\fR
208 T}:T{
209 Similar to \fBmanager\fR, but for the root user\&. Compare with the \fBuser\fR vs\&. \fBuser\-early\fR situation\&. (Added in v256\&.)
210 T}
211 .TE
212 .sp 1
213 Added in version 197\&.
214 .RE
215 .PP
216 \fItype=\fR
217 .RS 4
218 Takes a string argument which sets the session type\&. The
219 \fIXDG_SESSION_TYPE\fR
220 environment variable (see below) takes precedence\&. One of
221 \fBunspecified\fR,
222 \fBtty\fR,
223 \fBx11\fR,
224 \fBwayland\fR,
225 \fBmir\fR, or
226 \fBweb\fR\&. See
227 \fBsd_session_get_type\fR(3)
228 for details about the session type\&.
229 .sp
230 Added in version 209\&.
231 .RE
232 .PP
233 \fIdesktop=\fR
234 .RS 4
235 Takes a single, short identifier string for the desktop environment\&. The
236 \fIXDG_SESSION_DESKTOP\fR
237 environment variable (see below) takes precedence\&. This may be used to indicate the session desktop used, where this applies and if this information is available\&. For example:
238 \fBGNOME\fR, or
239 \fBKDE\fR\&. It is recommended to use the same identifiers and capitalization as for
240 \fI$XDG_CURRENT_DESKTOP\fR, as defined by the
241 \m[blue]\fBDesktop Entry Specification\fR\m[]\&\s-2\u[2]\d\s+2\&. (However, note that the option only takes a single item, and not a colon\-separated list like
242 \fI$XDG_CURRENT_DESKTOP\fR\&.) See
243 \fBsd_session_get_desktop\fR(3)
244 for further details\&.
245 .sp
246 Added in version 240\&.
247 .RE
248 .PP
249 \fIdefault\-capability\-bounding\-set=\fR, \fIdefault\-capability\-ambient\-set=\fR
250 .RS 4
251 Takes a comma\-separated list of process capabilities (e\&.g\&.
252 \fBCAP_WAKE_ALARM\fR,
253 \fBCAP_BLOCK_SUSPEND\fR, \&...) to set for the invoked session\*(Aqs processes, if the user record does not encode appropriate sets of capabilities directly\&. See
254 \fBcapabilities\fR(7)
255 for details on the capabilities concept\&. If not specified, the default bounding set is left as is (i\&.e\&. usually contains the full set of capabilities)\&. The default ambient set is set to
256 \fBCAP_WAKE_ALARM\fR
257 for regular users if the PAM session is associated with a local seat or if it is invoked for the systemd user service
258 user@\&.service\&. Otherwise, defaults to the empty set\&.
259 .sp
260 Added in version 254\&.
261 .RE
262 .PP
263 \fIdebug\fR[=]
264 .RS 4
265 Takes an optional boolean argument\&. If yes or without the argument, the module will log debugging information as it operates\&.
266 .RE
267 .SH "MODULE TYPES PROVIDED"
268 .PP
269 Only
270 \fBsession\fR
271 is provided\&.
272 .SH "ENVIRONMENT"
273 .PP
274 The following environment variables are initialized by the module and available to the processes of the user\*(Aqs session:
275 .PP
276 \fI$XDG_SESSION_ID\fR
277 .RS 4
278 A short session identifier, suitable to be used in filenames\&. The string itself should be considered opaque, although often it is just the audit session ID as reported by
279 /proc/self/sessionid\&. Each ID will be assigned only once during machine uptime\&. It may hence be used to uniquely label files or other resources of this session\&. Combine this ID with the boot identifier, as returned by
280 \fBsd_id128_get_boot\fR(3), for a globally unique identifier\&.
281 .RE
282 .PP
283 \fI$XDG_RUNTIME_DIR\fR
284 .RS 4
285 Path to a user\-private user\-writable directory that is bound to the user login time on the machine\&. It is automatically created the first time a user logs in and removed on the user\*(Aqs final logout\&. If a user logs in twice at the same time, both sessions will see the same
286 \fI$XDG_RUNTIME_DIR\fR
287 and the same contents\&. If a user logs in once, then logs out again, and logs in again, the directory contents will have been lost in between, but applications should not rely on this behavior and must be able to deal with stale files\&. To store session\-private data in this directory, the user should include the value of
288 \fI$XDG_SESSION_ID\fR
289 in the filename\&. This directory shall be used for runtime file system objects such as
290 \fBAF_UNIX\fR
291 sockets, FIFOs, PID files and similar\&. It is guaranteed that this directory is local and offers the greatest possible file system feature set the operating system provides\&. For further details, see the
292 \m[blue]\fBXDG Base Directory Specification\fR\m[]\&\s-2\u[3]\d\s+2\&.
293 \fI$XDG_RUNTIME_DIR\fR
294 is not set if the current user is not the original user of the session\&.
295 .RE
296 .PP
297 \fI$TZ\fR, \fI$EMAIL\fR, \fI$LANG\fR
298 .RS 4
299 If a JSON user record is known for the user logging in these variables are initialized from the respective data in the record\&.
300 .sp
301 Added in version 245\&.
302 .RE
303 .PP
304 \fI$SHELL_PROMPT_PREFIX\fR, \fI$SHELL_PROMPT_SUFFIX\fR, \fI$SHELL_WELCOME\fR
305 .RS 4
306 These environment variables are initialized from the service credentials
307 "shell\&.prompt\&.prefix",
308 "shell\&.prompt\&.suffix"
309 and
310 "shell\&.welcome"
311 if set\&. They are passed to the invoked session processes, where they are imported into any shell prompt (specifically
312 \fI$SHELL_PROMPT_PREFIX\fR
313 is added as prefix to
314 \fI$PS1\fR, and
315 \fI$SHELL_PROMPT_SUFFIX\fR
316 as suffix) or printed on screen when a shell first initializes\&.
317 .sp
318 Added in version 257\&.
319 .RE
320 .PP
321 The following environment variables are read by the module and may be used by the PAM service to pass metadata to the module\&. If these variables are not set when the PAM module is invoked but can be determined otherwise they are set by the module, so that these variables are initialized for the session and applications if known at all\&.
322 .PP
323 \fI$XDG_SESSION_TYPE\fR
324 .RS 4
325 The session type\&. This may be used instead of
326 \fItype=\fR
327 on the module parameter line, and is usually preferred\&.
328 .sp
329 Added in version 209\&.
330 .RE
331 .PP
332 \fI$XDG_SESSION_CLASS\fR
333 .RS 4
334 The session class\&. This may be used instead of
335 \fIclass=\fR
336 on the module parameter line, and is usually preferred\&.
337 .sp
338 Added in version 209\&.
339 .RE
340 .PP
341 \fI$XDG_SESSION_DESKTOP\fR
342 .RS 4
343 The desktop identifier\&. This may be used instead of
344 \fIdesktop=\fR
345 on the module parameter line, and is usually preferred\&.
346 .sp
347 Added in version 209\&.
348 .RE
349 .PP
350 \fI$XDG_SEAT\fR
351 .RS 4
352 The seat name the session shall be registered for, if any\&.
353 .sp
354 Added in version 209\&.
355 .RE
356 .PP
357 \fI$XDG_VTNR\fR
358 .RS 4
359 The VT number the session shall be registered for, if any\&. (Only applies to seats with a VT available, such as
360 "seat0")
361 .sp
362 Added in version 209\&.
363 .RE
364 .PP
365 If not set,
366 \fBpam_systemd\fR
367 will initialize
368 \fI$XDG_SEAT\fR
369 and
370 \fI$XDG_VTNR\fR
371 based on the
372 \fI$DISPLAY\fR
373 variable (if the latter is set)\&.
374 .SH "SESSION LIMITS"
375 .PP
376 PAM modules earlier in the stack, that is those that come before
377 \fBpam_systemd\&.so\fR, can set session scope limits using the PAM context objects\&. The data for these objects is provided as
378 \fBNUL\fR\-terminated C strings and maps directly to the respective unit resource control directives\&. Note that these limits apply to individual sessions of the user, they do not apply to all user processes as a combined whole\&. In particular, the per\-user
379 \fBuser@\&.service\fR
380 unit instance, which runs the
381 \fBsystemd \-\-user\fR
382 manager process and its children, and is tracked outside of any session, being shared by all the user\*(Aqs sessions, is not covered by these limits\&.
383 .PP
384 See
385 \fBsystemd.resource-control\fR(5)
386 for more information about the resources\&. Also, see
387 \fBpam_set_data\fR(3)
388 for additional information about how to set the context objects\&.
389 .PP
390 \fIsystemd\&.memory_max=\fR
391 .RS 4
392 Sets unit
393 \fIMemoryMax=\fR\&.
394 .sp
395 Added in version 239\&.
396 .RE
397 .PP
398 \fIsystemd\&.tasks_max=\fR
399 .RS 4
400 Sets unit
401 \fITasksMax=\fR\&.
402 .sp
403 Added in version 239\&.
404 .RE
405 .PP
406 \fIsystemd\&.cpu_weight=\fR
407 .RS 4
408 Sets unit
409 \fICPUWeight=\fR\&.
410 .sp
411 Added in version 239\&.
412 .RE
413 .PP
414 \fIsystemd\&.io_weight=\fR
415 .RS 4
416 Sets unit
417 \fIIOWeight=\fR\&.
418 .sp
419 Added in version 239\&.
420 .RE
421 .PP
422 \fIsystemd\&.runtime_max_sec=\fR
423 .RS 4
424 Sets unit
425 \fIRuntimeMaxSec=\fR\&.
426 .sp
427 Added in version 244\&.
428 .RE
429 .PP
430 Example data as can be provided from an another PAM module:
431 .sp
432 .if n \{\
433 .RS 4
434 .\}
435 .nf
436 pam_set_data(handle, "systemd\&.memory_max", (void *)"200M", cleanup);
437 pam_set_data(handle, "systemd\&.tasks_max", (void *)"50", cleanup);
438 pam_set_data(handle, "systemd\&.cpu_weight", (void *)"100", cleanup);
439 pam_set_data(handle, "systemd\&.io_weight", (void *)"340", cleanup);
440 pam_set_data(handle, "systemd\&.runtime_max_sec", (void *)"3600", cleanup);
441 .fi
442 .if n \{\
443 .RE
444 .\}
445 .sp
446 .SH "EXAMPLE"
447 .PP
448 Here\*(Aqs an example PAM configuration fragment that allows users sessions to be managed by
449 systemd\-logind\&.service:
450 .sp
451 .if n \{\
452 .RS 4
453 .\}
454 .nf
455 #%PAM\-1\&.0
456 auth sufficient pam_unix\&.so
457 \-auth sufficient pam_systemd_home\&.so
458 auth required pam_deny\&.so
459
460 account required pam_nologin\&.so
461 \-account sufficient pam_systemd_home\&.so
462 account sufficient pam_unix\&.so
463 account required pam_permit\&.so
464
465 \-password sufficient pam_systemd_home\&.so
466 password sufficient pam_unix\&.so sha512 shadow try_first_pass
467 password required pam_deny\&.so
468
469 \-session optional pam_keyinit\&.so revoke
470 \-session optional pam_loginuid\&.so
471 \-session optional pam_systemd_home\&.so
472 \fB\-session optional pam_systemd\&.so\fR
473 session required pam_unix\&.so
474 .fi
475 .if n \{\
476 .RE
477 .\}
478 .SH "SEE ALSO"
479 .PP
480 \fBsystemd\fR(1), \fBsystemd-user-sessions.service\fR(8), \[email protected]\fR(5), \fBsystemd-logind.service\fR(8), \fBlogind.conf\fR(5), \fBloginctl\fR(1), \fBpam_systemd_home\fR(8), \fBpam.conf\fR(5), \fBpam.d\fR(5), \fBpam\fR(8), \fBpam_loginuid\fR(8), \fBsystemd.scope\fR(5), \fBsystemd.slice\fR(5), \fBsystemd.service\fR(5)
481 .SH "NOTES"
482 .IP " 1." 4
483 JSON User Records
484 .RS 4
485 \%https://systemd.io/USER_RECORD
486 .RE
487 .IP " 2." 4
488 Desktop Entry Specification
489 .RS 4
490 \%https://standards.freedesktop.org/desktop-entry-spec/latest/
491 .RE
492 .IP " 3." 4
493 XDG Base Directory Specification
494 .RS 4
495 \%https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
496 .RE