From 1bc466f40169abc2d63a0afeff6846b0fd4aa3c8 Mon Sep 17 00:00:00 2001 From: Joan Torres Lopez Date: Thu, 21 Aug 2025 10:37:27 +0200 Subject: [PATCH] Fix precedence order when loading sessions Resolves: RHEL-4133 --- ...-collect-twice-sessions-on-usr-share.patch | 167 ++++++++++++++++++ gdm.spec | 8 +- 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 0001-libgdm-Don-t-collect-twice-sessions-on-usr-share.patch diff --git a/0001-libgdm-Don-t-collect-twice-sessions-on-usr-share.patch b/0001-libgdm-Don-t-collect-twice-sessions-on-usr-share.patch new file mode 100644 index 0000000..fe19d32 --- /dev/null +++ b/0001-libgdm-Don-t-collect-twice-sessions-on-usr-share.patch @@ -0,0 +1,167 @@ +From b52648f991e4537b18620444f4d7b2f9663aed33 Mon Sep 17 00:00:00 2001 +From: Joan Torres Lopez +Date: Mon, 9 Jun 2025 17:00:54 +0200 +Subject: [PATCH 1/2] libgdm: Don't collect twice sessions on /usr/share + +Using system_data_dirs already includes /usr/share, so we don't need to +add it manually. +--- + docs/C/index.docbook | 4 ++-- + libgdm/gdm-sessions.c | 9 --------- + 2 files changed, 2 insertions(+), 11 deletions(-) + +diff --git a/docs/C/index.docbook b/docs/C/index.docbook +index 134b9bc..ab2a87f 100644 +--- a/docs/C/index.docbook ++++ b/docs/C/index.docbook +@@ -2002,8 +2002,8 @@ AutostartCondition=GNOME /desktop/gnome/applications/at/screen_keyboard_enabled + search the following directories in this order to find desktop files: + <etc>/X11/sessions/, + <dmconfdir>/Sessions, +- <share>/xsessions, and +- <share>/gdm/BuiltInSessions. By default the ++ <share>/gdm/BuiltInSessions, and ++ <share>/xsessions. By default the + <dmconfdir> is set to + <etc>/dm/ unless GDM is configured to use + a different directory via the "--with-dmconfdir" option. +diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c +index f078e04..e4a0e6b 100644 +--- a/libgdm/gdm-sessions.c ++++ b/libgdm/gdm-sessions.c +@@ -275,7 +275,6 @@ collect_sessions (void) + "/etc/X11/sessions/", + DMCONFDIR "/Sessions/", + DATADIR "/gdm/BuiltInSessions/", +- DATADIR "/xsessions/", + }; + g_auto (GStrv) supported_session_types = NULL; + +@@ -296,20 +295,12 @@ collect_sessions (void) + } + + #ifdef ENABLE_WAYLAND_SUPPORT +- const char *wayland_search_dirs[] = { +- DATADIR "/wayland-sessions/", +- }; +- + wayland_search_array = g_ptr_array_new_with_free_func (g_free); + + for (i = 0; system_data_dirs[i]; i++) { + session_dir = g_build_filename (system_data_dirs[i], "wayland-sessions", NULL); + g_ptr_array_add (wayland_search_array, session_dir); + } +- +- for (i = 0; i < G_N_ELEMENTS (wayland_search_dirs); i++) { +- g_ptr_array_add (wayland_search_array, g_strdup (wayland_search_dirs[i])); +- } + #endif + + if (gdm_available_sessions_map == NULL) { +-- +2.50.1 + +From ac9d403b5b27cbd8396a696223cd96fbac56f142 Mon Sep 17 00:00:00 2001 +From: Joan Torres Lopez +Date: Mon, 9 Jun 2025 17:11:01 +0200 +Subject: [PATCH 2/2] libgdm: Ensure loading session files is done in the right + order + +Loading session files is done with the following precedence order: +1. Sessions defined in /etc/X11/sessions/ +2. Sessions defined in /Sessions +3. Built-in sessions in /gdm/BuiltInSessions +4. X11 sessions in system_data_dirs +5. Wayland sessions in system_data_dirs + +Sessions dirs have precedence in the order they are added to +dirs_search_array. + +This fixes an issue where sessions at system_data_dirs were being added +before sessions in /etc/. +--- + libgdm/gdm-sessions.c | 49 +++++++++++++++++-------------------------- + 1 file changed, 19 insertions(+), 30 deletions(-) + +diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c +index e4a0e6b..e0d0044 100644 +--- a/libgdm/gdm-sessions.c ++++ b/libgdm/gdm-sessions.c +@@ -267,8 +267,7 @@ static void + collect_sessions (void) + { + g_autoptr(GHashTable) names_seen_before = NULL; +- g_autoptr(GPtrArray) xorg_search_array = NULL; +- g_autoptr(GPtrArray) wayland_search_array = NULL; ++ g_autoptr(GPtrArray) dirs_search_array = NULL; + gchar *session_dir = NULL; + int i; + const char *xorg_search_dirs[] = { +@@ -281,26 +280,30 @@ collect_sessions (void) + supported_session_types = g_strsplit (g_getenv ("GDM_SUPPORTED_SESSION_TYPES"), ":", -1); + + names_seen_before = g_hash_table_new (g_str_hash, g_str_equal); +- xorg_search_array = g_ptr_array_new_with_free_func (g_free); ++ dirs_search_array = g_ptr_array_new_with_free_func (g_free); + + const gchar * const *system_data_dirs = g_get_system_data_dirs (); + +- for (i = 0; system_data_dirs[i]; i++) { +- session_dir = g_build_filename (system_data_dirs[i], "xsessions", NULL); +- g_ptr_array_add (xorg_search_array, session_dir); +- } ++ if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "x11")) { ++ for (i = 0; i < G_N_ELEMENTS (xorg_search_dirs); i++) { ++ g_ptr_array_add (dirs_search_array, g_strdup (xorg_search_dirs[i])); ++ } + +- for (i = 0; i < G_N_ELEMENTS (xorg_search_dirs); i++) { +- g_ptr_array_add (xorg_search_array, g_strdup (xorg_search_dirs[i])); ++ for (i = 0; system_data_dirs[i]; i++) { ++ session_dir = g_build_filename (system_data_dirs[i], "xsessions", NULL); ++ g_ptr_array_add (dirs_search_array, session_dir); ++ } + } + + #ifdef ENABLE_WAYLAND_SUPPORT +- wayland_search_array = g_ptr_array_new_with_free_func (g_free); +- +- for (i = 0; system_data_dirs[i]; i++) { +- session_dir = g_build_filename (system_data_dirs[i], "wayland-sessions", NULL); +- g_ptr_array_add (wayland_search_array, session_dir); ++#ifdef ENABLE_USER_DISPLAY_SERVER ++ if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "wayland")) { ++ for (i = 0; system_data_dirs[i]; i++) { ++ session_dir = g_build_filename (system_data_dirs[i], "wayland-sessions", NULL); ++ g_ptr_array_add (dirs_search_array, session_dir); ++ } + } ++#endif + #endif + + if (gdm_available_sessions_map == NULL) { +@@ -308,22 +311,10 @@ collect_sessions (void) + g_free, (GDestroyNotify)gdm_session_file_free); + } + +- if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "x11")) { +- for (i = 0; i < xorg_search_array->len; i++) { +- collect_sessions_from_directory (g_ptr_array_index (xorg_search_array, i)); +- } ++ for (i = dirs_search_array->len - 1; i >= 0; i--) { ++ collect_sessions_from_directory (g_ptr_array_index (dirs_search_array, i)); + } + +-#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++) { +- collect_sessions_from_directory (g_ptr_array_index (wayland_search_array, i)); +- } +- } +-#endif +-#endif +- + g_hash_table_foreach_remove (gdm_available_sessions_map, + remove_duplicate_sessions, + names_seen_before); diff --git a/gdm.spec b/gdm.spec index 04574c1..c2af1c4 100644 --- a/gdm.spec +++ b/gdm.spec @@ -11,7 +11,7 @@ Name: gdm Epoch: 1 Version: 40.1 -Release: 36%{?dist} +Release: 37%{?dist} Summary: The GNOME Display Manager License: GPLv2+ @@ -68,6 +68,8 @@ Patch130001: 0001-Handle-conflicting-sessions.patch Patch140001: 0001-session-Fix-memory-leak-on-new-outside-connection.patch +Patch150001: 0001-libgdm-Don-t-collect-twice-sessions-on-usr-share.patch + # Non-upstreamable workarounds Patch66610001: 0001-data-reap-gdm-sessions-on-shutdown.patch @@ -371,6 +373,10 @@ dconf update || : %{_libdir}/pkgconfig/gdm-pam-extensions.pc %changelog +* Thu Aug 21 2025 Joan Torres Lopez - 40.1-37 +- Fix precedence order when loading sessions + Resolves: RHEL-4133 + * Thu Jul 31 2025 Joan Torres - 40.1-36 - Remove adding -nocursor option. Using a cursor-theme already allows this. Related: RHEL-81194