Debian Codegraph @

upstream/mageia-cauldron/man8/pam_systemd.8

raw
1 '\" t
2 .TH "PAM_SYSTEMD" "8" "" "systemd 258.7" "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 Added in version 197\&.
232 .RE
233 .PP
234 \fItype=\fR
235 .RS 4
236 Takes a string argument which sets the session type\&. The
237 \fIXDG_SESSION_TYPE\fR
238 environment variable (see below) takes precedence\&. One of
239 \fBunspecified\fR,
240 \fBtty\fR,
241 \fBx11\fR,
242 \fBwayland\fR,
243 \fBmir\fR, or
244 \fBweb\fR\&. See
245 \fBsd_session_get_type\fR(3)
246 for details about the session type\&.
247 .sp
248 Added in version 209\&.
249 .RE
250 .PP
251 \fIdesktop=\fR
252 .RS 4
253 Takes a single, short identifier string for the desktop environment\&. The
254 \fIXDG_SESSION_DESKTOP\fR
255 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:
256 \fBGNOME\fR, or
257 \fBKDE\fR\&. It is recommended to use the same identifiers and capitalization as for
258 \fI$XDG_CURRENT_DESKTOP\fR, as defined by the
259 \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
260 \fI$XDG_CURRENT_DESKTOP\fR\&.) See
261 \fBsd_session_get_desktop\fR(3)
262 for further details\&.
263 .sp
264 Added in version 240\&.
265 .RE
266 .PP
267 \fIarea=\fR
268 .RS 4
269 Takes a filename as parameter\&. If specified and the user logs into their account the
270 \fI$HOME\fR
271 environment variable will be set to
272 ~/Areas/
273 suffixed by the specified string, but only if that directory exists\&. Moreover, the
274 \fI$XDG_AREA\fR
275 variable will be set to the (unprefixed) parameter\&.
276 .sp
277 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
278 \fBpam_systemd_home\fR(8)
279 do), but this parameter may be used to define a default if that\*(Aqs not provided\&.
280 .sp
281 Note that this only adjusts
282 \fI$HOME\fR
283 during login, it does not affect the otherwise reported home directory of the user\&. Specifically this means that
284 \fBsshd\fR(8)
285 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\&.
286 .sp
287 Note that the default area to log into can also be configured as part of the user account\&. The area specified via
288 \fIarea=\fR
289 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\&.
290 .sp
291 For details on the area concept see
292 \fBpam_systemd_home\fR(8)\&.
293 .sp
294 Added in version 258\&.
295 .RE
296 .PP
297 \fIdefault\-capability\-bounding\-set=\fR, \fIdefault\-capability\-ambient\-set=\fR
298 .RS 4
299 Takes a comma\-separated list of process capabilities (e\&.g\&.
300 \fBCAP_WAKE_ALARM\fR,
301 \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
302 \fBcapabilities\fR(7)
303 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
304 \fBCAP_WAKE_ALARM\fR
305 for regular users if the PAM session is associated with a local seat or if it is invoked for the systemd user service
306 user@\&.service\&. Otherwise, defaults to the empty set\&.
307 .sp
308 Added in version 254\&.
309 .RE
310 .PP
311 \fIdebug\fR[=]
312 .RS 4
313 Takes an optional boolean argument\&. If yes or without the argument, the module will log debugging information as it operates\&.
314 .RE
315 .SH "MODULE TYPES PROVIDED"
316 .PP
317 Only
318 \fBsession\fR
319 is provided\&.
320 .SH "ENVIRONMENT"
321 .PP
322 The following environment variables are initialized by the module and available to the processes of the user\*(Aqs session:
323 .PP
324 \fI$XDG_SESSION_ID\fR
325 .RS 4
326 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
327 /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
328 \fBsd_id128_get_boot\fR(3), for a globally unique identifier\&.
329 .RE
330 .PP
331 \fI$XDG_RUNTIME_DIR\fR
332 .RS 4
333 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
334 \fI$XDG_RUNTIME_DIR\fR
335 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
336 \fI$XDG_SESSION_ID\fR
337 in the filename\&. This directory shall be used for runtime file system objects such as
338 \fBAF_UNIX\fR
339 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
340 \m[blue]\fBXDG Base Directory Specification\fR\m[]\&\s-2\u[3]\d\s+2\&.
341 \fI$XDG_RUNTIME_DIR\fR
342 is not set if the current user is not the original user of the session\&.
343 .RE
344 .PP
345 \fI$TZ\fR, \fI$EMAIL\fR, \fI$LANG\fR
346 .RS 4
347 If a JSON user record is known for the user logging in these variables are initialized from the respective data in the record\&.
348 .sp
349 Added in version 245\&.
350 .RE
351 .PP
352 \fI$SHELL_PROMPT_PREFIX\fR, \fI$SHELL_PROMPT_SUFFIX\fR, \fI$SHELL_WELCOME\fR
353 .RS 4
354 These environment variables are initialized from the service credentials
355 "shell\&.prompt\&.prefix",
356 "shell\&.prompt\&.suffix"
357 and
358 "shell\&.welcome"
359 if set\&. They are passed to the invoked session processes, where they are imported into any shell prompt (specifically
360 \fI$SHELL_PROMPT_PREFIX\fR
361 is added as prefix to
362 \fI$PS1\fR, and
363 \fI$SHELL_PROMPT_SUFFIX\fR
364 as suffix) or printed on screen when a shell first initializes\&.
365 .sp
366 Added in version 257\&.
367 .RE
368 .PP
369 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\&.
370 .PP
371 \fI$XDG_SESSION_TYPE\fR
372 .RS 4
373 The session type\&. This may be used instead of
374 \fItype=\fR
375 on the module parameter line, and is usually preferred\&.
376 .sp
377 Added in version 209\&.
378 .RE
379 .PP
380 \fI$XDG_SESSION_CLASS\fR
381 .RS 4
382 The session class\&. This may be used instead of
383 \fIclass=\fR
384 on the module parameter line, and is usually preferred\&.
385 .sp
386 Added in version 209\&.
387 .RE
388 .PP
389 \fI$XDG_SESSION_DESKTOP\fR
390 .RS 4
391 The desktop identifier\&. This may be used instead of
392 \fIdesktop=\fR
393 on the module parameter line, and is usually preferred\&.
394 .sp
395 Added in version 209\&.
396 .RE
397 .PP
398 \fI$XDG_SEAT\fR
399 .RS 4
400 The seat name the session shall be registered for, if any\&.
401 .sp
402 Added in version 209\&.
403 .RE
404 .PP
405 \fI$XDG_VTNR\fR
406 .RS 4
407 The VT number the session shall be registered for, if any\&. (Only applies to seats with a VT available, such as
408 "seat0")
409 .sp
410 Added in version 209\&.
411 .RE
412 .PP
413 \fI$XDG_AREA\fR
414 .RS 4
415 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\&.
416 .sp
417 Added in version 258\&.
418 .RE
419 .PP
420 If not set,
421 \fBpam_systemd\fR
422 will initialize
423 \fI$XDG_SEAT\fR
424 and
425 \fI$XDG_VTNR\fR
426 based on the
427 \fI$DISPLAY\fR
428 variable (if the latter is set)\&.
429 .SH "SESSION LIMITS"
430 .PP
431 PAM modules earlier in the stack, that is those that come before
432 \fBpam_systemd\&.so\fR, can set session scope limits using the PAM context objects\&. The data for these objects is provided as
433 \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
434 \fBuser@\&.service\fR
435 unit instance, which runs the
436 \fBsystemd \-\-user\fR
437 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\&.
438 .PP
439 See
440 \fBsystemd.resource-control\fR(5)
441 for more information about the resources\&. Also, see
442 \fBpam_set_data\fR(3)
443 for additional information about how to set the context objects\&.
444 .PP
445 \fIsystemd\&.memory_max=\fR
446 .RS 4
447 Sets unit
448 \fIMemoryMax=\fR\&.
449 .sp
450 Added in version 239\&.
451 .RE
452 .PP
453 \fIsystemd\&.tasks_max=\fR
454 .RS 4
455 Sets unit
456 \fITasksMax=\fR\&.
457 .sp
458 Added in version 239\&.
459 .RE
460 .PP
461 \fIsystemd\&.cpu_weight=\fR
462 .RS 4
463 Sets unit
464 \fICPUWeight=\fR\&.
465 .sp
466 Added in version 239\&.
467 .RE
468 .PP
469 \fIsystemd\&.io_weight=\fR
470 .RS 4
471 Sets unit
472 \fIIOWeight=\fR\&.
473 .sp
474 Added in version 239\&.
475 .RE
476 .PP
477 \fIsystemd\&.runtime_max_sec=\fR
478 .RS 4
479 Sets unit
480 \fIRuntimeMaxSec=\fR\&.
481 .sp
482 Added in version 244\&.
483 .RE
484 .PP
485 Example data as can be provided from an another PAM module:
486 .sp
487 .if n \{\
488 .RS 4
489 .\}
490 .nf
491 pam_set_data(handle, "systemd\&.memory_max", (void *)"200M", cleanup);
492 pam_set_data(handle, "systemd\&.tasks_max", (void *)"50", cleanup);
493 pam_set_data(handle, "systemd\&.cpu_weight", (void *)"100", cleanup);
494 pam_set_data(handle, "systemd\&.io_weight", (void *)"340", cleanup);
495 pam_set_data(handle, "systemd\&.runtime_max_sec", (void *)"3600", cleanup);
496 .fi
497 .if n \{\
498 .RE
499 .\}
500 .sp
501 .SH "EXAMPLE"
502 .PP
503 Here\*(Aqs an example PAM configuration fragment that allows users sessions to be managed by
504 systemd\-logind\&.service:
505 .sp
506 .if n \{\
507 .RS 4
508 .\}
509 .nf
510 #%PAM\-1\&.0
511 \-auth [success=done authtok_err=bad perm_denied=bad maxtries=bad default=ignore] pam_systemd_home\&.so
512 auth sufficient pam_unix\&.so
513 auth required pam_deny\&.so
514
515 account required pam_nologin\&.so
516 \-account [success=done authtok_expired=bad new_authtok_reqd=bad maxtries=bad acct_expired=bad default=ignore] pam_systemd_home\&.so
517 account required pam_unix\&.so
518
519 \-password sufficient pam_systemd_home\&.so
520 password sufficient pam_unix\&.so sha512 shadow try_first_pass
521 password required pam_deny\&.so
522
523 \-session optional pam_keyinit\&.so revoke
524 \-session optional pam_loginuid\&.so
525 \-session optional pam_systemd_home\&.so
526 \fB\-session optional pam_systemd\&.so\fR
527 session required pam_unix\&.so
528 .fi
529 .if n \{\
530 .RE
531 .\}
532 .SH "SEE ALSO"
533 .PP
534 \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)
535 .SH "NOTES"
536 .IP " 1." 4
537 JSON User Records
538 .RS 4
539 \%https://systemd.io/USER_RECORD
540 .RE
541 .IP " 2." 4
542 Desktop Entry Specification
543 .RS 4
544 \%https://standards.freedesktop.org/desktop-entry-spec/latest/
545 .RE
546 .IP " 3." 4
547 XDG Base Directory Specification
548 .RS 4
549 \%https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
550 .RE