Hello community, here is the log from the commit of package spice-vdagent for openSUSE:Factory checked in at 2019-12-12 23:19:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/spice-vdagent (Old) and /work/SRC/openSUSE:Factory/.spice-vdagent.new.4691 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "spice-vdagent" Thu Dec 12 23:19:11 2019 rev:14 rq:755921 version:0.19.0 Changes: -------- --- /work/SRC/openSUSE:Factory/spice-vdagent/spice-vdagent.changes 2019-06-19 20:57:45.825948210 +0200 +++ /work/SRC/openSUSE:Factory/.spice-vdagent.new.4691/spice-vdagent.changes 2019-12-12 23:19:17.862207374 +0100 @@ -1,0 +2,7 @@ +Wed Dec 11 17:33:36 UTC 2019 - Bruce Rogers <[email protected]> + +- Add upstream fix for spice-vdagent running on recent GNOME (eg. + 3.34) with systemd integration (boo#1157235) + vdagentd-Fix-session-lookup-for-new-GNOME-versions.patch + +------------------------------------------------------------------- New: ---- vdagentd-Fix-session-lookup-for-new-GNOME-versions.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ spice-vdagent.spec ++++++ --- /var/tmp/diff_new_pack.3ktD6I/_old 2019-12-12 23:19:18.498207317 +0100 +++ /var/tmp/diff_new_pack.3ktD6I/_new 2019-12-12 23:19:18.498207317 +0100 @@ -1,7 +1,7 @@ # # spec file for package spice-vdagent # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LLC # Copyright (c) 2014 B1 Systems GmbH, Vohburg, Germany. # # All modifications and additions to the file contributed by third parties @@ -23,11 +23,12 @@ Summary: Agent for Spice guests License: GPL-3.0-or-later Group: System/Daemons -Url: http://spice-space.org/ +URL: http://spice-space.org/ Source: http://spice-space.org/download/releases/%{name}-%{version}.tar.bz2 Source1: http://spice-space.org/download/releases/%{name}-%{version}.tar.bz2.sig Source2: %{name}.keyring Patch0: spice-vdagent-var_run.patch +Patch1: vdagentd-Fix-session-lookup-for-new-GNOME-versions.patch BuildRequires: alsa-devel >= 1.0.22 BuildRequires: desktop-file-utils BuildRequires: glib2-devel @@ -61,6 +62,7 @@ %prep %setup -q %patch0 -p1 +%patch1 -p1 %build %configure \ ++++++ vdagentd-Fix-session-lookup-for-new-GNOME-versions.patch ++++++ >From b67ff71f1b30992f5b8d4583cc93adb789d247fa Mon Sep 17 00:00:00 2001 From: Benjamin Berg <[email protected]> Date: Fri, 13 Sep 2019 17:00:27 +0200 Subject: [PATCH] vdagentd: Fix session lookup for new GNOME versions New GNOME versions have started to manage the session using the systemd user instance. The effect of this is that the spice-vdagent running in the user session is forked off (indirectly) from the systemd user instance and does technically not belong to any session. The correct way of handling this situation is to simply assume that the process belongs to the users graphical session. Add a heuristic to find the graphical session based on the UID, fixing spice-vdagent running on GNOME 3.34 with systemd integration. Acked-by: Victor Toso <[email protected]> [BR: boo#1157235] Signed-off-by: Bruce Rogers <[email protected]> --- src/vdagentd/systemd-login.c | 59 +++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/src/vdagentd/systemd-login.c b/src/vdagentd/systemd-login.c index a11b66d..0b8f3c1 100644 --- a/src/vdagentd/systemd-login.c +++ b/src/vdagentd/systemd-login.c @@ -286,15 +286,66 @@ const char *session_info_get_active_session(struct session_info *si) char *session_info_session_for_pid(struct session_info *si, uint32_t pid) { + int i; int r; + GStrv sessions = NULL; char *session = NULL; + uid_t uid; r = sd_pid_get_session(pid, &session); - if (r < 0) - syslog(LOG_ERR, "Error getting session for pid %u: %s", - pid, strerror(-r)); - else if (si->verbose) + if (r >= 0) { + goto out; + } + + /* If we could not get a session for the pid then the agent is probably + * running in a systemd managed session. In that case we simply assume + * it is actually part of the newest graphical session we can find. */ + r = sd_pid_get_owner_uid(pid, &uid); + if (r < 0) { + syslog(LOG_ERR, "Error getting owner UID for pid %u: %s", + pid, strerror(-r)); + goto out; + } + + r = sd_uid_get_sessions(uid, 0, &sessions); + if (r < 0) { + syslog(LOG_ERR, "Error getting sessions for UID %d: %s", + (int) uid, strerror(-r)); + goto out; + } + + for (i = 0; sessions[i] != NULL; i++) { + char *session_type = NULL; + + r = sd_session_get_type(sessions[i], &session_type); + + if (r < 0) { + syslog(LOG_ERR, "Error getting session type for session %s: %s", + sessions[i], strerror(-r)); + continue; + } + + if (g_strcmp0(session_type, "wayland") == 0 || + g_strcmp0(session_type, "x11") == 0 || + g_strcmp0(session_type, "mir") == 0) { + + /* We prefer the newest session (i.e. last entry) from the + * user, assuming that any old session that still exist has + * just not yet died properly. */ + if (session != NULL) + free (session); + session = g_strdup(sessions[i]); + } + + free(session_type); + } + + g_strfreev(sessions); + +out: + if (session != NULL && si->verbose) { syslog(LOG_INFO, "Session for pid %u: %s", pid, session); + } return session; } -- 2.24.0
