diff --git a/mission-control-plugins/Makefile.am b/mission-control-plugins/Makefile.am index 513aab6..38bd856 100644 --- a/mission-control-plugins/Makefile.am +++ b/mission-control-plugins/Makefile.am @@ -54,6 +54,11 @@ libmission_control_plugins_la_SOURCES = \ request.c \ request-policy.c +if ENABLE_AEGIS +libmission_control_plugins_la_SOURCES += builtin-aegis-acl.c +libmission_control_plugins_la_LIBADD += $(AEGIS_LIBS) +endif + BUILT_SOURCES = $(nodist_libmission_control_plugins_la_SOURCES) CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/mcp-dbus-aegis-acl.c b/mission-control-plugins/builtin-aegis-acl.c similarity index 85% rename from plugins/mcp-dbus-aegis-acl.c rename to mission-control-plugins/builtin-aegis-acl.c index 71d953c..38cfc5e 100644 --- a/plugins/mcp-dbus-aegis-acl.c +++ b/mission-control-plugins/builtin-aegis-acl.c @@ -1,5 +1,5 @@ /* - * An Aegis/libcreds plugin that checks the caller's permission tokens + * A pseudo-plugin that checks the caller's Aegis permission tokens * * Copyright © 2010-2011 Nokia Corporation * Copyright © 2010-2011 Collabora Ltd. @@ -19,12 +19,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include +#ifdef G_LOG_DOMAIN +#undef G_LOG_DOMAIN +#endif +#define G_LOG_DOMAIN "mission-control-DBus-Access-ACL" +#define DEBUG(_f, ...) g_debug ("%s: " _f, G_STRLOC, ##__VA_ARGS__) + #include +#include #include +#include "builtin-aegis-acl.h" + #define CREATE_CHANNEL TP_IFACE_CONNECTION_INTERFACE_REQUESTS ".CreateChannel" #define ENSURE_CHANNEL TP_IFACE_CONNECTION_INTERFACE_REQUESTS ".EnsureChannel" #define SEND_MESSAGE \ @@ -32,8 +38,6 @@ #define AEGIS_CALL_TOKEN "Cellular" -#define DEBUG g_debug - #define PLUGIN_NAME "dbus-aegis-acl" #define PLUGIN_DESCRIPTION \ "This plugin uses libcreds to check the aegis security tokens " \ @@ -52,36 +56,22 @@ static gchar *restricted[] = NULL }; -static void dbus_acl_iface_init (McpDBusAclIface *, +static void aegis_acl_iface_init (McpDBusAclIface *, gpointer); -typedef struct { - GObject parent; -} DBusAegisAcl; - -typedef struct { - GObjectClass parent_class; - creds_value_t token; - creds_type_t token_type; -} DBusAegisAclClass; - -GType dbus_aegis_acl_get_type (void) G_GNUC_CONST; - -#define DBUS_AEGIS_ACL(o) \ - (G_TYPE_CHECK_INSTANCE_CAST ((o), dbus_aegis_acl_get_type (), \ - DBusAegisAcl)) +static GType aegis_acl_get_type (void); -G_DEFINE_TYPE_WITH_CODE (DBusAegisAcl, dbus_aegis_acl, +G_DEFINE_TYPE_WITH_CODE (AegisAcl, aegis_acl, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (MCP_TYPE_DBUS_ACL, dbus_acl_iface_init)); + G_IMPLEMENT_INTERFACE (MCP_TYPE_DBUS_ACL, aegis_acl_iface_init)); static void -dbus_aegis_acl_init (DBusAegisAcl *self) +aegis_acl_init (AegisAcl *self) { } static void -dbus_aegis_acl_class_init (DBusAegisAclClass *cls) +aegis_acl_class_init (AegisAclClass *cls) { if (token_initialised == TRUE) return; @@ -263,7 +253,7 @@ caller_async_authorised (const McpDBusAcl *self, static void -dbus_acl_iface_init (McpDBusAclIface *iface, +aegis_acl_iface_init (McpDBusAclIface *iface, gpointer unused G_GNUC_UNUSED) { mcp_dbus_acl_iface_set_name (iface, PLUGIN_NAME); @@ -273,18 +263,8 @@ dbus_acl_iface_init (McpDBusAclIface *iface, mcp_dbus_acl_iface_implement_authorised_async (iface, caller_async_authorised); } -GObject * -mcp_plugin_ref_nth_object (guint n) +AegisAcl * +aegis_acl_new (void) { - DEBUG ("Initializing mcp-dbus-caller-id plugin (n=%u)", n); - - switch (n) - { - case 0: - return g_object_new (dbus_aegis_acl_get_type (), NULL); - - default: - return NULL; - } + return g_object_new (aegis_acl_get_type (), NULL); } - diff --git a/mission-control-plugins/builtin-aegis-acl.h b/mission-control-plugins/builtin-aegis-acl.h new file mode 100644 index 0000000..058c0ec --- /dev/null +++ b/mission-control-plugins/builtin-aegis-acl.h @@ -0,0 +1,49 @@ +/* + * A pseudo-plugin that checks the caller's Aegis permission tokens + * + * Copyright © 2010-2011 Nokia Corporation + * Copyright © 2010-2011 Collabora Ltd. + * + * 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AEGIS_ACL_H +#define AEGIS_ACL_H + +#include +#include +#include +#include + +G_BEGIN_DECLS + +typedef struct { + GObject parent; +} _AegisAcl; + +typedef struct { + GObjectClass parent_class; + creds_value_t token; + creds_type_t token_type; +} _AegisAclClass; + +typedef _AegisAcl AegisAcl; +typedef _AegisAclClass AegisAclClass; + +AegisAcl *aegis_acl_new (void); + +G_END_DECLS + +#endif diff --git a/mission-control-plugins/dbus-acl.c b/mission-control-plugins/dbus-acl.c index 652f18b..ade299b 100644 --- a/mission-control-plugins/dbus-acl.c +++ b/mission-control-plugins/dbus-acl.c @@ -62,6 +62,11 @@ #include #include #include +#include "config.h" + +#if ENABLE_AEGIS +#include "builtin-aegis-acl.h" +#endif #ifdef ENABLE_DEBUG @@ -138,6 +143,11 @@ cached_acls (void) } } +#if ENABLE_AEGIS + DEBUG (NULL, "Initialising built-in Aegis ACL plugin"); + dbus_acls = g_list_prepend (dbus_acls, aegis_acl_new ()); +#endif + acl_plugins_cached = TRUE; return dbus_acls; diff --git a/plugins/Makefile.am b/plugins/Makefile.am index d801724..05d47e2 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -15,15 +15,3 @@ plugin_LDFLAGS = -module -shared -avoid-version -rpath @abs_builddir@ inst_LTLIBRARIES = -if ENABLE_AEGIS - -inst_LTLIBRARIES += mcp-dbus-aegis-acl.la - -mcp_dbus_aegis_acl_la_SOURCES = mcp-dbus-aegis-acl.c -mcp_dbus_aegis_acl_la_LDFLAGS = \ - $(plugin_LDFLAGS) \ - $(TELEPATHY_LIBS) \ - $(DBUS_LIBS) \ - $(AEGIS_LIBS) - -endif