Commit 36fc7a6d authored by David Zeuthen's avatar David Zeuthen

Add support for querying and revoking temporary authorizations

Also change how authentication agents are registered (take a Subject
instead of the session-id) and add convenience functions to
asynchronously construct a PolkitUnixSession object given a process id
(by querying ConsoleKit).
parent ae8ea087
......@@ -30,7 +30,7 @@
<!-- Identity struct -->
<annotation name="org.gtk.EggDBus.DeclareStruct" value="Identity">
<annotation name="org.gtk.EggDBus.DocString.Summary" value="Subjects"/>
<annotation name="org.gtk.EggDBus.DocString.Summary" value="Identities"/>
<annotation name="org.gtk.EggDBus.DocString" value="<para>This struct describes identities such as UNIX users and UNIX groups. It is typically used to check if a given process is authorized for an action.</para><para>The following kinds of identities are known:</para>
<formalpara><title>Unix User</title><para><literal>identity_kind</literal> should be set to <literal>unix-user</literal> with key <literal>uid</literal> (of type <literal>uint32</literal>).</para></formalpara>
<formalpara><title>Unix Group</title><para><literal>identity_kind</literal> should be set to <literal>unix-group</literal> with key <literal>gid</literal> (of type <literal>uint32</literal>).</para></formalpara>
......@@ -254,8 +254,9 @@
<method name="RegisterAuthenticationAgent">
<annotation name="org.gtk.EggDBus.DocString" value="<para>Register an authentication agent.</para><para>Note that current versions of PolicyKit will only work if @session_id is set to the empty string. In the future it might work for non-empty strings if the caller is sufficiently privileged.</para>"/>
<arg name="session_id" direction="in" type="s">
<annotation name="org.gtk.EggDBus.DocString" value="The session to register the authentication for or blank for the session the caller of the method is in."/>
<arg name="subject" direction="in" type="(sa{sv})">
<annotation name="org.gtk.EggDBus.Type" value="Subject"/>
<annotation name="org.gtk.EggDBus.DocString" value="The subject to register the authentication agent for, typically a session subject."/>
</arg>
<arg name="locale" direction="in" type="s">
......@@ -270,12 +271,13 @@
<method name="UnregisterAuthenticationAgent">
<annotation name="org.gtk.EggDBus.DocString" value="Unregister an authentication agent."/>
<arg name="session_id" direction="in" type="s">
<annotation name="org.gtk.EggDBus.DocString" value="The session identifier passed to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()."/>
<arg name="subject" direction="in" type="(sa{sv})">
<annotation name="org.gtk.EggDBus.Type" value="Subject"/>
<annotation name="org.gtk.EggDBus.DocString" value="The @subject passed to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()."/>
</arg>
<arg name="object_path" direction="in" type="s">
<annotation name="org.gtk.EggDBus.DocString" value="The object path of authentication agent object on the unique name of the caller."/>
<annotation name="org.gtk.EggDBus.DocString" value="The @object_path passed to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()."/>
</arg>
</method>
......@@ -292,6 +294,62 @@
</arg>
</method>
<!-- ---------------------------------------------------------------------------------------------------- -->
<!-- TemporaryAuthorization struct -->
<annotation name="org.gtk.EggDBus.DeclareStruct" value="TemporaryAuthorization">
<annotation name="org.gtk.EggDBus.DocString.Summary" value="Temporary Authorizations"/>
<annotation name="org.gtk.EggDBus.DocString" value="This struct describes a temporary authorization."/>
<annotation name="org.gtk.EggDBus.Struct.Member" value="String:id">
<annotation name="org.gtk.EggDBus.DocString" value="An opaque identifier for the temporary authorization."/>
</annotation>
<annotation name="org.gtk.EggDBus.Struct.Member" value="String:action_id">
<annotation name="org.gtk.EggDBus.DocString" value="The action the temporary authorization is for."/>
</annotation>
<annotation name="org.gtk.EggDBus.Struct.Member" value="Subject:subject">
<annotation name="org.gtk.EggDBus.Type" value="Subject"/>
<annotation name="org.gtk.EggDBus.DocString" value="The subject the temporary authorization is for."/>
</annotation>
<annotation name="org.gtk.EggDBus.Struct.Member" value="UInt64:time_obtained">
<annotation name="org.gtk.EggDBus.DocString" value="When the temporary authorization was obtained, in seconds since the Epoch Jan 1, 1970 0:00 UTC."/>
</annotation>
<annotation name="org.gtk.EggDBus.Struct.Member" value="UInt64:time_expires">
<annotation name="org.gtk.EggDBus.DocString" value="When the temporary authorization is set to expire, in seconds since the Epoch Jan 1, 1970 0:00 UTC."/>
</annotation>
</annotation>
<!-- ---------------------------------------------------------------------------------------------------- -->
<method name="EnumerateTemporaryAuthorizations">
<annotation name="org.gtk.EggDBus.DocString" value="Retrieves all temporary authorizations that applies to @subject."/>
<arg name="subject" direction="in" type="(sa{sv})">
<annotation name="org.gtk.EggDBus.Type" value="Subject"/>
<annotation name="org.gtk.EggDBus.DocString" value="The subject to get temporary authorizations for."/>
</arg>
<arg name="temporary_authorizations" direction="out" type="a(ss(sa{sv})tt)">
<annotation name="org.gtk.EggDBus.Type" value="Array<TemporaryAuthorization>"/>
<annotation name="org.gtk.EggDBus.DocString" value="An array of #TemporaryAuthorization structs."/>
</arg>
</method>
<method name="RevokeTemporaryAuthorizations">
<annotation name="org.gtk.EggDBus.DocString" value="Revokes all temporary authorizations that applies to @subject."/>
<arg name="subject" direction="in" type="(sa{sv})">
<annotation name="org.gtk.EggDBus.Type" value="Subject"/>
<annotation name="org.gtk.EggDBus.DocString" value="The subject to revoke temporary authorizations from."/>
</arg>
</method>
<!-- ---------------------------------------------------------------------------------------------------- -->
<signal name="Changed">
<annotation name="org.gtk.EggDBus.DocString" value="This signal is emitted when actions and/or authorizations change"/>
</signal>
......
......@@ -72,6 +72,7 @@
<xi:include href="xml/polkitdetails.xml"/>
<xi:include href="xml/polkiterror.xml"/>
<xi:include href="xml/polkitactiondescription.xml"/>
<xi:include href="xml/polkittemporaryauthorization.xml"/>
<chapter id="subjects">
<title>Subjects</title>
<xi:include href="xml/polkitsubject.xml"/>
......
......@@ -31,11 +31,17 @@ polkit_authority_unregister_authentication_agent
polkit_authority_unregister_authentication_agent_finish
polkit_authority_authentication_agent_response
polkit_authority_authentication_agent_response_finish
polkit_authority_enumerate_temporary_authorizations
polkit_authority_enumerate_temporary_authorizations_finish
polkit_authority_revoke_temporary_authorizations
polkit_authority_revoke_temporary_authorizations_finish
polkit_authority_check_authorization_sync
polkit_authority_enumerate_actions_sync
polkit_authority_register_authentication_agent_sync
polkit_authority_unregister_authentication_agent_sync
polkit_authority_authentication_agent_response_sync
polkit_authority_enumerate_temporary_authorizations_sync
polkit_authority_revoke_temporary_authorizations_sync
<SUBSECTION Standard>
PolkitAuthorityClass
POLKIT_AUTHORITY
......@@ -104,6 +110,9 @@ POLKIT_UNIX_GROUP_GET_CLASS
<FILE>polkitunixsession</FILE>
PolkitUnixSession
polkit_unix_session_new
polkit_unix_session_new_for_process
polkit_unix_session_new_for_process_finish
polkit_unix_session_new_for_process_sync
polkit_unix_session_get_session_id
polkit_unix_session_set_session_id
<SUBSECTION Standard>
......@@ -158,6 +167,9 @@ PolkitSubject
PolkitSubjectIface
polkit_subject_hash
polkit_subject_equal
polkit_subject_exists
polkit_subject_exists_finish
polkit_subject_exists_sync
polkit_subject_to_string
polkit_subject_from_string
<SUBSECTION Standard>
......@@ -252,6 +264,8 @@ polkit_backend_authority_unregister_authentication_agent
polkit_backend_authority_authentication_agent_response
polkit_backend_authority_enumerate_actions
polkit_backend_authority_system_bus_name_owner_changed
polkit_backend_authority_enumerate_temporary_authorizations
polkit_backend_authority_revoke_temporary_authorizations
polkit_backend_authority_get
polkit_backend_register_authority
<SUBSECTION Standard>
......@@ -420,3 +434,23 @@ POLKIT_AGENT_LISTENER_CLASS
POLKIT_AGENT_IS_LISTENER_CLASS
POLKIT_AGENT_LISTENER_GET_CLASS
</SECTION>
<SECTION>
<FILE>polkittemporaryauthorization</FILE>
<TITLE>PolkitTemporaryAuthorization</TITLE>
PolkitTemporaryAuthorization
PolkitTemporaryAuthorizationClass
polkit_temporary_authorization_get_id
polkit_temporary_authorization_get_action_id
polkit_temporary_authorization_get_subject
polkit_temporary_authorization_get_time_obtained
polkit_temporary_authorization_get_time_expires
<SUBSECTION Standard>
POLKIT_TEMPORARY_AUTHORIZATION
POLKIT_TEMPORARY_IS_AUTHORIZATION
POLKIT_TEMPORARY_TYPE_AUTHORIZATION
polkit_temporary_authorization_get_type
POLKIT_TEMPORARY_AUTHORIZATION_CLASS
POLKIT_TEMPORARY_IS_AUTHORIZATION_CLASS
POLKIT_TEMPORARY_AUTHORIZATION_GET_CLASS
</SECTION>
......@@ -12,6 +12,7 @@ polkit_unix_session_get_type
polkit_system_bus_name_get_type
polkit_error_get_type
polkit_authorization_result_get_type
polkit_temporary_authorization_get_type
polkit_backend_authority_get_type
polkit_backend_interactive_authority_get_type
......
......@@ -33,7 +33,7 @@ polkit-built-sources.stamp : Makefile.am $(top_srcdir)/data/org.freedesktop.Poli
# keep in sync with contents of polkit-built-sources.stamp (Thanks autotools)
#
polkit_built_sources = _polkitbindingsmarshal.c _polkitbindingsmarshal.h _polkitbindingsmarshal.list _polkitbindings.c _polkitbindings.h _polkitbindingstypes.h _polkitauthenticationagent.c _polkitauthenticationagent.h docbook-interface-org.freedesktop.PolicyKit1.AuthenticationAgent.xml _polkitauthority.c _polkitauthority.h docbook-interface-org.freedesktop.PolicyKit1.Authority.xml _polkiterror.c _polkiterror.h _polkitimplicitauthorization.c _polkitimplicitauthorization.h _polkitauthorizationresult.c _polkitauthorizationresult.h _polkitcheckauthorizationflags.c _polkitcheckauthorizationflags.h _polkitactiondescription.c _polkitactiondescription.h _polkitidentity.c _polkitidentity.h _polkitsubject.c _polkitsubject.h
polkit_built_sources = _polkitactiondescription.c _polkitactiondescription.h _polkitauthenticationagent.c _polkitauthenticationagent.h _polkitauthority.c _polkitauthority.h _polkitauthorizationresult.c _polkitauthorizationresult.h _polkitbindings.c _polkitbindings.h _polkitbindingsmarshal.c _polkitbindingsmarshal.h _polkitbindingstypes.h _polkitcheckauthorizationflags.c _polkitcheckauthorizationflags.h _polkiterror.c _polkiterror.h _polkitidentity.c _polkitidentity.h _polkitimplicitauthorization.c _polkitimplicitauthorization.h _polkitsubject.c _polkitsubject.h _polkittemporaryauthorization.c _polkittemporaryauthorization.h docbook-interface-org.freedesktop.PolicyKit1.AuthenticationAgent.xml docbook-interface-org.freedesktop.PolicyKit1.Authority.xml
lib_LTLIBRARIES=libpolkit-gobject-1.la
......@@ -57,6 +57,7 @@ libpolkit_gobject_1include_HEADERS = \
polkitauthorizationresult.h \
polkitcheckauthorizationflags.h \
polkitimplicitauthorization.h \
polkittemporaryauthorization.h \
$(NULL)
libpolkit_gobject_1_la_SOURCES = \
......@@ -77,6 +78,7 @@ libpolkit_gobject_1_la_SOURCES = \
polkitauthorizationresult.c polkitauthorizationresult.h \
polkitcheckauthorizationflags.c polkitcheckauthorizationflags.h \
polkitimplicitauthorization.c polkitimplicitauthorization.h \
polkittemporaryauthorization.c polkittemporaryauthorization.h \
$(NULL)
libpolkit_gobject_1_la_CFLAGS = \
......
......@@ -38,6 +38,7 @@
#include <polkit/polkitcheckauthorizationflags.h>
#include <polkit/polkitauthority.h>
#include <polkit/polkitdetails.h>
#include <polkit/polkittemporaryauthorization.h>
#undef _POLKIT_INSIDE_POLKIT_H
......
......@@ -33,7 +33,7 @@
/**
* SECTION:polkitactiondescription
* @title: PolkitActionDescription
* @short_description: Actions
* @short_description: Description of Actions
*
* Object used to encapsulate a registered action.
*/
......
This diff is collapsed.
......@@ -71,14 +71,14 @@ PolkitAuthorizationResult *polkit_authority_check_authorization_sync (PolkitAuth
GError **error);
gboolean polkit_authority_register_authentication_agent_sync (PolkitAuthority *authority,
const gchar *session_id,
PolkitSubject *subject,
const gchar *locale,
const gchar *object_path,
GCancellable *cancellable,
GError **error);
gboolean polkit_authority_unregister_authentication_agent_sync (PolkitAuthority *authority,
const gchar *session_id,
PolkitSubject *subject,
const gchar *object_path,
GCancellable *cancellable,
GError **error);
......@@ -89,6 +89,16 @@ gboolean polkit_authority_authentication_agent_response_sync (
GCancellable *cancellable,
GError **error);
GList *polkit_authority_enumerate_temporary_authorizations_sync (PolkitAuthority *authority,
PolkitSubject *subject,
GCancellable *cancellable,
GError **error);
gboolean polkit_authority_revoke_temporary_authorizations_sync (PolkitAuthority *authority,
PolkitSubject *subject,
GCancellable *cancellable,
GError **error);
/* ---------------------------------------------------------------------------------------------------- */
void polkit_authority_enumerate_actions (PolkitAuthority *authority,
......@@ -114,7 +124,7 @@ PolkitAuthorizationResult *polkit_authority_check_authorization_finish (PolkitAu
GError **error);
void polkit_authority_register_authentication_agent (PolkitAuthority *authority,
const gchar *session_id,
PolkitSubject *subject,
const gchar *locale,
const gchar *object_path,
GCancellable *cancellable,
......@@ -126,7 +136,7 @@ gboolean polkit_authority_register_authentication_agent_finish
GError **error);
void polkit_authority_unregister_authentication_agent (PolkitAuthority *authority,
const gchar *session_id,
PolkitSubject *subject,
const gchar *object_path,
GCancellable *cancellable,
GAsyncReadyCallback callback,
......@@ -147,6 +157,26 @@ gboolean polkit_authority_authentication_agent_response_finish
GAsyncResult *res,
GError **error);
void polkit_authority_enumerate_temporary_authorizations (PolkitAuthority *authority,
PolkitSubject *subject,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GList *polkit_authority_enumerate_temporary_authorizations_finish (PolkitAuthority *authority,
GAsyncResult *res,
GError **error);
void polkit_authority_revoke_temporary_authorizations (PolkitAuthority *authority,
PolkitSubject *subject,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean polkit_authority_revoke_temporary_authorizations_finish (PolkitAuthority *authority,
GAsyncResult *res,
GError **error);
/* ---------------------------------------------------------------------------------------------------- */
G_END_DECLS
......
......@@ -26,6 +26,7 @@
#include "polkitactiondescription.h"
#include "polkitsubject.h"
#include "polkitauthorizationresult.h"
#include "polkittemporaryauthorization.h"
#include "_polkitbindings.h"
/* notes:
......@@ -47,6 +48,8 @@ _PolkitIdentity *polkit_identity_get_real (PolkitIdentity *identity);
PolkitAuthorizationResult *polkit_authorization_result_new_for_real (_PolkitAuthorizationResult *real);
_PolkitAuthorizationResult *polkit_authorization_result_get_real (PolkitAuthorizationResult *authorization_result);
_PolkitTemporaryAuthorization *polkit_temporary_authorization_get_real (PolkitTemporaryAuthorization *authorization);
PolkitTemporaryAuthorization *polkit_temporary_authorization_new_for_real (_PolkitTemporaryAuthorization *real);
PolkitDetails *polkit_details_new_for_hash (GHashTable *hash);
GHashTable *polkit_details_get_hash (PolkitDetails *details);
......
......@@ -125,6 +125,74 @@ polkit_subject_to_string (PolkitSubject *subject)
return POLKIT_SUBJECT_GET_IFACE (subject)->to_string (subject);
}
/**
* polkit_subject_exists:
* @subject: A #PolkitSubject.
* @cancellable: A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied
* @user_data: The data to pass to @callback.
*
* Asynchronously checks if @subject exists.
*
* When the operation is finished, @callback will be invoked. You can
* then call polkit_subject_exists_finish() to get the result of the
* operation.
**/
void
polkit_subject_exists (PolkitSubject *subject,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
POLKIT_SUBJECT_GET_IFACE (subject)->exists (subject,
cancellable,
callback,
user_data);
}
/**
* polkit_subject_exists_finish:
* @subject: A #PolkitSubject.
* @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to polkit_subject_exists().
* @error: Return location for error or %NULL.
*
* Finishes checking whether a subject exists.
*
* Returns: %TRUE if the subject exists, %FALSE if not or @error is set.
*/
gboolean
polkit_subject_exists_finish (PolkitSubject *subject,
GAsyncResult *res,
GError **error)
{
return POLKIT_SUBJECT_GET_IFACE (subject)->exists_finish (subject,
res,
error);
}
/**
* polkit_subject_exists_sync:
* @subject: A #PolkitSubject.
* @cancellable: A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
*
* Checks if @subject exists.
*
* This is a synchronous blocking call, see polkit_subject_exists()
* for the asynchronous version.
*
* Returns: %TRUE if the subject exists, %FALSE if not or @error is set.
*/
gboolean
polkit_subject_exists_sync (PolkitSubject *subject,
GCancellable *cancellable,
GError **error)
{
return POLKIT_SUBJECT_GET_IFACE (subject)->exists_sync (subject,
cancellable,
error);
}
/**
* polkit_subject_from_string:
* @str: A string obtained from polkit_subject_to_string().
......
......@@ -54,6 +54,9 @@ typedef struct _PolkitSubjectIface PolkitSubjectIface;
* @equal: Checks if two #PolkitSubject<!-- -->s are equal.
* @to_string: Serializes a #PolkitSubject to a string that can be
* used in polkit_subject_from_string().
* @exists: Asynchronously check if a #PolkitSubject exists.
* @exists_finish: Finishes checking if a #PolkitSubject exists.
* @exists_sync: Synchronously check if a #PolkitSubject exists.
*
* An interface for subjects.
*/
......@@ -61,21 +64,44 @@ struct _PolkitSubjectIface
{
GTypeInterface parent_iface;
guint (*hash) (PolkitSubject *subject);
guint (*hash) (PolkitSubject *subject);
gboolean (*equal) (PolkitSubject *a,
PolkitSubject *b);
gboolean (*equal) (PolkitSubject *a,
PolkitSubject *b);
gchar * (*to_string) (PolkitSubject *subject);
gchar * (*to_string) (PolkitSubject *subject);
void (*exists) (PolkitSubject *subject,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*exists_finish) (PolkitSubject *subject,
GAsyncResult *res,
GError **error);
gboolean (*exists_sync) (PolkitSubject *subject,
GCancellable *cancellable,
GError **error);
};
GType polkit_subject_get_type (void) G_GNUC_CONST;
guint polkit_subject_hash (PolkitSubject *subject);
gboolean polkit_subject_equal (PolkitSubject *a,
PolkitSubject *b);
gchar *polkit_subject_to_string (PolkitSubject *subject);
PolkitSubject *polkit_subject_from_string (const gchar *str,
GError **error);
GType polkit_subject_get_type (void) G_GNUC_CONST;
guint polkit_subject_hash (PolkitSubject *subject);
gboolean polkit_subject_equal (PolkitSubject *a,
PolkitSubject *b);
gchar *polkit_subject_to_string (PolkitSubject *subject);
PolkitSubject *polkit_subject_from_string (const gchar *str,
GError **error);
void polkit_subject_exists (PolkitSubject *subject,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean polkit_subject_exists_finish (PolkitSubject *subject,
GAsyncResult *res,
GError **error);
gboolean polkit_subject_exists_sync (PolkitSubject *subject,
GCancellable *cancellable,
GError **error);
G_END_DECLS
......
......@@ -224,10 +224,158 @@ polkit_system_bus_name_to_string (PolkitSubject *subject)
return g_strdup_printf ("system-bus-name:%s", system_bus_name->name);
}
static void
name_exists_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
EggDBusMessage *reply;
GError *error;
error = NULL;
reply = egg_dbus_connection_send_message_with_reply_finish (EGG_DBUS_CONNECTION (source_object),
res,
&error);
if (reply != NULL)
{
gboolean has_owner;
if (egg_dbus_message_extract_boolean (reply, &has_owner, &error))
{
g_simple_async_result_set_op_res_gboolean (simple, has_owner);
}
g_object_unref (reply);
}
if (error != NULL)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
static void
polkit_system_bus_name_exists (PolkitSubject *subject,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
PolkitSystemBusName *name = POLKIT_SYSTEM_BUS_NAME (subject);
EggDBusMessage *message;
EggDBusConnection *connection;
GSimpleAsyncResult *simple;
message = NULL;
connection = NULL;
connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
message = egg_dbus_connection_new_message_for_method_call (connection,
NULL,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"NameHasOwner");
egg_dbus_message_append_string (message, name->name, NULL);
simple = g_simple_async_result_new (G_OBJECT (name),
callback,
user_data,
polkit_system_bus_name_exists);
egg_dbus_connection_send_message_with_reply (connection,
EGG_DBUS_CALL_FLAGS_NONE,
message,
NULL,
cancellable,
name_exists_cb,
simple);
g_object_unref (message);
g_object_unref (connection);
}
static gboolean
polkit_system_bus_name_exists_sync (PolkitSubject *subject,
GCancellable *cancellable,
GError **error)
{
PolkitSystemBusName *name = POLKIT_SYSTEM_BUS_NAME (subject);
EggDBusMessage *message;
EggDBusMessage *reply;
EggDBusConnection *connection;
gboolean ret;
message = NULL;
reply = NULL;
connection = NULL;
ret = FALSE;
connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
message = egg_dbus_connection_new_message_for_method_call (connection,
NULL,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"NameHasOwner");
egg_dbus_message_append_string (message, name->name, NULL);
reply = egg_dbus_connection_send_message_with_reply_sync (connection,
EGG_DBUS_CALL_FLAGS_NONE,
message,
NULL,
cancellable,
error);
if (reply == NULL)
goto out;
if (!egg_dbus_message_extract_boolean (reply, &ret, error))
goto out;
out:
if (message != NULL)
g_object_unref (message);
if (reply != NULL)
g_object_unref (reply);
if (connection != NULL)
g_object_unref (connection);
return ret;
}
static gboolean
polkit_system_bus_name_exists_finish (PolkitSubject *subject,
GAsyncResult *res,
GError **error)
{
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
gboolean ret;
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == polkit_system_bus_name_exists);
ret = FALSE;
if (g_simple_async_result_propagate_error (simple, error))
goto out;
ret = g_simple_async_result_get_op_res_gboolean (simple);
out:
return ret;
}
static void
subject_iface_init (PolkitSubjectIface *subject_iface)
{
subject_iface->hash = polkit_system_bus_name_hash;
subject_iface->equal = polkit_system_bus_name_equal;
subject_iface->to_string = polkit_system_bus_name_to_string;
subject_iface->hash = polkit_system_bus_name_hash;
subject_iface->equal = polkit_system_bus_name_equal;
subject_iface->to_string = polkit_system_bus_name_to_string;
subject_iface->exists = polkit_system_bus_name_exists;
subject_iface->exists_finish = polkit_system_bus_name_exists_finish;
subject_iface->exists_sync = polkit_system_bus_name_exists_sync;
}
/*
* 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 <string.h>
#include "polkitimplicitauthorization.h"
#include "polkittemporaryauthorization.h"
#include "_polkittemporaryauthorization.h"
#include "polkitprivate.h"
/**
* SECTION:polkittemporaryauthorization
* @title: PolkitTemporaryAuthorization
* @short_description: Temporary Authorizations
*
* Object used to describe a temporary authorization.
*/
/**
* PolkitTemporaryAuthorization:
*
* The #PolkitTemporaryAuthorization struct should not be accessed directly.
*/
struct _PolkitTemporaryAuthorization
{
GObject parent_instance;
_PolkitTemporaryAuthorization *real;
gchar **annotation_keys;
};
struct _PolkitTemporaryAuthorizationClass
{
GObjectClass parent_class;
};
G_DEFINE_TYPE (PolkitTemporaryAuthorization, polkit_temporary_authorization, G_TYPE_OBJECT);
static void
polkit_temporary_authorization_init (PolkitTemporaryAuthorization *authorization)
{
}
static void
polkit_temporary_authorization_finalize (GObject *object)
{
PolkitTemporaryAuthorization *authorization;
authorization = POLKIT_TEMPORARY_AUTHORIZATION (object);
g_object_unref (authorization->real);
if (G_OBJECT_CLASS (polkit_temporary_authorization_parent_class)->finalize != NULL)
G_OBJECT_CLASS (polkit_temporary_authorization_parent_class)->finalize (object);
}
static void
polkit_temporary_authorization_class_init (PolkitTemporaryAuthorizationClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = polkit_temporary_authorization_finalize;
}
/**
* polkit_temporary_authorization_new:
* @id: Id for temporary authorization
* @action_id: An action id.
* @subject: A #PolkitSubject.
* @time_obtained: Time obtained, since the Epoch Jan 1, 1970 0:00 UTC.
* @time_expires: Time the temporary authorization will expire, since the Epoch Jan 1, 1970 0:00 UTC.
*
* Creates a new temporary authorization.
*
* Returns: A #PolkitTemporaryAuthorization, free with g_object_unref()
**/