}
/**
+ * kit_list_copy:
+ * @list: existing list
+ *
+ * Makes a copy of a list. It is not a deep copy.
+ *
+ * Returns: A copy of the new list or #NULL on OOM. Free with kit_list_free().
+ **/
+KitList *
+kit_list_copy (KitList *list)
+{
+ KitList *l;
+ KitList *j;
+
+ l = NULL;
+ for (j = list; j != NULL; j = j->next) {
+ /* TODO: prepend, then reverse */
+ l = kit_list_append (l, j->data);
+ if (l == NULL)
+ goto oom;
+ }
+
+ return l;
+oom:
+ kit_list_free (l);
+ return NULL;
+}
+
+/**
* kit_list_prepend:
* @list: existing list or #NULL to create a new list
* @data: data to prepend to the list
{
KitList *l;
KitList *auths;
+ KitList *auths_copy;
polkit_bool_t ret;
char *action_id;
if (auths == NULL)
goto out;
- for (l = auths; l != NULL; l = l->next) {
+ /* have to copy the list and ref the auths because the authdb
+ * may disappear from under us due to revoke_if_one_shot...
+ */
+ auths_copy = kit_list_copy (auths);
+ if (auths_copy == NULL)
+ goto out;
+ for (l = auths_copy; l != NULL; l = l->next)
+ polkit_authorization_ref ((PolKitAuthorization *) l->data);
+
+ kit_warning ("once...");
+
+ for (l = auths_copy; l != NULL; l = l->next) {
PolKitAuthorization *auth = l->data;
//kit_warning ("%d: action_id=%s uid=%d",
if (cb (authdb, auth, user_data)) {
ret = TRUE;
- goto out;
+ break;
}
}
+ for (l = auths_copy; l != NULL; l = l->next)
+ polkit_authorization_unref ((PolKitAuthorization *) l->data);
+ kit_list_free (auths_copy);
+
out:
return ret;
}
polkit_uint64_t caller_pid_start_time;
CheckData *cd = (CheckData *) user_data;
+ kit_warning ("check auth for caller");
ret = FALSE;
if (strcmp (polkit_authorization_get_action_id (auth), cd->action_id) != 0)
if (cd->revoke_if_one_shot) {
cd->error = NULL;
if (!polkit_authorization_db_revoke_entry (authdb, auth, &(cd->error))) {
- //kit_warning ("Cannot revoke one-shot auth: %s: %s",
+ //kit_warning ("Cannot revoke one-shot auth: %s: %s",
// polkit_error_get_error_name (cd->error),
// polkit_error_get_error_message (cd->error));
/* stop iterating */
ret = TRUE;
goto no_match;
}
+ /* revoked; now purge internal cache */
+ _polkit_authorization_db_invalidate_cache (authdb);
}
}
break;