implement 'polkit-1 list authorizations'
authorDavid Zeuthen <davidz@redhat.com>
Fri, 16 Jan 2009 17:25:09 +0000 (12:25 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Fri, 16 Jan 2009 17:25:09 +0000 (12:25 -0500)
src/polkit/polkitauthority.c
src/polkit/polkitauthority.h
src/polkit/polkitauthorizationresult.c [new file with mode: 0644]
src/polkit/polkitauthorizationresult.h [new file with mode: 0644]
src/polkit/polkitprivate.h
src/polkit/polkittypes.h
src/polkitbackend/polkitbackendlocalauthority.c
src/programs/polkit.c

index 2f78472..018de0f 100644 (file)
@@ -116,6 +116,17 @@ generic_cb (GObject      *source_obj,
   *target_res = g_object_ref (res);
 }
 
+static void
+generic_async_cb (GObject      *source_obj,
+                  GAsyncResult *res,
+                  gpointer      user_data)
+{
+  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
+
+  g_simple_async_result_set_op_res_gpointer (simple, g_object_ref (res), g_object_unref);
+  g_simple_async_result_complete (simple);
+}
+
 /* ---------------------------------------------------------------------------------------------------- */
 
 static guint
@@ -126,13 +137,19 @@ polkit_authority_enumerate_actions_async (PolkitAuthority     *authority,
                                           gpointer             user_data)
 {
   guint call_id;
+  GSimpleAsyncResult *simple;
+
+  simple = g_simple_async_result_new (G_OBJECT (authority),
+                                      callback,
+                                      user_data,
+                                      polkit_authority_enumerate_actions_async);
 
   call_id = _polkit_authority_enumerate_actions (authority->real,
                                                  EGG_DBUS_CALL_FLAGS_NONE,
                                                  locale,
                                                  cancellable,
-                                                 callback,
-                                                 user_data);
+                                                 generic_async_cb,
+                                                 simple);
 
   return call_id;
 }
@@ -155,12 +172,19 @@ polkit_authority_enumerate_actions_finish (PolkitAuthority *authority,
   EggDBusArraySeq *array_seq;
   GList *result;
   guint n;
+  GSimpleAsyncResult *simple;
+  GAsyncResult *real_res;
+
+  simple = G_SIMPLE_ASYNC_RESULT (res);
+  real_res = G_ASYNC_RESULT (g_simple_async_result_get_op_res_gpointer (simple));
+
+  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_enumerate_actions_async);
 
   result = NULL;
 
   if (!_polkit_authority_enumerate_actions_finish (authority->real,
                                                    &array_seq,
-                                                   res,
+                                                   real_res,
                                                    error))
     goto out;
 
@@ -178,6 +202,7 @@ polkit_authority_enumerate_actions_finish (PolkitAuthority *authority,
   g_object_unref (array_seq);
 
  out:
+  g_object_unref (real_res);
   return result;
 }
 
@@ -212,12 +237,18 @@ polkit_authority_enumerate_users_async (PolkitAuthority     *authority,
                                         gpointer             user_data)
 {
   guint call_id;
+  GSimpleAsyncResult *simple;
+
+  simple = g_simple_async_result_new (G_OBJECT (authority),
+                                      callback,
+                                      user_data,
+                                      polkit_authority_enumerate_actions_async);
 
   call_id = _polkit_authority_enumerate_users (authority->real,
                                                EGG_DBUS_CALL_FLAGS_NONE,
                                                cancellable,
-                                               callback,
-                                               user_data);
+                                               generic_async_cb,
+                                               simple);
 
   return call_id;
 }
@@ -239,12 +270,19 @@ polkit_authority_enumerate_users_finish (PolkitAuthority *authority,
   EggDBusArraySeq *array_seq;
   GList *result;
   guint n;
+  GSimpleAsyncResult *simple;
+  GAsyncResult *real_res;
+
+  simple = G_SIMPLE_ASYNC_RESULT (res);
+  real_res = G_ASYNC_RESULT (g_simple_async_result_get_op_res_gpointer (simple));
+
+  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_enumerate_actions_async);
 
   result = NULL;
 
   if (!_polkit_authority_enumerate_users_finish (authority->real,
                                                  &array_seq,
-                                                 res,
+                                                 real_res,
                                                  error))
     goto out;
 
@@ -262,6 +300,7 @@ polkit_authority_enumerate_users_finish (PolkitAuthority *authority,
   g_object_unref (array_seq);
 
  out:
+  g_object_unref (real_res);
   return result;
 }
 
