PolicyKit: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Wed May 13 09:32:54 PDT 2009


 src/examples/cancel.c                        |   33 +++++++++++----------------
 src/nullbackend/polkitbackendnullauthority.c |   12 ++++-----
 src/programs/polkit.c                        |   12 ++++++---
 3 files changed, 28 insertions(+), 29 deletions(-)

New commits:
commit 8e547a59a1fdac54329605f4b3576122f5236479
Author: David Zeuthen <davidz at redhat.com>
Date:   Wed May 13 12:30:26 2009 -0400

    Port examples and command-line tools to new API

diff --git a/src/examples/cancel.c b/src/examples/cancel.c
index 7191398..351f974 100644
--- a/src/examples/cancel.c
+++ b/src/examples/cancel.c
@@ -37,7 +37,7 @@ check_authorization_cb (PolkitAuthority *authority,
                         GMainLoop       *loop)
 {
   GError *error;
-  PolkitAuthorizationResult result;
+  PolkitAuthorizationResult *result;
 
   error = NULL;
   result = polkit_authority_check_authorization_finish (authority, res, &error);
@@ -48,27 +48,22 @@ check_authorization_cb (PolkitAuthority *authority,
     }
   else
     {
-      gchar *result_str;
-      switch (result)
+      const gchar *result_str;
+      if (polkit_authorization_result_get_is_authorized (result))
         {
-        case POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED:
-          result_str = g_strdup ("POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED");
-          break;
-
-        case POLKIT_AUTHORIZATION_RESULT_AUTHORIZED:
-          result_str = g_strdup ("POLKIT_AUTHORIZATION_RESULT_AUTHORIZED");
-          break;
-
-        case POLKIT_AUTHORIZATION_RESULT_CHALLENGE:
-          result_str = g_strdup ("POLKIT_AUTHORIZATION_RESULT_CHALLENGE");
-          break;
-
-        default:
-          result_str = g_strdup_printf ("Unknown return code %d", result);
-          break;
+          result_str = "authorized";
+        }
+      else if (polkit_authorization_result_get_is_challenge (result))
+        {
+          result_str = "challenge";
+        }
+      else
+        {
+          result_str = "not authorized";
         }
+
       g_print ("Authorization result: %s\n", result_str);
-      g_free (result_str);
+      /* TODO: print details if authorized */
     }
 
   g_main_loop_quit (loop);
diff --git a/src/nullbackend/polkitbackendnullauthority.c b/src/nullbackend/polkitbackendnullauthority.c
index 11b75f2..5e65010 100644
--- a/src/nullbackend/polkitbackendnullauthority.c
+++ b/src/nullbackend/polkitbackendnullauthority.c
@@ -48,9 +48,9 @@ static void authority_check_authorization (PolkitBackendAuthority        *author
                                            GAsyncReadyCallback            callback,
                                            gpointer                       user_data);
 
-static PolkitAuthorizationResult authority_check_authorization_finish (PolkitBackendAuthority  *authority,
-                                                                       GAsyncResult            *res,
-                                                                       GError                 **error);
+static PolkitAuthorizationResult *authority_check_authorization_finish (PolkitBackendAuthority  *authority,
+                                                                        GAsyncResult            *res,
+                                                                        GError                 **error);
 
 G_DEFINE_DYNAMIC_TYPE (PolkitBackendNullAuthority, polkit_backend_null_authority,POLKIT_BACKEND_TYPE_AUTHORITY);
 
@@ -154,20 +154,20 @@ authority_check_authorization (PolkitBackendAuthority        *authority,
   g_object_unref (simple);
 }
 
-static PolkitAuthorizationResult
+static PolkitAuthorizationResult *
 authority_check_authorization_finish (PolkitBackendAuthority  *authority,
                                       GAsyncResult            *res,
                                       GError                 **error)
 {
   GSimpleAsyncResult *simple;
-  PolkitAuthorizationResult result;
+  PolkitAuthorizationResult *result;
 
   simple = G_SIMPLE_ASYNC_RESULT (res);
 
   g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == authority_check_authorization);
 
   /* we always return NOT_AUTHORIZED, never an error */
-  result = POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
+  result = polkit_authorization_result_new (FALSE, FALSE, NULL);
 
   if (g_simple_async_result_propagate_error (simple, error))
     goto out;
diff --git a/src/programs/polkit.c b/src/programs/polkit.c
index b194c78..bff32b5 100644
--- a/src/programs/polkit.c
+++ b/src/programs/polkit.c
@@ -54,10 +54,10 @@ 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 list_authorizations (void);
 static gboolean list_explicit_authorizations (void);
 
-static gboolean do_check (void);
+//static gboolean do_check (void);
 static gboolean do_add (void);
 static gboolean do_remove (void);
 
@@ -303,7 +303,8 @@ main (int argc, char *argv[])
     }
   else if (opt_list_authorizations)
     {
-      ret = list_authorizations ();
+      g_assert_not_reached ();
+      //ret = list_authorizations ();
     }
   else if (opt_list_explicit_authorizations)
     {
@@ -317,7 +318,8 @@ main (int argc, char *argv[])
           goto out;
         }
 
-      ret = do_check ();
+      //ret = do_check ();
+      g_assert_not_reached ();
     }
   else if (opt_add)
     {
@@ -597,6 +599,7 @@ list_groups (void)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+#if 0
 static gboolean
 do_check (void)
 {
@@ -775,6 +778,7 @@ list_authorizations (void)
   g_main_loop_unref (authz_data_loop);
   return ret;
 }
+#endif
 
 /* ---------------------------------------------------------------------------------------------------- */
 


More information about the hal-commit mailing list