[gdm] daemon: Replace old method/signal-based API with async method calls
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] daemon: Replace old method/signal-based API with async method calls
- Date: Wed, 1 Aug 2012 15:21:24 +0000 (UTC)
commit 2672f6a1f43d054c0aab34b623f0f0e6edd8ed5f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jul 18 17:36:44 2012 -0400
daemon: Replace old method/signal-based API with async method calls
Before, the session worker and session communicated by a series of signals
and methods... but backwards. The session worker would listen for a series
of signals sent out by the session, and respond back by calling methods on
it. This requires a lot of annoying, silly manual labor when trying to add
another method to the API.
So, reverse the API so that the worker manager calls async methods on the
worker itself.
https://bugzilla.gnome.org/show_bug.cgi?id=678057
.gitignore | 2 +
daemon/Makefile.am | 22 +
daemon/gdm-session-worker-common.c | 57 +++
daemon/gdm-session-worker-common.h | 49 +++
daemon/gdm-session-worker.c | 774 ++++++++++++++++-------------------
daemon/gdm-session-worker.h | 25 +-
daemon/gdm-session-worker.xml | 86 ++++
daemon/gdm-session.c | 809 ++++++++++++++++--------------------
daemon/gdm-session.xml | 137 ------
daemon/session-worker-main.c | 3 -
10 files changed, 922 insertions(+), 1042 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 8e1605f..60a4d5b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,6 +39,8 @@ gdm-safe-restart
gdm.schemas
gdm-session-glue.h
gdm-session-glue.c
+gdm-session-worker-glue.h
+gdm-session-worker-glue.c
gdm-settings-glue.h
gdm-settings-glue.c
gdm-simple-greeter.desktop.in
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index abf5062..b7c86c4 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -38,6 +38,7 @@ BUILT_SOURCES = \
gdm-transient-display-glue.h \
gdm-local-display-factory-glue.h \
gdm-session-glue.h \
+ gdm-session-worker-glue.h \
gdm-session-enum-types.h \
$(NULL)
@@ -96,6 +97,13 @@ gdm-session-glue.c gdm-session-glue.h : gdm-session.xml Makefile.am
--generate-c-code=gdm-session-glue \
$(srcdir)/gdm-session.xml
+gdm-session-worker-glue.c gdm-session-worker-glue.h : gdm-session-worker.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace=GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-session-worker-glue \
+ $(srcdir)/gdm-session-worker.xml
+
gdm-slave-glue.c gdm-slave-glue.h: gdm-slave.xml Makefile.am
$(AM_V_GEN)gdbus-codegen \
--c-namespace=GdmDBus \
@@ -150,6 +158,8 @@ gdm_simple_slave_SOURCES = \
gdm-session.h \
gdm-session-record.c \
gdm-session-record.h \
+ gdm-session-worker-common.c \
+ gdm-session-worker-common.h \
gdm-session-worker-job.c \
gdm-session-worker-job.h \
gdm-xerrors.h \
@@ -169,6 +179,8 @@ nodist_gdm_simple_slave_SOURCES = \
gdm-session-enum-types.h \
gdm-session-glue.c \
gdm-session-glue.h \
+ gdm-session-worker-glue.c \
+ gdm-session-worker-glue.h \
gdm-slave-glue.c \
gdm-slave-glue.h \
$(NULL)
@@ -192,6 +204,8 @@ gdm_xdmcp_chooser_slave_SOURCES = \
gdm-session.h \
gdm-session-record.c \
gdm-session-record.h \
+ gdm-session-worker-common.c \
+ gdm-session-worker-common.h \
gdm-session-worker-job.c \
gdm-session-worker-job.h \
gdm-welcome-session.c \
@@ -209,6 +223,8 @@ gdm_xdmcp_chooser_slave_SOURCES = \
nodist_gdm_xdmcp_chooser_slave_SOURCES = \
gdm-session-glue.c \
gdm-session-glue.h \
+ gdm-session-worker-glue.c \
+ gdm-session-worker-glue.h \
gdm-session-enum-types.c \
gdm-session-enum-types.h \
gdm-display-glue.c \
@@ -241,6 +257,8 @@ gdm_session_worker_SOURCES = \
gdm-session-worker.h \
gdm-session-worker.c \
gdm-session-worker-job.c \
+ gdm-session-worker-common.c \
+ gdm-session-worker-common.h \
gdm-dbus-util.c \
gdm-dbus-util.h \
$(NULL)
@@ -248,6 +266,8 @@ gdm_session_worker_SOURCES = \
nodist_gdm_session_worker_SOURCES = \
gdm-session-glue.h \
gdm-session-glue.c \
+ gdm-session-worker-glue.c \
+ gdm-session-worker-glue.h \
gdm-session-enum-types.c \
gdm-session-enum-types.h \
$(NULL)
@@ -380,6 +400,7 @@ CLEANFILES = \
gdm-local-display-factory-glue.c \
gdm-manager-glue.c \
gdm-session-glue.c \
+ gdm-session-worker-glue.c \
gdm-session-enum-types.c \
gdm-slave-glue.c \
gdm-static-display-glue.c \
@@ -392,6 +413,7 @@ CLEANFILES = \
EXTRA_DIST = \
gdm.in \
gdm-manager.xml \
+ gdm-session-worker.xml \
gdm-session.xml \
gdm-slave.xml \
gdm-xdmcp-chooser-slave.xml \
diff --git a/daemon/gdm-session-worker-common.c b/daemon/gdm-session-worker-common.c
new file mode 100644
index 0000000..235df84
--- /dev/null
+++ b/daemon/gdm-session-worker-common.c
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Ray Strode <rstrode redhat com>
+ * Copyright (C) 2012 Jasper St. Pierre <jstpierre mecheye net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "gdm-session-worker-common.h"
+
+static const GDBusErrorEntry gdm_session_worker_error_entries[] = {
+ { GDM_SESSION_WORKER_ERROR_GENERIC , "org.gnome.DisplayManager.SessionWorker.Error.Generic", },
+ { GDM_SESSION_WORKER_ERROR_WITH_SESSION_COMMAND , "org.gnome.DisplayManager.SessionWorker.Error.WithSessionCommand" },
+ { GDM_SESSION_WORKER_ERROR_FORKING , "org.gnome.DisplayManager.SessionWorker.Error.Forking" },
+ { GDM_SESSION_WORKER_ERROR_OPENING_MESSAGE_PIPE , "org.gnome.DisplayManager.SessionWorker.Error.OpeningMessagePipe" },
+ { GDM_SESSION_WORKER_ERROR_COMMUNICATING , "org.gnome.DisplayManager.SessionWorker.Error.Communicating" },
+ { GDM_SESSION_WORKER_ERROR_WORKER_DIED , "org.gnome.DisplayManager.SessionWorker.Error.WorkerDied" },
+ { GDM_SESSION_WORKER_ERROR_SERVICE_UNAVAILABLE , "org.gnome.DisplayManager.SessionWorker.Error.ServiceUnavailable" },
+ { GDM_SESSION_WORKER_ERROR_AUTHENTICATING , "org.gnome.DisplayManager.SessionWorker.Error.Authenticating" },
+ { GDM_SESSION_WORKER_ERROR_AUTHORIZING , "org.gnome.DisplayManager.SessionWorker.Error.Authorizing" },
+ { GDM_SESSION_WORKER_ERROR_OPENING_LOG_FILE , "org.gnome.DisplayManager.SessionWorker.Error.OpeningLogFile" },
+ { GDM_SESSION_WORKER_ERROR_OPENING_SESSION , "org.gnome.DisplayManager.SessionWorker.Error.OpeningSession" },
+ { GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS , "org.gnome.DisplayManager.SessionWorker.Error.GivingCredentials" },
+ { GDM_SESSION_WORKER_ERROR_WRONG_STATE , "org.gnome.DisplayManager.SessionWorker.Error.WrongState" },
+ { GDM_SESSION_WORKER_ERROR_OUTSTANDING_REQUEST , "org.gnome.DisplayManager.SessionWorker.Error.OutstandingRequest" },
+ { GDM_SESSION_WORKER_ERROR_IN_REAUTH_SESSION , "org.gnome.DisplayManager.SessionWorker.Error.InReauthSession" }
+};
+
+GQuark
+gdm_session_worker_error_quark (void)
+{
+ static volatile gsize error_quark = 0;
+
+ g_dbus_error_register_error_domain ("gdm-session-worker-error-quark",
+ &error_quark,
+ gdm_session_worker_error_entries,
+ G_N_ELEMENTS (gdm_session_worker_error_entries));
+
+ return (GQuark) error_quark;
+}
diff --git a/daemon/gdm-session-worker-common.h b/daemon/gdm-session-worker-common.h
new file mode 100644
index 0000000..647a7e9
--- /dev/null
+++ b/daemon/gdm-session-worker-common.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Ray Strode <rstrode redhat com>
+ * Copyright (C) 2012 Jasper St. Pierre <jstpierre mecheye net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __GDM_SESSION_WORKER_COMMON_H
+#define __GDM_SESSION_WORKER_COMMON_H
+
+#include <glib-object.h>
+
+#define GDM_SESSION_WORKER_ERROR (gdm_session_worker_error_quark ())
+
+GQuark gdm_session_worker_error_quark (void);
+
+typedef enum _GdmSessionWorkerError {
+ GDM_SESSION_WORKER_ERROR_GENERIC = 0,
+ GDM_SESSION_WORKER_ERROR_WITH_SESSION_COMMAND,
+ GDM_SESSION_WORKER_ERROR_FORKING,
+ GDM_SESSION_WORKER_ERROR_OPENING_MESSAGE_PIPE,
+ GDM_SESSION_WORKER_ERROR_COMMUNICATING,
+ GDM_SESSION_WORKER_ERROR_WORKER_DIED,
+ GDM_SESSION_WORKER_ERROR_SERVICE_UNAVAILABLE,
+ GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
+ GDM_SESSION_WORKER_ERROR_AUTHORIZING,
+ GDM_SESSION_WORKER_ERROR_OPENING_LOG_FILE,
+ GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
+ GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS,
+ GDM_SESSION_WORKER_ERROR_WRONG_STATE,
+ GDM_SESSION_WORKER_ERROR_OUTSTANDING_REQUEST,
+ GDM_SESSION_WORKER_ERROR_IN_REAUTH_SESSION,
+} GdmSessionWorkerError;
+
+#endif /* GDM_SESSION_WORKER_COMMON_H */
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index f5038d4..a422bb7 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -68,6 +68,8 @@
#define GDM_SESSION_DBUS_NAME "org.gnome.DisplayManager.Session"
#define GDM_SESSION_DBUS_ERROR_CANCEL "org.gnome.DisplayManager.Session.Error.Cancel"
+#define GDM_WORKER_DBUS_PATH "/org/gnome/DisplayManager/Worker"
+
#ifndef GDM_PASSWD_AUXILLARY_BUFFER_SIZE
#define GDM_PASSWD_AUXILLARY_BUFFER_SIZE 1024
#endif
@@ -155,6 +157,8 @@ struct GdmSessionWorkerPrivate
GdmSessionAuditor *auditor;
GdmSessionSettings *user_settings;
+
+ GDBusMethodInvocation *pending_invocation;
};
enum {
@@ -173,24 +177,19 @@ static void gdm_session_worker_set_environment_variable (GdmSessionWorker *w
static void queue_state_change (GdmSessionWorker *worker);
+static void worker_interface_init (GdmDBusWorkerIface *iface);
+
typedef int (* GdmSessionWorkerPamNewMessagesFunc) (int,
const struct pam_message **,
struct pam_response **,
gpointer);
-G_DEFINE_TYPE (GdmSessionWorker, gdm_session_worker, G_TYPE_OBJECT)
-
-GQuark
-gdm_session_worker_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (error_quark == 0)
- error_quark = g_quark_from_static_string ("gdm-session-worker");
-
- return error_quark;
-}
+G_DEFINE_TYPE_WITH_CODE (GdmSessionWorker,
+ gdm_session_worker,
+ GDM_DBUS_TYPE_WORKER_SKELETON,
+ G_IMPLEMENT_INTERFACE (GDM_DBUS_TYPE_WORKER,
+ worker_interface_init))
#ifdef WITH_CONSOLE_KIT
static gboolean
@@ -635,11 +634,8 @@ gdm_session_worker_update_username (GdmSessionWorker *worker)
worker->priv->username = username;
username = NULL;
- gdm_dbus_worker_manager_call_username_changed_sync (worker->priv->manager,
- worker->priv->service,
- worker->priv->username,
- NULL,
- NULL);
+ gdm_dbus_worker_emit_username_changed (GDM_DBUS_WORKER (worker),
+ worker->priv->username);
/* We have a new username to try. If we haven't been able to
* read user settings up until now, then give it a go now
@@ -776,10 +772,7 @@ gdm_session_worker_process_pam_message (GdmSessionWorker *worker,
}
if (worker->priv->timed_out) {
- gdm_dbus_worker_manager_call_cancel_pending_query_sync (worker->priv->manager,
- worker->priv->service,
- NULL,
- NULL);
+ gdm_dbus_worker_emit_cancel_pending_query (GDM_DBUS_WORKER (worker));
worker->priv->timed_out = FALSE;
}
@@ -1578,11 +1571,9 @@ session_worker_child_watch (GPid pid,
gdm_session_worker_uninitialize_pam (worker, PAM_SUCCESS);
- gdm_dbus_worker_manager_call_session_exited_sync (worker->priv->manager,
- worker->priv->service,
- status,
- NULL,
- NULL);
+ gdm_dbus_worker_emit_session_exited (GDM_DBUS_WORKER (worker),
+ worker->priv->service,
+ status);
worker->priv->child_pid = -1;
}
@@ -1999,44 +1990,56 @@ gdm_session_worker_get_property (GObject *object,
}
}
-static void
-on_set_environment_variable (GdmDBusWorkerManager *proxy,
- const char *key,
- const char *value,
- GdmSessionWorker *worker)
+static gboolean
+gdm_session_worker_handle_set_environment_variable (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *key,
+ const char *value)
{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
g_debug ("GdmSessionWorker: set env: %s = %s", key, value);
gdm_session_worker_set_environment_variable (worker, key, value);
+ gdm_dbus_worker_complete_set_environment_variable (object, invocation);
+ return TRUE;
}
-static void
-on_set_session_name (GdmDBusWorkerManager *proxy,
- const char *session_name,
- GdmSessionWorker *worker)
+static gboolean
+gdm_session_worker_handle_set_session_name (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *session_name)
{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
g_debug ("GdmSessionWorker: session name set to %s", session_name);
gdm_session_settings_set_session_name (worker->priv->user_settings,
session_name);
+ gdm_dbus_worker_complete_set_session_name (object, invocation);
+ return TRUE;
}
-static void
-on_set_session_type (GdmDBusWorkerManager *proxy,
- const char *session_type,
- GdmSessionWorker *worker)
+static gboolean
+gdm_session_worker_handle_set_session_type (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *session_type)
{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
g_debug ("GdmSessionWorker: session type set to %s", session_type);
g_free (worker->priv->session_type);
worker->priv->session_type = g_strdup (session_type);
+ gdm_dbus_worker_complete_set_session_type (object, invocation);
+ return TRUE;
}
-static void
-on_set_language_name (GdmDBusWorkerManager *proxy,
- const char *language_name,
- GdmSessionWorker *worker)
+static gboolean
+gdm_session_worker_handle_set_language_name (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *language_name)
{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
g_debug ("GdmSessionWorker: language name set to %s", language_name);
gdm_session_settings_set_language_name (worker->priv->user_settings,
language_name);
+ gdm_dbus_worker_complete_set_language_name (object, invocation);
+ return TRUE;
}
static void
@@ -2047,10 +2050,8 @@ on_saved_language_name_read (GdmSessionWorker *worker)
language_name = gdm_session_settings_get_language_name (worker->priv->user_settings);
g_debug ("GdmSessionWorker: Saved language is %s", language_name);
- gdm_dbus_worker_manager_call_saved_language_name_read_sync (worker->priv->manager,
- language_name,
- NULL,
- NULL);
+ gdm_dbus_worker_emit_saved_language_name_read (GDM_DBUS_WORKER (worker),
+ language_name);
g_free (language_name);
}
@@ -2062,10 +2063,8 @@ on_saved_session_name_read (GdmSessionWorker *worker)
session_name = gdm_session_settings_get_session_name (worker->priv->user_settings);
g_debug ("GdmSessionWorker: Saved session is %s", session_name);
- gdm_dbus_worker_manager_call_saved_session_name_read_sync (worker->priv->manager,
- session_name,
- NULL,
- NULL);
+ gdm_dbus_worker_emit_saved_session_name_read (GDM_DBUS_WORKER (worker),
+ session_name);
g_free (session_name);
}
@@ -2086,25 +2085,13 @@ do_setup (GdmSessionWorker *worker)
worker->priv->display_device,
worker->priv->display_seat_id,
&error);
- if (! res) {
- if (g_error_matches (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_SERVICE_UNAVAILABLE)) {
- gdm_dbus_worker_manager_call_service_unavailable_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
- } else {
- gdm_dbus_worker_manager_call_setup_failed_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
- }
- g_error_free (error);
- return;
+
+ if (res) {
+ g_dbus_method_invocation_return_value (worker->priv->pending_invocation, NULL);
+ } else {
+ g_dbus_method_invocation_take_error (worker->priv->pending_invocation, error);
}
+ worker->priv->pending_invocation = NULL;
/* These singal handlers should be disconnected after the loading,
* so that gdm_session_settings_set_* APIs don't cause the emitting
@@ -2117,11 +2104,6 @@ do_setup (GdmSessionWorker *worker)
g_signal_handlers_disconnect_by_func (worker->priv->user_settings,
G_CALLBACK (on_saved_language_name_read),
worker);
-
- gdm_dbus_worker_manager_call_setup_complete_sync (worker->priv->manager,
- worker->priv->service,
- NULL,
- NULL);
}
static void
@@ -2136,40 +2118,21 @@ do_authenticate (GdmSessionWorker *worker)
res = gdm_session_worker_authenticate_user (worker,
worker->priv->password_is_required,
&error);
- if (! res) {
- if (g_error_matches (error,
- GDM_SESSION_WORKER_ERROR,
- GDM_SESSION_WORKER_ERROR_SERVICE_UNAVAILABLE)) {
- g_debug ("GdmSessionWorker: Unable to use authentication service");
- gdm_dbus_worker_manager_call_service_unavailable_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
- } else {
- g_debug ("GdmSessionWorker: Unable to verify user");
- gdm_dbus_worker_manager_call_authentication_failed_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
+ if (res) {
+ /* we're authenticated. Let's make sure we've been given
+ * a valid username for the system
+ */
+ if (!worker->priv->is_program_session) {
+ g_debug ("GdmSessionWorker: trying to get updated username");
+ gdm_session_worker_update_username (worker);
}
- g_error_free (error);
- return;
- }
- /* we're authenticated. Let's make sure we've been given
- * a valid username for the system
- */
- if (!worker->priv->is_program_session) {
- g_debug ("GdmSessionWorker: trying to get updated username");
- gdm_session_worker_update_username (worker);
+ gdm_dbus_worker_complete_authenticate (GDM_DBUS_WORKER (worker), worker->priv->pending_invocation);
+ } else {
+ g_debug ("GdmSessionWorker: Unable to verify user");
+ g_dbus_method_invocation_take_error (worker->priv->pending_invocation, error);
}
-
- gdm_dbus_worker_manager_call_authenticated_sync (worker->priv->manager,
- worker->priv->service,
- NULL,
- NULL);
+ worker->priv->pending_invocation = NULL;
}
static void
@@ -2184,20 +2147,12 @@ do_authorize (GdmSessionWorker *worker)
res = gdm_session_worker_authorize_user (worker,
worker->priv->password_is_required,
&error);
- if (! res) {
- gdm_dbus_worker_manager_call_authorization_failed_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
- g_error_free (error);
- return;
+ if (res) {
+ gdm_dbus_worker_complete_authorize (GDM_DBUS_WORKER (worker), worker->priv->pending_invocation);
+ } else {
+ g_dbus_method_invocation_take_error (worker->priv->pending_invocation, error);
}
-
- gdm_dbus_worker_manager_call_authorized_sync (worker->priv->manager,
- worker->priv->service,
- NULL,
- NULL);
+ worker->priv->pending_invocation = NULL;
}
static void
@@ -2211,20 +2166,12 @@ do_accredit (GdmSessionWorker *worker)
error = NULL;
res = gdm_session_worker_accredit_user (worker, &error);
- if (! res) {
- gdm_dbus_worker_manager_call_accreditation_failed_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
- g_error_free (error);
- return;
+ if (res) {
+ gdm_dbus_worker_complete_establish_credentials (GDM_DBUS_WORKER (worker), worker->priv->pending_invocation);
+ } else {
+ g_dbus_method_invocation_take_error (worker->priv->pending_invocation, error);
}
-
- gdm_dbus_worker_manager_call_accredited_sync (worker->priv->manager,
- worker->priv->service,
- NULL,
- NULL);
+ worker->priv->pending_invocation = NULL;
}
static void
@@ -2293,22 +2240,18 @@ do_open_session (GdmSessionWorker *worker)
error = NULL;
res = gdm_session_worker_open_session (worker, &error);
- if (! res) {
- gdm_dbus_worker_manager_call_open_failed_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
- g_error_free (error);
- return;
- }
- gdm_dbus_worker_manager_call_opened_sync (worker->priv->manager,
- worker->priv->service,
- worker->priv->session_id ?
- worker->priv->session_id : "",
- NULL,
- NULL);
+ if (res) {
+ char *session_id = worker->priv->session_id;
+ if (session_id == NULL) {
+ session_id = "";
+ }
+
+ gdm_dbus_worker_complete_open (GDM_DBUS_WORKER (worker), worker->priv->pending_invocation, session_id);
+ } else {
+ g_dbus_method_invocation_take_error (worker->priv->pending_invocation, error);
+ }
+ worker->priv->pending_invocation = NULL;
}
static void
@@ -2319,21 +2262,14 @@ do_start_session (GdmSessionWorker *worker)
error = NULL;
res = gdm_session_worker_start_session (worker, &error);
- if (! res) {
- gdm_dbus_worker_manager_call_session_start_failed_sync (worker->priv->manager,
- worker->priv->service,
- error->message,
- NULL,
- NULL);
- g_error_free (error);
- return;
+ if (res) {
+ gdm_dbus_worker_complete_start_program (GDM_DBUS_WORKER (worker),
+ worker->priv->pending_invocation,
+ worker->priv->child_pid);
+ } else {
+ g_dbus_method_invocation_take_error (worker->priv->pending_invocation, error);
}
-
- gdm_dbus_worker_manager_call_session_started_sync (worker->priv->manager,
- worker->priv->service,
- worker->priv->child_pid,
- NULL,
- NULL);
+ worker->priv->pending_invocation = NULL;
}
static const char *
@@ -2426,33 +2362,224 @@ queue_state_change (GdmSessionWorker *worker)
worker->priv->state_change_idle_id = g_idle_add ((GSourceFunc)state_change_idle, worker);
}
+static gboolean
+validate_state_change (GdmSessionWorker *worker,
+ GDBusMethodInvocation *invocation,
+ int new_state)
+{
+ if (worker->priv->pending_invocation != NULL) {
+ g_dbus_method_invocation_return_error (invocation,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_OUTSTANDING_REQUEST,
+ "Cannot process state change to %s, as there is already an outstanding request to move to state %s",
+ get_state_name (new_state),
+ get_state_name (worker->priv->state + 1));
+ return FALSE;
+ } else if (worker->priv->state != new_state - 1) {
+ g_dbus_method_invocation_return_error (invocation,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_WRONG_STATE,
+ "Cannot move to state %s, in state %s, not %s",
+ get_state_name (new_state),
+ get_state_name (worker->priv->state),
+ get_state_name (new_state - 1));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
-on_start_program (GdmDBusWorkerManager *proxy,
- const char *text,
- GdmSessionWorker *worker)
+validate_and_queue_state_change (GdmSessionWorker *worker,
+ GDBusMethodInvocation *invocation,
+ int new_state)
{
- GError *parse_error = NULL;
+ if (validate_state_change (worker, invocation, new_state)) {
+ worker->priv->pending_invocation = invocation;
+ queue_state_change (worker);
+ }
+}
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_SESSION_OPENED) {
- g_debug ("GdmSessionWorker: ignoring spurious start program while in state %s", get_state_name (worker->priv->state));
- return;
+static gboolean
+gdm_session_worker_handle_authenticate (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+ validate_and_queue_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_AUTHENTICATED);
+ return TRUE;
+}
+
+static gboolean
+gdm_session_worker_handle_authorize (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+ validate_and_queue_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_AUTHORIZED);
+ return TRUE;
+}
+
+static gboolean
+gdm_session_worker_handle_establish_credentials (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+ validate_and_queue_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_ACCREDITED);
+
+ if (!worker->priv->is_reauth_session) {
+ worker->priv->cred_flags = PAM_ESTABLISH_CRED;
+ } else {
+ worker->priv->cred_flags = PAM_REINITIALIZE_CRED;
}
+ return TRUE;
+}
+
+static gboolean
+gdm_session_worker_handle_open (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+ validate_and_queue_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_ACCOUNT_DETAILS_SAVED);
+ return TRUE;
+}
+
+static gboolean
+gdm_session_worker_handle_setup (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *service,
+ const char *x11_display_name,
+ const char *x11_authority_file,
+ const char *console,
+ const char *seat_id,
+ const char *hostname,
+ gboolean display_is_local)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+ validate_and_queue_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_SETUP_COMPLETE);
+
+ worker->priv->service = g_strdup (service);
+ worker->priv->x11_display_name = g_strdup (x11_display_name);
+ worker->priv->x11_authority_file = g_strdup (x11_authority_file);
+ worker->priv->display_device = g_strdup (console);
+ worker->priv->display_seat_id = g_strdup (seat_id);
+ worker->priv->hostname = g_strdup (hostname);
+ worker->priv->display_is_local = display_is_local;
+ worker->priv->username = NULL;
+
+ return TRUE;
+}
+
+static gboolean
+gdm_session_worker_handle_setup_for_user (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *service,
+ const char *username,
+ const char *x11_display_name,
+ const char *x11_authority_file,
+ const char *console,
+ const char *seat_id,
+ const char *hostname,
+ gboolean display_is_local)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+
+ if (!validate_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_SETUP_COMPLETE))
+ return TRUE;
+
+ worker->priv->service = g_strdup (service);
+ worker->priv->x11_display_name = g_strdup (x11_display_name);
+ worker->priv->x11_authority_file = g_strdup (x11_authority_file);
+ worker->priv->display_device = g_strdup (console);
+ worker->priv->display_seat_id = g_strdup (seat_id);
+ worker->priv->hostname = g_strdup (hostname);
+ worker->priv->display_is_local = display_is_local;
+ worker->priv->username = g_strdup (username);
+
+ g_signal_connect_swapped (worker->priv->user_settings,
+ "notify::language-name",
+ G_CALLBACK (on_saved_language_name_read),
+ worker);
+
+ g_signal_connect_swapped (worker->priv->user_settings,
+ "notify::session-name",
+ G_CALLBACK (on_saved_session_name_read),
+ worker);
+
+ /* Load settings from accounts daemon before continuing
+ * FIXME: need to handle username not loading
+ */
+ worker->priv->pending_invocation = invocation;
+ if (gdm_session_settings_load (worker->priv->user_settings, username)) {
+ queue_state_change (worker);
+ } else {
+ g_signal_connect (G_OBJECT (worker->priv->user_settings),
+ "notify::is-loaded",
+ G_CALLBACK (on_settings_is_loaded_changed),
+ worker);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+gdm_session_worker_handle_setup_for_program (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *service,
+ const char *username,
+ const char *x11_display_name,
+ const char *x11_authority_file,
+ const char *console,
+ const char *seat_id,
+ const char *hostname,
+ gboolean display_is_local,
+ const char *log_file)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+ validate_and_queue_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_SETUP_COMPLETE);
+
+ worker->priv->service = g_strdup (service);
+ worker->priv->x11_display_name = g_strdup (x11_display_name);
+ worker->priv->x11_authority_file = g_strdup (x11_authority_file);
+ worker->priv->display_device = g_strdup (console);
+ worker->priv->display_seat_id = g_strdup (seat_id);
+ worker->priv->hostname = g_strdup (hostname);
+ worker->priv->display_is_local = display_is_local;
+ worker->priv->username = g_strdup (username);
+ worker->priv->log_file = g_strdup (log_file);
+ worker->priv->is_program_session = TRUE;
+
+ return TRUE;
+}
+
+static gboolean
+gdm_session_worker_handle_start_program (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ const char *text)
+{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
+ GError *parse_error = NULL;
+ validate_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_SESSION_STARTED);
+
if (worker->priv->is_reauth_session) {
- g_debug ("GdmSessionWorker: ignoring start program request in reauthentication session");
- return;
+ g_dbus_method_invocation_return_error (invocation,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_IN_REAUTH_SESSION,
+ "Cannot start a program while in a reauth session");
+ return TRUE;
}
g_debug ("GdmSessionWorker: start program: %s", text);
g_clear_pointer (&worker->priv->arguments, (GDestroyNotify) g_strfreev);
if (! g_shell_parse_argv (text, NULL, &worker->priv->arguments, &parse_error)) {
- g_warning ("Unable to parse command: %s", parse_error->message);
- g_error_free (parse_error);
- return;
+ g_dbus_method_invocation_take_error (invocation, parse_error);
+ return TRUE;
}
+ worker->priv->pending_invocation = invocation;
queue_state_change (worker);
+
+ return TRUE;
}
static void
@@ -2506,9 +2633,9 @@ on_reauthentication_conversation_stopped (GdmSession *session,
}
static void
-on_verification_complete (GdmSession *session,
- const char *service_name,
- ReauthenticationRequest *request)
+on_reauthentication_verification_complete (GdmSession *session,
+ const char *service_name,
+ ReauthenticationRequest *request)
{
GdmSessionWorker *worker;
@@ -2520,16 +2647,14 @@ on_verification_complete (GdmSession *session,
service_name);
gdm_session_reset (session);
- gdm_dbus_worker_manager_call_reauthenticated_sync (worker->priv->manager,
- service_name,
- NULL,
- NULL);
+ gdm_dbus_worker_emit_reauthenticated (GDM_DBUS_WORKER (worker));
}
static ReauthenticationRequest *
-reauthentication_request_new (GdmSessionWorker *worker,
- GPid pid_of_caller,
- uid_t uid_of_caller)
+reauthentication_request_new (GdmSessionWorker *worker,
+ GPid pid_of_caller,
+ uid_t uid_of_caller,
+ GDBusMethodInvocation *invocation)
{
ReauthenticationRequest *request;
char *address;
@@ -2570,212 +2695,43 @@ reauthentication_request_new (GdmSessionWorker *worker,
request);
g_signal_connect (request->session,
"verification-complete",
- G_CALLBACK (on_verification_complete),
+ G_CALLBACK (on_reauthentication_verification_complete),
request);
address = gdm_session_get_server_address (request->session);
- gdm_dbus_worker_manager_call_reauthentication_started_sync (worker->priv->manager,
- pid_of_caller,
- address,
- NULL,
- NULL);
+ gdm_dbus_worker_complete_start_reauthentication (GDM_DBUS_WORKER (worker),
+ invocation,
+ address);
g_free (address);
return request;
}
-static void
-on_start_reauthentication (GdmDBusWorkerManager *proxy,
- int pid_of_caller,
- int uid_of_caller,
- GdmSessionWorker *worker)
+static gboolean
+gdm_session_worker_handle_start_reauthentication (GdmDBusWorker *object,
+ GDBusMethodInvocation *invocation,
+ int pid_of_caller,
+ int uid_of_caller)
{
+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object);
ReauthenticationRequest *request;
if (worker->priv->state != GDM_SESSION_WORKER_STATE_SESSION_STARTED) {
- g_debug ("GdmSessionWorker: ignoring spurious start reauthentication while in state %s", get_state_name (worker->priv->state));
- return;
+ g_dbus_method_invocation_return_error (invocation,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_WRONG_STATE,
+ "Cannot reauthenticate while in state %s",
+ get_state_name (worker->priv->state));
+ return TRUE;
}
g_debug ("GdmSessionWorker: start reauthentication");
- request = reauthentication_request_new (worker, pid_of_caller, uid_of_caller);
+ request = reauthentication_request_new (worker, pid_of_caller, uid_of_caller, invocation);
g_hash_table_replace (worker->priv->reauthentication_requests,
GINT_TO_POINTER (pid_of_caller),
request);
-}
-
-static void
-on_setup (GdmDBusWorkerManager *proxy,
- const char *service,
- const char *x11_display_name,
- const char *x11_authority_file,
- const char *console,
- const char *seat_id,
- const char *hostname,
- gboolean display_is_local,
- GdmSessionWorker *worker)
-{
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_NONE) {
- g_debug ("GdmSessionWorker: ignoring spurious setup while in state %s", get_state_name (worker->priv->state));
- return;
- }
-
- worker->priv->service = g_strdup (service);
- worker->priv->x11_display_name = g_strdup (x11_display_name);
- worker->priv->x11_authority_file = g_strdup (x11_authority_file);
- worker->priv->display_device = g_strdup (console);
- worker->priv->display_seat_id = g_strdup (seat_id);
- worker->priv->hostname = g_strdup (hostname);
- worker->priv->display_is_local = display_is_local;
- worker->priv->username = NULL;
-
- g_debug ("GdmSessionWorker: queuing setup: %s %s", service, console);
- queue_state_change (worker);
-}
-
-static void
-on_setup_for_user (GdmDBusWorkerManager *proxy,
- const char *service,
- const char *username,
- const char *x11_display_name,
- const char *x11_authority_file,
- const char *console,
- const char *seat_id,
- const char *hostname,
- gboolean display_is_local,
- GdmSessionWorker *worker)
-{
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_NONE) {
- g_debug ("GdmSessionWorker: ignoring spurious setup while in state %s", get_state_name (worker->priv->state));
- return;
- }
-
- worker->priv->service = g_strdup (service);
- worker->priv->x11_display_name = g_strdup (x11_display_name);
- worker->priv->x11_authority_file = g_strdup (x11_authority_file);
- worker->priv->display_device = g_strdup (console);
- worker->priv->display_seat_id = g_strdup (seat_id);
- worker->priv->hostname = g_strdup (hostname);
- worker->priv->display_is_local = display_is_local;
- worker->priv->username = g_strdup (username);
-
- g_signal_connect_swapped (worker->priv->user_settings,
- "notify::language-name",
- G_CALLBACK (on_saved_language_name_read),
- worker);
-
- g_signal_connect_swapped (worker->priv->user_settings,
- "notify::session-name",
- G_CALLBACK (on_saved_session_name_read),
- worker);
-
- /* Load settings from accounts daemon before continuing
- * FIXME: need to handle username not loading
- */
- if (gdm_session_settings_load (worker->priv->user_settings, username)) {
- queue_state_change (worker);
- } else {
- g_signal_connect (G_OBJECT (worker->priv->user_settings),
- "notify::is-loaded",
- G_CALLBACK (on_settings_is_loaded_changed),
- worker);
- }
-}
-
-static void
-on_setup_for_program (GdmDBusWorkerManager *proxy,
- const char *service,
- const char *username,
- const char *x11_display_name,
- const char *x11_authority_file,
- const char *console,
- const char *seat_id,
- const char *hostname,
- gboolean display_is_local,
- const char *log_file,
- GdmSessionWorker *worker)
-{
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_NONE) {
- g_debug ("GdmSessionWorker: ignoring spurious setup while in state %s", get_state_name (worker->priv->state));
- return;
- }
-
- worker->priv->service = g_strdup (service);
- worker->priv->x11_display_name = g_strdup (x11_display_name);
- worker->priv->x11_authority_file = g_strdup (x11_authority_file);
- worker->priv->display_device = g_strdup (console);
- worker->priv->display_seat_id = g_strdup (seat_id);
- worker->priv->hostname = g_strdup (hostname);
- worker->priv->display_is_local = display_is_local;
- worker->priv->username = g_strdup (username);
- worker->priv->log_file = g_strdup (log_file);
- worker->priv->is_program_session = TRUE;
-
- queue_state_change (worker);
-}
-
-static void
-on_authenticate (GdmDBusWorkerManager *manager,
- const char *service_name,
- GdmSessionWorker *worker)
-{
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_SETUP_COMPLETE) {
- g_debug ("GdmSessionWorker: ignoring spurious authenticate for user while in state %s", get_state_name (worker->priv->state));
- return;
- }
-
- queue_state_change (worker);
-}
-
-static void
-on_authorize (GdmDBusWorkerManager *manager,
- const char *service_name,
- GdmSessionWorker *worker)
-{
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_AUTHENTICATED) {
- g_debug ("GdmSessionWorker: ignoring spurious authorize for user while in state %s", get_state_name (worker->priv->state));
- return;
- }
-
- queue_state_change (worker);
-}
-
-static void
-on_establish_credentials (GdmDBusWorkerManager *manager,
- const char *service_name,
- GdmSessionWorker *worker)
-{
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_AUTHORIZED) {
- g_debug ("GdmSessionWorker: ignoring spurious establish credentials for user while in state %s", get_state_name (worker->priv->state));
- return;
- }
-
- if (!worker->priv->is_reauth_session) {
- worker->priv->cred_flags = PAM_ESTABLISH_CRED;
- } else {
- worker->priv->cred_flags = PAM_REINITIALIZE_CRED;
- }
-
- queue_state_change (worker);
-}
-
-static void
-on_open_session (GdmDBusWorkerManager *manager,
- const char *service_name,
- GdmSessionWorker *worker)
-{
- if (worker->priv->state != GDM_SESSION_WORKER_STATE_ACCREDITED) {
- g_debug ("GdmSessionWorker: ignoring spurious open session for user while in state %s", get_state_name (worker->priv->state));
- return;
- }
-
- if (worker->priv->is_reauth_session) {
- g_debug ("GdmSessionWorker: ignoring open session request in reauthentication session");
- return;
- }
-
- queue_state_change (worker);
+ return TRUE;
}
static GObject *
@@ -2818,60 +2774,15 @@ gdm_session_worker_constructor (GType type,
exit (1);
}
- g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (worker->priv->manager), -1);
+ if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (worker),
+ worker->priv->connection,
+ GDM_WORKER_DBUS_PATH,
+ &error)) {
+ g_warning ("Error while exporting object: %s", error->message);
+ exit (1);
+ }
- g_signal_connect (worker->priv->manager,
- "authenticate",
- G_CALLBACK (on_authenticate),
- worker);
- g_signal_connect (worker->priv->manager,
- "authorize",
- G_CALLBACK (on_authorize),
- worker);
- g_signal_connect (worker->priv->manager,
- "establish-credentials",
- G_CALLBACK (on_establish_credentials),
- worker);
- g_signal_connect (worker->priv->manager,
- "open-session",
- G_CALLBACK (on_open_session),
- worker);
- g_signal_connect (worker->priv->manager,
- "set-environment-variable",
- G_CALLBACK (on_set_environment_variable),
- worker);
- g_signal_connect (worker->priv->manager,
- "set-session-name",
- G_CALLBACK (on_set_session_name),
- worker);
- g_signal_connect (worker->priv->manager,
- "set-language-name",
- G_CALLBACK (on_set_language_name),
- worker);
- g_signal_connect (worker->priv->manager,
- "set-session-type",
- G_CALLBACK (on_set_session_type),
- worker);
- g_signal_connect (worker->priv->manager,
- "setup",
- G_CALLBACK (on_setup),
- worker);
- g_signal_connect (worker->priv->manager,
- "setup-for-user",
- G_CALLBACK (on_setup_for_user),
- worker);
- g_signal_connect (worker->priv->manager,
- "setup-for-program",
- G_CALLBACK (on_setup_for_program),
- worker);
- g_signal_connect (worker->priv->manager,
- "start-program",
- G_CALLBACK (on_start_program),
- worker);
- g_signal_connect (worker->priv->manager,
- "start-reauthentication",
- G_CALLBACK (on_start_reauthentication),
- worker);
+ g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (worker->priv->manager), -1);
/* Send an initial Hello message so that the session can associate
* the conversation we manage with our pid.
@@ -2884,6 +2795,24 @@ gdm_session_worker_constructor (GType type,
}
static void
+worker_interface_init (GdmDBusWorkerIface *interface)
+{
+ interface->handle_setup = gdm_session_worker_handle_setup;
+ interface->handle_setup_for_user = gdm_session_worker_handle_setup_for_user;
+ interface->handle_setup_for_program = gdm_session_worker_handle_setup_for_program;
+ interface->handle_authenticate = gdm_session_worker_handle_authenticate;
+ interface->handle_authorize = gdm_session_worker_handle_authorize;
+ interface->handle_establish_credentials = gdm_session_worker_handle_establish_credentials;
+ interface->handle_open = gdm_session_worker_handle_open;
+ interface->handle_set_language_name = gdm_session_worker_handle_set_language_name;
+ interface->handle_set_session_name = gdm_session_worker_handle_set_session_name;
+ interface->handle_set_session_type = gdm_session_worker_handle_set_session_type;
+ interface->handle_set_environment_variable = gdm_session_worker_handle_set_environment_variable;
+ interface->handle_start_program = gdm_session_worker_handle_start_program;
+ interface->handle_start_reauthentication = gdm_session_worker_handle_start_reauthentication;
+}
+
+static void
gdm_session_worker_class_init (GdmSessionWorkerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -2922,7 +2851,6 @@ reauthentication_request_free (ReauthenticationRequest *request)
static void
gdm_session_worker_init (GdmSessionWorker *worker)
{
-
worker->priv = GDM_SESSION_WORKER_GET_PRIVATE (worker);
worker->priv->user_settings = gdm_session_settings_new ();
diff --git a/daemon/gdm-session-worker.h b/daemon/gdm-session-worker.h
index da5ec3f..71805a0 100644
--- a/daemon/gdm-session-worker.h
+++ b/daemon/gdm-session-worker.h
@@ -23,6 +23,9 @@
#include <glib-object.h>
+#include "gdm-session-worker-glue.h"
+#include "gdm-session-worker-common.h"
+
G_BEGIN_DECLS
#define GDM_TYPE_SESSION_WORKER (gdm_session_worker_get_type ())
@@ -32,38 +35,20 @@ G_BEGIN_DECLS
#define GDM_IS_SESSION_WORKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDM_TYPE_SESSION_WORKER))
#define GDM_SESSION_WORKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GDM_TYPE_SESSION_WORKER, GdmSessionWorkerClass))
-#define GDM_SESSION_WORKER_ERROR (gdm_session_worker_error_quark ())
-
-typedef enum _GdmSessionWorkerError {
- GDM_SESSION_WORKER_ERROR_GENERIC = 0,
- GDM_SESSION_WORKER_ERROR_WITH_SESSION_COMMAND,
- GDM_SESSION_WORKER_ERROR_FORKING,
- GDM_SESSION_WORKER_ERROR_OPENING_MESSAGE_PIPE,
- GDM_SESSION_WORKER_ERROR_COMMUNICATING,
- GDM_SESSION_WORKER_ERROR_WORKER_DIED,
- GDM_SESSION_WORKER_ERROR_SERVICE_UNAVAILABLE,
- GDM_SESSION_WORKER_ERROR_AUTHENTICATING,
- GDM_SESSION_WORKER_ERROR_AUTHORIZING,
- GDM_SESSION_WORKER_ERROR_OPENING_LOG_FILE,
- GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
- GDM_SESSION_WORKER_ERROR_GIVING_CREDENTIALS
-} GdmSessionWorkerError;
-
typedef struct GdmSessionWorkerPrivate GdmSessionWorkerPrivate;
typedef struct
{
- GObject parent;
+ GdmDBusWorkerSkeleton parent;
GdmSessionWorkerPrivate *priv;
} GdmSessionWorker;
typedef struct
{
- GObjectClass parent_class;
+ GdmDBusWorkerSkeletonClass parent_class;
} GdmSessionWorkerClass;
GType gdm_session_worker_get_type (void);
-GQuark gdm_session_worker_error_quark (void);
GdmSessionWorker * gdm_session_worker_new (const char *server_address,
gboolean is_for_reauth) G_GNUC_MALLOC;
diff --git a/daemon/gdm-session-worker.xml b/daemon/gdm-session-worker.xml
new file mode 100644
index 0000000..990a133
--- /dev/null
+++ b/daemon/gdm-session-worker.xml
@@ -0,0 +1,86 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node name="/org/gnome/DisplayManager/Worker">
+ <interface name="org.gnome.DisplayManager.Worker">
+ <method name="Authenticate" />
+ <method name="Authorize" />
+ <method name="EstablishCredentials" />
+ <method name="Open">
+ <arg name="session_id" direction="out" type="s"/>
+ </method>
+ <method name="SetLanguageName">
+ <arg name="language" direction="in" type="s"/>
+ </method>
+ <method name="SetSessionName">
+ <arg name="session_name" direction="in" type="s" />
+ </method>
+ <method name="SetSessionType">
+ <arg name="session_type" direction="in" type="s"/>
+ </method>
+ <method name="SetEnvironmentVariable">
+ <arg name="name" direction="in" type="s"/>
+ <arg name="value" direction="in" type="s"/>
+ </method>
+ <method name="StartProgram">
+ <arg name="command" direction="in" type="s"/>
+ <arg name="child_pid" direction="out" type="i"/>
+ </method>
+ <method name="Setup">
+ <arg name="service_name" direction="in" type="s"/>
+ <arg name="x11_display_name" direction="in" type="s"/>
+ <arg name="x11_authority_file" direction="in" type="s"/>
+ <arg name="display_device" direction="in" type="s"/>
+ <arg name="display_seat" direction="in" type="s"/>
+ <arg name="hostname" direction="in" type="s"/>
+ <arg name="display_is_local" direction="in" type="b"/>
+ </method>
+ <method name="SetupForUser">
+ <arg name="service_name" direction="in" type="s"/>
+ <arg name="user_name" direction="in" type="s"/>
+ <arg name="x11_display_name" direction="in" type="s"/>
+ <arg name="x11_authority_file" direction="in" type="s"/>
+ <arg name="display_device" direction="in" type="s"/>
+ <arg name="display_seat" direction="in" type="s"/>
+ <arg name="hostname" direction="in" type="s"/>
+ <arg name="display_is_local" direction="in" type="b"/>
+ </method>
+ <method name="SetupForProgram">
+ <arg name="service_name" direction="in" type="s"/>
+ <arg name="user_name" direction="in" type="s"/>
+ <arg name="x11_display_name" direction="in" type="s"/>
+ <arg name="x11_authority_file" direction="in" type="s"/>
+ <arg name="display_device" direction="in" type="s"/>
+ <arg name="display_seat" direction="in" type="s"/>
+ <arg name="hostname" direction="in" type="s"/>
+ <arg name="display_is_local" direction="in" type="b"/>
+ <arg name="log_file" direction="in" type="s"/>
+ </method>
+ <method name="StartReauthentication">
+ <arg name="pid_of_caller" direction="in" type="i"/>
+ <arg name="uid_of_caller" direction="in" type="i"/>
+ <arg name="address" direction="out" type="s"/>
+ </method>
+
+ <signal name="SessionExited">
+ <arg name="service_name" type="s" />
+ <!-- This is a combination of exit code and exit
+ signal. Use macros in sys/wait.h to handle it. -->
+ <arg name="status" type="i" />
+ </signal>
+ <signal name="SavedLanguageNameRead">
+ <arg name="language_name" type="s"/>
+ </signal>
+ <signal name="SavedSessionNameRead">
+ <arg name="session_name" type="s"/>
+ </signal>
+ <signal name="UsernameChanged">
+ <arg name="new_username" type="s"/>
+ </signal>
+ <signal name="ServiceUnavailable">
+ <arg name="message" type="s"/>
+ </signal>
+ <signal name="Reauthenticated">
+ </signal>
+ <signal name="CancelPendingQuery">
+ </signal>
+ </interface>
+</node>
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index 58b2e31..f72c808 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -55,7 +55,9 @@
#include "gdm-session.h"
#include "gdm-session-enum-types.h"
#include "gdm-session-record.h"
+#include "gdm-session-worker-common.h"
#include "gdm-session-worker-job.h"
+#include "gdm-session-worker-glue.h"
#include "gdm-common.h"
#define GDM_SESSION_DBUS_ERROR_CANCEL "org.gnome.DisplayManager.Session.Error.Cancel"
@@ -65,6 +67,8 @@
#define GDM_SESSION_DEFAULT_PATH "/usr/local/bin:/usr/bin:/bin"
#endif
+#define GDM_WORKER_DBUS_PATH "/org/gnome/DisplayManager/Worker"
+
typedef struct
{
GdmSession *session;
@@ -76,8 +80,11 @@ typedef struct
char *starting_username;
GDBusMethodInvocation *pending_invocation;
GdmDBusWorkerManager *worker_manager_interface;
+ GdmDBusWorker *worker_proxy;
char *session_id;
guint32 is_stopping : 1;
+
+ GPid reauth_pid_of_caller;
} GdmSessionConversation;
struct _GdmSessionPrivate
@@ -225,209 +232,121 @@ on_session_exited (GdmSession *self,
}
static void
-report_problem_and_stop_conversation (GdmSession *self,
- const char *service_name,
- const char *message)
-{
- if (self->priv->user_verifier_interface != NULL) {
- gdm_dbus_user_verifier_emit_problem (self->priv->user_verifier_interface,
- service_name,
- message);
- gdm_dbus_user_verifier_emit_verification_failed (self->priv->user_verifier_interface,
- service_name);
- }
-
- gdm_session_stop_conversation (self, service_name);
-}
-
-static gboolean
-gdm_session_handle_service_unavailable (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *message,
- GdmSession *self)
+report_and_stop_conversation (GdmSession *self,
+ const char *service_name,
+ const char *message,
+ gboolean service_unavailable)
{
- gdm_dbus_worker_manager_complete_service_unavailable (worker_manager_interface,
- invocation);
-
if (self->priv->user_verifier_interface != NULL) {
- gdm_dbus_user_verifier_emit_service_unavailable (self->priv->user_verifier_interface,
- service_name,
- message);
+ if (service_unavailable) {
+ gdm_dbus_user_verifier_emit_service_unavailable (self->priv->user_verifier_interface,
+ service_name,
+ message);
+ } else {
+ gdm_dbus_user_verifier_emit_problem (self->priv->user_verifier_interface,
+ service_name,
+ message);
+ }
gdm_dbus_user_verifier_emit_verification_failed (self->priv->user_verifier_interface,
service_name);
}
gdm_session_stop_conversation (self, service_name);
-
- return TRUE;
-}
-
-static gboolean
-gdm_session_handle_setup_complete (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- GdmSession *self)
-{
- GdmSessionConversation *conversation;
-
- conversation = find_conversation_by_name (self, service_name);
- if (conversation != NULL) {
- if (conversation->starting_invocation != NULL) {
- g_dbus_method_invocation_return_value (conversation->starting_invocation,
- NULL);
- g_clear_object (&conversation->starting_invocation);
- }
- }
- gdm_dbus_worker_manager_complete_setup_complete (worker_manager_interface,
- invocation);
-
- g_signal_emit (G_OBJECT (self),
- signals [SETUP_COMPLETE],
- 0,
- service_name);
-
- gdm_session_authenticate (self, service_name);
-
- return TRUE;
}
-static gboolean
-gdm_session_handle_setup_failed (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *message,
- GdmSession *self)
+static void
+report_problem_and_stop_conversation (GdmSession *self,
+ const char *service_name,
+ const char *message)
{
- GdmSessionConversation *conversation;
-
- conversation = find_conversation_by_name (self, service_name);
- if (conversation != NULL) {
- if (conversation->starting_invocation != NULL) {
- g_dbus_method_invocation_return_dbus_error (conversation->starting_invocation,
- "org.gnome.DisplayManager.Session.Error.SetupFailed",
- message);
-
- g_clear_object (&conversation->starting_invocation);
- }
- }
-
- gdm_dbus_worker_manager_complete_setup_failed (worker_manager_interface,
- invocation);
-
- report_problem_and_stop_conversation (self, service_name, message);
-
- return TRUE;
+ return report_and_stop_conversation (self, service_name, message, FALSE);
}
-static gboolean
-gdm_session_handle_authenticated (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- GdmSession *self)
+static void
+on_authenticate_cb (GdmDBusWorker *proxy,
+ GAsyncResult *res,
+ gpointer user_data)
{
- gdm_dbus_worker_manager_complete_authenticated (worker_manager_interface,
- invocation);
- gdm_session_authorize (self, service_name);
-
- return TRUE;
-}
+ GdmSessionConversation *conversation = user_data;
+ GdmSession *self = conversation->session;
+ char *service_name = conversation->service_name;
-static gboolean
-gdm_session_handle_authentication_failed (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *message,
- GdmSession *self)
-{
- GdmSessionConversation *conversation;
+ GError *error = NULL;
+ gboolean worked;
- gdm_dbus_worker_manager_complete_authentication_failed (worker_manager_interface,
- invocation);
+ worked = gdm_dbus_worker_call_authenticate_finish (proxy, res, &error);
- conversation = find_conversation_by_name (self, service_name);
- if (conversation != NULL) {
+ if (worked) {
+ gdm_session_authorize (self, service_name);
+ } else {
gdm_session_record_failed (conversation->worker_pid,
self->priv->selected_user,
self->priv->display_hostname,
self->priv->display_name,
self->priv->display_device);
- }
-
- report_problem_and_stop_conversation (self, service_name, message);
- return TRUE;
+ report_and_stop_conversation (self, service_name, error->message,
+ g_error_matches (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_SERVICE_UNAVAILABLE));
+ }
}
-static gboolean
-gdm_session_handle_authorized (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- GdmSession *self)
+static void
+on_authorize_cb (GdmDBusWorker *proxy,
+ GAsyncResult *res,
+ gpointer user_data)
{
- gdm_dbus_worker_manager_complete_authorized (worker_manager_interface,
- invocation);
- gdm_session_accredit (self, service_name);
+ GdmSessionConversation *conversation = user_data;
+ GdmSession *self = conversation->session;
+ char *service_name = conversation->service_name;
- return TRUE;
-}
+ GError *error = NULL;
+ gboolean worked;
-static gboolean
-gdm_session_handle_authorization_failed (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *message,
- GdmSession *self)
-{
- gdm_dbus_worker_manager_complete_authorization_failed (worker_manager_interface,
- invocation);
+ worked = gdm_dbus_worker_call_authorize_finish (proxy, res, &error);
- report_problem_and_stop_conversation (self, service_name, message);
- return TRUE;
+ if (worked) {
+ gdm_session_accredit (self, service_name);
+ } else {
+ report_problem_and_stop_conversation (self, service_name, error->message);
+ }
}
-static gboolean
-gdm_session_handle_accredited (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- GdmSession *self)
+static void
+on_establish_credentials_cb (GdmDBusWorker *proxy,
+ GAsyncResult *res,
+ gpointer user_data)
{
- gdm_dbus_worker_manager_complete_accredited (worker_manager_interface,
- invocation);
-
-
- switch (self->priv->verification_mode) {
- case GDM_SESSION_VERIFICATION_MODE_REAUTHENTICATE:
- if (self->priv->user_verifier_interface != NULL) {
- gdm_dbus_user_verifier_emit_verification_complete (self->priv->user_verifier_interface,
- service_name);
- g_signal_emit (self, signals[VERIFICATION_COMPLETE], 0, service_name);
- }
- break;
+ GdmSessionConversation *conversation = user_data;
+ GdmSession *self = conversation->session;
+ char *service_name = conversation->service_name;
- case GDM_SESSION_VERIFICATION_MODE_LOGIN:
- case GDM_SESSION_VERIFICATION_MODE_CHOOSER:
- gdm_session_open_session (self, service_name);
- break;
- default:
- break;
- }
+ GError *error = NULL;
+ gboolean worked;
- return TRUE;
-}
+ worked = gdm_dbus_worker_call_establish_credentials_finish (proxy, res, &error);
-static gboolean
-gdm_session_handle_accreditation_failed (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *message,
- GdmSession *self)
-{
- gdm_dbus_worker_manager_complete_accreditation_failed (worker_manager_interface,
- invocation);
+ if (worked) {
+ switch (self->priv->verification_mode) {
+ case GDM_SESSION_VERIFICATION_MODE_REAUTHENTICATE:
+ if (self->priv->user_verifier_interface != NULL) {
+ gdm_dbus_user_verifier_emit_verification_complete (self->priv->user_verifier_interface,
+ service_name);
+ g_signal_emit (self, signals[VERIFICATION_COMPLETE], 0, service_name);
+ }
+ break;
- report_problem_and_stop_conversation (self, service_name, message);
- return TRUE;
+ case GDM_SESSION_VERIFICATION_MODE_LOGIN:
+ case GDM_SESSION_VERIFICATION_MODE_CHOOSER:
+ gdm_session_open_session (self, service_name);
+ break;
+ default:
+ break;
+ }
+ } else {
+ report_problem_and_stop_conversation (self, service_name, error->message);
+ }
}
static const char **
@@ -701,26 +620,6 @@ gdm_session_select_user (GdmSession *self,
self->priv->saved_language = NULL;
}
-static gboolean
-gdm_session_handle_username_changed (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *username,
- GdmSession *self)
-{
- gdm_dbus_worker_manager_complete_username_changed (worker_manager_interface,
- invocation);
-
- g_debug ("GdmSession: changing username from '%s' to '%s'",
- self->priv->selected_user != NULL ? self->priv->selected_user : "<unset>",
- (strlen (username)) ? username : "<unset>");
-
- gdm_session_select_user (self, (strlen (username) > 0) ? g_strdup (username) : NULL);
- gdm_session_defaults_changed (self);
-
- return TRUE;
-}
-
static void
cancel_pending_query (GdmSessionConversation *conversation)
{
@@ -816,21 +715,11 @@ gdm_session_handle_info (GdmDBusWorkerManager *worker_manager_interface,
return TRUE;
}
-static gboolean
-gdm_session_handle_cancel_pending_query (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- GdmSession *self)
+static void
+worker_on_cancel_pending_query (GdmDBusWorker *worker,
+ GdmSessionConversation *conversation)
{
- GdmSessionConversation *conversation;
-
- conversation = find_conversation_by_name (self, service_name);
cancel_pending_query (conversation);
-
- gdm_dbus_worker_manager_complete_cancel_pending_query (worker_manager_interface,
- invocation);
-
- return TRUE;
}
static gboolean
@@ -851,110 +740,72 @@ gdm_session_handle_problem (GdmDBusWorkerManager *worker_manager_interface,
return TRUE;
}
-static gboolean
-gdm_session_handle_opened (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *session_id,
- GdmSession *self)
+static void
+on_opened (GdmDBusWorker *worker,
+ GAsyncResult *res,
+ gpointer user_data)
{
- GdmSessionConversation *conversation;
+ GdmSessionConversation *conversation = user_data;
+ GdmSession *self = conversation->session;
+ char *service_name = conversation->service_name;
- gdm_dbus_worker_manager_complete_opened (worker_manager_interface,
- invocation);
+ GError *error = NULL;
+ gboolean worked;
+ char *session_id;
- conversation = find_conversation_by_name (self, service_name);
+ worked = gdm_dbus_worker_call_open_finish (worker,
+ &session_id,
+ res,
+ &error);
+ if (worked) {
+ g_clear_pointer (&conversation->session_id,
+ (GDestroyNotify) g_free);
- if (conversation == NULL) {
- return TRUE;
- }
+ conversation->session_id = g_strdup (session_id);
- g_clear_pointer (&conversation->session_id,
- (GDestroyNotify) g_free);
+ if (self->priv->greeter_interface != NULL) {
+ gdm_dbus_greeter_emit_session_opened (self->priv->greeter_interface,
+ service_name);
+ }
- conversation->session_id = g_strdup (session_id);
+ if (self->priv->user_verifier_interface != NULL) {
+ gdm_dbus_user_verifier_emit_verification_complete (self->priv->user_verifier_interface,
+ service_name);
+ g_signal_emit (self, signals[VERIFICATION_COMPLETE], 0, service_name);
+ }
- if (self->priv->greeter_interface != NULL) {
- gdm_dbus_greeter_emit_session_opened (self->priv->greeter_interface,
- service_name);
- }
+ g_debug ("GdmSession: Emitting 'session-opened' signal");
+ g_signal_emit (self, signals[SESSION_OPENED], 0, service_name, session_id);
+ } else {
+ report_problem_and_stop_conversation (self, service_name, error->message);
- if (self->priv->user_verifier_interface != NULL) {
- gdm_dbus_user_verifier_emit_verification_complete (self->priv->user_verifier_interface,
- service_name);
- g_signal_emit (self, signals[VERIFICATION_COMPLETE], 0, service_name);
+ g_debug ("GdmSession: Emitting 'session-start-failed' signal");
+ g_signal_emit (self, signals[SESSION_START_FAILED], 0, service_name, error->message);
}
-
- g_debug ("GdmSession: Emitting 'session-opened' signal");
- g_signal_emit (self, signals[SESSION_OPENED], 0, service_name, session_id);
-
- return TRUE;
-}
-
-static gboolean
-gdm_session_handle_open_failed (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *message,
- GdmSession *self)
-{
- gdm_dbus_worker_manager_complete_open_failed (worker_manager_interface,
- invocation);
-
- report_problem_and_stop_conversation (self, service_name, message);
-
- return TRUE;
}
-static gboolean
-gdm_session_handle_session_started (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- int pid,
- GdmSession *self)
+static void
+worker_on_username_changed (GdmDBusWorker *worker,
+ const char *username,
+ GdmSessionConversation *conversation)
{
- GdmSessionConversation *conversation;
-
- gdm_dbus_worker_manager_complete_session_started (worker_manager_interface,
- invocation);
-
- conversation = find_conversation_by_name (self, service_name);
-
- self->priv->session_pid = pid;
- self->priv->session_conversation = conversation;
-
- g_debug ("GdmSession: Emitting 'session-started' signal with pid '%d'", pid);
- g_signal_emit (self, signals[SESSION_STARTED], 0, service_name, pid);
-
- return TRUE;
-}
-
-static gboolean
-gdm_session_handle_session_start_failed (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- const char *message,
- GdmSession *self)
-{
- gdm_dbus_worker_manager_complete_session_start_failed (worker_manager_interface,
- invocation);
- gdm_session_stop_conversation (self, service_name);
+ GdmSession *self = conversation->session;
- g_debug ("GdmSession: Emitting 'session-start-failed' signal");
- g_signal_emit (self, signals[SESSION_START_FAILED], 0, service_name, message);
+ g_debug ("GdmSession: changing username from '%s' to '%s'",
+ self->priv->selected_user != NULL ? self->priv->selected_user : "<unset>",
+ (strlen (username)) ? username : "<unset>");
- return TRUE;
+ gdm_session_select_user (self, (strlen (username) > 0) ? g_strdup (username) : NULL);
+ gdm_session_defaults_changed (self);
}
-static gboolean
-gdm_session_handle_session_exited_or_died (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- int status,
- GdmSession *self)
+static void
+worker_on_session_exited (GdmDBusWorker *worker,
+ const char *service_name,
+ int status,
+ GdmSessionConversation *conversation)
{
- gdm_dbus_worker_manager_complete_session_exited (worker_manager_interface,
- invocation);
+ GdmSession *self = conversation->session;
self->priv->session_conversation = NULL;
@@ -967,47 +818,51 @@ gdm_session_handle_session_exited_or_died (GdmDBusWorkerManager *worker_manager
WTERMSIG (status));
g_signal_emit (self, signals[SESSION_DIED], 0, WTERMSIG (status));
}
-
- return TRUE;
}
static gboolean
-gdm_session_handle_reauthentication_started (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- int pid_of_caller,
- const char *address,
- GdmSession *self)
+on_reauthentication_started_cb (GdmDBusWorker *worker,
+ GAsyncResult *res,
+ gpointer user_data)
{
- gdm_dbus_worker_manager_complete_reauthentication_started (worker_manager_interface,
- invocation);
+ GdmSessionConversation *conversation = user_data;
+ GdmSession *self = conversation->session;
+
+ GError *error = NULL;
+ gboolean worked;
+ char *address;
+
+ worked = gdm_dbus_worker_call_start_reauthentication_finish (worker,
+ &address,
+ res,
+ &error);
+ if (worked) {
+ GPid pid_of_caller = conversation->reauth_pid_of_caller;
+ g_debug ("GdmSession: Emitting 'reauthentication-started' signal for caller pid '%d'", pid_of_caller);
+ g_signal_emit (self, signals[REAUTHENTICATION_STARTED], 0, pid_of_caller, address);
+ }
+
+ conversation->reauth_pid_of_caller = 0;
- g_debug ("GdmSession: Emitting 'reauthentication-started' signal for caller pid '%d'", pid_of_caller);
- g_signal_emit (self, signals[REAUTHENTICATION_STARTED], 0, pid_of_caller, address);
return TRUE;
}
-static gboolean
-gdm_session_handle_reauthenticated (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *service_name,
- GdmSession *self)
+static void
+worker_on_reauthenticated (GdmDBusWorker *worker,
+ const char *service_name,
+ GdmSessionConversation *conversation)
{
- gdm_dbus_worker_manager_complete_reauthenticated (worker_manager_interface,
- invocation);
-
+ GdmSession *self = conversation->session;
g_debug ("GdmSession: Emitting 'reauthenticated' signal ");
g_signal_emit (self, signals[REAUTHENTICATED], 0, service_name);
- return TRUE;
}
-static gboolean
-gdm_session_handle_saved_language_name_read (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *language_name,
- GdmSession *self)
+static void
+worker_on_saved_language_name_read (GdmDBusWorker *worker,
+ const char *language_name,
+ GdmSessionConversation *conversation)
{
- gdm_dbus_worker_manager_complete_saved_language_name_read (worker_manager_interface,
- invocation);
+ GdmSession *self = conversation->session;
if (strcmp (language_name,
get_default_language_name (self)) != 0) {
@@ -1019,25 +874,21 @@ gdm_session_handle_saved_language_name_read (GdmDBusWorkerManager *worker_manag
language_name);
}
}
-
- return TRUE;
}
-static gboolean
-gdm_session_handle_saved_session_name_read (GdmDBusWorkerManager *worker_manager_interface,
- GDBusMethodInvocation *invocation,
- const char *session_name,
- GdmSession *self)
+static void
+worker_on_saved_session_name_read (GdmDBusWorker *worker,
+ const char *session_name,
+ GdmSessionConversation *conversation)
{
- gdm_dbus_worker_manager_complete_saved_session_name_read (worker_manager_interface,
- invocation);
+ GdmSession *self = conversation->session;
if (! get_session_command_for_name (session_name, NULL)) {
/* ignore sessions that don't exist */
g_debug ("GdmSession: not using invalid .dmrc session: %s", session_name);
g_free (self->priv->saved_session);
self->priv->saved_session = NULL;
- goto out;
+ return;
}
if (strcmp (session_name,
@@ -1050,8 +901,6 @@ gdm_session_handle_saved_session_name_read (GdmDBusWorkerManager *worker_manage
session_name);
}
}
- out:
- return TRUE;
}
static GdmSessionConversation *
@@ -1166,6 +1015,30 @@ register_worker (GdmDBusWorkerManager *worker_manager_interface,
g_dbus_method_invocation_return_value (invocation, NULL);
conversation->worker_connection = connection;
+ conversation->worker_proxy = gdm_dbus_worker_proxy_new_sync (connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GDM_WORKER_DBUS_PATH,
+ NULL, NULL);
+ g_signal_connect (conversation->worker_proxy,
+ "username-changed",
+ G_CALLBACK (worker_on_username_changed), conversation);
+ g_signal_connect (conversation->worker_proxy,
+ "session-exited",
+ G_CALLBACK (worker_on_session_exited), conversation);
+ g_signal_connect (conversation->worker_proxy,
+ "reauthenticated",
+ G_CALLBACK (worker_on_reauthenticated), conversation);
+ g_signal_connect (conversation->worker_proxy,
+ "saved-language-name-read",
+ G_CALLBACK (worker_on_saved_language_name_read), conversation);
+ g_signal_connect (conversation->worker_proxy,
+ "saved-session-name-read",
+ G_CALLBACK (worker_on_saved_session_name_read), conversation);
+ g_signal_connect (conversation->worker_proxy,
+ "cancel-pending-query",
+ G_CALLBACK (worker_on_cancel_pending_query), conversation);
+
conversation->worker_manager_interface = g_object_ref (worker_manager_interface);
g_debug ("GdmSession: worker connection is %p", connection);
@@ -1206,58 +1079,6 @@ export_worker_manager_interface (GdmSession *self,
G_CALLBACK (register_worker),
self);
g_signal_connect (worker_manager_interface,
- "handle-cancel-pending-query",
- G_CALLBACK (gdm_session_handle_cancel_pending_query),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-username-changed",
- G_CALLBACK (gdm_session_handle_username_changed),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-saved-language-name-read",
- G_CALLBACK (gdm_session_handle_saved_language_name_read),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-saved-session-name-read",
- G_CALLBACK (gdm_session_handle_saved_session_name_read),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-service-unavailable",
- G_CALLBACK (gdm_session_handle_service_unavailable),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-setup-complete",
- G_CALLBACK (gdm_session_handle_setup_complete),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-setup-failed",
- G_CALLBACK (gdm_session_handle_setup_failed),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-authenticated",
- G_CALLBACK (gdm_session_handle_authenticated),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-authentication-failed",
- G_CALLBACK (gdm_session_handle_authentication_failed),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-authorized",
- G_CALLBACK (gdm_session_handle_authorized),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-authorization-failed",
- G_CALLBACK (gdm_session_handle_authorization_failed),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-accredited",
- G_CALLBACK (gdm_session_handle_accredited),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-accreditation-failed",
- G_CALLBACK (gdm_session_handle_accreditation_failed),
- self);
- g_signal_connect (worker_manager_interface,
"handle-info-query",
G_CALLBACK (gdm_session_handle_info_query),
self);
@@ -1273,34 +1094,6 @@ export_worker_manager_interface (GdmSession *self,
"handle-problem",
G_CALLBACK (gdm_session_handle_problem),
self);
- g_signal_connect (worker_manager_interface,
- "handle-opened",
- G_CALLBACK (gdm_session_handle_opened),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-open-failed",
- G_CALLBACK (gdm_session_handle_open_failed),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-session-started",
- G_CALLBACK (gdm_session_handle_session_started),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-session-start-failed",
- G_CALLBACK (gdm_session_handle_session_start_failed),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-session-exited",
- G_CALLBACK (gdm_session_handle_session_exited_or_died),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-reauthentication-started",
- G_CALLBACK (gdm_session_handle_reauthentication_started),
- self);
- g_signal_connect (worker_manager_interface,
- "handle-reauthenticated",
- G_CALLBACK (gdm_session_handle_reauthenticated),
- self);
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (worker_manager_interface),
connection,
@@ -2052,6 +1845,45 @@ gdm_session_stop_conversation (GdmSession *self,
}
static void
+on_setup_complete_cb (GdmDBusWorker *proxy,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GdmSessionConversation *conversation = user_data;
+ GdmSession *self = conversation->session;
+ char *service_name = conversation->service_name;
+
+ GError *error = NULL;
+ GVariant *ret;
+
+ ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, &error);
+
+ if (ret != NULL) {
+ if (conversation->starting_invocation) {
+ g_dbus_method_invocation_return_value (conversation->starting_invocation,
+ NULL);
+ }
+
+ g_signal_emit (G_OBJECT (self),
+ signals [SETUP_COMPLETE],
+ 0,
+ service_name);
+
+ gdm_session_authenticate (self, service_name);
+
+ } else {
+ g_dbus_method_invocation_take_error (conversation->starting_invocation, error);
+ report_and_stop_conversation (self, service_name, error->message,
+ g_error_matches (error,
+ GDM_SESSION_WORKER_ERROR,
+ GDM_SESSION_WORKER_ERROR_SERVICE_UNAVAILABLE));
+ }
+
+ g_variant_unref (ret);
+ g_clear_object (&conversation->starting_invocation);
+}
+
+static void
send_setup (GdmSession *self,
const char *service_name)
{
@@ -2094,14 +1926,17 @@ send_setup (GdmSession *self,
conversation = find_conversation_by_name (self, service_name);
if (conversation != NULL) {
- gdm_dbus_worker_manager_emit_setup (conversation->worker_manager_interface,
- service_name,
- display_name,
- display_x11_authority_file,
- display_device,
- display_seat_id,
- display_hostname,
- self->priv->display_is_local);
+ gdm_dbus_worker_call_setup (conversation->worker_proxy,
+ service_name,
+ display_name,
+ display_x11_authority_file,
+ display_device,
+ display_seat_id,
+ display_hostname,
+ self->priv->display_is_local,
+ NULL,
+ (GAsyncReadyCallback) on_setup_complete_cb,
+ conversation);
}
}
@@ -2155,15 +1990,18 @@ send_setup_for_user (GdmSession *self,
g_debug ("GdmSession: Beginning setup for user %s", self->priv->selected_user);
if (conversation != NULL) {
- gdm_dbus_worker_manager_emit_setup_for_user (conversation->worker_manager_interface,
- service_name,
- selected_user,
- display_name,
- display_x11_authority_file,
- display_device,
- display_seat_id,
- display_hostname,
- self->priv->display_is_local);
+ gdm_dbus_worker_call_setup_for_user (conversation->worker_proxy,
+ service_name,
+ selected_user,
+ display_name,
+ display_x11_authority_file,
+ display_device,
+ display_seat_id,
+ display_hostname,
+ self->priv->display_is_local,
+ NULL,
+ (GAsyncReadyCallback) on_setup_complete_cb,
+ conversation);
}
}
@@ -2212,16 +2050,19 @@ send_setup_for_program (GdmSession *self,
conversation = find_conversation_by_name (self, service_name);
if (conversation != NULL) {
- gdm_dbus_worker_manager_emit_setup_for_program (conversation->worker_manager_interface,
- service_name,
- username,
- display_name,
- display_x11_authority_file,
- display_device,
- display_seat_id,
- display_hostname,
- self->priv->display_is_local,
- log_file);
+ gdm_dbus_worker_call_setup_for_program (conversation->worker_proxy,
+ service_name,
+ username,
+ display_name,
+ display_x11_authority_file,
+ display_device,
+ display_seat_id,
+ display_hostname,
+ self->priv->display_is_local,
+ log_file,
+ NULL,
+ (GAsyncReadyCallback) on_setup_complete_cb,
+ conversation);
}
}
@@ -2274,8 +2115,10 @@ gdm_session_authenticate (GdmSession *self,
conversation = find_conversation_by_name (self, service_name);
if (conversation != NULL) {
- gdm_dbus_worker_manager_emit_authenticate (conversation->worker_manager_interface,
- service_name);
+ gdm_dbus_worker_call_authenticate (conversation->worker_proxy,
+ NULL,
+ (GAsyncReadyCallback) on_authenticate_cb,
+ conversation);
}
}
@@ -2289,8 +2132,10 @@ gdm_session_authorize (GdmSession *self,
conversation = find_conversation_by_name (self, service_name);
if (conversation != NULL) {
- gdm_dbus_worker_manager_emit_authorize (conversation->worker_manager_interface,
- service_name);
+ gdm_dbus_worker_call_authorize (conversation->worker_proxy,
+ NULL,
+ (GAsyncReadyCallback) on_authorize_cb,
+ conversation);
}
}
@@ -2303,12 +2148,13 @@ gdm_session_accredit (GdmSession *self,
g_return_if_fail (GDM_IS_SESSION (self));
conversation = find_conversation_by_name (self, service_name);
- if (conversation == NULL) {
- return;
+ if (conversation != NULL) {
+ gdm_dbus_worker_call_establish_credentials (conversation->worker_proxy,
+ NULL,
+ (GAsyncReadyCallback) on_establish_credentials_cb,
+ conversation);
}
- gdm_dbus_worker_manager_emit_establish_credentials (conversation->worker_manager_interface,
- service_name);
}
static void
@@ -2316,9 +2162,9 @@ send_environment_variable (const char *key,
const char *value,
GdmSessionConversation *conversation)
{
- gdm_dbus_worker_manager_emit_set_environment_variable (conversation->worker_manager_interface,
- key,
- value);
+ gdm_dbus_worker_call_set_environment_variable (conversation->worker_proxy,
+ key, value,
+ NULL, NULL, NULL);
}
static void
@@ -2446,8 +2292,9 @@ gdm_session_open_session (GdmSession *self,
conversation = find_conversation_by_name (self, service_name);
- gdm_dbus_worker_manager_emit_open_session (conversation->worker_manager_interface,
- service_name);
+ gdm_dbus_worker_call_open (conversation->worker_proxy,
+ NULL,
+ (GAsyncReadyCallback) on_opened, conversation);
}
static void
@@ -2505,6 +2352,37 @@ stop_all_other_conversations (GdmSession *self,
}
+static void
+on_start_program_cb (GdmDBusWorker *worker,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GdmSessionConversation *conversation = user_data;
+ GdmSession *self = conversation->session;
+ char *service_name = conversation->service_name;
+
+ GError *error = NULL;
+ gboolean worked;
+ GPid pid;
+
+ worked = gdm_dbus_worker_call_start_program_finish (worker,
+ &pid,
+ res,
+ &error);
+ if (worked) {
+ self->priv->session_pid = pid;
+ self->priv->session_conversation = conversation;
+
+ g_debug ("GdmSession: Emitting 'session-started' signal with pid '%d'", pid);
+ g_signal_emit (self, signals[SESSION_STARTED], 0, service_name, pid);
+ } else {
+ gdm_session_stop_conversation (self, service_name);
+
+ g_debug ("GdmSession: Emitting 'session-start-failed' signal");
+ g_signal_emit (self, signals[SESSION_START_FAILED], 0, service_name, error->message);
+ }
+}
+
void
gdm_session_start_session (GdmSession *self,
const char *service_name)
@@ -2543,8 +2421,11 @@ gdm_session_start_session (GdmSession *self,
setup_session_environment (self);
send_environment (self, conversation);
- gdm_dbus_worker_manager_emit_start_program (conversation->worker_manager_interface,
- program);
+ gdm_dbus_worker_call_start_program (conversation->worker_proxy,
+ program,
+ NULL,
+ (GAsyncReadyCallback) on_start_program_cb,
+ conversation);
g_free (program);
}
@@ -2665,11 +2546,18 @@ gdm_session_start_reauthentication (GdmSession *session,
GPid pid_of_caller,
uid_t uid_of_caller)
{
- g_return_if_fail (session->priv->session_conversation != NULL);
+ GdmSessionConversation *conversation = session->priv->session_conversation;
+
+ g_return_if_fail (conversation != NULL);
+
+ conversation->reauth_pid_of_caller = pid_of_caller;
- gdm_dbus_worker_manager_emit_start_reauthentication (session->priv->session_conversation->worker_manager_interface,
- (int) pid_of_caller,
- (int) uid_of_caller);
+ gdm_dbus_worker_call_start_reauthentication (conversation->worker_proxy,
+ (int) pid_of_caller,
+ (int) uid_of_caller,
+ NULL,
+ (GAsyncReadyCallback) on_reauthentication_started_cb,
+ conversation);
}
char *
@@ -2791,8 +2679,9 @@ gdm_session_select_session_type (GdmSession *self,
conversation = (GdmSessionConversation *) value;
- gdm_dbus_worker_manager_emit_set_session_type (conversation->worker_manager_interface,
- text);
+ gdm_dbus_worker_call_set_session_type (conversation->worker_proxy,
+ text,
+ NULL, NULL, NULL);
}
}
@@ -2817,8 +2706,9 @@ gdm_session_select_session (GdmSession *self,
conversation = (GdmSessionConversation *) value;
- gdm_dbus_worker_manager_emit_set_session_name (conversation->worker_manager_interface,
- get_session_name (self));
+ gdm_dbus_worker_call_set_session_name (conversation->worker_proxy,
+ get_session_name (self),
+ NULL, NULL, NULL);
}
}
@@ -2843,8 +2733,9 @@ gdm_session_select_language (GdmSession *self,
conversation = (GdmSessionConversation *) value;
- gdm_dbus_worker_manager_emit_set_language_name (conversation->worker_manager_interface,
- get_language_name (self));
+ gdm_dbus_worker_call_set_language_name (conversation->worker_proxy,
+ get_language_name (self),
+ NULL, NULL, NULL);
}
}
diff --git a/daemon/gdm-session.xml b/daemon/gdm-session.xml
index 53e9cd9..cf3103a 100644
--- a/daemon/gdm-session.xml
+++ b/daemon/gdm-session.xml
@@ -4,51 +4,6 @@
signals are emitted by the simple slave -->
<interface name="org.gnome.DisplayManager.WorkerManager">
<method name="Hello" />
- <method name="CancelPendingQuery">
- <arg name="service_name" type="s" direction="in"/>
- </method>
- <method name="UsernameChanged">
- <arg name="service_name" type="s" direction="in"/>
- <arg name="new_username" type="s" direction="in"/>
- </method>
- <method name="SavedLanguageNameRead">
- <arg name="language_name" type="s" direction="in"/>
- </method>
- <method name="SavedSessionNameRead">
- <arg name="session_name" type="s" direction="in"/>
- </method>
- <method name="ServiceUnavailable">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="message" direction="in" type="s"/>
- </method>
- <method name="SetupComplete">
- <arg name="service_name" direction="in" type="s"/>
- </method>
- <method name="SetupFailed">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="message" direction="in" type="s"/>
- </method>
- <method name="Authenticated">
- <arg name="service_name" direction="in" type="s"/>
- </method>
- <method name="AuthenticationFailed">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="message" direction="in" type="s"/>
- </method>
- <method name="Authorized">
- <arg name="service_name" direction="in" type="s"/>
- </method>
- <method name="AuthorizationFailed">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="message" direction="in" type="s"/>
- </method>
- <method name="Accredited">
- <arg name="service_name" direction="in" type="s"/>
- </method>
- <method name="AccreditationFailed">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="message" direction="in" type="s"/>
- </method>
<method name="InfoQuery">
<arg name="service_name" direction="in" type="s"/>
<arg name="query" direction="in" type="s"/>
@@ -67,98 +22,6 @@
<arg name="service_name" direction="in" type="s"/>
<arg name="problem" direction="in" type="s"/>
</method>
- <method name="ReauthenticationStarted">
- <arg name="pid_of_caller" direction="in" type="i"/>
- <arg name="address" direction="in" type="s"/>
- </method>
- <method name="Reauthenticated">
- <arg name="service_name" direction="in" type="s"/>
- </method>
- <method name="Opened">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="session_id" direction="in" type="s"/>
- </method>
- <method name="OpenFailed">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="message" direction="in" type="s"/>
- </method>
- <method name="SessionStarted">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="pid" direction="in" type="i"/>
- </method>
- <method name="SessionStartFailed">
- <arg name="service_name" direction="in" type="s"/>
- <arg name="message" direction="in" type="s"/>
- </method>
- <method name="SessionExited">
- <arg name="service_name" direction="in" type="s"/>
- <!-- This is a combination of exit code and exit
- signal. Use macros in sys/wait.h to handle it. -->
- <arg name="status" direction="in" type="i"/>
- </method>
-
- <signal name="StartProgram">
- <arg name="command" type="s"/>
- </signal>
- <signal name="Setup">
- <arg name="service_name" type="s"/>
- <arg name="x11_display_name" type="s"/>
- <arg name="x11_authority_file" type="s"/>
- <arg name="display_device" type="s"/>
- <arg name="display_seat" type="s"/>
- <arg name="hostname" type="s"/>
- <arg name="display_is_local" type="b"/>
- </signal>
- <signal name="SetupForUser">
- <arg name="service_name" type="s"/>
- <arg name="user_name" type="s"/>
- <arg name="x11_display_name" type="s"/>
- <arg name="x11_authority_file" type="s"/>
- <arg name="display_device" type="s"/>
- <arg name="display_seat" type="s"/>
- <arg name="hostname" type="s"/>
- <arg name="display_is_local" type="b"/>
- </signal>
- <signal name="SetupForProgram">
- <arg name="service_name" type="s"/>
- <arg name="user_name" type="s"/>
- <arg name="x11_display_name" type="s"/>
- <arg name="x11_authority_file" type="s"/>
- <arg name="display_device" type="s"/>
- <arg name="display_seat" type="s"/>
- <arg name="hostname" type="s"/>
- <arg name="display_is_local" type="b"/>
- <arg name="log_file" type="s"/>
- </signal>
- <signal name="Authenticate">
- <arg name="service_name" type="s"/>
- </signal>
- <signal name="Authorize">
- <arg name="service_name" type="s"/>
- </signal>
- <signal name="EstablishCredentials">
- <arg name="service_name" type="s"/>
- </signal>
- <signal name="OpenSession">
- <arg name="service_name" type="s"/>
- </signal>
- <signal name="StartReauthentication">
- <arg name="pid_of_caller" type="i"/>
- <arg name="uid_of_caller" type="i"/>
- </signal>
- <signal name="SetEnvironmentVariable">
- <arg name="name" type="s" />
- <arg name="value" type="s" />
- </signal>
- <signal name="SetLanguageName">
- <arg name="language" type="s" />
- </signal>
- <signal name="SetSessionName">
- <arg name="session_name" type="s" />
- </signal>
- <signal name="SetSessionType">
- <arg name="session_type" type="s" />
- </signal>
</interface>
<interface name="org.gnome.DisplayManager.UserVerifier">
<method name="BeginVerification">
diff --git a/daemon/session-worker-main.c b/daemon/session-worker-main.c
index 7a385ed..ddf3832 100644
--- a/daemon/session-worker-main.c
+++ b/daemon/session-worker-main.c
@@ -44,9 +44,6 @@
#include "gdm-settings-direct.h"
#include "gdm-settings-keys.h"
-#define SERVER_DBUS_PATH "/org/gnome/DisplayManager/SessionServer"
-#define SERVER_DBUS_INTERFACE "org.gnome.DisplayManager.SessionServer"
-
static GdmSettings *settings = NULL;
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]