@@ -289,17 +328,23 @@ polkit_authority_enumerate_users_sync (PolkitAuthority *authority,
 
 static guint
 polkit_authority_enumerate_groups_async (PolkitAuthority     *authority,
-                                        GCancellable        *cancellable,
-                                        GAsyncReadyCallback  callback,
-                                        gpointer             user_data)
+                                         GCancellable        *cancellable,
+                                         GAsyncReadyCallback  callback,
+                                         gpointer             user_data)
 {
   guint call_id;
+  GSimpleAsyncResult *simple;
+
+  simple = g_simple_async_result_new (G_OBJECT (authority),
+                                      callback,
+                                      user_data,
+                                      polkit_authority_enumerate_actions_async);
 
   call_id = _polkit_authority_enumerate_groups (authority->real,
-                                                EGG_DBUS_CALL_FLAGS_NONE,
-                                                cancellable,
-                                                callback,
-                                                user_data);
+                                               EGG_DBUS_CALL_FLAGS_NONE,
+                                               cancellable,
+                                               generic_async_cb,
+                                               simple);
 
   return call_id;
 }
@@ -321,12 +366,19 @@ polkit_authority_enumerate_groups_finish (PolkitAuthority *authority,
   EggDBusArraySeq *array_seq;
   GList *result;
   guint n;
+  GSimpleAsyncResult *simple;
+  GAsyncResult *real_res;
+
+  simple = G_SIMPLE_ASYNC_RESULT (res);
+  real_res = G_ASYNC_RESULT (g_simple_async_result_get_op_res_gpointer (simple));
+
+  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_enumerate_actions_async);
 
   result = NULL;
 
   if (!_polkit_authority_enumerate_groups_finish (authority->real,
                                                   &array_seq,
-                                                  res,
+                                                  real_res,
                                                   error))
     goto out;
 
@@ -344,6 +396,7 @@ polkit_authority_enumerate_groups_finish (PolkitAuthority *authority,
   g_object_unref (array_seq);
 
  out:
+  g_object_unref (real_res);
   return result;
 }
 
