Commit 0f830c76 authored by David Zeuthen's avatar David Zeuthen

Nuke polkitbackend library, localauthority backend and extension system

Any backend can now be implemented in JavaScript (if so desired) so we
don't need any of this any more.

Note that the libpolkitbackend library was never declared stable (the
preprocessor symbol POLKIT_BACKEND_I_KNOW_API_IS_SUBJECT_TO_CHANGE had
to be defined) so removing it is not an API/ABI break.
Signed-off-by: default avatarDavid Zeuthen <davidz@redhat.com>
parent 29950854
......@@ -461,7 +461,6 @@ src/polkitagent/Makefile
src/polkitd/Makefile
src/programs/Makefile
src/examples/Makefile
src/nullbackend/Makefile
docs/version.xml
docs/extensiondir.xml
docs/Makefile
......
......@@ -31,8 +31,6 @@ INCLUDES = \
$(GIO_CFLAGS) \
-I$(top_srcdir)/src/polkit \
-I$(top_builddir)/src/polkit \
-I$(top_srcdir)/src/polkitbackend \
-I$(top_builddir)/src/polkitbackend \
-I$(top_srcdir)/src/polkitagent \
-I$(top_builddir)/src/polkitagent \
$(NULL)
......@@ -42,7 +40,6 @@ GTKDOC_LIBS = \
$(GLIB_LIBS) \
$(GIO_LIBS) \
$(top_builddir)/src/polkit/libpolkit-gobject-1.la \
$(top_builddir)/src/polkitbackend/libpolkit-backend-1.la \
$(top_builddir)/src/polkitagent/libpolkit-agent-1.la \
$(NULL)
......
......@@ -90,37 +90,4 @@
</para>
</chapter>
<chapter id="polkit-extending">
<title>Extending polkit</title>
<para>
polkit exports a number of extension points to
replace/customize behavior of the polkit daemon. Note that
all extensions run with super user privileges in the same
process as the polkit daemon.
</para>
<para>
The polkit daemons loads extensions
from the <filename>&extensiondir;</filename> directory. See
the <link linkend="gio-Extension-Points">GIO Extension Point
documentation</link> for more information about the extension
system used by polkit.
</para>
<para>
The following extension points are currently defined by
polkit:
</para>
<formalpara>
<title>POLKIT_BACKEND_AUTHORITY_EXTENSION_POINT_NAME</title>
<para>
Allows replacing the Authority – the entity responsible for
making authorization decisions. Implementations of this
extension point must be derived from the
PolkitBackendAuthority class. See
the <filename>src/nullbackend/</filename> directory in the
polkit sources for an example.
</para>
</formalpara>
</chapter>
</part>
......@@ -23,7 +23,7 @@
</part>
<part id="ref-api">
<title>Client API Reference</title>
<title>Library API Reference</title>
<xi:include href="xml/polkitauthority.xml"/>
<xi:include href="xml/polkitauthorizationresult.xml"/>
<xi:include href="xml/polkitdetails.xml"/>
......@@ -47,13 +47,6 @@
</chapter>
</part>
<part id="ref-backend-api">
<title>Backend API Reference</title>
<xi:include href="xml/polkitbackendauthority.xml"/>
<xi:include href="xml/polkitbackendinteractiveauthority.xml"/>
<xi:include href="xml/polkitbackendlocalauthority.xml"/>
</part>
<part id="ref-authentication-agent-api">
<title>Authentication Agent API Reference</title>
<xi:include href="xml/polkitagentlistener.xml"/>
......
......@@ -290,86 +290,6 @@ POLKIT_IS_DETAILS_CLASS
POLKIT_DETAILS_GET_CLASS
</SECTION>
<SECTION>
<FILE>polkitbackendauthority</FILE>
<TITLE>PolkitBackendAuthority</TITLE>
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
polkit_backend_authority_unregister_authentication_agent
polkit_backend_authority_authentication_agent_response
polkit_backend_authority_enumerate_actions
polkit_backend_authority_enumerate_temporary_authorizations
polkit_backend_authority_revoke_temporary_authorizations
polkit_backend_authority_revoke_temporary_authorization_by_id
polkit_backend_authority_get
polkit_backend_authority_register
polkit_backend_authority_unregister
<SUBSECTION Standard>
POLKIT_BACKEND_AUTHORITY
POLKIT_BACKEND_IS_AUTHORITY
POLKIT_BACKEND_TYPE_AUTHORITY
polkit_backend_authority_get_type
POLKIT_BACKEND_AUTHORITY_CLASS
POLKIT_BACKEND_IS_AUTHORITY_CLASS
POLKIT_BACKEND_AUTHORITY_GET_CLASS
</SECTION>
<SECTION>
<FILE>polkitbackendactionlookup</FILE>
<TITLE>PolkitBackendActionLookup</TITLE>
POLKIT_BACKEND_ACTION_LOOKUP_EXTENSION_POINT_NAME
PolkitBackendActionLookup
PolkitBackendActionLookupIface
polkit_backend_action_lookup_get_message
polkit_backend_action_lookup_get_icon_name
polkit_backend_action_lookup_get_details
<SUBSECTION Standard>
POLKIT_BACKEND_ACTION_LOOKUP
POLKIT_BACKEND_IS_ACTION_LOOKUP
POLKIT_BACKEND_TYPE_ACTION_LOOKUP
polkit_backend_action_lookup_get_type
POLKIT_BACKEND_ACTION_LOOKUP_GET_IFACE
</SECTION>
<SECTION>
<FILE>polkitbackendlocalauthority</FILE>
<TITLE>PolkitBackendLocalAuthority</TITLE>
PolkitBackendLocalAuthority
PolkitBackendLocalAuthorityClass
<SUBSECTION Standard>
POLKIT_BACKEND_LOCAL_AUTHORITY
POLKIT_BACKEND_IS_LOCAL_AUTHORITY
POLKIT_BACKEND_TYPE_LOCAL_AUTHORITY
polkit_backend_local_authority_get_type
POLKIT_BACKEND_LOCAL_AUTHORITY_CLASS
POLKIT_BACKEND_IS_LOCAL_AUTHORITY_CLASS
POLKIT_BACKEND_LOCAL_AUTHORITY_GET_CLASS
</SECTION>
<SECTION>
<FILE>polkitbackendinteractiveauthority</FILE>
<TITLE>PolkitBackendInteractiveAuthority</TITLE>
PolkitBackendInteractiveAuthority
PolkitBackendInteractiveAuthorityClass
polkit_backend_interactive_authority_get_admin_identities
polkit_backend_interactive_authority_check_authorization_sync
<SUBSECTION Standard>
POLKIT_BACKEND_INTERACTIVE_AUTHORITY
POLKIT_BACKEND_IS_INTERACTIVE_AUTHORITY
POLKIT_BACKEND_TYPE_INTERACTIVE_AUTHORITY
polkit_backend_interactive_authority_get_type
POLKIT_BACKEND_INTERACTIVE_AUTHORITY_CLASS
POLKIT_BACKEND_IS_INTERACTIVE_AUTHORITY_CLASS
POLKIT_BACKEND_INTERACTIVE_AUTHORITY_GET_CLASS
</SECTION>
<SECTION>
<FILE>polkitagentsession</FILE>
<TITLE>PolkitAgentSession</TITLE>
......
......@@ -16,15 +16,6 @@ polkit_authorization_result_get_type
polkit_temporary_authorization_get_type
polkit_permission_get_type
polkit_backend_authority_get_type
polkit_backend_interactive_authority_get_type
polkit_backend_local_authority_get_type
polkit_backend_action_lookup_get_type
polkit_backend_action_pool_get_type
polkit_backend_session_monitor_get_type
polkit_backend_config_source_get_type
polkit_backend_local_authorization_store_get_type
polkit_agent_session_get_type
polkit_agent_listener_get_type
polkit_agent_text_listener_get_type
......@@ -3,5 +3,4 @@
[encoding: UTF-8]
actions/org.freedesktop.policykit.policy.in
src/examples/org.freedesktop.policykit.examples.pkexec.policy.in
src/polkitbackend/polkitbackendlocalauthority.c
src/programs/pkexec.c
SUBDIRS = polkit polkitbackend polkitagent polkitd nullbackend programs
SUBDIRS = polkit polkitbackend polkitagent polkitd programs
if BUILD_EXAMPLES
SUBDIRS += examples
......
#
# Configuration file for the PolicyKit null backend.
#
# DO NOT EDIT THIS FILE, it will be overwritten on update.
#
# To change configuration, create another file in this directory with
# a filename that is sorted after the 50-nullback.conf and make
# sure it has the .conf extension.
#
# Only a single configuration item, Priority, is supported.
#
# See the PolicyKit documentation for more information about PolicyKit.
#
[Configuration]
Priority=-10
NULL =
module_flags = -export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_io_module_(load|unload)'
INCLUDES = \
-I$(top_builddir)/src \
-I$(top_srcdir)/src \
-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
-DPACKAGE_BIN_DIR=\""$(bindir)"\" \
-DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\" \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
-DPACKAGE_LIB_DIR=\""$(libdir)"\" \
-D_POSIX_PTHREAD_SEMANTICS \
-D_REENTRANT \
-D_POLKIT_BACKEND_COMPILATION \
$(NULL)
polkitmodulesdir = $(libdir)/polkit-1/extensions
polkitmodules_LTLIBRARIES = libnullbackend.la
libnullbackend_la_SOURCES = \
nullbackend.c \
polkitbackendnullauthority.c polkitbackendnullauthority.h \
$(NULL)
libnullbackend_la_CFLAGS = \
-DPOLKIT_BACKEND_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
-DG_LOG_DOMAIN=\"PolkitNullBackend\" \
$(GLIB_CFLAGS) \
$(NULL)
libnullbackend_la_LDFLAGS = \
$(module_flags) \
$(GLIB_LIBS) \
$(top_builddir)/src/polkitbackend/libpolkit-backend-1.la \
$(NULL)
libnullbackend_la_LIBADD = \
$(NULL)
nullconfigdir = $(sysconfdir)/polkit-1/nullbackend.conf.d
nullconfig_DATA = 50-nullbackend.conf
EXTRA_DIST = $(nullconfig_DATA)
clean-local :
rm -f *~
/*
* Copyright (C) 2009 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>
*/
#include "polkitbackendnullauthority.h"
void
g_io_module_load (GIOModule *module)
{
polkit_backend_null_authority_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}
/*
* 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>
*/
#include "config.h"
#include <errno.h>
#include <pwd.h>
#include <grp.h>
#include <string.h>
#include <glib/gstdio.h>
#include "polkitbackend/polkitbackendconfigsource.h"
#include "polkitbackendnullauthority.h"
struct _PolkitBackendNullAuthorityPrivate
{
gint foo;
};
static GList *authority_enumerate_actions (PolkitBackendAuthority *authority,
PolkitSubject *caller,
const gchar *locale,
GError **error);
static void authority_check_authorization (PolkitBackendAuthority *authority,
PolkitSubject *caller,
PolkitSubject *subject,
const gchar *action_id,
PolkitDetails *details,
PolkitCheckAuthorizationFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
static PolkitAuthorizationResult *authority_check_authorization_finish (PolkitBackendAuthority *authority,
GAsyncResult *res,
GError **error);
G_DEFINE_DYNAMIC_TYPE (PolkitBackendNullAuthority, polkit_backend_null_authority,POLKIT_BACKEND_TYPE_AUTHORITY);
static void
polkit_backend_null_authority_init (PolkitBackendNullAuthority *authority)
{
authority->priv = G_TYPE_INSTANCE_GET_PRIVATE (authority,
POLKIT_BACKEND_TYPE_NULL_AUTHORITY,
PolkitBackendNullAuthorityPrivate);
}
static void
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)
{
GObjectClass *gobject_class;
PolkitBackendAuthorityClass *authority_class;
gobject_class = G_OBJECT_CLASS (klass);
authority_class = POLKIT_BACKEND_AUTHORITY_CLASS (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;
g_type_class_add_private (klass, sizeof (PolkitBackendNullAuthorityPrivate));
}
static void
polkit_backend_null_authority_class_finalize (PolkitBackendNullAuthorityClass *klass)
{
}
void
polkit_backend_null_authority_register (GIOModule *module)
{
gint priority;
GFile *directory;
PolkitBackendConfigSource *source;
directory = g_file_new_for_path (PACKAGE_SYSCONF_DIR "/polkit-1/nullbackend.conf.d");
source = polkit_backend_config_source_new (directory);
priority = polkit_backend_config_source_get_integer (source, "Configuration", "Priority", NULL);
polkit_backend_null_authority_register_type (G_TYPE_MODULE (module));
g_print ("Registering null backend at priority %d\n", priority);
g_io_extension_point_implement (POLKIT_BACKEND_AUTHORITY_EXTENSION_POINT_NAME,
POLKIT_BACKEND_TYPE_NULL_AUTHORITY,
"null backend " PACKAGE_VERSION,
priority);
g_object_unref (directory);
g_object_unref (source);
}
/* ---------------------------------------------------------------------------------------------------- */
static GList *
authority_enumerate_actions (PolkitBackendAuthority *authority,
PolkitSubject *caller,
const gchar *locale,
GError **error)
{
/* We don't know any actions */
return NULL;
}
static void
authority_check_authorization (PolkitBackendAuthority *authority,
PolkitSubject *caller,
PolkitSubject *subject,
const gchar *action_id,
PolkitDetails *details,
PolkitCheckAuthorizationFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
/* complete immediately */
simple = g_simple_async_result_new (G_OBJECT (authority),
callback,
user_data,
authority_check_authorization);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
static PolkitAuthorizationResult *
authority_check_authorization_finish (PolkitBackendAuthority *authority,
GAsyncResult *res,
GError **error)
{
GSimpleAsyncResult *simple;
PolkitAuthorizationResult *result;
simple = G_SIMPLE_ASYNC_RESULT (res);
g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == authority_check_authorization);
/* we always return NOT_AUTHORIZED, never an error */
result = polkit_authorization_result_new (FALSE, FALSE, NULL);
if (g_simple_async_result_propagate_error (simple, error))
goto out;
out:
return result;
}
/*
* Copyright (C) 2009 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_BACKEND_NULL_AUTHORITY_H
#define __POLKIT_BACKEND_NULL_AUTHORITY_H
#include <polkitbackend/polkitbackend.h>
G_BEGIN_DECLS
#define POLKIT_BACKEND_TYPE_NULL_AUTHORITY (polkit_backend_null_authority_get_type ())
#define POLKIT_BACKEND_NULL_AUTHORITY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_BACKEND_TYPE_NULL_AUTHORITY, PolkitBackendNullAuthority))
#define POLKIT_BACKEND_NULL_AUTHORITY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_BACKEND_TYPE_NULL_AUTHORITY, PolkitBackendNullAuthorityClass))
#define POLKIT_BACKEND_NULL_AUTHORITY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_BACKEND_TYPE_NULL_AUTHORITY,PolkitBackendNullAuthorityClass))
#define POLKIT_BACKEND_IS_NULL_AUTHORITY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_BACKEND_TYPE_NULL_AUTHORITY))
#define POLKIT_BACKEND_IS_NULL_AUTHORITY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_BACKEND_TYPE_NULL_AUTHORITY))
typedef struct _PolkitBackendNullAuthority PolkitBackendNullAuthority;
typedef struct _PolkitBackendNullAuthorityClass PolkitBackendNullAuthorityClass;
typedef struct _PolkitBackendNullAuthorityPrivate PolkitBackendNullAuthorityPrivate;
struct _PolkitBackendNullAuthority
{
PolkitBackendAuthority parent_instance;
PolkitBackendNullAuthorityPrivate *priv;
};
struct _PolkitBackendNullAuthorityClass
{
PolkitBackendAuthorityClass parent_class;
};
GType polkit_backend_null_authority_get_type (void) G_GNUC_CONST;
void polkit_backend_null_authority_register (GIOModule *module);
G_END_DECLS
#endif /* __POLKIT_BACKEND_NULL_AUTHORITY_H */
......@@ -18,25 +18,13 @@ INCLUDES = \
-D_REENTRANT \
$(NULL)
lib_LTLIBRARIES=libpolkit-backend-1.la
libpolkit_backend_1includedir=$(includedir)/polkit-1/polkitbackend
noinst_LTLIBRARIES=libpolkit-backend-1.la
initjs.h : init.js
$(PERL) $(srcdir)/toarray.pl $(srcdir)/init.js init_js > $@
BUILT_SOURCES += initjs.h
libpolkit_backend_1include_HEADERS = \
polkitbackend.h \
polkitbackendtypes.h \
polkitbackendauthority.h \
polkitbackendinteractiveauthority.h \
polkitbackendlocalauthority.h \
polkitbackendactionlookup.h \
$(NULL)
libpolkit_backend_1_la_SOURCES = \
$(BUILT_SOURCES) \
polkitbackend.h \
......@@ -44,12 +32,10 @@ libpolkit_backend_1_la_SOURCES = \
polkitbackendprivate.h \
polkitbackendauthority.h polkitbackendauthority.c \
polkitbackendinteractiveauthority.h polkitbackendinteractiveauthority.c \
polkitbackendlocalauthority.h polkitbackendlocalauthority.c \
polkitbackendjsauthority.h polkitbackendjsauthority.c \
polkitbackendactionpool.h polkitbackendactionpool.c \
polkitbackendconfigsource.h polkitbackendconfigsource.c \
polkitbackendactionlookup.h polkitbackendactionlookup.c \
polkitbackendlocalauthorizationstore.h polkitbackendlocalauthorizationstore.c \
$(NULL)
if HAVE_LIBSYSTEMD_LOGIN
......@@ -76,15 +62,9 @@ libpolkit_backend_1_la_LIBADD = \
$(LIBJS_LIBS) \
$(NULL)
libpolkit_backend_1_la_LDFLAGS = -export-symbols-regex '(^polkit_.*)'
CLEANFILES = $(BUILT_SOURCES)
localauthorityconfigdir = $(sysconfdir)/polkit-1/localauthority.conf.d
localauthorityconfig_DATA = 50-localauthority.conf
EXTRA_DIST = \
$(localauthorityconfig_DATA) \
init.js \
toarray.pl \