logind: don't delay login for root even if systemd-user-sessions.service is not activ...
authorFranck Bui <fbui@suse.com>
Thu, 7 Jul 2022 10:02:04 +0000 (12:02 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 12 Jul 2022 21:54:39 +0000 (22:54 +0100)
commit278e815bfa3e4c2e3914e00121c37fc844cb2025
treecbeb7409cce18b625119ff7fdd6dbf0b117e9127
parentaa5ae9711ef3cd0c69b7fcfbd65bca05fb704a8a
logind: don't delay login for root even if systemd-user-sessions.service is not activated yet

If for any reason something goes wrong during the boot process (most likely due
to a network issue), system admins should be allowed to log in to the system to
debug the problem. However due to the login session barrier enforced by
systemd-user-sessions.service for all users, logins for root will be delayed
until a (dbus) timeout expires. Beside being confusing, it's not a nice user
experience to wait for an indefinite period of time (no message is shown) this
and also suggests that something went wrong in the background.

The reason of this delay is due to the fact that all units involved in the
creation of a user session are ordered after systemd-user-sessions.service,
which is subject to network issues. If root needs to log in at that time,
logind is requested to create a new session (via pam_systemd), which ultimately
ends up waiting for systemd-user-session.service to be activated. This has the
bad side effect to block login for root until the dbus call done by pam_systemd
times out and the PAM stack proceeds anyways.

To solve this problem, this patch orders the session scope units and the user
instances only after systemd-user-sessions.service for unprivileged users only.
src/login/logind-session.c
units/meson.build
units/user-.slice.d/10-defaults.conf
units/user-runtime-dir@.service.in
units/user@.service.d/10-login-barrier.conf [new file with mode: 0644]
units/user@.service.in
units/user@0.service.d/10-login-barrier.conf [new file with mode: 0644]