PolicyKit: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Fri Nov 30 21:05:06 PST 2007
src/polkit-dbus/polkit-dbus.c | 31 ++++++++++++++++++++-----------
src/polkit-grant/polkit-grant-helper.c | 14 ++++++++++++--
2 files changed, 32 insertions(+), 13 deletions(-)
New commits:
commit 7f4df53f29a20e6ba5c59714ed18079394b3baa0
Author: David Zeuthen <davidz at redhat.com>
Date: Sat Dec 1 00:03:32 2007 -0500
fix a bug where KitList elements were not properly freed
diff --git a/src/polkit-dbus/polkit-dbus.c b/src/polkit-dbus/polkit-dbus.c
index 7dec238..fc329d3 100644
--- a/src/polkit-dbus/polkit-dbus.c
+++ b/src/polkit-dbus/polkit-dbus.c
@@ -773,6 +773,13 @@ out:
return caller;
}
+static kit_bool_t
+_free_elem_in_list (KitList *list, void *data, void *user_data)
+{
+ kit_free (data);
+ return FALSE;
+}
+
static KitList *
_get_list_of_sessions (DBusConnection *con, uid_t uid, DBusError *error)
{
@@ -806,7 +813,7 @@ _get_list_of_sessions (DBusConnection *con, uid_t uid, DBusError *error)
if (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_OBJECT_PATH) {
kit_warning ("Wrong reply from ConsoleKit (element is not a string)");
- kit_list_foreach (ret, (KitListForeachFunc) kit_free, NULL);
+ kit_list_foreach (ret, _free_elem_in_list, NULL);
kit_list_free (ret);
goto out;
}
@@ -870,17 +877,19 @@ _polkit_is_authorization_relevant_internal (DBusConnection *con,
del_sessions = TRUE;
}
- for (i = sessions; i != NULL; i = i->next) {
- char *session_id = i->data;
- if (strcmp (session_id, polkit_authorization_scope_session_get_ck_objref (auth)) == 0) {
- ret = TRUE;
- break;
+ if (sessions != NULL) {
+ for (i = sessions; i != NULL; i = i->next) {
+ char *session_id = i->data;
+ if (strcmp (session_id, polkit_authorization_scope_session_get_ck_objref (auth)) == 0) {
+ ret = TRUE;
+ break;
+ }
+ }
+
+ if (del_sessions) {
+ kit_list_foreach (sessions, _free_elem_in_list, NULL);
+ kit_list_free (sessions);
}
- }
-
- if (del_sessions) {
- kit_list_foreach (sessions, (KitListForeachFunc) kit_free, NULL);
- kit_list_free (sessions);
}
break;
diff --git a/src/polkit-grant/polkit-grant-helper.c b/src/polkit-grant/polkit-grant-helper.c
index 827cb29..478fdbc 100644
--- a/src/polkit-grant/polkit-grant-helper.c
+++ b/src/polkit-grant/polkit-grant-helper.c
@@ -58,6 +58,7 @@
*/
#undef PGH_DEBUG
/* #define PGH_DEBUG */
+#define PGH_DEBUG
/* synopsis: polkit-grant-helper <pid> <action-name>
*
@@ -157,7 +158,7 @@
*
*/
static polkit_bool_t
-do_auth (const char *user_to_auth)
+do_auth (const char *user_to_auth, gboolean *empty_conversation)
{
int helper_pid;
int helper_stdin;
@@ -172,6 +173,7 @@ do_auth (const char *user_to_auth)
child_stdin = NULL;
child_stdout = NULL;
ret = FALSE;
+ *empty_conversation = TRUE;
g_error = NULL;
if (!g_spawn_async_with_pipes (NULL,
@@ -223,6 +225,9 @@ do_auth (const char *user_to_auth)
if (strcmp (buf, "FAILURE\n") == 0) {
goto out;
}
+
+ *empty_conversation = FALSE;
+
/* send to parent */
fprintf (stdout, buf);
fflush (stdout);
@@ -536,6 +541,7 @@ main (int argc, char *argv[])
PolKitCaller *caller;
uid_t caller_uid;
PolKitSession *session;
+ gboolean empty_conversation;
ret = 3;
@@ -749,10 +755,14 @@ main (int argc, char *argv[])
ret = 1;
/* Start authentication */
- if (!do_auth (user_to_auth)) {
+ if (!do_auth (user_to_auth, &empty_conversation)) {
goto out;
}
+#ifdef PGH_DEBUG
+ fprintf (stderr, "polkit-grant-helper: empty_conversation=%d\n", empty_conversation);
+#endif /* PGH_DEBUG */
+
/* Ask caller if he want to slim down grant type... e.g. he
* might want to go from auth_self_keep_always to
* auth_self_keep_session..
More information about the hal-commit
mailing list