Debian Codegraph @

upstream/debian-unstable/man8/pam_systemd.8

raw
1 '\" t
2 .TH "PAM_SYSTEMD" "8" "" "systemd 261~rc3" "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 l l
167 l l
168 l l.
169 T{
170 \fBuser\fR
171 T}:T{
172 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\&.
173 T}
174 T{
175 \fBuser\-early\fR
176 T}:T{
177 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\&.)
178 T}
179 T{
180 \fBuser\-light\fR
181 T}:T{
182 Similar to \fBuser\fR, but sessions of this class will not pull in the \[email protected]\fR(5) of the user, and thus possibly have no service manager of the user running\&. (Added in v258\&.)
183 T}
184 T{
185 \fBuser\-early\-light\fR
186 T}:T{
187 Similar to \fBuser\-early\fR, but sessions of this class will not pull in the \[email protected]\fR(5) of the user, and thus possibly have no service manager of the user running\&. (Added in v258\&.)
188 T}
189 T{
190 \fBuser\-incomplete\fR
191 T}:T{
192 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\&.
193 T}
194 T{
195 \fBgreeter\fR
196 T}:T{
197 Similar to \fBuser\fR but for sessions that are spawned by a display manager ephemerally and which prompt the user for login credentials\&.
198 T}
199 T{
200 \fBlock\-screen\fR
201 T}:T{
202 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\&.
203 T}
204 T{
205 \fBbackground\fR
206 T}:T{
207 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\&.
208 T}
209 T{
210 \fBbackground\-light\fR
211 T}:T{
212 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 service manager of the user running\&. (Added in v256\&.)
213 T}
214 T{
215 \fBmanager\fR
216 T}:T{
217 The \[email protected]\fR(5) service of the user is registered under this session class\&. (Added in v256\&.)
218 T}
219 T{
220 \fBmanager\-early\fR
221 T}:T{
222 Similar to \fBmanager\fR, but for the root user\&. Compare with the \fBuser\fR vs\&. \fBuser\-early\fR situation\&. (Added in v256\&.)
223 T}
224 T{
225 \fBnone\fR
226 T}:T{
227 Skips registering this session with logind\&. No session scope will be created, and the user service manager will not be started\&. (Added in v258\&.)
228 T}
229 .TE
230 .sp 1
231 If no session class is specified via either the PAM module option or via the
232 \fI$XDG_SESSION_CLASS\fR
233 environment variable, the class is automatically chosen, depending on various session parameters, such as the session type (if known), whether the session has a TTY or X11 display, and the user disposition\&. Note that various tools allow setting the session class for newly allocated PAM sessions explicitly by means of the
234 \fI$XDG_SESSION_CLASS\fR
235 environment variable\&. For example, classic UNIX cronjobs support environment variable assignments (see
236 \fBcrontab\fR(5)), which may be used to choose between the
237 \fBbackground\fR
238 and
239 \fBbackground\-light\fR
240 session class individually per cronjob, or
241 \fBrun0 \-\-setenv=XDG_SESSION_CLASS=user\-light\fR
242 may be used to choose between
243 \fBuser\fR
244 and
245 \fBuser\-light\fR
246 for invoked privileged sessions\&.
247 .sp
248 Added in version 197\&.
249 .RE
250 .PP
251 \fItype=\fR
252 .RS 4
253 Takes a string argument which sets the session type\&. The
254 \fIXDG_SESSION_TYPE\fR
255 environment variable (see below) takes precedence\&. One of
256 \fBunspecified\fR,
257 \fBtty\fR,
258 \fBx11\fR,
259 \fBwayland\fR,
260 \fBmir\fR, or
261 \fBweb\fR\&. See
262 \fBsd_session_get_type\fR(3)
263 for details about the session type\&.
264 .sp
265 Added in version 209\&.
266 .RE
267 .PP
268 \fIdesktop=\fR
269 .RS 4
270 Takes a single, short identifier string for the desktop environment\&. The
271 \fIXDG_SESSION_DESKTOP\fR
272 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:
273 \fBGNOME\fR, or
274 \fBKDE\fR\&. It is recommended to use the same identifiers and capitalization as for
275 \fI$XDG_CURRENT_DESKTOP\fR, as defined by the
276 \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
277 \fI$XDG_CURRENT_DESKTOP\fR\&.) See
278 \fBsd_session_get_desktop\fR(3)
279 for further details\&.
280 .sp
281 Added in version 240\&.
282 .RE
283 .PP
284 \fIarea=\fR
285 .RS 4
286 Takes a filename as parameter\&. If specified and the user logs into their account the
287 \fI$HOME\fR
288 environment variable will be set to
289 ~/Areas/
290 suffixed by the specified string, but only if that directory exists\&. Moreover, the
291 \fI$XDG_AREA\fR
292 variable will be set to the (unprefixed) parameter\&.
293 .sp
294 This functionality may be used to maintain multiple separate secondary home directories within the primary home directory of the user\&. Typically, the area to log into is specified while logging in, if the account permits that (accounts provided by
295 \fBpam_systemd_home\fR(8)
296 do), but this parameter may be used to define a default if that\*(Aqs not provided\&.
297 .sp
298 Note that this only adjusts
299 \fI$HOME\fR
300 during login, it does not affect the otherwise reported home directory of the user\&. Specifically this means that
301 \fBsshd\fR(8)
302 will continue to look for SSH keys of the user only in the primary home directory of the user, not in any of their areas\&.
303 .sp
304 Note that the default area to log into can also be configured as part of the user account\&. The area specified via
305 \fIarea=\fR
306 overrides the default area configured there\&. Also note that if the area is specified explicitly by the user at login time, it overrides both\&. Also note that setting this parameter to an empty string has the effect of undoing the effect of any default area configured as part of the user record, i\&.e\&. ensuring the user logs into the primary home directory of their account\&.
307 .sp
308 For details on the area concept see
309 \fBpam_systemd_home\fR(8)\&.
310 .sp
311 Added in version 258\&.
312 .RE
313 .PP
314 \fIdefault\-capability\-bounding\-set=\fR, \fIdefault\-capability\-ambient\-set=\fR
315 .RS 4
316 Takes a comma\-separated list of process capabilities (e\&.g\&.
317 \fBCAP_WAKE_ALARM\fR,
318 \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
319 \fBcapabilities\fR(7)
320 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
321 \fBCAP_WAKE_ALARM\fR
322 for regular users if the PAM session is associated with a local seat or if it is invoked for the systemd user service
323 user@\&.service\&. Otherwise, defaults to the empty set\&.
324 .sp
325 Added in version 254\&.
326 .RE
327 .PP
328 \fIdebug\fR[=]
329 .RS 4
330 Takes an optional boolean argument\&. If yes or without the argument, the module will log debugging information as it operates\&.
331 .RE
332 .SH "MODULE TYPES PROVIDED"
333 .PP
334 Only
335 \fBsession\fR
336 is provided\&.
337 .SH "ENVIRONMENT"
338 .PP
339 The following environment variables are initialized by the module and available to the processes of the user\*(Aqs session:
340 .PP
341 \fI$XDG_SESSION_ID\fR
342 .RS 4
343 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
344 /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
345 \fBsd_id128_get_boot\fR(3), for a globally unique identifier\&.
346 .RE
347 .PP
348 \fI$XDG_RUNTIME_DIR\fR
349 .RS 4
350 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
351 \fI$XDG_RUNTIME_DIR\fR
352 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
353 \fI$XDG_SESSION_ID\fR
354 in the filename\&. This directory shall be used for runtime file system objects such as
355 \fBAF_UNIX\fR
356 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
357 \m[blue]\fBXDG Base Directory Specification\fR\m[]\&\s-2\u[3]\d\s+2\&.
358 \fI$XDG_RUNTIME_DIR\fR
359 is not set if the current user is not the original user of the session\&.
360 .RE
361 .PP
362 \fI$TZ\fR, \fI$EMAIL\fR, \fI$LANG\fR
363 .RS 4
364 If a JSON user record is known for the user logging in these variables are initialized from the respective data in the record\&.
365 .sp
366 Added in version 245\&.
367 .RE
368 .PP
369 \fI$SHELL_PROMPT_PREFIX\fR, \fI$SHELL_PROMPT_SUFFIX\fR, \fI$SHELL_WELCOME\fR
370 .RS 4
371 These environment variables are initialized from the service credentials
372 "shell\&.prompt\&.prefix",
373 "shell\&.prompt\&.suffix"
374 and
375 "shell\&.welcome"
376 if set\&. They are passed to the invoked session processes, where they are imported into any shell prompt (specifically
377 \fI$SHELL_PROMPT_PREFIX\fR
378 is added as prefix to
379 \fI$PS1\fR, and
380 \fI$SHELL_PROMPT_SUFFIX\fR
381 as suffix) or printed on screen when a shell first initializes\&.
382 .sp
383 Added in version 257\&.
384 .RE
385 .PP
386 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\&.
387 .PP
388 \fI$XDG_SESSION_TYPE\fR
389 .RS 4
390 The session type\&. This may be used instead of
391 \fItype=\fR
392 on the module parameter line, and is usually preferred\&.
393 .sp
394 Added in version 209\&.
395 .RE
396 .PP
397 \fI$XDG_SESSION_CLASS\fR
398 .RS 4
399 The session class\&. This may be used instead of
400 \fIclass=\fR
401 on the module parameter line, and is usually preferred\&.
402 .sp
403 Added in version 209\&.
404 .RE
405 .PP
406 \fI$XDG_SESSION_DESKTOP\fR
407 .RS 4
408 The desktop identifier\&. This may be used instead of
409 \fIdesktop=\fR
410 on the module parameter line, and is usually preferred\&.
411 .sp
412 Added in version 209\&.
413 .RE
414 .PP
415 \fI$XDG_SEAT\fR
416 .RS 4
417 The seat name the session shall be registered for, if any\&.
418 .sp
419 Added in version 209\&.
420 .RE
421 .PP
422 \fI$XDG_VTNR\fR
423 .RS 4
424 The VT number the session shall be registered for, if any\&. (Only applies to seats with a VT available, such as
425 "seat0")
426 .sp
427 Added in version 209\&.
428 .RE
429 .PP
430 \fI$XDG_AREA\fR
431 .RS 4
432 If an area (secondary home directories of the user, within the primary home directory) to log into has been selected this variable is set to the area name (without any path prefix)\&. It is otherwise unset\&. For details about areas, see above\&.
433 .sp
434 Added in version 258\&.
435 .RE
436 .PP
437 \fI$XDG_SESSION_EXTRA_DEVICE_ACCESS\fR
438 .RS 4
439 The set of additional hardware devices that the session shall be granted access to\&. For every
440 "\fIID\fR"
441 in the list, the session is granted access to all devices tagged with
442 "xaccess\-\fIID\fR"
443 in udev\&.
444 .sp
445 Added in version 260\&.
446 .RE
447 .PP
448 If not set,
449 \fBpam_systemd\fR
450 will initialize
451 \fI$XDG_SEAT\fR
452 and
453 \fI$XDG_VTNR\fR
454 based on the
455 \fI$DISPLAY\fR
456 variable (if the latter is set)\&.
457 .SH "SESSION LIMITS"
458 .PP
459 PAM modules earlier in the stack, that is those that come before
460 \fBpam_systemd\&.so\fR, can set session scope limits using the PAM context objects\&. The data for these objects is provided as
461 \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
462 \fBuser@\&.service\fR
463 unit instance, which runs the
464 \fBsystemd \-\-user\fR
465 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\&.
466 .PP
467 See
468 \fBsystemd.resource-control\fR(5)
469 for more information about the resources\&. Also, see
470 \fBpam_set_data\fR(3)
471 for additional information about how to set the context objects\&.
472 .PP
473 \fIsystemd\&.memory_max=\fR
474 .RS 4
475 Sets unit
476 \fIMemoryMax=\fR\&.
477 .sp
478 Added in version 239\&.
479 .RE
480 .PP
481 \fIsystemd\&.tasks_max=\fR
482 .RS 4
483 Sets unit
484 \fITasksMax=\fR\&.
485 .sp
486 Added in version 239\&.
487 .RE
488 .PP
489 \fIsystemd\&.cpu_weight=\fR
490 .RS 4
491 Sets unit
492 \fICPUWeight=\fR\&.
493 .sp
494 Added in version 239\&.
495 .RE
496 .PP
497 \fIsystemd\&.io_weight=\fR
498 .RS 4
499 Sets unit
500 \fIIOWeight=\fR\&.
501 .sp
502 Added in version 239\&.
503 .RE
504 .PP
505 \fIsystemd\&.runtime_max_sec=\fR
506 .RS 4
507 Sets unit
508 \fIRuntimeMaxSec=\fR\&.
509 .sp
510 Added in version 244\&.
511 .RE
512 .PP
513 Example data as can be provided from an another PAM module:
514 .sp
515 .if n \{\
516 .RS 4
517 .\}
518 .nf
519 pam_set_data(handle, "systemd\&.memory_max", (void *)"200M", cleanup);
520 pam_set_data(handle, "systemd\&.tasks_max", (void *)"50", cleanup);
521 pam_set_data(handle, "systemd\&.cpu_weight", (void *)"100", cleanup);
522 pam_set_data(handle, "systemd\&.io_weight", (void *)"340", cleanup);
523 pam_set_data(handle, "systemd\&.runtime_max_sec", (void *)"3600", cleanup);
524 .fi
525 .if n \{\
526 .RE
527 .\}
528 .sp
529 .SH "EXAMPLE"
530 .PP
531 Here\*(Aqs an example PAM configuration fragment that allows users sessions to be managed by
532 systemd\-logind\&.service:
533 .sp
534 .if n \{\
535 .RS 4
536 .\}
537 .nf
538 #%PAM\-1\&.0
539 \-auth [success=done authtok_err=bad perm_denied=bad maxtries=bad default=ignore] pam_systemd_home\&.so
540 auth sufficient pam_unix\&.so
541 auth required pam_deny\&.so
542
543 account required pam_nologin\&.so
544 \-account [success=done authtok_expired=bad new_authtok_reqd=bad maxtries=bad acct_expired=bad default=ignore] pam_systemd_home\&.so
545 account required pam_unix\&.so
546
547 \-password sufficient pam_systemd_home\&.so
548 password sufficient pam_unix\&.so sha512 shadow try_first_pass
549 password required pam_deny\&.so
550
551 \-session optional pam_keyinit\&.so revoke
552 \-session optional pam_loginuid\&.so
553 \-session optional pam_systemd_home\&.so
554 \fB\-session optional pam_systemd\&.so\fR
555 session required pam_unix\&.so
556 .fi
557 .if n \{\
558 .RE
559 .\}
560 .SH "SEE ALSO"
561 .PP
562 \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)
563 .SH "NOTES"
564 .IP " 1." 4
565 JSON User Records
566 .RS 4
567 \%https://systemd.io/USER_RECORD
568 .RE
569 .IP " 2." 4
570 Desktop Entry Specification
571 .RS 4
572 \%https://standards.freedesktop.org/desktop-entry-spec/latest/
573 .RE
574 .IP " 3." 4
575 XDG Base Directory Specification
576 .RS 4
577 \%https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
578 .RE