Update debug_json_requests with extra optimization

Related: https://issues.redhat.com/browse/RHEL-14524
This commit is contained in:
Joan Torres Lopez 2026-02-17 14:22:24 +01:00
parent 8afdfe2799
commit 480bfd6124

View File

@ -1,7 +1,7 @@
From 68976aadfb6c311196012439d97094c8244cdc49 Mon Sep 17 00:00:00 2001
From: Joan Torres Lopez <joantolo@redhat.com>
Date: Thu, 18 Sep 2025 16:42:37 +0200
Subject: [PATCH 1/2] session: Log JSON request when GDM_DEBUG_JSON_REQUESTS is
Subject: [PATCH 1/3] session: Log JSON request when GDM_DEBUG_JSON_REQUESTS is
set
This is only useful for debugging and testing.
@ -32,7 +32,7 @@ index 388b0d037..9affbc438 100644
From bb975dec28884e371a5a54ae524315b8b7a7ea13 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 22 Jan 2024 09:40:39 -0500
Subject: [PATCH 2/2] data: Add support for unified authentication
Subject: [PATCH 2/3] data: Add support for unified authentication
At the moment, every authentication mechanism gets its own
separate PAM conversation.
@ -130,3 +130,36 @@ index 000000000..6648c3cec
--
2.51.1
From c18c8201c4d2af24b7aaf2168a3428fea542c733 Mon Sep 17 00:00:00 2001
From: Joan Torres Lopez <joantolo@redhat.com>
Date: Thu, 12 Feb 2026 18:12:01 +0100
Subject: [PATCH 3/3] session: Use g_once for GDM_DEBUG_JSON_REQUESTS environment
variable check
Part-of: <https://gitlab.gnome.org/GNOME/gdm/-/merge_requests/353>
---
daemon/gdm-session.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index 5f103eddb..5c04ad1be 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -832,7 +832,13 @@ gdm_session_handle_custom_json_request (GdmDBusWorkerManager *worker_manager_in
if (conversation != NULL) {
set_pending_query (conversation, invocation);
- if (g_getenv ("GDM_DEBUG_JSON_REQUESTS") != NULL)
+ static gsize debug_json_requests;
+
+ if (g_once_init_enter (&debug_json_requests))
+ g_once_init_leave (&debug_json_requests,
+ g_getenv ("GDM_DEBUG_JSON_REQUESTS") != NULL ? 1 : 2);
+
+ if (debug_json_requests == 1)
g_message ("GdmSession: emitting custom JSON request '%s' v%u: %s",
protocol, version, request);
gdm_dbus_user_verifier_custom_json_emit_request (custom_json_interface,
--
2.52.0