]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/login/pam_systemd.c
logind: don't start user@UID.service instance for background sessions
authorMichal Sekletar <msekleta@redhat.com>
Fri, 27 May 2022 19:11:37 +0000 (21:11 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 7 Jul 2022 01:10:42 +0000 (10:10 +0900)
commite73bf3425c0b5a6339388a3a459ce2bac497308b
tree93a34a771355ae7cd53a6a221cbb5201508b169c
parent948fce51184612dc083efb46282879910897dcc7
logind: don't start user@UID.service instance for background sessions

We have had background session class for a long time (since commit
e2acb67baa), but so far the only difference in handling of background
sessions was logging, i.e. we log some messages with LOG_DEBUG for such
sessions.

Previously there were complains [1] about excessive logging for each
time cron session is started. We used to advise user to enable lingering
for users if they want to avoid these log messages. However, on servers
with a lot of users the extra processes that result from lingering just
adds too much overhead. Hence I think that our current handling of
background sessions is not ideal and we should make better use of this
attribute.

This commit introduces a change in default behavior of logind. Logind is
now not going to start user instance of systemd when background session
is created and that should address excessive logging problem for cron
where background class is used by default. When the same user actually
logs in normally then user instance will be started as previously.

Also note that PAM_TTY variable is now always set to some value for PAM
sessions started via PAMName= option. Otherwise we would categorize such
sessions as "background" and user manager won't be started.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1825942
src/core/execute.c
src/login/logind-dbus.c
src/login/logind-session.c
src/login/logind-user.c
src/login/logind-user.h
src/login/logind.c
src/login/pam_systemd.c