From: David Zeuthen Date: Sun, 18 Jan 2009 21:14:39 +0000 (-0500) Subject: rename CheckClaim() to CheckAuthorization() X-Git-Tag: 0.91~48^2~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4653150b07c83d9140893b115699bdc1c238ee1a;p=platform%2Fupstream%2Fpolkit.git rename CheckClaim() to CheckAuthorization() Also get rid of AuthorizationClaim type and add D-Bus prototypes for a couple of other methods. --- diff --git a/data/org.freedesktop.PolicyKit1.Authority.xml b/data/org.freedesktop.PolicyKit1.Authority.xml index 76f68d6..1523dbd 100644 --- a/data/org.freedesktop.PolicyKit1.Authority.xml +++ b/data/org.freedesktop.PolicyKit1.Authority.xml @@ -46,17 +46,6 @@ - - - - - - - - - - - @@ -70,7 +59,7 @@ - + @@ -83,6 +72,23 @@ + + + + + + + + + + + + + + + + + @@ -111,14 +117,43 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/polkit/Makefile.am b/src/polkit/Makefile.am index 3a62076..0dc1af7 100644 --- a/src/polkit/Makefile.am +++ b/src/polkit/Makefile.am @@ -18,8 +18,9 @@ INCLUDES = \ 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 \ @@ -49,8 +50,8 @@ libpolkit_gobject_1include_HEADERS = \ polkitunixprocess.h \ polkitunixsession.h \ polkitsystembusname.h \ - polkitauthorizationclaim.h \ polkitauthorizationresult.h \ + polkitcheckauthorizationflags.h \ $(NULL) libpolkit_gobject_1_la_SOURCES = \ @@ -65,8 +66,8 @@ 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 = \ diff --git a/src/polkit/polkit.h b/src/polkit/polkit.h index 40df617..d872d54 100644 --- a/src/polkit/polkit.h +++ b/src/polkit/polkit.h @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include #include #undef _POLKIT_INSIDE_POLKIT_H diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c index 1646467..60f5017 100644 --- a/src/polkit/polkitauthority.c +++ b/src/polkit/polkitauthority.c @@ -24,6 +24,7 @@ #endif #include "polkitauthorizationresult.h" +#include "polkitcheckauthorizationflags.h" #include "polkitauthority.h" #include "polkitprivate.h" @@ -519,51 +520,61 @@ polkit_authority_enumerate_sessions_sync (PolkitAuthority *authority, /* ---------------------------------------------------------------------------------------------------- */ 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; @@ -572,11 +583,11 @@ polkit_authority_check_claim_finish (PolkitAuthority *authority, 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)) @@ -588,20 +599,28 @@ polkit_authority_check_claim_finish (PolkitAuthority *authority, } 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); diff --git a/src/polkit/polkitauthority.h b/src/polkit/polkitauthority.h index 85b1a51..2b69a4e 100644 --- a/src/polkit/polkitauthority.h +++ b/src/polkit/polkitauthority.h @@ -63,10 +63,12 @@ GList *polkit_authority_enumerate_sessions_sync (PolkitAutho 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); /* ---------------------------------------------------------------------------------------------------- */ @@ -107,15 +109,17 @@ GList * polkit_authority_enumerate_sessions_finish (PolkitAut 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); /* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/polkit/polkitcheckauthorizationflags.c b/src/polkit/polkitcheckauthorizationflags.c new file mode 100644 index 0000000..f6e1e23 --- /dev/null +++ b/src/polkit/polkitcheckauthorizationflags.c @@ -0,0 +1,35 @@ +/* + * 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 + */ + +#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 (); +} + + diff --git a/src/polkit/polkitcheckauthorizationflags.h b/src/polkit/polkitcheckauthorizationflags.h new file mode 100644 index 0000000..8d284f5 --- /dev/null +++ b/src/polkit/polkitcheckauthorizationflags.h @@ -0,0 +1,50 @@ +/* + * 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 + */ + +#ifndef __POLKIT_CHECK_AUTHORIZATION_FLAGS_H +#define __POLKIT_CHECK_AUTHORIZATION_FLAGS_H + +#include + +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 */ diff --git a/src/polkit/polkitprivate.h b/src/polkit/polkitprivate.h index 6aca70e..526de6a 100644 --- a/src/polkit/polkitprivate.h +++ b/src/polkit/polkitprivate.h @@ -40,7 +40,9 @@ _PolkitActionDescription *polkit_action_description_get_real (PolkitActionDe 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 */ diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c index f00cfbe..8dfa873 100644 --- a/src/polkitbackend/polkitbackendauthority.c +++ b/src/polkitbackend/polkitbackendauthority.c @@ -84,13 +84,15 @@ polkit_backend_authority_enumerate_sessions (PolkitBackendAuthority *authority } 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); } diff --git a/src/polkitbackend/polkitbackendauthority.h b/src/polkitbackend/polkitbackendauthority.h index fd641b3..950e853 100644 --- a/src/polkitbackend/polkitbackendauthority.h +++ b/src/polkitbackend/polkitbackendauthority.h @@ -64,9 +64,11 @@ struct _PolkitBackendAuthorityClass 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 */ @@ -97,9 +99,11 @@ void polkit_backend_authority_enumerate_groups (PolkitBackendAuthor 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); /* --- */ @@ -115,8 +119,8 @@ void polkit_backend_authority_enumerate_groups_finish (PolkitBackendPendin 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 diff --git a/src/polkitbackend/polkitbackendlocalauthority.c b/src/polkitbackend/polkitbackendlocalauthority.c index f6fda0b..4452dd7 100644 --- a/src/polkitbackend/polkitbackendlocalauthority.c +++ b/src/polkitbackend/polkitbackendlocalauthority.c @@ -51,13 +51,17 @@ static void polkit_backend_local_authority_enumerate_groups (PolkitBackendAuth 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); @@ -111,7 +115,7 @@ polkit_backend_local_authority_class_init (PolkitBackendLocalAuthorityClass *kla 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)); } @@ -256,14 +260,15 @@ polkit_backend_local_authority_enumerate_sessions (PolkitBackendAuthority *aut /* ---------------------------------------------------------------------------------------------------- */ 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; @@ -271,7 +276,6 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority, 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); @@ -279,7 +283,6 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority, error = NULL; inquirer = NULL; - subject = NULL; inquirer_str = NULL; subject_str = NULL; user_of_inquirer = NULL; @@ -288,8 +291,6 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority, 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); @@ -330,11 +331,11 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority, */ 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) { @@ -354,7 +355,7 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority, } } - 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); @@ -362,7 +363,7 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority, } else { - polkit_backend_authority_check_claim_finish (pending_call, result); + polkit_backend_authority_check_authorization_finish (pending_call, result); } out: @@ -382,17 +383,17 @@ polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority, /* ---------------------------------------------------------------------------------------------------- */ 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); @@ -401,9 +402,6 @@ check_claim_sync (PolkitBackendAuthority *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", diff --git a/src/polkitbackend/polkitbackendserver.c b/src/polkitbackend/polkitbackendserver.c index 915873c..d7b455a 100644 --- a/src/polkitbackend/polkitbackendserver.c +++ b/src/polkitbackend/polkitbackendserver.c @@ -261,29 +261,35 @@ polkit_backend_authority_enumerate_sessions_finish (PolkitBackendPendingCall *pe /* ---------------------------------------------------------------------------------------------------- */ 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); } @@ -297,5 +303,5 @@ authority_iface_init (_PolkitAuthorityIface *authority_iface) 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; } diff --git a/src/programs/polkit.c b/src/programs/polkit.c index 2ad71f6..0bd8c7d 100644 --- a/src/programs/polkit.c +++ b/src/programs/polkit.c @@ -528,30 +528,25 @@ static gboolean 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; } @@ -561,7 +556,7 @@ check (void) typedef struct { - PolkitAuthorizationClaim *claim; + gchar *action_id; PolkitAuthorizationResult result; } AuthzData; @@ -574,7 +569,7 @@ static GMainLoop *authz_data_loop = NULL; static void authz_data_free (AuthzData *data) { - g_object_unref (data->claim); + g_free (data->action_id); g_free (data); } @@ -582,18 +577,13 @@ static gint 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 @@ -610,12 +600,12 @@ list_authz_cb (GObject *source_obj, 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 @@ -662,26 +652,25 @@ list_authorizations (void) 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); @@ -696,7 +685,7 @@ list_authorizations (void) 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: