1 From c46d2d13eac240d2a609b2dd8fc617ea18a78bfa Mon Sep 17 00:00:00 2001
2 From: David Zeuthen <davidz@redhat.com>
3 Date: Mon, 6 Feb 2012 11:24:53 -0500
4 Subject: [PATCH 1/2] PolkitUnixSession: Set error if we cannot find a session for the given pid
6 Also, don't treat the integer returned by sd_pid_get_session() as a
7 boolean because that's just confusing. Also, don't confuse memory
8 supposed to be freed by g_free() and free(3) with each other. See
10 https://bugzilla.redhat.com/show_bug.cgi?id=787222
14 Signed-off-by: David Zeuthen <davidz@redhat.com>
17 Upstream-Status: Accepted
19 src/polkit/polkitunixsession-systemd.c | 21 ++++++++++++++++-----
20 1 files changed, 16 insertions(+), 5 deletions(-)
22 diff --git a/src/polkit/polkitunixsession-systemd.c b/src/polkit/polkitunixsession-systemd.c
23 index e7e913f..94a7ee4 100644
24 --- a/src/polkit/polkitunixsession-systemd.c
25 +++ b/src/polkit/polkitunixsession-systemd.c
32 #include "polkitunixsession.h"
33 #include "polkitsubject.h"
34 @@ -450,9 +451,8 @@ polkit_unix_session_initable_init (GInitable *initable,
37 PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable);
41 + gboolean ret = FALSE;
44 if (session->session_id != NULL)
46 @@ -461,8 +461,19 @@ polkit_unix_session_initable_init (GInitable *initable,
50 - if (!sd_pid_get_session (session->pid, &session->session_id))
52 + if (sd_pid_get_session (session->pid, &s) == 0)
54 + session->session_id = g_strdup (s);
62 + POLKIT_ERROR_FAILED,
63 + "No session for pid %d",
64 + (gint) session->pid);