Ray Strode 0ea0db
From f86c93014e698d81d43fe1ebaf805fa794e5a984 Mon Sep 17 00:00:00 2001
Ray Strode 0ea0db
From: Ray Strode <rstrode@redhat.com>
Ray Strode 0ea0db
Date: Tue, 22 Oct 2013 15:42:16 -0400
Ray Strode 0ea0db
Subject: [PATCH] daemon: rip out extension interface
Ray Strode 0ea0db
Ray Strode 0ea0db
It requires newer glib than we're shipping
Ray Strode 0ea0db
---
Ray Strode 0ea0db
 configure.ac    |   2 +-
Ray Strode 0ea0db
 src/Makefile.am |   1 -
Ray Strode 0ea0db
 src/daemon.c    |  11 ---
Ray Strode 0ea0db
 src/daemon.h    |   3 -
Ray Strode 0ea0db
 src/user.c      | 273 --------------------------------------------------------
Ray Strode 0ea0db
 5 files changed, 1 insertion(+), 289 deletions(-)
Ray Strode 0ea0db
Ray Strode 0ea0db
diff --git a/configure.ac b/configure.ac
Ray Strode 0ea0db
index cb1fcda..a7f4e20 100644
Ray Strode 0ea0db
--- a/configure.ac
Ray Strode 0ea0db
+++ b/configure.ac
Ray Strode 0ea0db
@@ -1,58 +1,58 @@
Ray Strode 0ea0db
 AC_INIT([AccountsService],[0.6.35])
Ray Strode 0ea0db
 AM_INIT_AUTOMAKE(no-dist-gzip dist-xz tar-ustar foreign)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 GETTEXT_PACKAGE=accounts-service
Ray Strode 0ea0db
 AC_SUBST(GETTEXT_PACKAGE)
Ray Strode 0ea0db
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",
Ray Strode 0ea0db
                    [the gettext translation domain])
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 # Support silent build rules, requires at least automake-1.11. Enable
Ray Strode 0ea0db
 # by either passing --enable-silent-rules to configure or passing V=0
Ray Strode 0ea0db
 # to make
Ray Strode 0ea0db
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 AC_USE_SYSTEM_EXTENSIONS
Ray Strode 0ea0db
 AC_PROG_CC
Ray Strode 0ea0db
 PKG_PROG_PKG_CONFIG
Ray Strode 0ea0db
 AM_GLIB_GNU_GETTEXT
Ray Strode 0ea0db
 IT_PROG_INTLTOOL([0.40.0])
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 LT_INIT
Ray Strode 0ea0db
 LT_CURRENT=0
Ray Strode 0ea0db
 LT_REVISION=0
Ray Strode 0ea0db
 LT_AGE=0
Ray Strode 0ea0db
 AC_SUBST(LT_CURRENT)
Ray Strode 0ea0db
 AC_SUBST(LT_REVISION)
Ray Strode 0ea0db
 AC_SUBST(LT_AGE)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
-PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.37.3 gio-unix-2.0)
Ray Strode 0ea0db
+PKG_CHECK_MODULES(GIO, gio-2.0 gio-unix-2.0)
Ray Strode 0ea0db
 PKG_CHECK_MODULES(POLKIT, gio-unix-2.0 polkit-gobject-1)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 AM_MAINTAINER_MODE([enable])
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 # client library dependencies
Ray Strode 0ea0db
 LIBACCOUNTSSERVICE_LIBS="$GIO_LIBS"
Ray Strode 0ea0db
 AC_SUBST(LIBACCOUNTSSERVICE_LIBS)
Ray Strode 0ea0db
 LIBACCOUNTSSERVICE_CFLAGS="$GIO_CFLAGS"
Ray Strode 0ea0db
 AC_SUBST(LIBACCOUNTSSERVICE_CFLAGS)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 GOBJECT_INTROSPECTION_CHECK([0.9.12])
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 dnl ---------------------------------------------------------------------------
Ray Strode 0ea0db
 dnl - Core configuration
Ray Strode 0ea0db
 dnl ---------------------------------------------------------------------------
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 AC_ARG_ENABLE(admin-group,
Ray Strode 0ea0db
         [AS_HELP_STRING([--enable-admin-group],[Set group for administrative accounts @<:@default=auto@:>@])],
Ray Strode 0ea0db
         ,enable_admin_group=auto)
Ray Strode 0ea0db
 AS_IF([test x$enable_admin_group = xauto], [
Ray Strode 0ea0db
   AC_CHECK_FILE(/etc/redhat-release, enable_admin_group=wheel)
Ray Strode 0ea0db
   AC_CHECK_FILE(/etc/debian_version, enable_admin_group=sudo)
Ray Strode 0ea0db
   AS_IF([test x$enable_admin_group = xauto], [
Ray Strode 0ea0db
     enable_admin_group=wheel
Ray Strode 0ea0db
   ])
Ray Strode 0ea0db
 ])
