summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Yan <tom.ty89@gmail.com>2024-07-08 16:10:43 +0200
committerLennart Poettering <lennart@poettering.net>2024-07-09 13:53:10 +0200
commit1df981a74ae19513b40167c6b320c30bd166ac34 (patch)
treea03bb688e063e8450c65d98747731209bbff4624
parentAdd or fix mount matrix for multiple handhelds. (#33586) (diff)
downloadsystemd-1df981a74ae19513b40167c6b320c30bd166ac34.tar.xz
systemd-1df981a74ae19513b40167c6b320c30bd166ac34.zip
logind-dbus: set gc_mode to USER_GC_BY_PIN when disable linger
The mode switch from any to pin is currently done in create_session(). However, if no (pinning) session is created before (or after) linger is disabled, the user will not be gc'd after that. Therefore, also perform the mode switch when linger is being disabled.
-rw-r--r--src/login/logind-dbus.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 3e419bb62e..f6b37c6465 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1509,8 +1509,11 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
return -errno;
u = hashmap_get(m->users, UID_TO_PTR(uid));
- if (u)
+ if (u) {
+ /* Make sure that disabling lingering will terminate the user tracking if no sessions pin it. */
+ u->gc_mode = USER_GC_BY_PIN;
user_add_to_gc_queue(u);
+ }
}
return sd_bus_reply_method_return(message, NULL);