Commit ac7047d8 authored by Ray Strode's avatar Ray Strode Committed by Debarshi Ray

identity: Separate identity service off into its own process

This commit segregates the kerberos specific functionality off
into its own helper process.

This has a couple of benefits:

1) It is actually a better fit for how the code was initially designed,
which was first staged in gnome-settings-daemon with g-o-a talking to
it. Right now we have gnome-online-accounts talking to itself,
in-process, through d-bus, which is suboptimal.

2) It keeps any leaks or crashes in the kerberos code from bringing
down the whole online accounts daemon.

https://bugzilla.gnome.org/show_bug.cgi?id=739593
parent 7ba73645
......@@ -11,9 +11,14 @@ gsettings_SCHEMAS = $(gsettings_in_files:.xml.in=.xml)
servicedir = $(datadir)/dbus-1/services
service_in_files = org.gnome.OnlineAccounts.service.in
if BUILD_KERBEROS
service_in_files += org.gnome.Identity.service.in
endif
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
%.service: %.service.in Makefile
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
EXTRA_DIST = \
......@@ -25,6 +30,7 @@ EXTRA_DIST = \
DISTCLEANFILES = \
$(gsettings_SCHEMAS) \
org.gnome.OnlineAccounts.service \
org.gnome.Identity.service \
$(NULL)
clean-local :
......
[D-BUS Service]
Name=org.gnome.Identity
Exec=@libexecdir@/goa-identity-service
......@@ -48,14 +48,6 @@ goa_daemon_LDADD = \
$(TP_LIBS) \
$(NULL)
if BUILD_KERBEROS
goa_daemon_LDADD += \
$(top_builddir)/src/goaidentity/libgoaidentity.la \
$(KRB5_LIBS) \
$(GCR_LIBS) \
$(NULL)
endif
clean-local :
rm -f *~
......
......@@ -25,9 +25,6 @@
#include "goadaemon.h"
#include "goabackend/goabackend.h"
#include "goabackend/goautils.h"
#ifdef GOA_KERBEROS_ENABLED
#include "goaidentity/goaidentityservice.h"
#endif
struct _GoaDaemon
{
......@@ -43,10 +40,6 @@ struct _GoaDaemon
GoaManager *manager;
#ifdef GOA_KERBEROS_ENABLED
GoaIdentityService *identity_service;
#endif
guint config_timeout_id;
};
......@@ -112,10 +105,6 @@ goa_daemon_finalize (GObject *object)
g_object_unref (daemon->object_manager);
g_object_unref (daemon->connection);
#ifdef GOA_KERBEROS_ENABLED
g_clear_object (&daemon->identity_service);
#endif
G_OBJECT_CLASS (goa_daemon_parent_class)->finalize (object);
}
......@@ -173,15 +162,32 @@ on_file_monitor_changed (GFileMonitor *monitor,
}
}
#ifdef GOA_KERBEROS_ENABLED
static void
activate_identity_service (GoaDaemon *daemon)
{
GoaProvider *provider;
/* We activate the identity service implicitly by using the kerberos
* backend. This way if the kerberos backend isn't enabled, we don't
* end up starting the identity service needlessly
*/
provider = goa_provider_get_for_provider_type (GOA_KERBEROS_NAME);
if (provider != NULL)
{
g_debug ("activated kerberos provider");
g_object_unref (provider);
}
}
#endif
static void
goa_daemon_init (GoaDaemon *daemon)
{
static volatile GQuark goa_error_domain = 0;
GoaObjectSkeleton *object;
gchar *path;
#ifdef GOA_KERBEROS_ENABLED
GError *error = NULL;
#endif
/* this will force associating errors in the GOA_ERROR error domain
* with org.freedesktop.Goa.Error.* errors via g_dbus_error_register_error_domain().
......@@ -228,14 +234,7 @@ goa_daemon_init (GoaDaemon *daemon)
g_dbus_object_manager_server_set_connection (daemon->object_manager, daemon->connection);
#ifdef GOA_KERBEROS_ENABLED
daemon->identity_service = goa_identity_service_new ();
if (!goa_identity_service_activate (daemon->identity_service,
&error))
{
g_warning ("Error activating identity service: %s", error->message);
g_error_free (error);
g_clear_object (&daemon->identity_service);
}
activate_identity_service (daemon);
#endif
}
......
......@@ -47,6 +47,7 @@ identity_sources = \
goakerberosidentity.c \
goakerberosidentityinquiry.c \
goakerberosidentitymanager.c \
main.c \
$(NULL)
identity_dbus_built_sources = \
......@@ -95,23 +96,24 @@ BUILT_SOURCES += $(realmd_dbus_built_sources)
EXTRA_DIST += org.freedesktop.realmd.xml
if BUILD_KERBEROS
noinst_LTLIBRARIES = libgoaidentity.la
libexec_PROGRAMS = goa-identity-service
libgoaidentity_la_SOURCES = \
goa_identity_service_SOURCES = \
goaidentityenumtypes.h goaidentityenumtypes.c \
$(identity_dbus_built_sources) \
$(realmd_dbus_built_sources) \
$(identity_sources) \
$(NULL)
libgoaidentity_la_CFLAGS = \
goa_identity_service_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(KRB5_CFLAGS) \
$(GCR_CFLAGS) \
$(NULL)
libgoaidentity_la_LIBADD = \
goa_identity_service_LDADD = \
$(top_builddir)/src/goa/libgoa-1.0.la \
$(GLIB_LIBS) \
$(GTK_LIBS) \
$(KRB5_LIBS) \
......
......@@ -1757,7 +1757,7 @@ on_name_lost (GDBusConnection *connection,
GoaIdentityService *self)
{
if (g_strcmp0 (name, "org.gnome.Identity") == 0)
g_debug ("GoaIdentityService: Lost name org.gnome.Identity");
raise (SIGTERM);
}
gboolean
......
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2014 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib/gi18n.h>
#include <glib-unix.h>
#include <gio/gio.h>
#include "goaidentityservice.h"
int
main (int argc,
char **argv)
{
GMainLoop *loop;
GoaIdentityService *service;
GError *error;
int ret = 1;
loop = g_main_loop_new (NULL, FALSE);
service = goa_identity_service_new ();
error = NULL;
goa_identity_service_activate (service, &error);
if (error != NULL) {
g_warning ("couldn't activate identity service: %s", error->message);
g_error_free (error);
goto out;
}
g_main_loop_run (loop);
goa_identity_service_deactivate (service);
ret = 0;
out:
g_object_unref (service);
g_main_loop_unref (loop);
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment