Zbigniew Jędrzejewski-Szmek 436654
From a3f788f9a2f5263fd91b5fbd2fce87af9dceca68 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 436654
From: Philip Withnall <philip.withnall@collabora.co.uk>
Zbigniew Jędrzejewski-Szmek 436654
Date: Tue, 2 Jun 2015 14:17:10 +0100
Zbigniew Jędrzejewski-Szmek 436654
Subject: [PATCH] =?UTF-8?q?logind:=20Save=20the=20user=E2=80=99s=20state?=
Zbigniew Jędrzejewski-Szmek 436654
 =?UTF-8?q?=20when=20a=20session=20enters=20SESSION=5FACTIVE?=
Zbigniew Jędrzejewski-Szmek 436654
MIME-Version: 1.0
Zbigniew Jędrzejewski-Szmek 436654
Content-Type: text/plain; charset=UTF-8
Zbigniew Jędrzejewski-Szmek 436654
Content-Transfer-Encoding: 8bit
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
When (for example) switching from X11 to a new VT and logging in there,
Zbigniew Jędrzejewski-Szmek 436654
creating a new session, the user state file (/run/systemd/users/$uid) is
Zbigniew Jędrzejewski-Szmek 436654
not updated after the session becomes active. The latest time it is
Zbigniew Jędrzejewski-Szmek 436654
saved is when the session is in SESSION_OPENING.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
This results in a /run/systemd/users/$uid file which contains
Zbigniew Jędrzejewski-Szmek 436654
STATE=online for the current user on the current active VT, which is
Zbigniew Jędrzejewski-Szmek 436654
obviously wrong.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
As functions like sd_uid_get_state() use this file to get the user’s
Zbigniew Jędrzejewski-Szmek 436654
state, this could result in things like PolicyKit making incorrect
Zbigniew Jędrzejewski-Szmek 436654
decisions about the user’s state. (See
Zbigniew Jędrzejewski-Szmek 436654
https://bugs.freedesktop.org/show_bug.cgi?id=76358.)
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
Fix this by re-saving the state for a session’s user after completing
Zbigniew Jędrzejewski-Szmek 436654
the state_job for that session.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
https://bugs.freedesktop.org/show_bug.cgi?id=90818
Zbigniew Jędrzejewski-Szmek 436654
(cherry picked from commit 41dfeaa194c18de49706b5cecf4e53accd12b7f6)
Zbigniew Jędrzejewski-Szmek 436654
---
Zbigniew Jędrzejewski-Szmek 436654
 src/login/logind-dbus.c | 1 +
Zbigniew Jędrzejewski-Szmek 436654
 1 file changed, 1 insertion(+)
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
Zbigniew Jędrzejewski-Szmek 436654
index 3555bcc2f5..47646a81bb 100644
Zbigniew Jędrzejewski-Szmek 436654
--- a/src/login/logind-dbus.c
Zbigniew Jędrzejewski-Szmek 436654
+++ b/src/login/logind-dbus.c
Zbigniew Jędrzejewski-Szmek 436654
@@ -2522,6 +2522,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
Zbigniew Jędrzejewski-Szmek 436654
                 session_jobs_reply(session, unit, result);
Zbigniew Jędrzejewski-Szmek 436654
 
Zbigniew Jędrzejewski-Szmek 436654
                 session_save(session);
Zbigniew Jędrzejewski-Szmek 436654
+                user_save(session->user);
Zbigniew Jędrzejewski-Szmek 436654
                 session_add_to_gc_queue(session);
Zbigniew Jędrzejewski-Szmek 436654
         }
Zbigniew Jędrzejewski-Szmek 436654