PolicyKit: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Sun Apr 15 20:37:29 PDT 2007


 libpolkit/libpolkit-context.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

New commits:
diff-tree 9e492bfb815dd352c23578a62caf6cd9ea0b112b (from 81401e166e69287f33f568ca06a959662b01d068)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun Apr 15 23:37:29 2007 -0400

    add some validation to public facing functions

diff --git a/libpolkit/libpolkit-context.c b/libpolkit/libpolkit-context.c
index 49f70f4..de9aad8 100644
--- a/libpolkit/libpolkit-context.c
+++ b/libpolkit/libpolkit-context.c
@@ -497,7 +497,7 @@ libpolkit_context_is_resource_associated
  * libpolkit_context_can_session_access_resource:
  * @pk_context: the PolicyKit context
  * @action: the type of access to check for
- * @resource: the resource in question
+ * @resource: the resource in question or #NULL to test for all resources
  * @session: the session in question
  *
  * Determine if a given session can access a given resource in a given way.
@@ -519,11 +519,22 @@ libpolkit_context_can_session_access_res
         GSList *i;
 
         current_result = LIBPOLKIT_RESULT_NO;
+        g_return_val_if_fail (pk_context != NULL, current_result);
 
         /* resource may actually by NULL */
         if (action == NULL || session == NULL)
                 goto out;
 
+
+        /* now validate the incoming objects */
+        if (!libpolkit_action_validate (action))
+                goto out;
+        if (resource == NULL)
+                if (!libpolkit_resource_validate (resource))
+                        goto out;
+        if (!libpolkit_session_validate (session))
+                goto out;
+
         cache = libpolkit_context_get_policy_cache (pk_context);
         if (cache == NULL)
                 goto out;
@@ -624,7 +635,7 @@ out:
  * libpolkit_context_can_caller_access_resource:
  * @pk_context: the PolicyKit context
  * @action: the type of access to check for
- * @resource: the resource in question
+ * @resource: the resource in question or #NULL to test for all resources
  * @caller: the resource in question
  *
  * Determine if a given caller can access a given resource in a given way.
@@ -645,6 +656,7 @@ libpolkit_context_can_caller_access_reso
         GSList *i;
 
         current_result = LIBPOLKIT_RESULT_NO;
+        g_return_val_if_fail (pk_context != NULL, current_result);
 
         /* resource may actually by NULL */
         if (action == NULL || caller == NULL)
@@ -654,6 +666,15 @@ libpolkit_context_can_caller_access_reso
         if (cache == NULL)
                 goto out;
 
+        /* now validate the incoming objects */
+        if (!libpolkit_action_validate (action))
+                goto out;
+        if (resource == NULL)
+                if (!libpolkit_resource_validate (resource))
+                        goto out;
+        if (!libpolkit_caller_validate (caller))
+                goto out;
+
         _pk_debug ("entering libpolkit_can_caller_access_resource()");
         libpolkit_action_debug (action);
         if (resource != NULL)


More information about the hal-commit mailing list