PolicyKit: Branch 'master' - 2 commits
David Zeuthen
david at kemper.freedesktop.org
Mon Feb 6 09:42:22 PST 2012
src/polkit/polkitunixsession-systemd.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
New commits:
commit 8fb8b406bab50c5ef8c5d4f743e3f13924bd5f73
Author: David Zeuthen <davidz at redhat.com>
Date: Mon Feb 6 11:26:06 2012 -0500
PolkitUnixSession: Actually return TRUE if a session exists
Also, don't treat the integer returned by sd_session_get_uid() as a
boolean because that's just confusing.
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/src/polkit/polkitunixsession-systemd.c b/src/polkit/polkitunixsession-systemd.c
index 94a7ee4..8a8bf65 100644
--- a/src/polkit/polkitunixsession-systemd.c
+++ b/src/polkit/polkitunixsession-systemd.c
@@ -361,17 +361,15 @@ polkit_unix_session_to_string (PolkitSubject *subject)
static gboolean
polkit_unix_session_exists_sync (PolkitSubject *subject,
- GCancellable *cancellable,
- GError **error)
+ GCancellable *cancellable,
+ GError **error)
{
PolkitUnixSession *session = POLKIT_UNIX_SESSION (subject);
- gboolean ret;
+ gboolean ret = FALSE;
uid_t uid;
- ret = FALSE;
-
- if (!sd_session_get_uid (session->session_id, &uid))
- ret = FALSE;
+ if (sd_session_get_uid (session->session_id, &uid) == 0)
+ ret = TRUE;
return ret;
}
commit c46d2d13eac240d2a609b2dd8fc617ea18a78bfa
Author: David Zeuthen <davidz at redhat.com>
Date: Mon Feb 6 11:24:53 2012 -0500
PolkitUnixSession: Set error if we cannot find a session for the given pid
Also, don't treat the integer returned by sd_pid_get_session() as a
boolean because that's just confusing. Also, don't confuse memory
supposed to be freed by g_free() and free(3) with each other. See
https://bugzilla.redhat.com/show_bug.cgi?id=787222
for more details.
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/src/polkit/polkitunixsession-systemd.c b/src/polkit/polkitunixsession-systemd.c
index e7e913f..94a7ee4 100644
--- a/src/polkit/polkitunixsession-systemd.c
+++ b/src/polkit/polkitunixsession-systemd.c
@@ -23,6 +23,7 @@
# include "config.h"
#endif
+#include <stdlib.h>
#include <string.h>
#include "polkitunixsession.h"
#include "polkitsubject.h"
@@ -450,9 +451,8 @@ polkit_unix_session_initable_init (GInitable *initable,
GError **error)
{
PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable);
- gboolean ret;
-
- ret = FALSE;
+ gboolean ret = FALSE;
+ char *s;
if (session->session_id != NULL)
{
@@ -461,8 +461,19 @@ polkit_unix_session_initable_init (GInitable *initable,
goto out;
}
- if (!sd_pid_get_session (session->pid, &session->session_id))
- ret = TRUE;
+ if (sd_pid_get_session (session->pid, &s) == 0)
+ {
+ session->session_id = g_strdup (s);
+ free (s);
+ ret = TRUE;
+ goto out;
+ }
+
+ g_set_error (error,
+ POLKIT_ERROR,
+ POLKIT_ERROR_FAILED,
+ "No session for pid %d",
+ (gint) session->pid);
out:
return ret;
More information about the hal-commit
mailing list