From: Tom Yan Date: Mon, 8 Jul 2024 14:10:43 +0000 (+0800) Subject: logind-dbus: set gc_mode to USER_GC_BY_PIN when disable linger X-Git-Tag: v257-rc1~936 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1df981a74ae19513b40167c6b320c30bd166ac34;p=thirdparty%2Fsystemd.git 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. --- 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);