summaryrefslogtreecommitdiff
path: root/src/login/logind-seat.c
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2015-01-28 18:14:01 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-28 20:03:38 +0100
commitbe94d95499bf9c63fe9331e9b9ecc64f32fe9d79 (patch)
tree232e19a8e3db2d63b301b40627c906c55d3c3767 /src/login/logind-seat.c
parent40672b99c7da7efd317fc31612504fe7d5ab0b65 (diff)
logind: handle closing sessions over daemon restarts
It may happen that you have several sessions with the same VT: - Open a session c1 which leaves some processes around, and log out. The session will stay in State=closing and become Active=no. - Log back in on the same VT, get a new session "c2" which is State=active and Active=yes. When restarting logind after that, the first session that matches the current VT becomes Active=yes, which will be c1; c2 thus is Active=no and does not get the usual polkit/device ACL privileges. Restore the "closing" state in session_load(), to avoid treating all restored sessions as State=active. In seat_active_vt_changed(), prefer active sessions over closing ones if more than one session matches the current VT. Finally, fix the confusing comment in session_load() and explain it a bit better. https://launchpad.net/bugs/1415104
Diffstat (limited to 'src/login/logind-seat.c')
-rw-r--r--src/login/logind-seat.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 197138c4e..126c5b84c 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -340,12 +340,24 @@ int seat_active_vt_changed(Seat *s, unsigned int vtnr) {
log_debug("VT changed to %u", vtnr);
+ /* we might have earlier closing sessions on the same VT, so try to
+ * find a running one first */
LIST_FOREACH(sessions_by_seat, i, s->sessions)
- if (i->vtnr == vtnr) {
+ if (i->vtnr == vtnr && !i->stopping) {
new_active = i;
break;
}
+ if (!new_active) {
+ /* no running one? then we can't decide which one is the
+ * active one, let the first one win */
+ LIST_FOREACH(sessions_by_seat, i, s->sessions)
+ if (i->vtnr == vtnr) {
+ new_active = i;
+ break;
+ }
+ }
+
r = seat_set_active(s, new_active);
manager_spawn_autovt(s->manager, vtnr);