From 4862efc8bb38e97a785bd9c368d9b701c2acba68 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Sun, 15 Dec 2019 14:51:44 -0500 Subject: [PATCH 5/5] daemon: fix wayland detection when deciding to bypass Xsession At the moment if there's a session file with the same name in both /usr/share/xsessions and /usr/share/wayland-sessions, GDM will think the wayland is getting used when deciding whether or not to bypass the /etc/gdm/Xsession script, even if wayland is explicitly being ignored. This commit fixes the check. --- daemon/gdm-session.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c index 2d471ec46..38a32fdab 100644 --- a/daemon/gdm-session.c +++ b/daemon/gdm-session.c @@ -2898,61 +2898,61 @@ gdm_session_start_session (GdmSession *self, char *command; char *program; gboolean register_session; g_return_if_fail (GDM_IS_SESSION (self)); g_return_if_fail (self->session_conversation == NULL); conversation = find_conversation_by_name (self, service_name); if (conversation == NULL) { g_warning ("GdmSession: Tried to start session of " "nonexistent conversation %s", service_name); return; } stop_all_other_conversations (self, conversation, FALSE); display_mode = gdm_session_get_display_mode (self); #ifdef ENABLE_WAYLAND_SUPPORT is_x11 = g_strcmp0 (self->session_type, "wayland") != 0; #endif if (display_mode == GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED || display_mode == GDM_SESSION_DISPLAY_MODE_NEW_VT) { run_launcher = TRUE; } register_session = !gdm_session_session_registers (self); - if (g_strcmp0 (priv->display_seat_id, "seat0") != 0 && !run_launcher) { + if (g_strcmp0 (self->display_seat_id, "seat0") != 0 && !run_launcher) { run_separate_bus = TRUE; } if (self->selected_program == NULL) { gboolean run_xsession_script; command = get_session_command (self); run_xsession_script = !gdm_session_bypasses_xsession (self); if (self->display_is_local) { gboolean disallow_tcp = TRUE; gdm_settings_direct_get_boolean (GDM_KEY_DISALLOW_TCP, &disallow_tcp); allow_remote_connections = !disallow_tcp; } else { allow_remote_connections = TRUE; } if (run_launcher) { if (is_x11) { 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\"%s\"", register_session ? "--register-session " : "", command); } @@ -3192,119 +3192,118 @@ gdm_session_get_session_id (GdmSession *self) return conversation->session_id; } const char * gdm_session_get_conversation_session_id (GdmSession *self, const char *service_name) { GdmSessionConversation *conversation; g_return_val_if_fail (GDM_IS_SESSION (self), NULL); conversation = find_conversation_by_name (self, service_name); if (conversation == NULL) { return NULL; } return conversation->session_id; } static char * get_session_filename (GdmSession *self) { return g_strdup_printf ("%s.desktop", get_session_name (self)); } #ifdef ENABLE_WAYLAND_SUPPORT static gboolean gdm_session_is_wayland_session (GdmSession *self) { - GKeyFile *key_file; + g_autoptr (GKeyFile) key_file = NULL; gboolean is_wayland_session = FALSE; - char *filename; - char *full_path = NULL; + g_autofree char *filename = NULL; + g_autofree char *full_path = 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, "wayland", &full_path); + if (!self->ignore_wayland) { + key_file = load_key_file_for_file (self, filename, "wayland", &full_path); - if (key_file == NULL) { - goto out; - } + if (key_file == NULL) { + goto out; + } - if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) { - is_wayland_session = TRUE; + if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) { + is_wayland_session = TRUE; + } } - g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no"); out: - g_clear_pointer (&key_file, g_key_file_free); - g_free (filename); + g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no"); return is_wayland_session; } #endif static void update_session_type (GdmSession *self) { #ifdef ENABLE_WAYLAND_SUPPORT gboolean is_wayland_session = FALSE; - if (!self->ignore_wayland) - is_wayland_session = gdm_session_is_wayland_session (self); + is_wayland_session = gdm_session_is_wayland_session (self); if (is_wayland_session) { set_session_type (self, "wayland"); } else { set_session_type (self, NULL); } #endif } 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); + key_file = load_key_file_for_file (self, filename, NULL, 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; GKeyFile *key_file; gboolean res; gboolean bypasses_xsession = FALSE; char *filename = NULL; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (GDM_IS_SESSION (self), FALSE); -- 2.31.1