Ray Strode 0ea0db
 AC_DEFINE_UNQUOTED([ADMIN_GROUP], ["$enable_admin_group"], [Define to the group for administrator users])
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 AC_ARG_ENABLE(user-heuristics,
Ray Strode 0ea0db
         [AS_HELP_STRING([--enable-user-heuristics],[Enable heuristics for guessing system vs. human users])],
Ray Strode 0ea0db
diff --git a/src/Makefile.am b/src/Makefile.am
Ray Strode 0ea0db
index 6940f2d..de57e7a 100644
Ray Strode 0ea0db
--- a/src/Makefile.am
Ray Strode 0ea0db
+++ b/src/Makefile.am
Ray Strode 0ea0db
@@ -7,52 +7,51 @@ INCLUDES = 			\
Ray Strode 0ea0db
 	-DICONDIR=\"$(localstatedir)/lib/AccountsService/icons\" \
Ray Strode 0ea0db
 	-DUSERDIR=\"$(localstatedir)/lib/AccountsService/users\" \
Ray Strode 0ea0db
 	-I$(srcdir)		\
Ray Strode 0ea0db
 	-I$(builddir)		\
Ray Strode 0ea0db
 	$(POLKIT_CFLAGS)	\
Ray Strode 0ea0db
 	$(WARN_CFLAGS)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 noinst_LTLIBRARIES = libaccounts-generated.la
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 libaccounts_generated_la_SOURCES = \
Ray Strode 0ea0db
 	accounts-generated.c		\
Ray Strode 0ea0db
 	accounts-generated.h		\
Ray Strode 0ea0db
 	accounts-user-generated.c	\
Ray Strode 0ea0db
 	accounts-user-generated.h	\
Ray Strode 0ea0db
 	$(NULL)
Ray Strode 0ea0db
 BUILT_SOURCES += $(libaccounts_generated_la_SOURCES)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 accounts-generated.c accounts-generated.h: $(top_srcdir)/data/org.freedesktop.Accounts.xml Makefile
Ray Strode 0ea0db
 	gdbus-codegen --generate-c-code accounts-generated --c-namespace Accounts --interface-prefix=org.freedesktop. $(top_srcdir)/data/org.freedesktop.Accounts.xml
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 accounts-user-generated.c accounts-user-generated.h: $(top_srcdir)/data/org.freedesktop.Accounts.User.xml Makefile
Ray Strode 0ea0db
 	gdbus-codegen --generate-c-code accounts-user-generated --c-namespace Accounts --interface-prefix=org.freedesktop.Accounts. $(top_srcdir)/data/org.freedesktop.Accounts.User.xml
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 libexec_PROGRAMS = accounts-daemon
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 accounts_daemon_SOURCES = 	\
Ray Strode 0ea0db
 	$(enums_h_sources)	\
Ray Strode 0ea0db
 	types.h			\
Ray Strode 0ea0db
 	daemon.h		\
Ray Strode 0ea0db
 	daemon.c		\
Ray Strode 0ea0db
-	extensions.c		\
Ray Strode 0ea0db
 	user-classify.h		\
Ray Strode 0ea0db
 	user-classify.c		\
Ray Strode 0ea0db
 	user.h			\
Ray Strode 0ea0db
 	user.c			\
Ray Strode 0ea0db
 	util.h			\
Ray Strode 0ea0db
 	util.c			\
Ray Strode 0ea0db
 	main.c
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 accounts_daemon_LDADD = 	\
Ray Strode 0ea0db
 	libaccounts-generated.la	\
Ray Strode 0ea0db
 	$(POLKIT_LIBS)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 CLEANFILES = \
Ray Strode 0ea0db
 	$(BUILT_SOURCES) \
Ray Strode 0ea0db
 	*.gcda \
Ray Strode 0ea0db
 	*.gcno \
Ray Strode 0ea0db
 	$(NULL)
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 install-data-hook:
Ray Strode 0ea0db
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/AccountsService/users"
Ray Strode 0ea0db
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/AccountsService/icons"
Ray Strode 0ea0db
diff --git a/src/daemon.c b/src/daemon.c
Ray Strode 0ea0db
index 9c9f617..ea75190 100644
Ray Strode 0ea0db
--- a/src/daemon.c
Ray Strode 0ea0db
+++ b/src/daemon.c
Ray Strode 0ea0db
@@ -53,61 +53,60 @@
Ray Strode 0ea0db
 #define PATH_GDM_CUSTOM "/etc/gdm/custom.conf"
Ray Strode 0ea0db
 #ifdef HAVE_UTMPX_H
Ray Strode 0ea0db
 #define PATH_WTMP _PATH_WTMPX
Ray Strode 0ea0db
 #endif
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 enum {
Ray Strode 0ea0db
         PROP_0,
Ray Strode 0ea0db
         PROP_DAEMON_VERSION
Ray Strode 0ea0db
 };
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 struct DaemonPrivate {
Ray Strode 0ea0db
         GDBusConnection *bus_connection;
Ray Strode 0ea0db
         GDBusProxy *bus_proxy;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         GHashTable *users;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         User *autologin;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         GFileMonitor *passwd_monitor;
Ray Strode 0ea0db
         GFileMonitor *shadow_monitor;
Ray Strode 0ea0db
         GFileMonitor *group_monitor;
Ray Strode 0ea0db
         GFileMonitor *gdm_monitor;
Ray Strode 0ea0db
 #ifdef HAVE_UTMPX_H
Ray Strode 0ea0db
         GFileMonitor *wtmp_monitor;
Ray Strode 0ea0db
 #endif
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         guint reload_id;
Ray Strode 0ea0db
         guint autologin_id;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         PolkitAuthority *authority;
Ray Strode 0ea0db
-        GHashTable *extension_ifaces;
Ray Strode 0ea0db
 };
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 typedef struct passwd * (* EntryGeneratorFunc) (GHashTable *, gpointer *);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static void daemon_accounts_accounts_iface_init (AccountsAccountsIface *iface);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 G_DEFINE_TYPE_WITH_CODE (Daemon, daemon, ACCOUNTS_TYPE_ACCOUNTS_SKELETON, G_IMPLEMENT_INTERFACE (ACCOUNTS_TYPE_ACCOUNTS, daemon_accounts_accounts_iface_init));
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 #define DAEMON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_DAEMON, DaemonPrivate))
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static const GDBusErrorEntry accounts_error_entries[] =
Ray Strode 0ea0db
 { 
Ray Strode 0ea0db
         { ERROR_FAILED, "org.freedesktop.Accounts.Error.Failed" },
Ray Strode 0ea0db
         { ERROR_USER_EXISTS, "org.freedesktop.Accounts.Error.UserExists" },
Ray Strode 0ea0db
         { ERROR_USER_DOES_NOT_EXIST, "org.freedesktop.Accounts.Error.UserDoesNotExist" },
Ray Strode 0ea0db
         { ERROR_PERMISSION_DENIED, "org.freedesktop.Accounts.Error.PermissionDenied" },
Ray Strode 0ea0db
         { ERROR_NOT_SUPPORTED, "org.freedesktop.Accounts.Error.NotSupported" }
Ray Strode 0ea0db
 };
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 GQuark
Ray Strode 0ea0db
 error_quark (void)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         static volatile gsize quark_volatile = 0;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         g_dbus_error_register_error_domain ("accounts_error",
Ray Strode 0ea0db
                                             &quark_volatile,
Ray Strode 0ea0db
                                             accounts_error_entries,
Ray Strode 0ea0db
                                             G_N_ELEMENTS (accounts_error_entries));
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         return (GQuark) quark_volatile;
Ray Strode 0ea0db
@@ -656,107 +655,103 @@ setup_monitor (Daemon             *daemon,
Ray Strode 0ea0db
                FileChangeCallback *callback)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         GError *error = NULL;
Ray Strode 0ea0db
         GFile *file;
Ray Strode 0ea0db
         GFileMonitor *monitor;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         file = g_file_new_for_path (path);
Ray Strode 0ea0db
         monitor = g_file_monitor_file (file,
Ray Strode 0ea0db
                                        G_FILE_MONITOR_NONE,
Ray Strode 0ea0db
                                        NULL,
Ray Strode 0ea0db
                                        &error);
Ray Strode 0ea0db
         if (monitor != NULL) {
Ray Strode 0ea0db
                 g_signal_connect (monitor,
Ray Strode 0ea0db
                                   "changed",
Ray Strode 0ea0db
                                   G_CALLBACK (callback),
Ray Strode 0ea0db
                                   daemon);
Ray Strode 0ea0db
         } else {
Ray Strode 0ea0db
                 g_warning ("Unable to monitor %s: %s", path, error->message);
Ray Strode 0ea0db
                 g_error_free (error);
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
         g_object_unref (file);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         return monitor;
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static void
Ray Strode 0ea0db
 daemon_init (Daemon *daemon)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         daemon->priv = DAEMON_GET_PRIVATE (daemon);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
-        daemon->priv->extension_ifaces = daemon_read_extension_ifaces ();
Ray Strode 0ea0db
-
Ray Strode 0ea0db
         daemon->priv->users = create_users_hash_table ();
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         daemon->priv->passwd_monitor = setup_monitor (daemon,
Ray Strode 0ea0db
                                                       PATH_PASSWD,
Ray Strode 0ea0db
                                                       on_users_monitor_changed);
Ray Strode 0ea0db
         daemon->priv->shadow_monitor = setup_monitor (daemon,
Ray Strode 0ea0db
                                                       PATH_SHADOW,
Ray Strode 0ea0db
                                                       on_users_monitor_changed);
Ray Strode 0ea0db
         daemon->priv->group_monitor = setup_monitor (daemon,
Ray Strode 0ea0db
                                                      PATH_GROUP,
Ray Strode 0ea0db
                                                      on_users_monitor_changed);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 #ifdef HAVE_UTMPX_H
Ray Strode 0ea0db
         daemon->priv->wtmp_monitor = setup_monitor (daemon,
Ray Strode 0ea0db
                                                     PATH_WTMP,
Ray Strode 0ea0db
                                                     on_users_monitor_changed);
Ray Strode 0ea0db
 #endif
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         daemon->priv->gdm_monitor = setup_monitor (daemon,
Ray Strode 0ea0db
                                                    PATH_GDM_CUSTOM,
Ray Strode 0ea0db
                                                    on_gdm_monitor_changed);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         queue_reload_users (daemon);
Ray Strode 0ea0db
         queue_reload_autologin (daemon);
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static void
Ray Strode 0ea0db
 daemon_finalize (GObject *object)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         Daemon *daemon;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         g_return_if_fail (IS_DAEMON (object));
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         daemon = DAEMON (object);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (daemon->priv->bus_proxy != NULL)
Ray Strode 0ea0db
                 g_object_unref (daemon->priv->bus_proxy);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (daemon->priv->bus_connection != NULL)
Ray Strode 0ea0db
                 g_object_unref (daemon->priv->bus_connection);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         g_hash_table_destroy (daemon->priv->users);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
-        g_hash_table_unref (daemon->priv->extension_ifaces);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
         G_OBJECT_CLASS (daemon_parent_class)->finalize (object);
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static gboolean
Ray Strode 0ea0db
 register_accounts_daemon (Daemon *daemon)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         GError *error = NULL;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         daemon->priv->authority = polkit_authority_get_sync (NULL, &error);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (daemon->priv->authority == NULL) {
Ray Strode 0ea0db
                 if (error != NULL) {
Ray Strode 0ea0db
                         g_critical ("error getting polkit authority: %s", error->message);
Ray Strode 0ea0db
                         g_error_free (error);
Ray Strode 0ea0db
                 }
Ray Strode 0ea0db
                 goto error;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         daemon->priv->bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
Ray Strode 0ea0db
         if (daemon->priv->bus_connection == NULL) {
Ray Strode 0ea0db
                 if (error != NULL) {
Ray Strode 0ea0db
                         g_critical ("error getting system bus: %s", error->message);
Ray Strode 0ea0db
                         g_error_free (error);
Ray Strode 0ea0db
                 }
Ray Strode 0ea0db
                 goto error;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (daemon),
Ray Strode 0ea0db
                                                daemon->priv->bus_connection,
Ray Strode 0ea0db
                                                "/org/freedesktop/Accounts",
Ray Strode 0ea0db
@@ -1526,66 +1521,60 @@ daemon_local_set_automatic_login (Daemon    *daemon,
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         if (daemon->priv->autologin == user && enabled) {
Ray Strode 0ea0db
                 return TRUE;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (daemon->priv->autologin != user && !enabled) {
Ray Strode 0ea0db
                 return TRUE;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (!save_autologin (daemon, user_get_user_name (user), enabled, error)) {
Ray Strode 0ea0db
                 return FALSE;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (daemon->priv->autologin != NULL) {
Ray Strode 0ea0db
                 g_object_set (daemon->priv->autologin, "automatic-login", FALSE, NULL);
Ray Strode 0ea0db
                 g_signal_emit_by_name (daemon->priv->autologin, "changed", 0);
Ray Strode 0ea0db
                 g_object_unref (daemon->priv->autologin);
Ray Strode 0ea0db
                 daemon->priv->autologin = NULL;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (enabled) {
Ray Strode 0ea0db
                 g_object_set (user, "automatic-login", TRUE, NULL);
Ray Strode 0ea0db
                 g_signal_emit_by_name (user, "changed", 0);
Ray Strode 0ea0db
                 g_object_ref (user);
Ray Strode 0ea0db
                 daemon->priv->autologin = user;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         return TRUE;
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
-GHashTable *
Ray Strode 0ea0db
-daemon_get_extension_ifaces (Daemon *daemon)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-  return daemon->priv->extension_ifaces;
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
 static void
Ray Strode 0ea0db
 get_property (GObject    *object,
Ray Strode 0ea0db
               guint       prop_id,
Ray Strode 0ea0db
               GValue     *value,
Ray Strode 0ea0db
               GParamSpec *pspec)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
        switch (prop_id) {
Ray Strode 0ea0db
         case PROP_DAEMON_VERSION:
Ray Strode 0ea0db
                 g_value_set_string (value, VERSION);
Ray Strode 0ea0db
                 break;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         default:
Ray Strode 0ea0db
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Ray Strode 0ea0db
                 break;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static void
Ray Strode 0ea0db
 set_property (GObject      *object,
Ray Strode 0ea0db
               guint         prop_id,
Ray Strode 0ea0db
               const GValue *value,
Ray Strode 0ea0db
               GParamSpec   *pspec)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
        switch (prop_id) {
Ray Strode 0ea0db
         case PROP_DAEMON_VERSION:
Ray Strode 0ea0db
                 g_assert_not_reached ();
Ray Strode 0ea0db
                 break;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         default:
Ray Strode 0ea0db
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Ray Strode 0ea0db
diff --git a/src/daemon.h b/src/daemon.h
Ray Strode 0ea0db
index b7e072e..e036407 100644
Ray Strode 0ea0db
--- a/src/daemon.h
Ray Strode 0ea0db
+++ b/src/daemon.h
Ray Strode 0ea0db
@@ -69,36 +69,33 @@ GQuark error_quark (void);
Ray Strode 0ea0db
 GType   daemon_get_type              (void) G_GNUC_CONST;
Ray Strode 0ea0db
 Daemon *daemon_new                   (void);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 /* local methods */
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 User *daemon_local_find_user_by_id   (Daemon                *daemon,
Ray Strode 0ea0db
                                       uid_t                  uid);
Ray Strode 0ea0db
 User *daemon_local_find_user_by_name (Daemon                *daemon,
Ray Strode 0ea0db
                                       const gchar           *name);
Ray Strode 0ea0db
 User *daemon_local_get_automatic_login_user (Daemon         *daemon);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 typedef void (*AuthorizedCallback)   (Daemon                *daemon,
Ray Strode 0ea0db
                                       User                  *user,
Ray Strode 0ea0db
                                       GDBusMethodInvocation *context,
Ray Strode 0ea0db
                                       gpointer               data);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 void         daemon_local_check_auth (Daemon                *daemon,
Ray Strode 0ea0db
                                       User                  *user,
Ray Strode 0ea0db
                                       const gchar           *action_id,
Ray Strode 0ea0db
                                       gboolean               allow_interaction,
Ray Strode 0ea0db
                                       AuthorizedCallback     auth_cb,
Ray Strode 0ea0db
                                       GDBusMethodInvocation *context,
Ray Strode 0ea0db
                                       gpointer               data,
Ray Strode 0ea0db
                                       GDestroyNotify         destroy_notify);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 gboolean   daemon_local_set_automatic_login (Daemon         *daemon,
Ray Strode 0ea0db
                                              User           *user,
Ray Strode 0ea0db
                                              gboolean        enabled,
Ray Strode 0ea0db
                                              GError        **error);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
-GHashTable * daemon_read_extension_ifaces (void);
Ray Strode 0ea0db
-GHashTable * daemon_get_extension_ifaces (Daemon *daemon);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
 G_END_DECLS
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 #endif /* __DAEMON_H__ */
Ray Strode 0ea0db
diff --git a/src/user.c b/src/user.c
Ray Strode 0ea0db
index 1698eeb..163d136 100644
Ray Strode 0ea0db
--- a/src/user.c
Ray Strode 0ea0db
+++ b/src/user.c
Ray Strode 0ea0db
@@ -77,63 +77,60 @@ struct User {
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         GDBusConnection *system_bus_connection;
Ray Strode 0ea0db
         gchar *object_path;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         Daemon       *daemon;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         GKeyFile     *keyfile;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         uid_t         uid;
Ray Strode 0ea0db
         gid_t         gid;
Ray Strode 0ea0db
         gchar        *user_name;
Ray Strode 0ea0db
         gchar        *real_name;
Ray Strode 0ea0db
         AccountType   account_type;
Ray Strode 0ea0db
         PasswordMode  password_mode;
Ray Strode 0ea0db
         gchar        *password_hint;
Ray Strode 0ea0db
         gchar        *home_dir;
Ray Strode 0ea0db
         gchar        *shell;
Ray Strode 0ea0db
         gchar        *email;
Ray Strode 0ea0db
         gchar        *language;
Ray Strode 0ea0db
         gchar        *x_session;
Ray Strode 0ea0db
         gchar        *location;
Ray Strode 0ea0db
         guint64       login_frequency;
Ray Strode 0ea0db
         gint64        login_time;
Ray Strode 0ea0db
         GVariant     *login_history;
Ray Strode 0ea0db
         gchar        *icon_file;
Ray Strode 0ea0db
         gchar        *default_icon_file;
Ray Strode 0ea0db
         gboolean      locked;
Ray Strode 0ea0db
         gboolean      automatic_login;
Ray Strode 0ea0db
         gboolean      system_account;
Ray Strode 0ea0db
         gboolean      local_account;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        guint        *extension_ids;
Ray Strode 0ea0db
-        guint         n_extension_ids;
Ray Strode 0ea0db
 };
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 typedef struct UserClass
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         AccountsUserSkeletonClass parent_class;
Ray Strode 0ea0db
 } UserClass;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static void user_accounts_user_iface_init (AccountsUserIface *iface);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 G_DEFINE_TYPE_WITH_CODE (User, user, ACCOUNTS_TYPE_USER_SKELETON, G_IMPLEMENT_INTERFACE (ACCOUNTS_TYPE_USER, user_accounts_user_iface_init));
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static gint
Ray Strode 0ea0db
 account_type_from_pwent (struct passwd *pwent)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         struct group *grp;
Ray Strode 0ea0db
         gid_t wheel;
Ray Strode 0ea0db
         gid_t *groups;
Ray Strode 0ea0db
         gint ngroups;
Ray Strode 0ea0db
         gint i;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (pwent->pw_uid == 0) {
Ray Strode 0ea0db
                 g_debug ("user is root so account type is administrator");
Ray Strode 0ea0db
                 return ACCOUNT_TYPE_ADMINISTRATOR;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         grp = getgrnam (ADMIN_GROUP);
Ray Strode 0ea0db
         if (grp == NULL) {
Ray Strode 0ea0db
                 g_debug (ADMIN_GROUP " group not found");
Ray Strode 0ea0db
                 return ACCOUNT_TYPE_STANDARD;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
@@ -436,379 +433,109 @@ save_extra_data (User *user)
Ray Strode 0ea0db
                                              user->user_name,
Ray Strode 0ea0db
                                              NULL);
Ray Strode 0ea0db
                 g_file_set_contents (filename, data, -1, &error);
Ray Strode 0ea0db
                 g_free (filename);
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
         if (error) {
Ray Strode 0ea0db
                 g_warning ("Saving data for user %s failed: %s",
Ray Strode 0ea0db
                            user->user_name, error->message);
Ray Strode 0ea0db
                 g_error_free (error);
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 static void
Ray Strode 0ea0db
 move_extra_data (const gchar *old_name,
Ray Strode 0ea0db
                  const gchar *new_name)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         gchar *old_filename;
Ray Strode 0ea0db
         gchar *new_filename;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         old_filename = g_build_filename (USERDIR,
Ray Strode 0ea0db
                                          old_name, NULL);
Ray Strode 0ea0db
         new_filename = g_build_filename (USERDIR,
Ray Strode 0ea0db
                                          new_name, NULL);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         g_rename (old_filename, new_filename);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         g_free (old_filename);
Ray Strode 0ea0db
         g_free (new_filename);
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
-static GVariant *
Ray Strode 0ea0db
-user_extension_get_value (User                    *user,
Ray Strode 0ea0db
-                          GDBusInterfaceInfo      *interface,
Ray Strode 0ea0db
-                          const GDBusPropertyInfo *property)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-        const GVariantType *type = G_VARIANT_TYPE (property->signature);
Ray Strode 0ea0db
-        GVariant *value;
Ray Strode 0ea0db
-        gchar *printed;
Ray Strode 0ea0db
-        gint i;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* First, try to get the value from the keyfile */
Ray Strode 0ea0db
-        printed = g_key_file_get_value (user->keyfile, interface->name, property->name, NULL);
Ray Strode 0ea0db
-        if (printed) {
Ray Strode 0ea0db
-                value = g_variant_parse (type, printed, NULL, NULL, NULL);
Ray Strode 0ea0db
-                g_free (printed);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                if (value != NULL)
Ray Strode 0ea0db
-                        return value;
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* If that didn't work, try for a default value annotation */
Ray Strode 0ea0db
-        for (i = 0; property->annotations && property->annotations[i]; i++) {
Ray Strode 0ea0db
-                GDBusAnnotationInfo *annotation = property->annotations[i];
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                if (g_str_equal (annotation->key, "org.freedesktop.Accounts.DefaultValue.String")) {
Ray Strode 0ea0db
-                        if (g_str_equal (property->signature, "s"))
Ray Strode 0ea0db
-                                return g_variant_ref_sink (g_variant_new_string (annotation->value));
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-                else if (g_str_equal (annotation->key, "org.freedesktop.Accounts.DefaultValue")) {
Ray Strode 0ea0db
-                        value = g_variant_parse (type, annotation->value, NULL, NULL, NULL);
Ray Strode 0ea0db
-                        if (value != NULL)
Ray Strode 0ea0db
-                                return value;
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* Nothing found... */
Ray Strode 0ea0db
-        return NULL;
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-static void
Ray Strode 0ea0db
-user_extension_get_property (User                  *user,
Ray Strode 0ea0db
-                             Daemon                *daemon,
Ray Strode 0ea0db
-                             GDBusInterfaceInfo    *interface,
Ray Strode 0ea0db
-                             GDBusMethodInvocation *invocation)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-        const GDBusPropertyInfo *property = g_dbus_method_invocation_get_property_info (invocation);
Ray Strode 0ea0db
-        GVariant *value;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        value = user_extension_get_value (user, interface, property);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        if (value) {
Ray Strode 0ea0db
-                g_dbus_method_invocation_return_value (invocation, g_variant_new ("(v)", value));
Ray Strode 0ea0db
-                g_variant_unref (value);
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-        else {
Ray Strode 0ea0db
-                g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
Ray Strode 0ea0db
-                                                       "Key '%s' is not set and has no default value",
Ray Strode 0ea0db
-                                                       property->name);
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-static void
Ray Strode 0ea0db
-user_extension_get_all_properties (User                  *user,
Ray Strode 0ea0db
-                                   Daemon                *daemon,
Ray Strode 0ea0db
-                                   GDBusInterfaceInfo    *interface,
Ray Strode 0ea0db
-                                   GDBusMethodInvocation *invocation)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-        GVariantBuilder builder;
Ray Strode 0ea0db
-        gint i;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
Ray Strode 0ea0db
-        for (i = 0; interface->properties && interface->properties[i]; i++) {
Ray Strode 0ea0db
-                GDBusPropertyInfo *property = interface->properties[i];
Ray Strode 0ea0db
-                GVariant *value;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                value = user_extension_get_value (user, interface, property);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                if (value) {
Ray Strode 0ea0db
-                        g_variant_builder_add (&builder, "{sv}", property->name, value);
Ray Strode 0ea0db
-                        g_variant_unref (value);
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a{sv})", &builder));
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-static void
Ray Strode 0ea0db
-user_extension_set_property (User                  *user,
Ray Strode 0ea0db
-                             Daemon                *daemon,
Ray Strode 0ea0db
-                             GDBusInterfaceInfo    *interface,
Ray Strode 0ea0db
-                             GDBusMethodInvocation *invocation)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-        const GDBusPropertyInfo *property = g_dbus_method_invocation_get_property_info (invocation);
Ray Strode 0ea0db
-        GVariant *value;
Ray Strode 0ea0db
-        gchar *printed;
Ray Strode 0ea0db
-        gchar *prev;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        g_variant_get_child (g_dbus_method_invocation_get_parameters (invocation), 2, "v", &value);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* We'll always have the type when we parse it back so
Ray Strode 0ea0db
-         * we don't need it to be printed with annotations.
Ray Strode 0ea0db
-         */
Ray Strode 0ea0db
-        printed = g_variant_print (value, FALSE);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* May as well try to avoid the thrashing... */
Ray Strode 0ea0db
-        prev = g_key_file_get_value (user->keyfile, interface->name, property->name, NULL);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        if (!prev || !g_str_equal (printed, prev)) {
Ray Strode 0ea0db
-                g_key_file_set_value (user->keyfile, interface->name, property->name, printed);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                /* Emit a change signal.  Use invalidation
Ray Strode 0ea0db
-                 * because the data may not be world-readable.
Ray Strode 0ea0db
-                 */
Ray Strode 0ea0db
-                g_dbus_connection_emit_signal (g_dbus_method_invocation_get_connection (invocation),
Ray Strode 0ea0db
-                                               NULL, /* destination_bus_name */
Ray Strode 0ea0db
-                                               g_dbus_method_invocation_get_object_path (invocation),
Ray Strode 0ea0db
-                                               "org.freedesktop.DBus.Properties", "PropertiesChanged",
Ray Strode 0ea0db
-                                               g_variant_new_parsed ("( %s, %a{sv}, [ %s ] )",
Ray Strode 0ea0db
-                                                                     interface->name, NULL, property->name),
Ray Strode 0ea0db
-                                               NULL);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                accounts_user_emit_changed (ACCOUNTS_USER (user));
Ray Strode 0ea0db
-                save_extra_data (user);
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        g_variant_unref (value);
Ray Strode 0ea0db
-        g_free (printed);
Ray Strode 0ea0db
-        g_free (prev);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-static void
Ray Strode 0ea0db
-user_extension_authentication_done (Daemon                *daemon,
Ray Strode 0ea0db
-                                    User                  *user,
Ray Strode 0ea0db
-                                    GDBusMethodInvocation *invocation,
Ray Strode 0ea0db
-                                    gpointer               user_data)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-        GDBusInterfaceInfo *interface = user_data;
Ray Strode 0ea0db
-        const gchar *method_name;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        method_name = g_dbus_method_invocation_get_method_name (invocation);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        if (g_str_equal (method_name, "Get"))
Ray Strode 0ea0db
-                user_extension_get_property (user, daemon, interface, invocation);
Ray Strode 0ea0db
-        else if (g_str_equal (method_name, "GetAll"))
Ray Strode 0ea0db
-                user_extension_get_all_properties (user, daemon, interface, invocation);
Ray Strode 0ea0db
-        else if (g_str_equal (method_name, "Set"))
Ray Strode 0ea0db
-                user_extension_set_property (user, daemon, interface, invocation);
Ray Strode 0ea0db
-        else
Ray Strode 0ea0db
-                g_assert_not_reached ();
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-static void
Ray Strode 0ea0db
-user_extension_method_call (GDBusConnection       *connection,
Ray Strode 0ea0db
-                            const gchar           *sender,
Ray Strode 0ea0db
-                            const gchar           *object_path,
Ray Strode 0ea0db
-                            const gchar           *interface_name,
Ray Strode 0ea0db
-                            const gchar           *method_name,
Ray Strode 0ea0db
-                            GVariant              *parameters,
Ray Strode 0ea0db
-                            GDBusMethodInvocation *invocation,
Ray Strode 0ea0db
-                            gpointer               user_data)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-        User *user = user_data;
Ray Strode 0ea0db
-        GDBusInterfaceInfo *iface_info;
Ray Strode 0ea0db
-        const gchar *annotation_name;
Ray Strode 0ea0db
-        const gchar *action_id;
Ray Strode 0ea0db
-        gint uid;
Ray Strode 0ea0db
-        gint i;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* We don't allow method calls on extension interfaces, so we
Ray Strode 0ea0db
-         * should only ever see property calls here.
Ray Strode 0ea0db
-         */
Ray Strode 0ea0db
-        g_assert_cmpstr (interface_name, ==, "org.freedesktop.DBus.Properties");
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* Now get the real interface name */
Ray Strode 0ea0db
-        g_variant_get_child (parameters, 0, "&s", &interface_name);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        if (get_caller_uid (invocation, &uid) && (uid_t) uid == user->uid) {
Ray Strode 0ea0db
-                /* Operation on sender's own User object */
Ray Strode 0ea0db
-                if (g_str_equal (method_name, "Set")) {
Ray Strode 0ea0db
-                        annotation_name = "org.freedesktop.Accounts.Authentication.ChangeOwn";
Ray Strode 0ea0db
-                        action_id = "org.freedesktop.accounts.change-own-user-data";
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-                else {
Ray Strode 0ea0db
-                        annotation_name = "org.freedesktop.Accounts.Authentication.ReadOwn";
Ray Strode 0ea0db
-                        action_id = ""; /* reading allowed by default */
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-        else {
Ray Strode 0ea0db
-                /* Operation on someone else's User object */
Ray Strode 0ea0db
-                if (g_str_equal (method_name, "Set")) {
Ray Strode 0ea0db
-                        annotation_name = "org.freedesktop.Accounts.Authentication.ChangeAny";
Ray Strode 0ea0db
-                        action_id = "org.freedesktop.accounts.user-administration";
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-                else {
Ray Strode 0ea0db
-                        annotation_name = "org.freedesktop.Accounts.Authentication.ReadAny";
Ray Strode 0ea0db
-                        action_id = ""; /* reading allowed by default */
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        iface_info = g_hash_table_lookup (daemon_get_extension_ifaces (user->daemon), interface_name);
Ray Strode 0ea0db
-        g_assert (iface_info != NULL);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        for (i = 0; iface_info->annotations && iface_info->annotations[i]; i++) {
Ray Strode 0ea0db
-                if (g_str_equal (iface_info->annotations[i]->key, annotation_name)) {
Ray Strode 0ea0db
-                        action_id = iface_info->annotations[i]->value;
Ray Strode 0ea0db
-                        break;
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        if (action_id[0] == '\0') {
Ray Strode 0ea0db
-                /* Should always allow this call, so just do it now */
Ray Strode 0ea0db
-                user_extension_authentication_done (user->daemon, user, invocation, iface_info);
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-        else {
Ray Strode 0ea0db
-                daemon_local_check_auth (user->daemon, user, action_id, TRUE,
Ray Strode 0ea0db
-                                         user_extension_authentication_done,
Ray Strode 0ea0db
-                                         invocation, iface_info, NULL);
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-static void
Ray Strode 0ea0db
-user_register_extensions (User *user)
Ray Strode 0ea0db
-{
Ray Strode 0ea0db
-        static const GDBusInterfaceVTable vtable = {
Ray Strode 0ea0db
-                user_extension_method_call,
Ray Strode 0ea0db
-                NULL /* get_property */,
Ray Strode 0ea0db
-                NULL /* set_property */
Ray Strode 0ea0db
-        };
Ray Strode 0ea0db
-        GHashTable *extensions;
Ray Strode 0ea0db
-        GHashTableIter iter;
Ray Strode 0ea0db
-        gpointer iface;
Ray Strode 0ea0db
-        gint i = 0;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        g_assert (user->extension_ids == NULL);
Ray Strode 0ea0db
-        g_assert (user->n_extension_ids == 0);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        extensions = daemon_get_extension_ifaces (user->daemon);
Ray Strode 0ea0db
-        user->n_extension_ids = g_hash_table_size (extensions);
Ray Strode 0ea0db
-        user->extension_ids = g_new (guint, user->n_extension_ids);
Ray Strode 0ea0db
-        g_hash_table_iter_init (&iter, extensions);
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        /* Ignore errors when registering more interfaces because (a)
Ray Strode 0ea0db
-         * they won't happen and (b) even if they do, we still want to
Ray Strode 0ea0db
-         * publish the main user interface.
Ray Strode 0ea0db
-         */
Ray Strode 0ea0db
-        while (g_hash_table_iter_next (&iter, NULL, &iface))
Ray Strode 0ea0db
-                user->extension_ids[i++] = g_dbus_connection_register_object (user->system_bus_connection,
Ray Strode 0ea0db
-                                                                              user->object_path, iface,
Ray Strode 0ea0db
-                                                                              &vtable, user, NULL, NULL);
Ray Strode 0ea0db
-}
Ray Strode 0ea0db
-
Ray Strode 0ea0db
 static gchar *
Ray Strode 0ea0db
 compute_object_path (User *user)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         gchar *object_path;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         object_path = g_strdup_printf ("/org/freedesktop/Accounts/User%ld",
Ray Strode 0ea0db
                                        (long) user->uid);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         return object_path;
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 void
Ray Strode 0ea0db
 user_register (User *user)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         GError *error = NULL;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         user->system_bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
Ray Strode 0ea0db
         if (user->system_bus_connection == NULL) {
Ray Strode 0ea0db
                 if (error != NULL) {
Ray Strode 0ea0db
                         g_critical ("error getting system bus: %s", error->message);
Ray Strode 0ea0db
                         g_error_free (error);
Ray Strode 0ea0db
                 }
Ray Strode 0ea0db
                 return;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         user->object_path = compute_object_path (user);
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (user),
Ray Strode 0ea0db
                                                user->system_bus_connection,
Ray Strode 0ea0db
                                                user->object_path,
Ray Strode 0ea0db
                                                &error)) {
Ray Strode 0ea0db
                 if (error != NULL) {
Ray Strode 0ea0db
                         g_critical ("error exporting user object: %s", error->message);
Ray Strode 0ea0db
                         g_error_free (error);
Ray Strode 0ea0db
                 }
Ray Strode 0ea0db
                 return;
Ray Strode 0ea0db
         }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        user_register_extensions (user);
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 void
Ray Strode 0ea0db
 user_save (User *user)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
     save_extra_data (user);
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 void
Ray Strode 0ea0db
 user_unregister (User *user)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (user));
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-        if (user->extension_ids) {
Ray Strode 0ea0db
-                guint i;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                for (i = 0; i < user->n_extension_ids; i++) {
Ray Strode 0ea0db
-                        /* In theory, if an error happened during registration, we could have 0 here. */
Ray Strode 0ea0db
-                        if (user->extension_ids[i] == 0)
Ray Strode 0ea0db
-                                continue;
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                        g_dbus_connection_unregister_object (user->system_bus_connection, user->extension_ids[i]);
Ray Strode 0ea0db
-                }
Ray Strode 0ea0db
-
Ray Strode 0ea0db
-                g_clear_pointer (&user->extension_ids, g_free);
Ray Strode 0ea0db
-                user->n_extension_ids = 0;
Ray Strode 0ea0db
-        }
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 void
Ray Strode 0ea0db
 user_changed (User *user)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         accounts_user_emit_changed (ACCOUNTS_USER (user));
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 User *
Ray Strode 0ea0db
 user_new (Daemon *daemon,
Ray Strode 0ea0db
           uid_t   uid)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         User *user;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         user = g_object_new (TYPE_USER, NULL);
Ray Strode 0ea0db
         user->daemon = daemon;
Ray Strode 0ea0db
         user->uid = uid;
Ray Strode 0ea0db
 
Ray Strode 0ea0db
         return user;
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 const gchar *
Ray Strode 0ea0db
 user_get_user_name (User *user)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
         return user->user_name;
Ray Strode 0ea0db
 }
Ray Strode 0ea0db
 
Ray Strode 0ea0db
 gboolean
Ray Strode 0ea0db
 user_get_system_account (User *user)
Ray Strode 0ea0db
 {
Ray Strode 0ea0db
-- 
Ray Strode 0ea0db
1.8.3.1
Ray Strode 0ea0db