From 3503910fa447a399d9444c1b10da513bf3c0ccd8 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 20 Apr 2023 17:14:19 -0400 Subject: libgdm: Fix session loading precedence One feature that GDM is supposed to support is a precedence order for loading xsession files. If someone has a file in /etc/X11/sessions it's supposed to override a file in /usr/share/xsessions. This works okay from a backend point of view. /etc/X11/sessions can change the command getting run, for instance, but it doesn't work from a front end point of view. Menu items can't get hidden in the session cog. This is due to a bug in libgdm where it inadvertently gives /usr/share/xsessions higher precedence than /etc/X11/sessions. This commit fixes that by processing the lists in reverse order, and making sure to remove already added entries if overriding entries are hidden. --- libgdm/gdm-sessions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c index d8b4d5cd..c3aeafdd 100644 --- a/libgdm/gdm-sessions.c +++ b/libgdm/gdm-sessions.c @@ -143,6 +143,7 @@ load_session_file (const char *id, if (!key_file_is_relevant (key_file)) { g_debug ("\"%s\" is hidden or contains non-executable TryExec program\n", path); + g_hash_table_remove (gdm_available_sessions_map, id); goto out; } @@ -322,7 +323,7 @@ collect_sessions (void) } if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "x11")) { - for (i = 0; i < xorg_search_array->len; i++) { + for (i = xorg_search_array->len - 1; i >= 0; i--) { collect_sessions_from_directory (g_ptr_array_index (xorg_search_array, i)); } } @@ -330,7 +331,7 @@ collect_sessions (void) #ifdef ENABLE_WAYLAND_SUPPORT #ifdef ENABLE_USER_DISPLAY_SERVER if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "wayland")) { - for (i = 0; i < wayland_search_array->len; i++) { + for (i = wayland_search_array->len - 1; i >= 0; i--) { collect_sessions_from_directory (g_ptr_array_index (wayland_search_array, i)); } } -- cgit v1.2.1