summaryrefslogtreecommitdiff
path: root/src/core/execute.c
diff options
context:
space:
mode:
authorMichal Sekletar <msekleta@redhat.com>2022-05-27 21:11:37 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-07-07 10:10:42 +0900
commite73bf3425c0b5a6339388a3a459ce2bac497308b (patch)
tree93a34a771355ae7cd53a6a221cbb5201508b169c /src/core/execute.c
parent948fce51184612dc083efb46282879910897dcc7 (diff)
downloadsystemd-e73bf3425c0b5a6339388a3a459ce2bac497308b.tar.gz
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
Diffstat (limited to 'src/core/execute.c')
-rw-r--r--src/core/execute.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 05fc00ca1c..962edc1eee 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1213,13 +1213,15 @@ static int setup_pam(
if (getttyname_malloc(STDIN_FILENO, &q) >= 0)
tty = strjoina("/dev/", q);
+ else
+ /* If everything else failed then let's just use value "systemd". This will cause that session
+ * isn't going to be marked as "background" and user manager will be started. */
+ tty = "systemd";
}
- if (tty) {
- pam_code = pam_set_item(handle, PAM_TTY, tty);
- if (pam_code != PAM_SUCCESS)
- goto fail;
- }
+ pam_code = pam_set_item(handle, PAM_TTY, tty);
+ if (pam_code != PAM_SUCCESS)
+ goto fail;
STRV_FOREACH(nv, *env) {
pam_code = pam_putenv(handle, *nv);