Debian Codegraph @

man/pam_systemd_home.xml

raw
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="pam_systemd_home" conditional='ENABLE_PAM_HOME'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>pam_systemd_home</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>pam_systemd_home</refentrytitle>
16 <manvolnum>8</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>pam_systemd_home</refname>
21 <refpurpose>Authenticate users and mount home directories via <filename>systemd-homed.service</filename>
22 </refpurpose>
23 </refnamediv>
24
25 <refsynopsisdiv>
26 <para><filename>pam_systemd_home.so</filename></para>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
32 <para><command>pam_systemd_home</command> ensures that home directories managed by
33 <citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
34 are automatically activated (mounted) on user login, and are deactivated (unmounted) when the last
35 session of the user ends. For such users, it also provides authentication (when per-user disk encryption
36 is used, the disk encryption key is derived from the authentication credential supplied at login time),
37 account management (the <ulink url="https://systemd.io/USER_RECORD/">JSON user record</ulink> embedded in
38 the home store contains account details), and implements the updating of the encryption password (which
39 is also used for user authentication).</para>
40 </refsect1>
41
42 <refsect1>
43 <title>Options</title>
44
45 <para>The following options are understood:</para>
46
47 <variablelist class='pam-directives'>
48
49 <varlistentry>
50 <term><varname>suspend=</varname></term>
51
52 <listitem><para>Takes a boolean argument. If true, the home directory of the user will be suspended
53 automatically during system suspend; if false it will remain active. Automatic suspending of the home
54 directory improves security substantially as secret key material is automatically removed from memory
55 before the system is put to sleep and must be re-acquired (through user re-authentication) when
56 coming back from suspend. It is recommended to set this parameter for all PAM applications that have
57 support for automatically re-authenticating via PAM on system resume. If multiple sessions of the
58 same user are open in parallel the user's home directory will be left unsuspended on system suspend
59 as long as at least one of the sessions does not set this parameter to on. Defaults to
60 off.</para>
61
62 <para>Note that TTY logins generally do not support re-authentication on system resume.
63 Re-authentication on system resume is primarily a concept implementable in graphical environments, in
64 the form of lock screens brought up automatically when the system goes to sleep. This means that if a
65 user concurrently uses graphical login sessions that implement the required re-authentication
66 mechanism and console logins that do not, the home directory is not locked during suspend, due to the
67 logic explained above. That said, it is possible to set this field for TTY logins too, ignoring the
68 fact that TTY logins actually do not support the re-authentication mechanism. In that case the TTY
69 sessions will appear hung until the user logs in on another virtual terminal (regardless of whether via
70 another TTY session or graphically) which will resume the home directory and unblock the original TTY
71 session. (Do note that lack of screen locking on TTY sessions means even though the TTY session
72 appears hung, keypresses can still be queued into it, and the existing screen contents be read
73 without re-authentication; this limitation is unrelated to the home directory management
74 <command>pam_systemd_home</command> and <filename>systemd-homed.service</filename> implement.)</para>
75
76 <para>Turning this option on by default is highly recommended for all sessions, but only if the
77 service managing these sessions correctly implements the aforementioned re-authentication. Note that
78 the re-authentication must take place from a component running outside of the user's context, so that
79 it does not require access to the user's home directory for operation. Traditionally, most desktop
80 environments do not implement screen locking this way, and need to be updated
81 accordingly.</para>
82
83 <para>This setting may also be controlled via the <varname>$SYSTEMD_HOME_SUSPEND</varname>
84 environment variable (see below), which <command>pam_systemd_home</command> reads during initialization and sets
85 for sessions. If both the environment variable is set and the module parameter specified the latter
86 takes precedence.</para>
87
88 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
89 </varlistentry>
90
91 <varlistentry>
92 <term><varname>debug</varname><optional>=</optional></term>
93
94 <listitem><para>Takes an optional boolean argument. If yes or without the argument, the module will log
95 debugging information as it operates.</para>
96
97 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
98 </varlistentry>
99 </variablelist>
100 </refsect1>
101
102 <refsect1>
103 <title>Home Area Support</title>
104
105 <para>Home directories managed by
106 <citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
107 support multiple home "areas", which are additional secondary home directories of the user within the
108 primary home directory. An example: at login time if a user <literal>lennart</literal> with a home
109 directory of <filename>/home/lennart</filename> specifies <literal>lennart%versuch1</literal> as account
110 name during login, then <command>pam_systemd_home</command> will execute a login into
111 <literal>lennart</literal> but ensure that the <varname>$HOME</varname> variable is set to
112 <filename>/home/lennart/Areas/versuch1</filename> instead of the usual
113 <filename>/home/lennart</filename>.</para>
114
115 <para>This is particularly useful when sharing the same home directory between multiple systems (for
116 example between a host and a VM), with the desire to share the home directory to a large degree, but
117 still have separate session configuration in place.</para>
118
119 <para>Note that the default area to log into can also be encoded in the user record, and it can be
120 specified among
121 <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
122 configuration parameters. However, an explicit area specified at login time (via the <literal>%</literal>
123 described above) overrides any such default. Also note that simply suffixing an account with
124 <literal>%</literal> at login time (i.e. specifying an empty area name) has the effect of ensuring a
125 login into the primary home directory, overriding any default area configuration via the user record or
126 PAM.</para>
127
128 <para>Note that not all login mechanisms are compatible with the <literal>%</literal> syntax at login
129 time. Most notably <citerefentry
130 project='man-pages'><refentrytitle>ssh</refentrytitle><manvolnum>8</manvolnum></citerefentry> is not.</para>
131
132 <para>Note that the area directory to log into must exist for the area specification to be respected. If
133 an area is specified during login via the <literal>%</literal> logic (or the other mentioned mechanisms)
134 and it does not actually exist the request will be ignored, and the user will log into the primary home
135 directory instead.</para>
136
137 <para>Typically, in order to make use of the mechanism set up an area first, like this:</para>
138
139 <programlisting>lennart@zeta$ mkdir -p ~/Areas
140 lennart@zeta$ cp -av /etc/skel ~/Areas/versuch1</programlisting>
141
142 <para>This should be enough to log into the newly created area, either via a regular terminal (using
143 <literal>lennart%versuch1</literal> when prompted for a user name), or via
144 <citerefentry><refentrytitle>run0</refentrytitle><manvolnum>1</manvolnum></citerefentry>:</para>
145
146 <programlisting>lennart@zeta$ run0 --area=versuch1</programlisting>
147 </refsect1>
148
149 <refsect1>
150 <title>Module Types Provided</title>
151
152 <para>The module implements all four PAM operations: <option>auth</option> (to allow authentication using
153 the encrypted data), <option>account</option> (because users with
154 <filename>systemd-homed.service</filename> user accounts are described in a <ulink
155 url="https://systemd.io/USER_RECORD/">JSON user record</ulink> and may be configured in more detail than
156 in the traditional Linux user database), <option>session</option> (because user sessions must be tracked
157 in order to implement automatic release when the last session of the user is gone),
158 <option>password</option> (to change the encryption password — also used for user authentication —
159 through PAM).</para>
160 </refsect1>
161
162 <refsect1>
163 <title>Environment</title>
164
165 <para>The following environment variables are initialized by the module and available to the processes of the
166 user's session:</para>
167
168 <variablelist class='environment-variables'>
169 <varlistentry>
170 <term><varname>$SYSTEMD_HOME=1</varname></term>
171
172 <listitem><para>Indicates that the user's home directory is managed by <filename>systemd-homed.service</filename>.</para>
173
174 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
175 </varlistentry>
176
177 <varlistentry>
178 <term><varname>$SYSTEMD_HOME_SUSPEND=</varname></term>
179
180 <listitem><para>Indicates whether the session has been registered with the suspend mechanism enabled
181 or disabled (see above). The variable's value is either <literal>0</literal> or
182 <literal>1</literal>. Note that the module both reads the variable when initializing, and sets it for
183 sessions.</para>
184
185 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
186 </varlistentry>
187
188 </variablelist>
189 </refsect1>
190
191 <refsect1>
192 <title>Example</title>
193
194 <para>Here's an example PAM configuration fragment that permits users managed by
195 <filename>systemd-homed.service</filename> to log in:</para>
196
197 <programlisting>#%PAM-1.0
198 <command>-auth [success=done authtok_err=bad perm_denied=bad maxtries=bad default=ignore] pam_systemd_home.so</command>
199 auth sufficient pam_unix.so
200 auth required pam_deny.so
201
202 account required pam_nologin.so
203 <command>-account [success=done authtok_expired=bad new_authtok_reqd=bad maxtries=bad acct_expired=bad default=ignore] pam_systemd_home.so</command>
204 account required pam_unix.so
205
206 <command>-password sufficient pam_systemd_home.so</command>
207 password sufficient pam_unix.so sha512 shadow try_first_pass
208 password required pam_deny.so
209
210 -session optional pam_keyinit.so revoke
211 -session optional pam_loginuid.so
212 <command>-session optional pam_systemd_home.so</command>
213 -session optional pam_systemd.so
214 session required pam_unix.so</programlisting>
215 </refsect1>
216
217 <refsect1>
218 <title>See Also</title>
219 <para><simplelist type="inline">
220 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
221 <member><citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
222 <member><citerefentry><refentrytitle>homed.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
223 <member><citerefentry><refentrytitle>homectl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
224 <member><citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
225 <member><citerefentry project='man-pages'><refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
226 <member><citerefentry project='man-pages'><refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
227 <member><citerefentry project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
228 </simplelist></para>
229 </refsect1>
230
231 </refentry>