Blob Blame History Raw
From ef789e1e30c8682ac04e9ed29d40352992bf8aa9 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Thu, 20 Dec 2018 14:51:38 -0500
Subject: [PATCH] manager: allow multiple xdmcp logins for the same user

---
 common/gdm-settings-keys.h |  1 +
 daemon/gdm-manager.c       | 27 +++++++++++++++++++++++++++
 data/gdm.schemas           |  5 +++++
 data/gdm.schemas.in.in     |  5 +++++
 4 files changed, 38 insertions(+)

diff --git a/common/gdm-settings-keys.h b/common/gdm-settings-keys.h
index f0059b5..33676a8 100644
--- a/common/gdm-settings-keys.h
+++ b/common/gdm-settings-keys.h
@@ -55,6 +55,7 @@ G_BEGIN_DECLS
 #define GDM_KEY_MAX_WAIT_INDIRECT "xdmcp/MaxWaitIndirect"
 #define GDM_KEY_PING_INTERVAL "xdmcp/PingIntervalSeconds"
 #define GDM_KEY_WILLING "xdmcp/Willing"
+#define GDM_KEY_ALLOW_MULTIPLE_SESSIONS_PER_USER "xdmcp/AllowMultipleSessionsPerUser"
 
 #define GDM_KEY_MULTICAST "chooser/Multicast"
 #define GDM_KEY_MULTICAST_ADDR "chooser/MulticastAddr"
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index 031c61c..225de1d 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -612,6 +612,11 @@ switch_to_compatible_user_session (GdmManager *manager,
         username = gdm_session_get_username (session);
         seat_id = gdm_session_get_display_seat_id (session);
 
+        if (!seat_id || !sd_seat_can_multi_session (seat_id)) {
+                g_debug ("GdmManager: unable to activate existing sessions unless on seat0");
+                goto out;
+        }
+
         if (!fail_if_already_switched) {
                 session = NULL;
         }
@@ -1091,6 +1096,20 @@ open_temporary_reauthentication_channel (GdmManager            *self,
 }
 
 static gboolean
+remote_users_can_log_in_more_than_once (GdmManager *manager)
+{
+        gboolean enabled;
+
+        enabled = FALSE;
+
+        gdm_settings_direct_get_boolean (GDM_KEY_ALLOW_MULTIPLE_SESSIONS_PER_USER, &enabled);
+
+	g_debug ("GdmDisplay: Remote users allowed to log in more than once: %s", enabled? "yes" : "no");
+
+        return enabled;
+}
+
+static gboolean
 gdm_manager_handle_open_reauthentication_channel (GdmDBusManager        *manager,
                                                   GDBusMethodInvocation *invocation,
                                                   const char            *username)
@@ -1122,6 +1141,14 @@ gdm_manager_handle_open_reauthentication_channel (GdmDBusManager        *manager
                 return TRUE;
         }
 
+        if (is_login_screen && is_remote && remote_users_can_log_in_more_than_once (self)) {
+                g_dbus_method_invocation_return_error_literal (invocation,
+                                                               G_DBUS_ERROR,
+                                                               G_DBUS_ERROR_ACCESS_DENIED,
+                                                               "Login screen creates new sessions for remote connections");
+		return TRUE;
+        }
+
         if (is_login_screen) {
                 session = find_session_for_user_on_seat (self,
                                                          username,
diff --git a/data/gdm.schemas.in.in b/data/gdm.schemas.in.in
index 8ad2031..003f92c 100644
--- a/data/gdm.schemas.in.in
+++ b/data/gdm.schemas.in.in
@@ -129,5 +129,10 @@
       <signature>s</signature>
       <default>@gdmconfdir@/Xwilling</default>
     </schema>
+    <schema>
+      <key>xdmcp/AllowMultipleSessionsPerUser</key>
+      <signature>b</signature>
+      <default>false</default>
+    </schema>
   </schemalist>
 </gdmschemafile>
-- 
1.8.3.1