summaryrefslogtreecommitdiff
path: root/daemon/gdm-session.c
diff options
context:
space:
mode:
authorIain Lane <iainl@gnome.org>2019-05-07 16:00:14 +0100
committerIain Lane <iain@orangesquash.org.uk>2019-05-29 15:53:35 +0000
commit1c061b84ffc3e874da825982d18d970556ff74bb (patch)
tree64f56c787fdfa6e2a205ea726d589fad546da300 /daemon/gdm-session.c
parent9496f639715b1b8e31b2b0a5bd37a8b6761249b3 (diff)
downloadgdm-1c061b84ffc3e874da825982d18d970556ff74bb.tar.gz
Allow sessions to register with GDM
Recording when sessions start, for Wayland → Xorg fallback or transitioning to the user session, is currently done with timeouts. This isn't ideal, because on some very slow machines the timeout can be hit before the session has had a chance to fail: if gnome-session takes more than 3 seconds to fail then the session will be considered to have exited rather than failed, and so we don't do Xorg fallback. We can do this more reliably if we allow sessions to optionally register themselves with GDM. Then we will know when they've started, so can shut down the greeter or fall back to Xorg as appropriate. The mechanism is that they specify X-GDM-SessionRegisters=true in their file, and then call RegsterSession on the DisplayManager interface on the bus (added in the previous commit) to say that they've started up. If X-GDM-SessionRegisters is missing or false, GDM will call the same method for them after 10 seconds. Closes: #483
Diffstat (limited to 'daemon/gdm-session.c')
-rw-r--r--daemon/gdm-session.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index 6a116a85..d0e09b53 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -2837,6 +2837,7 @@ gdm_session_start_session (GdmSession *self,
gboolean allow_remote_connections = FALSE;
char *command;
char *program;
+ gboolean register_session;
g_return_if_fail (GDM_IS_SESSION (self));
g_return_if_fail (self->session_conversation == NULL);
@@ -2862,6 +2863,8 @@ gdm_session_start_session (GdmSession *self,
run_launcher = TRUE;
}
+ register_session = !gdm_session_session_registers (self);
+
if (self->selected_program == NULL) {
gboolean run_xsession_script;
@@ -2879,12 +2882,14 @@ gdm_session_start_session (GdmSession *self,
if (run_launcher) {
if (is_x11) {
- program = g_strdup_printf (LIBEXECDIR "/gdm-x-session %s %s\"%s\"",
+ program = g_strdup_printf (LIBEXECDIR "/gdm-x-session %s%s %s\"%s\"",
+ register_session ? "--register-session " : "",
run_xsession_script? "--run-script " : "",
allow_remote_connections? "--allow-remote-connections " : "",
command);
} else {
- program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session \"%s\"",
+ program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"%s\"",
+ register_session ? "--register-session " : "",
command);
}
} else if (run_xsession_script) {
@@ -2897,10 +2902,12 @@ gdm_session_start_session (GdmSession *self,
} else {
if (run_launcher) {
if (is_x11) {
- program = g_strdup_printf (LIBEXECDIR "/gdm-x-session \"%s\"",
+ program = g_strdup_printf (LIBEXECDIR "/gdm-x-session %s\"%s\"",
+ register_session ? "--register-session " : "",
self->selected_program);
} else {
- program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session \"%s\"",
+ program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"%s\"",
+ register_session ? "--register-session " : "",
self->selected_program);
}
} else {
@@ -3178,6 +3185,38 @@ update_session_type (GdmSession *self)
}
gboolean
+gdm_session_session_registers (GdmSession *self)
+{
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GKeyFile) key_file = NULL;
+ gboolean session_registers = FALSE;
+ g_autofree char *filename = NULL;
+
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
+
+ filename = get_session_filename (self);
+
+ key_file = load_key_file_for_file (self, filename, NULL);
+
+ session_registers = g_key_file_get_boolean (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ "X-GDM-SessionRegisters",
+ &error);
+ if (!session_registers &&
+ error != NULL &&
+ !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
+ g_warning ("GdmSession: Couldn't read session file '%s'", filename);
+ return FALSE;
+ }
+
+ g_debug ("GdmSession: '%s' %s self", filename,
+ session_registers ? "registers" : "does not register");
+
+ return session_registers;
+}
+
+gboolean
gdm_session_bypasses_xsession (GdmSession *self)
{
GError *error;