PolicyKit: Branch 'gdbus'
David Zeuthen
david at kemper.freedesktop.org
Mon Aug 2 12:05:55 PDT 2010
src/polkit/polkitauthority.c | 11 ++++++++++-
src/polkit/polkitprivate.h | 3 ++-
src/polkit/polkittemporaryauthorization.c | 27 ++++++++++++++++++++++++---
3 files changed, 36 insertions(+), 5 deletions(-)
New commits:
commit b224c80463d7408e6d410f718686d609ab16d1c7
Author: David Zeuthen <davidz at redhat.com>
Date: Mon Aug 2 15:05:18 2010 -0400
Implement polkit_temporary_authorization_new_for_gvariant()
This is hit by the authentication agent in order to display a padlock
when temporary authorizations exist.
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c
index 1a66add..8edbfa3 100644
--- a/src/polkit/polkitauthority.c
+++ b/src/polkit/polkitauthority.c
@@ -1126,8 +1126,17 @@ polkit_authority_enumerate_temporary_authorizations_finish (PolkitAuthority *aut
g_variant_iter_init (&iter, array);
while ((child = g_variant_iter_next_value (&iter)) != NULL)
{
- ret = g_list_prepend (ret, polkit_temporary_authorization_new_for_gvariant (child));
+ PolkitTemporaryAuthorization *auth;
+ auth = polkit_temporary_authorization_new_for_gvariant (child, error);
g_variant_unref (child);
+ if (auth == NULL)
+ {
+ g_prefix_error (error, "Error serializing return value of EnumerateTemporaryAuthorizations: ");
+ g_list_foreach (ret, (GFunc) g_object_unref, NULL);
+ g_list_free (ret);
+ goto out;
+ }
+ ret = g_list_prepend (ret, auth);
}
ret = g_list_reverse (ret);
g_variant_unref (array);
diff --git a/src/polkit/polkitprivate.h b/src/polkit/polkitprivate.h
index bdf03c1..579cc25 100644
--- a/src/polkit/polkitprivate.h
+++ b/src/polkit/polkitprivate.h
@@ -40,7 +40,8 @@ PolkitIdentity *polkit_identity_new_for_gvariant (GVariant *variant, GError **er
PolkitAuthorizationResult *polkit_authorization_result_new_for_gvariant (GVariant *value);
GVariant *polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result);
-PolkitTemporaryAuthorization *polkit_temporary_authorization_new_for_gvariant (GVariant *value);
+PolkitTemporaryAuthorization *polkit_temporary_authorization_new_for_gvariant (GVariant *value,
+ GError **error);
GVariant *polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization);
GVariant *polkit_details_to_gvariant (PolkitDetails *details);
diff --git a/src/polkit/polkittemporaryauthorization.c b/src/polkit/polkittemporaryauthorization.c
index d6e946b..71092b4 100644
--- a/src/polkit/polkittemporaryauthorization.c
+++ b/src/polkit/polkittemporaryauthorization.c
@@ -186,10 +186,31 @@ polkit_temporary_authorization_get_time_expires (PolkitTemporaryAuthorization *a
}
PolkitTemporaryAuthorization *
-polkit_temporary_authorization_new_for_gvariant (GVariant *value)
+polkit_temporary_authorization_new_for_gvariant (GVariant *value,
+ GError **error)
{
- g_assert_not_reached ();
- return NULL;
+ PolkitTemporaryAuthorization *authorization;
+ GVariant *subject_gvariant;
+
+ authorization = POLKIT_TEMPORARY_AUTHORIZATION (g_object_new (POLKIT_TYPE_TEMPORARY_AUTHORIZATION, NULL));
+ g_variant_get (value,
+ "(ss@(sa{sv})tt)",
+ &authorization->id,
+ &authorization->action_id,
+ &subject_gvariant,
+ &authorization->time_obtained,
+ &authorization->time_expires);
+ authorization->subject = polkit_subject_new_for_gvariant (subject_gvariant, error);
+ if (authorization->subject == NULL)
+ {
+ g_object_unref (authorization);
+ authorization = NULL;
+ goto out;
+ }
+
+ out:
+ g_variant_unref (subject_gvariant);
+ return authorization;
}
GVariant *
More information about the hal-commit
mailing list