@@ -378,15 +431,23 @@ polkit_authority_check_claim_async (PolkitAuthority          *authority,
 {
   _PolkitAuthorizationClaim *real_claim;
   guint call_id;
+  GSimpleAsyncResult *simple;
 
   real_claim = polkit_authorization_claim_get_real (claim);
 
+  simple = g_simple_async_result_new (G_OBJECT (authority),
+                                      callback,
+                                      user_data,
+                                      polkit_authority_check_claim_async);
+
+  g_object_set_data_full (G_OBJECT (simple), "claim", g_object_ref (claim), (GDestroyNotify) g_object_unref);
+
   call_id = _polkit_authority_check_claim (authority->real,
                                            EGG_DBUS_CALL_FLAGS_NONE,
                                            real_claim,
                                            cancellable,
-                                           callback,
-                                           user_data);
+                                           generic_async_cb,
+                                           simple);
 
   g_object_unref (real_claim);
 
@@ -410,22 +471,29 @@ polkit_authority_check_claim_finish (PolkitAuthority          *authority,
 {
   _PolkitAuthorizationResult result;
   EggDBusHashMap *result_attributes;
+  GSimpleAsyncResult *simple;
+  GAsyncResult *real_res;
+
+  simple = G_SIMPLE_ASYNC_RESULT (res);
+  real_res = G_ASYNC_RESULT (g_simple_async_result_get_op_res_gpointer (simple));
+
+  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_check_claim_async);
 
   result = _POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
 
   if (!_polkit_authority_check_claim_finish (authority->real,
                                              &result,
                                              &result_attributes,
-                                             res,
+                                             real_res,
                                              error))
     goto out;
 
-  /* TODO: pass these back */
+  /* TODO: pass these back? */
   if (result_attributes != NULL)
     g_object_unref (result_attributes);
 
  out:
-
+  g_object_unref (real_res);
   return result;
 }
 
index b3d0333..ba7bad3 100644 (file)
@@ -46,63 +46,63 @@ PolkitAuthority *polkit_authority_get (void);
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-GList                    *polkit_authority_enumerate_actions_sync (PolkitAuthority *authority,
-                                                                   const gchar     *locale,
-                                                                   GCancellable    *cancellable,
-                                                                   GError         **error);
-
-GList                    *polkit_authority_enumerate_users_sync (PolkitAuthority *authority,
-                                                                 GCancellable    *cancellable,
-                                                                 GError         **error);
+GList                     *polkit_authority_enumerate_actions_sync (PolkitAuthority *authority,
+                                                                    const gchar     *locale,
+                                                                    GCancellable    *cancellable,
+                                                                    GError         **error);
 
-GList                    *polkit_authority_enumerate_groups_sync (PolkitAuthority *authority,
+GList                     *polkit_authority_enumerate_users_sync (PolkitAuthority *authority,
                                                                   GCancellable    *cancellable,
                                                                   GError         **error);
 
-PolkitAuthorizationResult polkit_authority_check_claim_sync (PolkitAuthority          *authority,
-                                                             PolkitAuthorizationClaim *claim,
-                                                             GCancellable             *cancellable,
-                                                             GError                  **error);
-
-/* ---------------------------------------------------------------------------------------------------- */
+GList                     *polkit_authority_enumerate_groups_sync (PolkitAuthority *authority,
+                                                                   GCancellable    *cancellable,
+                                                                   GError         **error);
 
-void                      polkit_authority_enumerate_actions (PolkitAuthority     *authority,
-                                                              const gchar         *locale,
-                                                              GCancellable        *cancellable,
-                                                              GAsyncReadyCallback  callback,
-                                                              gpointer             user_data);
+PolkitAuthorizationResult  polkit_authority_check_claim_sync (PolkitAuthority          *authority,
+                                                              PolkitAuthorizationClaim *claim,
+                                                              GCancellable             *cancellable,
+                                                              GError                  **error);
 
-GList *                   polkit_authority_enumerate_actions_finish (PolkitAuthority *authority,
-                                                                     GAsyncResult    *res,
-                                                                     GError         **error);
+/* ---------------------------------------------------------------------------------------------------- */
 
-void                      polkit_authority_enumerate_users (PolkitAuthority     *authority,
-                                                            GCancellable        *cancellable,
-                                                            GAsyncReadyCallback  callback,
-                                                            gpointer             user_data);
+void                       polkit_authority_enumerate_actions (PolkitAuthority     *authority,
+                                                               const gchar         *locale,
+                                                               GCancellable        *cancellable,
+                                                               GAsyncReadyCallback  callback,
+                                                               gpointer             user_data);
 
-GList *                   polkit_authority_enumerate_users_finish (PolkitAuthority *authority,
-                                                                   GAsyncResult    *res,
-                                                                   GError         **error);
+GList *                    polkit_authority_enumerate_actions_finish (PolkitAuthority *authority,
+                                                                      GAsyncResult    *res,
+                                                                      GError         **error);
 
-void                      polkit_authority_enumerate_groups (PolkitAuthority     *authority,
+void                       polkit_authority_enumerate_users (PolkitAuthority     *authority,
                                                              GCancellable        *cancellable,
                                                              GAsyncReadyCallback  callback,
                                                              gpointer             user_data);
 
-GList *                   polkit_authority_enumerate_groups_finish (PolkitAuthority *authority,
+GList *                    polkit_authority_enumerate_users_finish (PolkitAuthority *authority,
                                                                     GAsyncResult    *res,
                                                                     GError         **error);
 
-void                      polkit_authority_check_claim (PolkitAuthority          *authority,
-                                                        PolkitAuthorizationClaim *claim,
-                                                        GCancellable             *cancellable,
-                                                        GAsyncReadyCallback       callback,
-                                                        gpointer                  user_data);
+void                       polkit_authority_enumerate_groups (PolkitAuthority     *authority,
+                                                              GCancellable        *cancellable,
+                                                              GAsyncReadyCallback  callback,
+                                                              gpointer             user_data);
+
+GList *                    polkit_authority_enumerate_groups_finish (PolkitAuthority *authority,
+                                                                     GAsyncResult    *res,
+                                                                     GError         **error);
+
+void                       polkit_authority_check_claim (PolkitAuthority          *authority,
+                                                         PolkitAuthorizationClaim *claim,
+                                                         GCancellable             *cancellable,
+                                                         GAsyncReadyCallback       callback,
+                                                         gpointer                  user_data);
 
-PolkitAuthorizationResult polkit_authority_check_claim_finish (PolkitAuthority          *authority,
-                                                               GAsyncResult             *res,
-                                                               GError                  **error);
+PolkitAuthorizationResult  polkit_authority_check_claim_finish (PolkitAuthority          *authority,
+                                                                GAsyncResult             *res,
+                                                                GError                  **error);
 
 /* ---------------------------------------------------------------------------------------------------- */
 
diff --git a/src/polkit/polkitauthorizationresult.c b/src/polkit/polkitauthorizationresult.c
new file mode 100644 (file)
index 0000000..ad224f3
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "polkitauthorizationresult.h"
+#include "polkitprivate.h"
+
+
+/**
+ * SECTION:polkitauthorizationresult
+ * @title: PolkitAuthorizationResult
+ * @short_result: Authorization Results
+ *
+ * Results of a check for an claim.
+ */
+
+GType
+polkit_authorization_result_get_type (void)
+{
+  return _polkit_authorization_result_get_type ();
+}
+
diff --git a/src/polkit/polkitauthorizationresult.h b/src/polkit/polkitauthorizationresult.h
new file mode 100644 (file)
index 0000000..6e6f445
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_AUTHORIZATION_RESULT_H
+#define __POLKIT_AUTHORIZATION_RESULT_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+GType polkit_authorization_result_get_type (void) G_GNUC_CONST;
+
+#define POLKIT_TYPE_AUTHORIZATION_RESULT (polkit_authorization_result_get_type ())
+
+/**
+ * PolkitAuthorizationResult:
+ * @POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED: The subject is not authorized for the specified action
+ * @POLKIT_AUTHORIZATION_RESULT_AUTHORIZED: The subject is authorized for the specified action
+ * @POLKIT_AUTHORIZATION_RESULT_CHALLENGE: The subject is authorized if more information is provided
+ *
+ * Result codes for checking whether a subject is authorized for an action.
+ */
+typedef enum
+{
+  POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED = 0,
+  POLKIT_AUTHORIZATION_RESULT_AUTHORIZED = 1,
+  POLKIT_AUTHORIZATION_RESULT_CHALLENGE = 2,
+} PolkitAuthorizationResult;
+
+G_END_DECLS
+
+#endif /* __POLKIT_AUTHORIZATION_RESULT_H */
index 9976fad..6aca70e 100644 (file)
@@ -43,5 +43,4 @@ _PolkitSubject *polkit_subject_get_real     (PolkitSubject  *subject);
 PolkitAuthorizationClaim  *polkit_authorization_claim_new_for_real (_PolkitAuthorizationClaim *real);
 _PolkitAuthorizationClaim *polkit_authorization_claim_get_real     (PolkitAuthorizationClaim  *claim);
 
-
 #endif /* __POLKIT_PRIVATE_H */
index 235f92d..e1ab45d 100644 (file)
@@ -47,5 +47,4 @@ typedef struct _PolkitSystemBusName PolkitSystemBusName;
 struct _PolkitAuthorizationClaim;
 typedef struct _PolkitAuthorizationClaim PolkitAuthorizationClaim;
 
-
 #endif /* __POLKIT_TYPES_H */
index ea292c2..c4dbba8 100644 (file)
@@ -246,10 +246,15 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority   *authority,
            subject_str,
            action_id);
 
+  /* TODO: temp */
+  polkit_backend_authority_check_claim_finish (pending_call, POLKIT_AUTHORIZATION_RESULT_AUTHORIZED);
+
+#if 0
   polkit_backend_pending_call_return_error (pending_call,
                                             POLKIT_ERROR,
                                             POLKIT_ERROR_NOT_SUPPORTED,
                                             "Not implemented");
+#endif
 
   g_free (inquirer_str);
   g_free (subject_str);
index d436338..6c79538 100644 (file)
@@ -44,14 +44,19 @@ static PolkitSubject *subject = NULL;
 
 static gchar *action_id = NULL;
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static gboolean list_actions (void);
 static gboolean list_users (void);
 static gboolean list_groups (void);
+static gboolean list_authorizations (void);
 
 static gboolean check (void);
 
 static gboolean show_action (const gchar *action_id);
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static void
 usage (int argc, char *argv[])
 {
@@ -69,6 +74,8 @@ usage (int argc, char *argv[])
     }
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 int
 main (int argc, char *argv[])
 {
@@ -210,6 +217,10 @@ main (int argc, char *argv[])
     {
       ret = list_groups ();
     }
+  else if (opt_list_authorizations)
+    {
+      ret = list_authorizations ();
+    }
   else if (opt_check)
     {
       if (subject == NULL || action_id == NULL)
@@ -238,6 +249,8 @@ main (int argc, char *argv[])
   return ret ? 0 : 1;
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static void
 print_action (PolkitActionDescription *action)
 {
@@ -279,6 +292,8 @@ print_action (PolkitActionDescription *action)
     }
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static gboolean
 show_action (const gchar *action_id)
 {
@@ -380,6 +395,8 @@ list_actions (void)
   return ret;
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static void
 print_subjects (GList *subjects)
 {
@@ -396,6 +413,8 @@ print_subjects (GList *subjects)
     }
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static gboolean
 list_users (void)
 {
@@ -427,6 +446,8 @@ list_users (void)
   return ret;
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static gboolean
 list_groups (void)
 {
@@ -458,6 +479,8 @@ list_groups (void)
   return ret;
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static gboolean
 check (void)
 {
@@ -483,8 +506,6 @@ check (void)
       goto out;
     }
 
-  g_debug ("result = %d", result);
-
  out:
   if (claim != NULL)
     g_object_unref (claim);
@@ -492,3 +513,161 @@ check (void)
   return result == POLKIT_AUTHORIZATION_RESULT_AUTHORIZED;
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
+
+typedef struct
+{
+  PolkitAuthorizationClaim *claim;
+  PolkitAuthorizationResult result;
+} AuthzData;
+
+static GPtrArray *authz_data_array;
+
+static gint authz_data_num_pending = 0;
+
+static GMainLoop *authz_data_loop = NULL;
+
+static void
+authz_data_free (AuthzData *data)
+{
+  g_object_unref (data->claim);
+  g_free (data);
+}
+
+static gint
+authz_data_sort_func (gconstpointer a,
+                      gconstpointer b)
+{
+  AuthzData *da;
+  AuthzData *db;
+  const gchar *aa;
+  const gchar *ab;
+
+  da = (AuthzData *) *((gpointer **) a);
+  db = (AuthzData *) *((gpointer **) b);
+
+  aa = polkit_authorization_claim_get_action_id (da->claim);
+  ab = polkit_authorization_claim_get_action_id (db->claim);
+
+  return strcmp (aa, ab);
+}
+
+static void
+list_authz_cb (GObject      *source_obj,
+               GAsyncResult *res,
+               gpointer      user_data)
+{
+  PolkitAuthority *authority;
+  AuthzData *data;
+  GError *error;
+  PolkitAuthorizationResult result;
+
+  authority = POLKIT_AUTHORITY (source_obj);
+  data = user_data;
+  error = NULL;
+
+  result = polkit_authority_check_claim_finish (authority,
+                                                res,
+                                                &error);
+  if (error != NULL)
+    {
+      g_printerr ("Unable to check claim: %s\n", error->message);
+      g_error_free (error);
+    }
+  else
+    {
+      data->result = result;
+    }
+
+  authz_data_num_pending -= 1;
+
+  if (authz_data_num_pending == 0)
+    g_main_loop_quit (authz_data_loop);
+}
+
+static gboolean
+list_authorizations (void)
+{
+  GError *error;
+  GList *actions;
+  GList *l;
+  gboolean ret;
+  PolkitSubject *calling_process;
+  guint n;
+
+  ret = FALSE;
+
+  authz_data_array = g_ptr_array_new ();
+  authz_data_num_pending = 0;
+  authz_data_loop = g_main_loop_new (NULL, FALSE);
+
+  calling_process = polkit_unix_process_new (getppid ());
+
+  error = NULL;
+  actions = polkit_authority_enumerate_actions_sync (authority,
+                                                     NULL,
+                                                     NULL,
+                                                     &error);
+  if (error != NULL)
+    {
+      g_printerr ("Error enumerating actions: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  for (l = actions; l != NULL; l = l->next)
+    {
+      PolkitActionDescription *action = POLKIT_ACTION_DESCRIPTION (l->data);
+      PolkitAuthorizationClaim *claim;
+      AuthzData *data;
+
+      claim = polkit_authorization_claim_new (calling_process,
+                                              polkit_action_description_get_action_id (action));
+
+      data = g_new0 (AuthzData, 1);
+      data->claim = g_object_ref (claim);
+
+      g_ptr_array_add (authz_data_array, data);
+
+      authz_data_num_pending += 1;
+
+      polkit_authority_check_claim (authority,
+                                    claim,
+                                    NULL,
+                                    list_authz_cb,
+                                    data);
+
+      g_object_unref (claim);
+    }
+
+  g_main_loop_run (authz_data_loop);
+
+  ret = TRUE;
+
+  /* sort authorizations by name */
+  g_ptr_array_sort (authz_data_array, authz_data_sort_func);
+
+  for (n = 0; n < authz_data_array->len; n++)
+    {
+      AuthzData *data = authz_data_array->pdata[n];
+
+      if (data->result == POLKIT_AUTHORIZATION_RESULT_AUTHORIZED)
+        g_print ("%s\n", polkit_authorization_claim_get_action_id (data->claim));
+    }
+
+ out:
+
+  g_list_foreach (actions, (GFunc) g_object_unref, NULL);
+  g_list_free (actions);
+
+  g_ptr_array_foreach (authz_data_array, (GFunc) authz_data_free, NULL);
+  g_ptr_array_free (authz_data_array, TRUE);
+
+  g_object_unref (calling_process);
+
+  g_main_loop_unref (authz_data_loop);
+  return ret;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */