]> git.ipfire.org Git - thirdparty/systemd.git/blame - docs/USERDB_AND_DESKTOPS.md
Merge pull request #32324 from mrc0mmand/more-website-fixes
[thirdparty/systemd.git] / docs / USERDB_AND_DESKTOPS.md
CommitLineData
b05e1220
LP
1---
2title: systemd-homed and JSON User/Group Record Support in Desktop Environments
5fe63895 3category: Users, Groups and Home Directories
b05e1220 4layout: default
0aff7b75 5SPDX-License-Identifier: LGPL-2.1-or-later
b05e1220
LP
6---
7
8# `systemd-homed` and JSON User/Group Record Support in Desktop Environments
9
10Starting with version 245, systemd supports a new subsystem
11[`systemd-homed.service`](https://www.freedesktop.org/software/systemd/man/systemd-homed.service.html)
d85c8335 12for managing regular ("human") users and their home directories.
13Along with it a new concept `userdb` got merged that brings rich, extensible JSON user/group
14records, extending the classic UNIX/glibc NSS `struct passwd`/`struct group` structures.
15Both additions are added in a fully backwards compatible way, accessible through `getpwnam()`/`getgrnam()`/… (i.e. libc NSS) and PAM as
b05e1220 16usual, meaning that for basic support no changes in the upper layers of the
d85c8335 17stack (in particular desktop environments, such as GNOME or KDE) have to be made.
18However, for better support a number of changes to desktop environments are recommended.
19A few areas where that applies are discussed below.
b05e1220
LP
20
21Before reading on, please read up on the basic concepts, specifically:
22
0d592a5e
FS
23* [Home Directories](/HOME_DIRECTORY)
24* [JSON User Records](/USER_RECORD)
25* [JSON Group Records](/GROUP_RECORD)
26* [User/Group Record Lookup API via Varlink](/USER_GROUP_API)
b05e1220
LP
27
28## Support for Suspending Home Directory Access during System Suspend
29
30One key feature of `systemd-homed` managed encrypted home directories is the
31ability that access to them can be suspended automatically during system sleep,
d85c8335 32removing any cryptographic key material from memory while doing so.
33This is important in a world where most laptop users seldom shut down their computers
34but most of the time just suspend them instead.
35Previously, the encryption keys for the home directories remained in memory during system suspend, so that
36sufficiently equipped attackers could read them from there and gain full access to the device.
37By removing the key material from memory before suspend, and re-requesting it on resume this attack vector can be closed down effectively.
b05e1220
LP
38
39Supporting this mechanism requires support in the desktop environment, since
40the encryption keys (i.e. the user's login password) need to be reacquired on
d85c8335 41system resume, from a lock screen or similar.
42This lock screen must run in system context, and cannot run in the user's own context, since otherwise it
b05e1220
LP
43might end up accessing the home directory of the user even though access to it
44is temporarily suspended and thus will hang if attempted.
45
46It is suggested that desktop environments that implement lock screens run them
47from system context, for example by switching back to the display manager, and
48only revert back to the session after re-authentication via this system lock
49screen (re-authentication in this case refers to passing the user's login
d85c8335 50credentials to the usual PAM authentication hooks).
51Or in other words, when going into system suspend it is recommended that GNOME Shell switches back to
b05e1220
LP
52the GNOME Display Manager login screen which now should double as screen lock,
53and only switches back to the shell's UI after the user re-authenticated there.
54
55Note that this change in behavior is a good idea in any case, and does not
d85c8335 56create any dependencies on `systemd-homed` or systemd-specific APIs.
57It's simply a change of behavior regarding use of existing APIs, not a suggested hook-up to any new APIs.
b05e1220
LP
58
59A display manager which supports this kind of out-of-context screen lock
60operation needs to inform systemd-homed about this so that systemd-homed knows
d85c8335 61that it is safe to suspend the user's home directory on suspend.
62This is done via the `suspend=` argument to the
b05e1220 63[`pam_systemd_home`](https://www.freedesktop.org/software/systemd/man/pam_systemd_home.html)
d85c8335 64PAM module.
65A display manager should hence change its PAM stack configurationto set this parameter to on.
66`systemd-homed` will not suspend home directories if there's at least one active session of the user that does not support
b05e1220
LP
67suspending, as communicated via this parameter.
68
69## User Management UIs
70
71The rich user/group records `userdb` and `systemd-homed` support carry various
d85c8335 72fields of relevance to UIs that manage the local user database or parts thereof.
73In particular, most of the metadata `accounts-daemon` (also see below)
74supports is directly available in these JSON records.
75Hence it makes sense for any user management UI to expose them directly.
b05e1220
LP
76
77`systemd-homed` exposes APIs to add, remove and make changes to local users via
d85c8335 78D-Bus, with full [polkit](https://www.freedesktop.org/software/polkit/docs/latest/) hook-up.
79On the command line this is exposed via the `homectl` command. A graphical UI that exposes similar functionality would be
b05e1220
LP
80very useful, exposing the various new account settings, and in particular
81providing a stream-lined UI for enrolling new-style authentication tokens such
d85c8335 82as PKCS#11/YubiKey-style devices.
83(Ideally, if the user plugs in an uninitialized YubiKey during operation it might be nice if the Desktop would
b05e1220
LP
84automatically ask if a key pair shall be written to it and the local account be
85bound to it, `systemd-homed` provides enough YubiKey/PKCS#11 support to make
86this a reality today; except that it will not take care of token
87initialization).
88
d85c8335 89A strong point of `systemd-homed` is per-user resource management.
90In particular disk space assignments are something that most likely should be
b05e1220 91exposed in a user management UI. Various metadata fields are supplied allowing
d85c8335 92exposure of disk space assignment "slider" UI.
93Note however that the file system back-ends of `systemd-homed.service` have different feature sets.
94Specifically, only btrfs has online file system shrinking support, ext4 only offline file
b05e1220 95system shrinking support, and xfs no shrinking support at all (all three file
d85c8335 96systems support online file system growing however).
97This means if the LUKS back-end is used, disk space assignment cannot be instant for logged in users, unless btrfs is used.
98
99Note that only `systemd-homed` provides an API for modifying/creating/deleting users.
100The generic `userdb` subsystem (which might have other back-ends, besides
101`systemd-homed`, for example LDAP or Windows) exclusively provides a read-only interface.
102(This is unlikely to change, as the other back-ends might have very
103different concepts of adding or modifying users, i.e. might not even have any local concept for that at all).
104This means any user management UI that intends to change (and not just view) user accounts should talk directly to
b05e1220
LP
105`systemd-homed` to make use of its features; there's no abstraction available
106to support other back-ends under the same API.
107
d85c8335 108Unfortunately there's currently no documentation for the `systemd-homed` D-Bus API.
109Consider using the `homectl` sources as guidelines for implementing a user management UI.
110The JSON user/records are well documented however, see above,
b05e1220
LP
111and the D-Bus API provides limited introspection.
112
113## Relationship to `accounts-daemon`
114
115For a long time `accounts-daemon` has been included in Linux distributions
d85c8335 116providing richer user accounts.
117The functionality of this daemon overlaps in many areas with the functionality of `systemd-homed` or `userdb`, but there are
b05e1220 118systematic differences, which means that `systemd-homed` cannot replace
d85c8335 119`accounts-daemon` fully.
120Most importantly: `accounts-daemon` provides "side-car" metadata for *any* type of user account, while `systemd-homed` only
121provides additional metadata for the users it defines itself.
122In other words: `accounts-daemon` will augment foreign accounts; `systemd-homed` cannot be used
123to augment users defined elsewhere, for example in LDAP or as classic `/etc/passwd` records.
b05e1220
LP
124
125This probably means that for the time being, a user management UI (or other UI)
126that wants to support rich user records with compatibility with the status quo
127ante should probably talk to both `systemd-homed` and `accounts-daemon` at the
d85c8335 128same time, and ignore `accounts-daemon`'s records if `systemd-homed` defines them.
129While I (Lennart) personally believe in the long run `systemd-homed` is
b05e1220
LP
130the way to go for rich user records, any UI that wants to manage and support
131rich records for classic records has to support `accounts-daemon` in parallel
132for the time being.
133
134In the short term, it might make sense to also expose the `userdb` provided
135records via `accounts-daemon`, so that clients of the latter can consume them
136without changes. However, I think in the long run `accounts-daemon` should
137probably be removed from the general stack, hence this sounds like a temporary
138solution only.
139
140In case you wonder, there's no automatic mechanism for converting existing
d85c8335 141users registered in `/etc/passwd` or LDAP to users managed by `systemd-homed`.
142There's documentation for doing this manually though, see
0d592a5e 143[Converting Existing Users to systemd-homed managed Users](/CONVERTING_TO_HOMED).
b05e1220
LP
144
145## Future Additions
146
d85c8335 147JSON user/group records are extensible, hence we can easily add any additional fields desktop environments require.
148For example, pattern-based authentication is likely very useful on touch-based devices,
149and the user records should hence learn them natively.
150Fields for other authentication mechanisms, such as fingerprint authentication should be provided as well, eventually.
b05e1220
LP
151
152It is planned to extend the `userdb` Varlink API to support look-ups by partial
153user name and real name (GECOS) data, so that log-in screens can optionally
154implement simple complete-as-you-type login screens.
155
156It is planned to extend the `systemd-homed` D-Bus API to instantly inform clients
157about hardware associated with a specific user being plugged in, to which login
d85c8335 158screens can listen in order to initiate authentication.
159Specifically, any YubiKey-like security token plugged in that is associated with a local user
b05e1220
LP
160record should initiate authentication for that user, making typing in of the
161username unnecessary.