</annotation>
- <!-- AuthorizationClaim struct -->
- <annotation name="org.gtk.EggDBus.DeclareStruct" value="AuthorizationClaim">
- <annotation name="org.gtk.EggDBus.Struct.Member" value="(sa{sv}):subject">
- <annotation name="org.gtk.EggDBus.DocString" value="Subject the claim is for"/>
- </annotation>
-
- <annotation name="org.gtk.EggDBus.Struct.Member" value="s:action_id">
- <annotation name="org.gtk.EggDBus.DocString" value="Action Identifier for the claim"/>
- </annotation>
- </annotation>
-
<!-- The error domain used for reporting errors -->
<annotation name="org.gtk.EggDBus.DeclareErrorDomain" value="Error">
<annotation name="org.gtk.EggDBus.ErrorDomain.Member" value="org.freedesktop.PolicyKit1.Error.Failed">
</annotation>
</annotation>
- <!-- An enumeration for results of CheckClaim() (TODO: implement this method) -->
+ <!-- An enumeration for results when checking for an authorization -->
<annotation name="org.gtk.EggDBus.DeclareEnum" value="AuthorizationResult">
<annotation name="org.gtk.EggDBus.Enum.Member" value="NotAuthorized">
<annotation name="org.gtk.EggDBus.DocString" value="The subject is not authorized for the specified action"/>
</annotation>
</annotation>
+ <!-- Flags used for checking authorizations -->
+ <annotation name="org.gtk.EggDBus.DeclareFlags" value="CheckAuthorizationFlags">
+ <annotation name="org.gtk.EggDBus.Flags.Member" value="AllowUserInteraction">
+ <annotation name="org.gtk.EggDBus.DocString" value="If the subject can obtain the authorization through authentication, and an authentication agent is available, then attempt to do so. Note, this means that the #CheckAuthorization() method is likely to block for a long time."/>
+ </annotation>
+ </annotation>
+
+ <!-- Authorization struct -->
+ <annotation name="org.gtk.EggDBus.DeclareStruct" value="Authorization">
+ <annotation name="org.gtk.EggDBus.Struct.Member" value="s:action_id">
+ <annotation name="org.gtk.EggDBus.DocString" value="Action Identifier for the authorization"/>
+ </annotation>
+
+ <annotation name="org.gtk.EggDBus.Struct.Member" value="a{sv}:attributes">
+ <annotation name="org.gtk.EggDBus.DocString" value="Attributes of the authorization"/>
+ </annotation>
+ </annotation>
<interface name="org.freedesktop.PolicyKit1.Authority">
</arg>
</method>
- <method name="CheckClaim">
- <arg name="claim" direction="in" type="((sa{sv})s)">
- <annotation name="org.gtk.EggDBus.StructType" value="AuthorizationClaim"/>
+ <method name="CheckAuthorization">
+ <arg name="subject" direction="in" type="(sa{sv})">
+ <annotation name="org.gtk.EggDBus.StructType" value="Subject"/>
+ </arg>
+ <arg name="action_id" direction="in" type="s"/>
+ <arg name="flags" direction="in" type="i">
+ <annotation name="org.gtk.EggDBus.FlagsType" value="CheckAuthorizationFlags"/>
</arg>
+
<arg name="result" direction="out" type="i">
<annotation name="org.gtk.EggDBus.EnumType" value="AuthorizationResult"/>
</arg>
</method>
+ <method name="GrantAuthorization">
+ <arg name="subject" direction="in" type="(sa{sv})">
+ <annotation name="org.gtk.EggDBus.StructType" value="Subject"/>
+ </arg>
+ <arg name="action_id" direction="in" type="s"/>
+ </method>
+
+ <method name="RevokeAuthorization">
+ <arg name="subject" direction="in" type="(sa{sv})">
+ <annotation name="org.gtk.EggDBus.StructType" value="Subject"/>
+ </arg>
+ <arg name="action_id" direction="in" type="s"/>
+ </method>
+
+ <method name="EnumerateAuthorizations">
+ <arg name="subject" direction="in" type="(sa{sv})">
+ <annotation name="org.gtk.EggDBus.StructType" value="Subject"/>
+ </arg>
+ <arg name="authorizations" direction="out" type="a(sa{sv})">
+ <annotation name="org.gtk.EggDBus.StructType" value="Authorization"/>
+ </arg>
+ </method>
+
+
</interface>
</node>
BUILT_SOURCES = \
_polkitactiondescription.c _polkitactiondescription.h \
_polkitauthority.c _polkitauthority.h \
- _polkitauthorizationclaim.c _polkitauthorizationclaim.h \
+ _polkitauthorization.c _polkitauthorization.h \
_polkitauthorizationresult.c _polkitauthorizationresult.h \
+ _polkitcheckauthorizationflags.c _polkitcheckauthorizationflags.h \
_polkitbindings.c _polkitbindings.h \
_polkitbindingsmarshal.c _polkitbindingsmarshal.h \
_polkitbindingstypes.h \
polkitunixprocess.h \
polkitunixsession.h \
polkitsystembusname.h \
- polkitauthorizationclaim.h \
polkitauthorizationresult.h \
+ polkitcheckauthorizationflags.h \
$(NULL)
libpolkit_gobject_1_la_SOURCES = \
polkitunixprocess.c polkitunixprocess.h \
polkitunixsession.c polkitunixsession.h \
polkitsystembusname.c polkitsystembusname.h \
- polkitauthorizationclaim.c polkitauthorizationclaim.h \
polkitauthorizationresult.c polkitauthorizationresult.h \
+ polkitcheckauthorizationflags.c polkitcheckauthorizationflags.h \
$(NULL)
libpolkit_gobject_1_la_CFLAGS = \
#include <polkit/polkitunixprocess.h>
#include <polkit/polkitunixsession.h>
#include <polkit/polkitsystembusname.h>
-#include <polkit/polkitauthorizationclaim.h>
#include <polkit/polkitauthorizationresult.h>
+#include <polkit/polkitcheckauthorizationflags.h>
#include <polkit/polkitauthority.h>
#undef _POLKIT_INSIDE_POLKIT_H
#endif
#include "polkitauthorizationresult.h"
+#include "polkitcheckauthorizationflags.h"
#include "polkitauthority.h"
#include "polkitprivate.h"
/* ---------------------------------------------------------------------------------------------------- */
static guint
-polkit_authority_check_claim_async (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+polkit_authority_check_authorization_async (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- _PolkitAuthorizationClaim *real_claim;
+ _PolkitSubject *real_subject;
guint call_id;
GSimpleAsyncResult *simple;
- real_claim = polkit_authorization_claim_get_real (claim);
+ real_subject = polkit_subject_get_real (subject);
simple = g_simple_async_result_new (G_OBJECT (authority),
callback,
user_data,
- polkit_authority_check_claim_async);
+ polkit_authority_check_authorization_async);
- g_object_set_data_full (G_OBJECT (simple), "claim", g_object_ref (claim), (GDestroyNotify) g_object_unref);
+ call_id = _polkit_authority_check_authorization (authority->real,
+ EGG_DBUS_CALL_FLAGS_NONE,
+ real_subject,
+ action_id,
+ flags,
+ cancellable,
+ generic_async_cb,
+ simple);
- call_id = _polkit_authority_check_claim (authority->real,
- EGG_DBUS_CALL_FLAGS_NONE,
- real_claim,
- cancellable,
- generic_async_cb,
- simple);
-
- g_object_unref (real_claim);
+ g_object_unref (real_subject);
return call_id;
}
void
-polkit_authority_check_claim (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+polkit_authority_check_authorization (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
- polkit_authority_check_claim_async (authority, claim, cancellable, callback, user_data);
+ polkit_authority_check_authorization_async (authority,
+ subject,
+ action_id,
+ flags,
+ cancellable,
+ callback,
+ user_data);
}
PolkitAuthorizationResult
-polkit_authority_check_claim_finish (PolkitAuthority *authority,
- GAsyncResult *res,
- GError **error)
+polkit_authority_check_authorization_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error)
{
_PolkitAuthorizationResult result;
GSimpleAsyncResult *simple;
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);
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_authority_check_authorization_async);
result = _POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
- if (!_polkit_authority_check_claim_finish (authority->real,
+ if (!_polkit_authority_check_authorization_finish (authority->real,
&result,
real_res,
error))
}
PolkitAuthorizationResult
-polkit_authority_check_claim_sync (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GError **error)
+polkit_authority_check_authorization_sync (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GError **error)
{
guint call_id;
GAsyncResult *res;
PolkitAuthorizationResult result;
- call_id = polkit_authority_check_claim_async (authority, claim, cancellable, generic_cb, &res);
+ call_id = polkit_authority_check_authorization_async (authority,
+ subject,
+ action_id,
+ flags,
+ cancellable,
+ generic_cb,
+ &res);
egg_dbus_connection_pending_call_block (authority->system_bus, call_id);
- result = polkit_authority_check_claim_finish (authority, res, error);
+ result = polkit_authority_check_authorization_finish (authority, res, error);
g_object_unref (res);
GCancellable *cancellable,
GError **error);
-PolkitAuthorizationResult polkit_authority_check_claim_sync (PolkitAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GCancellable *cancellable,
- GError **error);
+PolkitAuthorizationResult polkit_authority_check_authorization_sync (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GError **error);
/* ---------------------------------------------------------------------------------------------------- */
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);
+void polkit_authority_check_authorization (PolkitAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+PolkitAuthorizationResult polkit_authority_check_authorization_finish (PolkitAuthority *authority,
+ GAsyncResult *res,
+ GError **error);
/* ---------------------------------------------------------------------------------------------------- */
--- /dev/null
+/*
+ * 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 "polkitcheckauthorizationflags.h"
+#include "polkitprivate.h"
+
+GType
+polkit_check_authorization_flags_get_type (void)
+{
+ return _polkit_check_authorization_flags_get_type ();
+}
+
+
--- /dev/null
+/*
+ * 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_CHECK_AUTHORIZATION_FLAGS_H
+#define __POLKIT_CHECK_AUTHORIZATION_FLAGS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+GType polkit_check_authorization_flags_get_type (void) G_GNUC_CONST;
+
+#define POLKIT_TYPE_CHECK_AUTHORIZATION_FLAGS (polkit_check_authorization_flags_get_type ())
+
+/**
+ * PolkitCheckAuthorizationFlags:
+ * @POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE: No flags set.
+ * @POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION: If the subject can obtain the authorization
+ * through authentication, and an authentication agent is available, then attempt to do so. Note, this
+ * means that the method used for checking authorization is likely to block for a long time.
+ *
+ * Possible flags when checking authorizations.
+ */
+typedef enum
+{
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE = 0x0000, /*< nick=none >*/
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION = 0x0001,
+} PolkitCheckAuthorizationFlags;
+
+G_END_DECLS
+
+#endif /* __POLKIT_CHECK_AUTHORIZATION_FLAGS_H */
PolkitSubject *polkit_subject_new_for_real (_PolkitSubject *real);
_PolkitSubject *polkit_subject_get_real (PolkitSubject *subject);
+#if 0
PolkitAuthorizationClaim *polkit_authorization_claim_new_for_real (_PolkitAuthorizationClaim *real);
_PolkitAuthorizationClaim *polkit_authorization_claim_get_real (PolkitAuthorizationClaim *claim);
+#endif
#endif /* __POLKIT_PRIVATE_H */
}
void
-polkit_backend_authority_check_claim (PolkitBackendAuthority *authority,
- PolkitAuthorizationClaim *claim,
- PolkitBackendPendingCall *pending_call)
+polkit_backend_authority_check_authorization (PolkitBackendAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendAuthorityClass *klass;
klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority);
- klass->check_claim (authority, claim, pending_call);
+ klass->check_authorization (authority, subject, action_id, flags, pending_call);
}
void (*enumerate_sessions) (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
- void (*check_claim) (PolkitBackendAuthority *authority,
- PolkitAuthorizationClaim *claim,
- PolkitBackendPendingCall *pending_call);
+ void (*check_authorization) (PolkitBackendAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ PolkitBackendPendingCall *pending_call);
/*< private >*/
/* Padding for future expansion */
void polkit_backend_authority_enumerate_sessions (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
-void polkit_backend_authority_check_claim (PolkitBackendAuthority *authority,
- PolkitAuthorizationClaim *claim,
- PolkitBackendPendingCall *pending_call);
+void polkit_backend_authority_check_authorization (PolkitBackendAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ PolkitBackendPendingCall *pending_call);
/* --- */
void polkit_backend_authority_enumerate_sessions_finish (PolkitBackendPendingCall *pending_call,
GList *sessions);
-void polkit_backend_authority_check_claim_finish (PolkitBackendPendingCall *pending_call,
- PolkitAuthorizationResult result);
+void polkit_backend_authority_check_authorization_finish (PolkitBackendPendingCall *pending_call,
+ PolkitAuthorizationResult result);
G_END_DECLS
static void polkit_backend_local_authority_enumerate_sessions (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
-static void polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority,
- PolkitAuthorizationClaim *claim,
- PolkitBackendPendingCall *pending_call);
-
-static PolkitAuthorizationResult check_claim_sync (PolkitBackendAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GError **error);
+static void polkit_backend_local_authority_check_authorization (PolkitBackendAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ PolkitBackendPendingCall *pending_call);
+
+static PolkitAuthorizationResult check_authorization_sync (PolkitBackendAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GError **error);
G_DEFINE_TYPE (PolkitBackendLocalAuthority, polkit_backend_local_authority, POLKIT_BACKEND_TYPE_AUTHORITY);
authority_class->enumerate_users = polkit_backend_local_authority_enumerate_users;
authority_class->enumerate_groups = polkit_backend_local_authority_enumerate_groups;
authority_class->enumerate_sessions = polkit_backend_local_authority_enumerate_sessions;
- authority_class->check_claim = polkit_backend_local_authority_check_claim;
+ authority_class->check_authorization = polkit_backend_local_authority_check_authorization;
g_type_class_add_private (klass, sizeof (PolkitBackendLocalAuthorityPrivate));
}
/* ---------------------------------------------------------------------------------------------------- */
static void
-polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority,
- PolkitAuthorizationClaim *claim,
- PolkitBackendPendingCall *pending_call)
+polkit_backend_local_authority_check_authorization (PolkitBackendAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ PolkitBackendPendingCall *pending_call)
{
PolkitBackendLocalAuthority *local_authority;
PolkitBackendLocalAuthorityPrivate *priv;
PolkitSubject *inquirer;
- PolkitSubject *subject;
gchar *inquirer_str;
gchar *subject_str;
PolkitSubject *user_of_inquirer;
gchar *user_of_inquirer_str;
gchar *user_of_subject_str;
PolkitAuthorizationResult result;
- const gchar *action_id;
GError *error;
local_authority = POLKIT_BACKEND_LOCAL_AUTHORITY (authority);
error = NULL;
inquirer = NULL;
- subject = NULL;
inquirer_str = NULL;
subject_str = NULL;
user_of_inquirer = NULL;
user_of_subject_str = NULL;
inquirer = polkit_backend_pending_call_get_caller (pending_call);
- subject = polkit_authorization_claim_get_subject (claim);
- action_id = polkit_authorization_claim_get_action_id (claim);
inquirer_str = polkit_subject_to_string (inquirer);
subject_str = polkit_subject_to_string (subject);
*/
if (!polkit_subject_equal (user_of_inquirer, user_of_subject))
{
- PolkitAuthorizationClaim *read_claim;
-
- read_claim = polkit_authorization_claim_new (user_of_inquirer, "org.freedesktop.policykit.read");
- result = check_claim_sync (authority, read_claim, &error);
- g_object_unref (read_claim);
+ result = check_authorization_sync (authority,
+ user_of_inquirer,
+ "org.freedesktop.policykit.read",
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE, /* no user interaction */
+ &error);
if (error != NULL)
{
}
}
- result = check_claim_sync (authority, claim, &error);
+ result = check_authorization_sync (authority, subject, action_id, flags, &error);
if (error != NULL)
{
polkit_backend_pending_call_return_gerror (pending_call, error);
}
else
{
- polkit_backend_authority_check_claim_finish (pending_call, result);
+ polkit_backend_authority_check_authorization_finish (pending_call, result);
}
out:
/* ---------------------------------------------------------------------------------------------------- */
static PolkitAuthorizationResult
-check_claim_sync (PolkitBackendAuthority *authority,
- PolkitAuthorizationClaim *claim,
- GError **error)
+check_authorization_sync (PolkitBackendAuthority *authority,
+ PolkitSubject *subject,
+ const gchar *action_id,
+ PolkitCheckAuthorizationFlags flags,
+ GError **error)
{
PolkitBackendLocalAuthority *local_authority;
PolkitBackendLocalAuthorityPrivate *priv;
PolkitAuthorizationResult result;
- PolkitSubject *subject;
PolkitSubject *user_of_subject;
gchar *subject_str;
- const gchar *action_id;
local_authority = POLKIT_BACKEND_LOCAL_AUTHORITY (authority);
priv = POLKIT_BACKEND_LOCAL_AUTHORITY_GET_PRIVATE (local_authority);
user_of_subject = NULL;
subject_str = NULL;
- subject = polkit_authorization_claim_get_subject (claim);
- action_id = polkit_authorization_claim_get_action_id (claim);
-
subject_str = polkit_subject_to_string (subject);
g_debug ("checking whether %s is authorized for %s",
/* ---------------------------------------------------------------------------------------------------- */
static void
-authority_handle_check_claim (_PolkitAuthority *instance,
- _PolkitAuthorizationClaim *real_claim,
- EggDBusMethodInvocation *method_invocation)
+authority_handle_check_authorization (_PolkitAuthority *instance,
+ _PolkitSubject *real_subject,
+ const gchar *action_id,
+ _PolkitCheckAuthorizationFlags flags,
+ EggDBusMethodInvocation *method_invocation)
{
PolkitBackendServer *server = POLKIT_BACKEND_SERVER (instance);
PolkitBackendPendingCall *pending_call;
- PolkitAuthorizationClaim *claim;
+ PolkitSubject *subject;
pending_call = _polkit_backend_pending_call_new (method_invocation, server);
- claim = polkit_authorization_claim_new_for_real (real_claim);
+ subject = polkit_subject_new_for_real (real_subject);
- g_object_set_data_full (G_OBJECT (pending_call), "claim", claim, (GDestroyNotify) g_object_unref);
+ g_object_set_data_full (G_OBJECT (pending_call), "subject", subject, (GDestroyNotify) g_object_unref);
- polkit_backend_authority_check_claim (server->authority, claim, pending_call);
+ polkit_backend_authority_check_authorization (server->authority,
+ subject,
+ action_id,
+ flags,
+ pending_call);
}
void
-polkit_backend_authority_check_claim_finish (PolkitBackendPendingCall *pending_call,
- PolkitAuthorizationResult result)
+polkit_backend_authority_check_authorization_finish (PolkitBackendPendingCall *pending_call,
+ PolkitAuthorizationResult result)
{
- _polkit_authority_handle_check_claim_finish (_polkit_backend_pending_call_get_method_invocation (pending_call),
- result);
+ _polkit_authority_handle_check_authorization_finish (_polkit_backend_pending_call_get_method_invocation (pending_call),
+ result);
g_object_unref (pending_call);
}
authority_iface->handle_enumerate_users = authority_handle_enumerate_users;
authority_iface->handle_enumerate_groups = authority_handle_enumerate_groups;
authority_iface->handle_enumerate_sessions = authority_handle_enumerate_sessions;
- authority_iface->handle_check_claim = authority_handle_check_claim;
+ authority_iface->handle_check_authorization = authority_handle_check_authorization;
}
check (void)
{
PolkitAuthorizationResult result;
- PolkitAuthorizationClaim *claim;
GError *error;
error = NULL;
- claim = NULL;
result = POLKIT_AUTHORIZATION_RESULT_NOT_AUTHORIZED;
- claim = polkit_authorization_claim_new (subject,
- action_id);
-
- result = polkit_authority_check_claim_sync (authority,
- claim,
- NULL,
- &error);
+ result = polkit_authority_check_authorization_sync (authority,
+ subject,
+ action_id,
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
+ NULL,
+ &error);
if (error != NULL)
{
- g_printerr ("Error checking authorization claim: %s\n", error->message);
+ g_printerr ("Error checking authorization: %s\n", error->message);
g_error_free (error);
goto out;
}
out:
- if (claim != NULL)
- g_object_unref (claim);
return result == POLKIT_AUTHORIZATION_RESULT_AUTHORIZED;
}
typedef struct
{
- PolkitAuthorizationClaim *claim;
+ gchar *action_id;
PolkitAuthorizationResult result;
} AuthzData;
static void
authz_data_free (AuthzData *data)
{
- g_object_unref (data->claim);
+ g_free (data->action_id);
g_free (data);
}
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);
+ AuthzData *data_a;
+ AuthzData *data_b;
- aa = polkit_authorization_claim_get_action_id (da->claim);
- ab = polkit_authorization_claim_get_action_id (db->claim);
+ data_a = (AuthzData *) *((gpointer **) a);
+ data_b = (AuthzData *) *((gpointer **) b);
- return strcmp (aa, ab);
+ return strcmp (data_a->action_id, data_b->action_id);
}
static void
data = user_data;
error = NULL;
- result = polkit_authority_check_claim_finish (authority,
- res,
- &error);
+ result = polkit_authority_check_authorization_finish (authority,
+ res,
+ &error);
if (error != NULL)
{
- g_printerr ("Unable to check claim: %s\n", error->message);
+ g_printerr ("Unable to check authorization: %s\n", error->message);
g_error_free (error);
}
else
for (l = actions; l != NULL; l = l->next)
{
PolkitActionDescription *action = POLKIT_ACTION_DESCRIPTION (l->data);
- PolkitAuthorizationClaim *claim;
+ const gchar *action_id;
AuthzData *data;
- claim = polkit_authorization_claim_new (calling_process,
- polkit_action_description_get_action_id (action));
+ action_id = polkit_action_description_get_action_id (action);
data = g_new0 (AuthzData, 1);
- data->claim = g_object_ref (claim);
+ data->action_id = g_strdup (action_id);
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);
+ polkit_authority_check_authorization (authority,
+ calling_process,
+ action_id,
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
+ NULL,
+ list_authz_cb,
+ data);
}
g_main_loop_run (authz_data_loop);
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));
+ g_print ("%s\n", data->action_id);
}
out: