From 1df981a74ae19513b40167c6b320c30bd166ac34 Mon Sep 17 00:00:00 2001 From: Tom Yan Date: Mon, 8 Jul 2024 22:10:43 +0800 Subject: [PATCH] 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. --- src/login/logind-dbus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 3e419bb62e5..f6b37c64654 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); -- 2.47.3