teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
Blob Blame History Raw
From a01e2476f0421026d12384292b34f303fc01c43c Mon Sep 17 00:00:00 2001
From: Philip Withnall <philip.withnall@collabora.co.uk>
Date: Tue, 2 Jun 2015 14:17:10 +0100
Subject: [PATCH] =?UTF-8?q?logind:=20Save=20the=20user=E2=80=99s=20state?=
 =?UTF-8?q?=20when=20a=20session=20enters=20SESSION=5FACTIVE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When (for example) switching from X11 to a new VT and logging in there,
creating a new session, the user state file (/run/systemd/users/$uid) is
not updated after the session becomes active. The latest time it is
saved is when the session is in SESSION_OPENING.

This results in a /run/systemd/users/$uid file which contains
STATE=online for the current user on the current active VT, which is
obviously wrong.

As functions like sd_uid_get_state() use this file to get the user’s
state, this could result in things like PolicyKit making incorrect
decisions about the user’s state. (See
https://bugs.freedesktop.org/show_bug.cgi?id=76358.)

Fix this by re-saving the state for a session’s user after completing
the state_job for that session.

https://bugs.freedesktop.org/show_bug.cgi?id=90818
(cherry picked from commit 41dfeaa194c18de49706b5cecf4e53accd12b7f6)

Cherry-picked from: 41dfeaa
Resolves: #1222517
---
 src/login/logind-dbus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 8b0bafd..fb84e92 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2124,6 +2124,7 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b
                 session_jobs_reply(session, unit, result);
 
                 session_save(session);
+                user_save(session->user);
                 session_add_to_gc_queue(session);
         }