diff options
author | David Zeuthen <davidz@redhat.com> | 2009-09-16 11:47:34 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2009-09-16 11:47:34 -0400 |
commit | 49de132d4ed313926f7e7f92da22cd6a3e50da18 (patch) | |
tree | c81fb937f9a9dfa12aaffa6f637a617fb7925879 | |
parent | 50385761decb0a5a79c6cdc975b427c5918d7de3 (diff) | |
download | polkit-49de132d4ed313926f7e7f92da22cd6a3e50da18.tar.gz |
Add properties with information about the currently used authority
Also bump requirement on EggDBus to 0.6 (to be released later) for a
bug-fix with flag properties.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | data/org.freedesktop.PolicyKit1.Authority.xml | 31 | ||||
-rw-r--r-- | docs/polkit/polkit-1-sections.txt | 7 | ||||
-rw-r--r-- | src/nullbackend/polkitbackendnullauthority.c | 21 | ||||
-rw-r--r-- | src/polkit/Makefile.am | 6 | ||||
-rw-r--r-- | src/polkit/polkit.h | 1 | ||||
-rw-r--r-- | src/polkit/polkitauthority.c | 139 | ||||
-rw-r--r-- | src/polkit/polkitauthority.h | 5 | ||||
-rw-r--r-- | src/polkit/polkitauthorityfeatures.c | 29 | ||||
-rw-r--r-- | src/polkit/polkitauthorityfeatures.h | 51 | ||||
-rw-r--r-- | src/polkit/polkitcheckauthorizationflags.h | 4 | ||||
-rw-r--r-- | src/polkitbackend/polkitbackendauthority.c | 94 | ||||
-rw-r--r-- | src/polkitbackend/polkitbackendauthority.h | 8 | ||||
-rw-r--r-- | src/polkitbackend/polkitbackendinteractiveauthority.c | 21 | ||||
-rw-r--r-- | src/polkitbackend/polkitbackendlocalauthority.c | 23 |
15 files changed, 436 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index f3fe83a..7d42ac0 100644 --- a/configure.ac +++ b/configure.ac @@ -124,7 +124,7 @@ PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.21.4 gio-2.0 >= 2.21.4]) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) -PKG_CHECK_MODULES(EGG_DBUS, [eggdbus-1 >= 0.5]) +PKG_CHECK_MODULES(EGG_DBUS, [eggdbus-1 >= 0.6]) AC_SUBST(EGG_DBUS_CFLAGS) AC_SUBST(EGG_DBUS_LIBS) diff --git a/data/org.freedesktop.PolicyKit1.Authority.xml b/data/org.freedesktop.PolicyKit1.Authority.xml index e71dc20..188f8e1 100644 --- a/data/org.freedesktop.PolicyKit1.Authority.xml +++ b/data/org.freedesktop.PolicyKit1.Authority.xml @@ -195,6 +195,37 @@ <!-- ---------------------------------------------------------------------------------------------------- --> + <!-- Flags describing what features the Authority implementation supports --> + <annotation name="org.gtk.EggDBus.DeclareFlags" value="AuthorityFeatures"> + <annotation name="org.gtk.EggDBus.DocString.Summary" value="Authority Features"/> + <annotation name="org.gtk.EggDBus.DocString" value="Flags describing features supported by the Authority implementation."/> + + <annotation name="org.gtk.EggDBus.Flags.Member" value="TemporaryAuthorization"> + <annotation name="org.gtk.EggDBus.DocString" value="The authority supports temporary authorizations that can be obtained through authentication."/> + </annotation> + + <annotation name="org.gtk.EggDBus.Flags.Member" value="Lockdown"> + <annotation name="org.gtk.EggDBus.DocString" value="The authority supports the XXX method."/> + </annotation> + </annotation> + + <!-- ---------------------------------------------------------------------------------------------------- --> + + <property name="BackendName" type="s" access="read"> + <annotation name="org.gtk.EggDBus.DocString" value="The name of the currently used Authority backend."/> + </property> + + <property name="BackendVersion" type="s" access="read"> + <annotation name="org.gtk.EggDBus.DocString" value="The version of the currently used Authority backend."/> + </property> + + <property name="BackendFeatures" type="u" access="read"> + <annotation name="org.gtk.EggDBus.Type" value="AuthorityFeatures"/> + <annotation name="org.gtk.EggDBus.DocString" value="The features supported by the currently used Authority backend."/> + </property> + + <!-- ---------------------------------------------------------------------------------------------------- --> + <method name="EnumerateActions"> <annotation name="org.gtk.EggDBus.DocString" value="Enumerates all registered PolicyKit actions."/> diff --git a/docs/polkit/polkit-1-sections.txt b/docs/polkit/polkit-1-sections.txt index f5bc3a8..6c2be93 100644 --- a/docs/polkit/polkit-1-sections.txt +++ b/docs/polkit/polkit-1-sections.txt @@ -19,8 +19,12 @@ POLKIT_UNIX_USER_GET_CLASS <SECTION> <FILE>polkitauthority</FILE> PolkitAuthority +PolkitAuthorityFeatures PolkitCheckAuthorizationFlags polkit_authority_get +polkit_authority_get_backend_name +polkit_authority_get_backend_version +polkit_authority_get_backend_features polkit_authority_check_authorization polkit_authority_check_authorization_finish polkit_authority_enumerate_actions @@ -265,6 +269,9 @@ POLKIT_DETAILS_GET_CLASS POLKIT_BACKEND_AUTHORITY_EXTENSION_POINT_NAME PolkitBackendAuthority PolkitBackendAuthorityClass +polkit_backend_authority_get_name +polkit_backend_authority_get_version +polkit_backend_authority_get_features polkit_backend_authority_check_authorization polkit_backend_authority_check_authorization_finish polkit_backend_authority_register_authentication_agent diff --git a/src/nullbackend/polkitbackendnullauthority.c b/src/nullbackend/polkitbackendnullauthority.c index ae91331..9451b14 100644 --- a/src/nullbackend/polkitbackendnullauthority.c +++ b/src/nullbackend/polkitbackendnullauthority.c @@ -72,6 +72,24 @@ polkit_backend_null_authority_finalize (GObject *object) G_OBJECT_CLASS (polkit_backend_null_authority_parent_class)->finalize (object); } +static const gchar * +authority_get_name (PolkitBackendAuthority *authority) +{ + return "null"; +} + +static const gchar * +authority_get_version (PolkitBackendAuthority *authority) +{ + return PACKAGE_VERSION; +} + +static PolkitAuthorityFeatures +authority_get_features (PolkitBackendAuthority *authority) +{ + return POLKIT_AUTHORITY_FEATURES_NONE; +} + static void polkit_backend_null_authority_class_init (PolkitBackendNullAuthorityClass *klass) { @@ -83,6 +101,9 @@ polkit_backend_null_authority_class_init (PolkitBackendNullAuthorityClass *klass gobject_class->finalize = polkit_backend_null_authority_finalize; + authority_class->get_name = authority_get_name; + authority_class->get_version = authority_get_version; + authority_class->get_features = authority_get_features; authority_class->enumerate_actions = authority_enumerate_actions; authority_class->check_authorization = authority_check_authorization; authority_class->check_authorization_finish = authority_check_authorization_finish; diff --git a/src/polkit/Makefile.am b/src/polkit/Makefile.am index bc119b2..ad345db 100644 --- a/src/polkit/Makefile.am +++ b/src/polkit/Makefile.am @@ -20,7 +20,7 @@ BUILT_SOURCES = \ polkitenumtypes.c polkitenumtypes.h \ $(NULL) -enum_headers = polkitcheckauthorizationflags.h polkiterror.h polkitimplicitauthorization.h +enum_headers = polkitcheckauthorizationflags.h polkiterror.h polkitimplicitauthorization.h polkitauthorityfeatures.h polkitenumtypes.h: $(enum_headers) polkitenumtypes.h.template ( top_builddir=`cd $(top_builddir) && pwd`; \ @@ -46,7 +46,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 = _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 _polkitbindingsmarshal.list +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 _polkitbindingsmarshal.list _polkitauthorityfeatures.h _polkitauthorityfeatures.c noinst_LTLIBRARIES = libpolkit-private.la @@ -73,6 +73,7 @@ libpolkit_gobject_1include_HEADERS = \ polkittypes.h \ polkitenumtypes.h \ polkitactiondescription.h \ + polkitauthorityfeatures.h \ polkitdetails.h \ polkitauthority.h \ polkiterror.h \ @@ -93,6 +94,7 @@ libpolkit_gobject_1_la_SOURCES = \ $(BUILT_SOURCES) \ polkit.h \ polkitactiondescription.c polkitactiondescription.h \ + polkitauthorityfeatures.h polkitauthorityfeatures.c \ polkitdetails.c polkitdetails.h \ polkitauthority.c polkitauthority.h \ polkiterror.c polkiterror.h \ diff --git a/src/polkit/polkit.h b/src/polkit/polkit.h index c878194..5e5fc66 100644 --- a/src/polkit/polkit.h +++ b/src/polkit/polkit.h @@ -28,6 +28,7 @@ #include <polkit/polkitenumtypes.h> #include <polkit/polkitimplicitauthorization.h> #include <polkit/polkitactiondescription.h> +#include <polkit/polkitauthorityfeatures.h> #include <polkit/polkiterror.h> #include <polkit/polkitidentity.h> #include <polkit/polkitunixuser.h> diff --git a/src/polkit/polkitauthority.c b/src/polkit/polkitauthority.c index 7d2c235..5792a5f 100644 --- a/src/polkit/polkitauthority.c +++ b/src/polkit/polkitauthority.c @@ -27,6 +27,7 @@ #include "polkitcheckauthorizationflags.h" #include "polkitauthority.h" #include "polkiterror.h" +#include "polkitenumtypes.h" #include "polkitprivate.h" @@ -62,6 +63,8 @@ struct _PolkitAuthority EggDBusObjectProxy *authority_object_proxy; _PolkitAuthority *real; + gchar *name; + gchar *version; guint cancellation_id_counter; }; @@ -82,6 +85,14 @@ enum LAST_SIGNAL, }; +enum +{ + PROP_0, + PROP_BACKEND_NAME, + PROP_BACKEND_VERSION, + PROP_BACKEND_FEATURES +}; + static guint signals[LAST_SIGNAL] = {0}; G_DEFINE_TYPE (PolkitAuthority, polkit_authority, G_TYPE_OBJECT); @@ -121,6 +132,8 @@ polkit_authority_finalize (GObject *object) g_object_unref (authority->authority_object_proxy); g_object_unref (authority->system_bus); + g_free (authority->name); + g_free (authority->version); the_authority = NULL; @@ -129,11 +142,89 @@ polkit_authority_finalize (GObject *object) } static void +polkit_authority_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + PolkitAuthority *authority = POLKIT_AUTHORITY (object); + + switch (prop_id) + { + case PROP_BACKEND_NAME: + g_value_set_string (value, polkit_authority_get_backend_name (authority)); + break; + + case PROP_BACKEND_VERSION: + g_value_set_string (value, polkit_authority_get_backend_version (authority)); + break; + + case PROP_BACKEND_FEATURES: + g_value_set_flags (value, polkit_authority_get_backend_features (authority)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void polkit_authority_class_init (PolkitAuthorityClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = polkit_authority_finalize; + gobject_class->finalize = polkit_authority_finalize; + gobject_class->get_property = polkit_authority_get_property; + + /** + * PolkitAuthority:backend-name: + * + * The name of the currently used Authority backend. + */ + g_object_class_install_property (gobject_class, + PROP_BACKEND_NAME, + g_param_spec_string ("backend-name", + "Backend name", + "The name of the currently used Authority backend.", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + /** + * PolkitAuthority:version: + * + * The version of the currently used Authority backend. + */ + g_object_class_install_property (gobject_class, + PROP_BACKEND_VERSION, + g_param_spec_string ("backend-version", + "Backend version", + "The version of the currently used Authority backend.", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + + /** + * PolkitAuthority:backend-features: + * + * The features of the currently used Authority backend. + */ + g_object_class_install_property (gobject_class, + PROP_BACKEND_FEATURES, + g_param_spec_flags ("backend-features", + "Backend features", + "The features of the currently used Authority backend.", + POLKIT_TYPE_AUTHORITY_FEATURES, + POLKIT_AUTHORITY_FEATURES_NONE, + G_PARAM_READABLE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); /** * PolkitAuthority::changed: @@ -1391,3 +1482,49 @@ polkit_authority_revoke_temporary_authorization_by_id_sync (PolkitAuthority } /* ---------------------------------------------------------------------------------------------------- */ + +/** + * polkit_authority_get_backend_name: + * @authority: A #PolkitAuthority. + * + * Gets the name of the authority backend. + * + * Returns: The name of the backend. + */ +const gchar * +polkit_authority_get_backend_name (PolkitAuthority *authority) +{ + if (authority->name == NULL) + authority->name = _polkit_authority_get_backend_name (authority->real); + return authority->name; +} + +/** + * polkit_authority_get_backend_version: + * @authority: A #PolkitAuthority. + * + * Gets the version of the authority backend. + * + * Returns: The name of the backend. + */ +const gchar * +polkit_authority_get_backend_version (PolkitAuthority *authority) +{ + if (authority->version == NULL) + authority->version = _polkit_authority_get_backend_version (authority->real); + return authority->version; +} + +/** + * polkit_authority_get_backend_features: + * @authority: A #PolkitAuthority. + * + * Gets the features supported by the authority backend. + * + * Returns: Flags from #PolkitAuthorityFeatures. + */ +PolkitAuthorityFeatures +polkit_authority_get_backend_features (PolkitAuthority *authority) +{ + return _polkit_authority_get_backend_features (authority->real); +} diff --git a/src/polkit/polkitauthority.h b/src/polkit/polkitauthority.h index e45b3a1..6575d27 100644 --- a/src/polkit/polkitauthority.h +++ b/src/polkit/polkitauthority.h @@ -29,6 +29,7 @@ #include <glib-object.h> #include <gio/gio.h> #include <polkit/polkittypes.h> +#include <polkit/polkitauthorityfeatures.h> G_BEGIN_DECLS @@ -48,6 +49,10 @@ GType polkit_authority_get_type (void) G_GNUC_CONST; PolkitAuthority *polkit_authority_get (void); +const gchar *polkit_authority_get_backend_name (PolkitAuthority *authority); +const gchar *polkit_authority_get_backend_version (PolkitAuthority *authority); +PolkitAuthorityFeatures polkit_authority_get_backend_features (PolkitAuthority *authority); + /* ---------------------------------------------------------------------------------------------------- */ GList *polkit_authority_enumerate_actions_sync (PolkitAuthority *authority, diff --git a/src/polkit/polkitauthorityfeatures.c b/src/polkit/polkitauthorityfeatures.c new file mode 100644 index 0000000..16a9125 --- /dev/null +++ b/src/polkit/polkitauthorityfeatures.c @@ -0,0 +1,29 @@ +/* + * 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" + + diff --git a/src/polkit/polkitauthorityfeatures.h b/src/polkit/polkitauthorityfeatures.h new file mode 100644 index 0000000..35a3ecc --- /dev/null +++ b/src/polkit/polkitauthorityfeatures.h @@ -0,0 +1,51 @@ +/* + * 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> + */ + +#if !defined (_POLKIT_COMPILATION) && !defined(_POLKIT_INSIDE_POLKIT_H) +#error "Only <polkit/polkit.h> can be included directly, this file may disappear or change contents." +#endif + +#ifndef __POLKIT_AUTHORITY_FEATURES_H +#define __POLKIT_AUTHORITY_FEATURES_H + +#include <glib-object.h> + +G_BEGIN_DECLS + +/** + * PolkitAuthorityFeatures: + * @POLKIT_AUTHORITY_FEATURES_NONE: No flags set. + * @POLKIT_AUTHORITY_FEATURES_TEMPORARY_AUTHORIZATION: The authority supports temporary authorizations + * that can be obtained through authentication. + * @POLKIT_AUTHORITY_FEATURES_LOCKDOWN: The authority supports the XXX method. + * + * Flags describing features supported by the Authority implementation. + */ +typedef enum +{ + POLKIT_AUTHORITY_FEATURES_NONE = 0, + POLKIT_AUTHORITY_FEATURES_TEMPORARY_AUTHORIZATION = (1<<0), + POLKIT_AUTHORITY_FEATURES_LOCKDOWN = (1<<1) +} PolkitAuthorityFeatures; + +G_END_DECLS + +#endif /* __POLKIT_AUTHORITY_FEATURES_H */ diff --git a/src/polkit/polkitcheckauthorizationflags.h b/src/polkit/polkitcheckauthorizationflags.h index e8689c6..94aa070 100644 --- a/src/polkit/polkitcheckauthorizationflags.h +++ b/src/polkit/polkitcheckauthorizationflags.h @@ -45,8 +45,8 @@ GType polkit_check_authorization_flags_get_type (void) G_GNUC_CONST; */ typedef enum { - POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE = 0x0000, /*< nick=none >*/ - POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION = 0x0001, + POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE = 0, + POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION = (1<<0), } PolkitCheckAuthorizationFlags; G_END_DECLS diff --git a/src/polkitbackend/polkitbackendauthority.c b/src/polkitbackend/polkitbackendauthority.c index 28731af..9735cdf 100644 --- a/src/polkitbackend/polkitbackendauthority.c +++ b/src/polkitbackend/polkitbackendauthority.c @@ -94,6 +94,60 @@ polkit_backend_authority_system_bus_name_owner_changed (PolkitBackendAuthority } /** + * polkit_backend_authority_get_name: + * @authority: A #PolkitBackendAuthority. + * + * Gets the name of the authority backend. + * + * Returns: The name of the backend. + */ +const gchar * +polkit_backend_authority_get_name (PolkitBackendAuthority *authority) +{ + PolkitBackendAuthorityClass *klass; + klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority); + if (klass->get_name == NULL) + return "(not set)"; + return klass->get_name (authority); +} + +/** + * polkit_backend_authority_get_version: + * @authority: A #PolkitBackendAuthority. + * + * Gets the version of the authority backend. + * + * Returns: The name of the backend. + */ +const gchar * +polkit_backend_authority_get_version (PolkitBackendAuthority *authority) +{ + PolkitBackendAuthorityClass *klass; + klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority); + if (klass->get_version == NULL) + return "(not set)"; + return klass->get_version (authority); +} + +/** + * polkit_backend_authority_get_features: + * @authority: A #PolkitBackendAuthority. + * + * Gets the features supported by the authority backend. + * + * Returns: Flags from #PolkitAuthorityFeatures. + */ +PolkitAuthorityFeatures +polkit_backend_authority_get_features (PolkitBackendAuthority *authority) +{ + PolkitBackendAuthorityClass *klass; + klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority); + if (klass->get_features == NULL) + return POLKIT_AUTHORITY_FEATURES_NONE; + return klass->get_features (authority); +} + +/** * polkit_backend_authority_enumerate_actions: * @authority: A #PolkitBackendAuthority. * @caller: The system bus name that initiated the query. @@ -483,6 +537,14 @@ struct _ServerClass GObjectClass parent_class; }; +enum +{ + PROP_0, + PROP_BACKEND_NAME, + PROP_BACKEND_VERSION, + PROP_BACKEND_FEATURES +}; + static void authority_iface_init (_PolkitAuthorityIface *authority_iface); G_DEFINE_TYPE_WITH_CODE (Server, server, G_TYPE_OBJECT, @@ -521,6 +583,35 @@ server_finalize (GObject *object) } static void +server_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + Server *server = SERVER (object); + + switch (prop_id) + { + case PROP_BACKEND_NAME: + g_value_set_string (value, polkit_backend_authority_get_name (server->authority)); + break; + + case PROP_BACKEND_VERSION: + g_value_set_string (value, polkit_backend_authority_get_version (server->authority)); + break; + + case PROP_BACKEND_FEATURES: + g_value_set_flags (value, polkit_backend_authority_get_features (server->authority)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void server_class_init (ServerClass *klass) { GObjectClass *gobject_class; @@ -528,6 +619,9 @@ server_class_init (ServerClass *klass) gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = server_finalize; + gobject_class->get_property = server_get_property; + + g_assert (_polkit_authority_override_properties (gobject_class, PROP_BACKEND_NAME) == PROP_BACKEND_FEATURES); } static void diff --git a/src/polkitbackend/polkitbackendauthority.h b/src/polkitbackend/polkitbackendauthority.h index 56d46be..d87bb14 100644 --- a/src/polkitbackend/polkitbackendauthority.h +++ b/src/polkitbackend/polkitbackendauthority.h @@ -112,6 +112,10 @@ struct _PolkitBackendAuthorityClass /* VTable */ + const gchar *(*get_name) (PolkitBackendAuthority *authority); + const gchar *(*get_version) (PolkitBackendAuthority *authority); + PolkitAuthorityFeatures (*get_features) (PolkitBackendAuthority *authority); + GList *(*enumerate_actions) (PolkitBackendAuthority *authority, PolkitSubject *caller, const gchar *locale, @@ -211,6 +215,10 @@ GType polkit_backend_authority_get_type (void) G_GNUC_CONST; /* --- */ +const gchar *polkit_backend_authority_get_name (PolkitBackendAuthority *authority); +const gchar *polkit_backend_authority_get_version (PolkitBackendAuthority *authority); +PolkitAuthorityFeatures polkit_backend_authority_get_features (PolkitBackendAuthority *authority); + void polkit_backend_authority_system_bus_name_owner_changed (PolkitBackendAuthority *authority, const gchar *name, const gchar *old_owner, diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c index add7a60..c09067d 100644 --- a/src/polkitbackend/polkitbackendinteractiveauthority.c +++ b/src/polkitbackend/polkitbackendinteractiveauthority.c @@ -276,6 +276,24 @@ polkit_backend_interactive_authority_finalize (GObject *object) G_OBJECT_CLASS (polkit_backend_interactive_authority_parent_class)->finalize (object); } +static const gchar * +polkit_backend_interactive_authority_get_name (PolkitBackendAuthority *authority) +{ + return "interactive"; +} + +static const gchar * +polkit_backend_interactive_authority_get_version (PolkitBackendAuthority *authority) +{ + return PACKAGE_VERSION; +} + +static PolkitAuthorityFeatures +polkit_backend_interactive_authority_get_features (PolkitBackendAuthority *authority) +{ + return POLKIT_AUTHORITY_FEATURES_TEMPORARY_AUTHORIZATION; +} + static void polkit_backend_interactive_authority_class_init (PolkitBackendInteractiveAuthorityClass *klass) { @@ -287,6 +305,9 @@ polkit_backend_interactive_authority_class_init (PolkitBackendInteractiveAuthori gobject_class->finalize = polkit_backend_interactive_authority_finalize; + authority_class->get_name = polkit_backend_interactive_authority_get_name; + authority_class->get_version = polkit_backend_interactive_authority_get_version; + authority_class->get_features = polkit_backend_interactive_authority_get_features; authority_class->system_bus_name_owner_changed = polkit_backend_interactive_authority_system_bus_name_owner_changed; authority_class->enumerate_actions = polkit_backend_interactive_authority_enumerate_actions; authority_class->check_authorization = polkit_backend_interactive_authority_check_authorization; diff --git a/src/polkitbackend/polkitbackendlocalauthority.c b/src/polkitbackend/polkitbackendlocalauthority.c index 932706e..0f58a81 100644 --- a/src/polkitbackend/polkitbackendlocalauthority.c +++ b/src/polkitbackend/polkitbackendlocalauthority.c @@ -161,16 +161,39 @@ polkit_backend_local_authority_finalize (GObject *object) G_OBJECT_CLASS (polkit_backend_local_authority_parent_class)->finalize (object); } +static const gchar * +polkit_backend_local_authority_get_name (PolkitBackendAuthority *authority) +{ + return "local"; +} + +static const gchar * +polkit_backend_local_authority_get_version (PolkitBackendAuthority *authority) +{ + return PACKAGE_VERSION; +} + +static PolkitAuthorityFeatures +polkit_backend_local_authority_get_features (PolkitBackendAuthority *authority) +{ + return POLKIT_AUTHORITY_FEATURES_TEMPORARY_AUTHORIZATION | POLKIT_AUTHORITY_FEATURES_LOCKDOWN; +} + static void polkit_backend_local_authority_class_init (PolkitBackendLocalAuthorityClass *klass) { GObjectClass *gobject_class; + PolkitBackendAuthorityClass *authority_class; PolkitBackendInteractiveAuthorityClass *interactive_authority_class; gobject_class = G_OBJECT_CLASS (klass); + authority_class = POLKIT_BACKEND_AUTHORITY_CLASS (klass); interactive_authority_class = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_CLASS (klass); gobject_class->finalize = polkit_backend_local_authority_finalize; + authority_class->get_name = polkit_backend_local_authority_get_name; + authority_class->get_version = polkit_backend_local_authority_get_version; + authority_class->get_features = polkit_backend_local_authority_get_features; interactive_authority_class->get_admin_identities = polkit_backend_local_authority_get_admin_auth_identities; interactive_authority_class->check_authorization_sync = polkit_backend_local_authority_check_authorization_sync; |