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.
This commit is contained in:
Tom Yan
2024-07-09 13:53:10 +02:00
committed by Lennart Poettering
parent 13e9ec55cd
commit 1df981a74a
+4 -1
View File
@@ -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);