|
|
ffa191 |
From d99f12385d6b04023cbe17f3f6fc2a917066c6e8 Mon Sep 17 00:00:00 2001
|
|
|
ffa191 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
f83012 |
Date: Thu, 20 Dec 2018 14:51:38 -0500
|
|
|
ffa191 |
Subject: [PATCH 1/3] manager: allow multiple xdmcp logins for the same user
|
|
|
f83012 |
|
|
|
f83012 |
---
|
|
|
f83012 |
common/gdm-settings-keys.h | 1 +
|
|
|
f83012 |
daemon/gdm-manager.c | 71 ++++++++++++++++++++++++++++----------
|
|
|
ffa191 |
data/gdm.schemas.in | 5 +++
|
|
|
f83012 |
3 files changed, 59 insertions(+), 18 deletions(-)
|
|
|
f83012 |
|
|
|
f83012 |
diff --git a/common/gdm-settings-keys.h b/common/gdm-settings-keys.h
|
|
|
f83012 |
index f0059b5cf..33676a851 100644
|
|
|
f83012 |
--- a/common/gdm-settings-keys.h
|
|
|
f83012 |
+++ b/common/gdm-settings-keys.h
|
|
|
f83012 |
@@ -28,37 +28,38 @@ G_BEGIN_DECLS
|
|
|
f83012 |
#define GDM_KEY_USER "daemon/User"
|
|
|
f83012 |
#define GDM_KEY_GROUP "daemon/Group"
|
|
|
f83012 |
#define GDM_KEY_AUTO_LOGIN_ENABLE "daemon/AutomaticLoginEnable"
|
|
|
f83012 |
#define GDM_KEY_AUTO_LOGIN_USER "daemon/AutomaticLogin"
|
|
|
f83012 |
#define GDM_KEY_TIMED_LOGIN_ENABLE "daemon/TimedLoginEnable"
|
|
|
f83012 |
#define GDM_KEY_TIMED_LOGIN_USER "daemon/TimedLogin"
|
|
|
f83012 |
#define GDM_KEY_TIMED_LOGIN_DELAY "daemon/TimedLoginDelay"
|
|
|
f83012 |
#define GDM_KEY_INITIAL_SETUP_ENABLE "daemon/InitialSetupEnable"
|
|
|
f83012 |
#define GDM_KEY_WAYLAND_ENABLE "daemon/WaylandEnable"
|
|
|
f83012 |
|
|
|
f83012 |
#define GDM_KEY_DEBUG "debug/Enable"
|
|
|
f83012 |
|
|
|
f83012 |
#define GDM_KEY_INCLUDE "greeter/Include"
|
|
|
f83012 |
#define GDM_KEY_EXCLUDE "greeter/Exclude"
|
|
|
f83012 |
#define GDM_KEY_INCLUDE_ALL "greeter/IncludeAll"
|
|
|
f83012 |
|
|
|
f83012 |
#define GDM_KEY_DISALLOW_TCP "security/DisallowTCP"
|
|
|
f83012 |
#define GDM_KEY_ALLOW_REMOTE_AUTOLOGIN "security/AllowRemoteAutoLogin"
|
|
|
f83012 |
|
|
|
f83012 |
#define GDM_KEY_XDMCP_ENABLE "xdmcp/Enable"
|
|
|
f83012 |
#define GDM_KEY_SHOW_LOCAL_GREETER "xdmcp/ShowLocalGreeter"
|
|
|
f83012 |
#define GDM_KEY_MAX_PENDING "xdmcp/MaxPending"
|
|
|
f83012 |
#define GDM_KEY_MAX_SESSIONS "xdmcp/MaxSessions"
|
|
|
f83012 |
#define GDM_KEY_MAX_WAIT "xdmcp/MaxWait"
|
|
|
f83012 |
#define GDM_KEY_DISPLAYS_PER_HOST "xdmcp/DisplaysPerHost"
|
|
|
f83012 |
#define GDM_KEY_UDP_PORT "xdmcp/Port"
|
|
|
f83012 |
#define GDM_KEY_INDIRECT "xdmcp/HonorIndirect"
|
|
|
f83012 |
#define GDM_KEY_MAX_WAIT_INDIRECT "xdmcp/MaxWaitIndirect"
|
|
|
f83012 |
#define GDM_KEY_PING_INTERVAL "xdmcp/PingIntervalSeconds"
|
|
|
f83012 |
#define GDM_KEY_WILLING "xdmcp/Willing"
|
|
|
f83012 |
+#define GDM_KEY_ALLOW_MULTIPLE_SESSIONS_PER_USER "xdmcp/AllowMultipleSessionsPerUser"
|
|
|
f83012 |
|
|
|
f83012 |
#define GDM_KEY_MULTICAST "chooser/Multicast"
|
|
|
f83012 |
#define GDM_KEY_MULTICAST_ADDR "chooser/MulticastAddr"
|
|
|
f83012 |
|
|
|
f83012 |
G_END_DECLS
|
|
|
f83012 |
|
|
|
f83012 |
#endif /* _GDM_SETTINGS_KEYS_H */
|
|
|
f83012 |
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
|
|
|
ffa191 |
index 9c10adff3..b96295ab6 100644
|
|
|
f83012 |
--- a/daemon/gdm-manager.c
|
|
|
f83012 |
+++ b/daemon/gdm-manager.c
|
|
|
ffa191 |
@@ -566,93 +566,106 @@ get_display_and_details_for_bus_sender (GdmManager *self,
|
|
|
f83012 |
*out_tty = get_tty_for_session_id (session_id, &error);
|
|
|
f83012 |
|
|
|
f83012 |
if (error != NULL) {
|
|
|
f83012 |
g_debug ("GdmManager: Error while retrieving tty for session: %s",
|
|
|
f83012 |
error->message);
|
|
|
f83012 |
g_clear_error (&error);
|
|
|
f83012 |
}
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
display = gdm_display_store_find (self->priv->display_store,
|
|
|
f83012 |
lookup_by_session_id,
|
|
|
f83012 |
(gpointer) session_id);
|
|
|
f83012 |
|
|
|
ffa191 |
out:
|
|
|
f83012 |
if (out_display != NULL) {
|
|
|
f83012 |
*out_display = display;
|
|
|
f83012 |
}
|
|
|
ffa191 |
|
|
|
f83012 |
g_free (session_id);
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
static gboolean
|
|
|
f83012 |
switch_to_compatible_user_session (GdmManager *manager,
|
|
|
f83012 |
GdmSession *session,
|
|
|
f83012 |
gboolean fail_if_already_switched)
|
|
|
f83012 |
{
|
|
|
f83012 |
gboolean res;
|
|
|
f83012 |
gboolean ret;
|
|
|
f83012 |
const char *username;
|
|
|
f83012 |
const char *seat_id;
|
|
|
f83012 |
- const char *ssid_to_activate;
|
|
|
f83012 |
+ const char *ssid_to_activate = NULL;
|
|
|
f83012 |
GdmSession *existing_session;
|
|
|
f83012 |
|
|
|
f83012 |
ret = FALSE;
|
|
|
f83012 |
|
|
|
f83012 |
username = gdm_session_get_username (session);
|
|
|
f83012 |
seat_id = gdm_session_get_display_seat_id (session);
|
|
|
f83012 |
|
|
|
f83012 |
- if (!fail_if_already_switched) {
|
|
|
f83012 |
- session = NULL;
|
|
|
f83012 |
- }
|
|
|
f83012 |
+ if (!fail_if_already_switched)
|
|
|
f83012 |
+ ssid_to_activate = gdm_session_get_session_id (session);
|
|
|
f83012 |
|
|
|
f83012 |
- existing_session = find_session_for_user_on_seat (manager, username, seat_id, session);
|
|
|
f83012 |
+ if (ssid_to_activate == NULL) {
|
|
|
f83012 |
+ if (!seat_id || !sd_seat_can_multi_session (seat_id)) {
|
|
|
f83012 |
+ g_debug ("GdmManager: unable to activate existing sessions from login screen unless on seat0");
|
|
|
f83012 |
+ goto out;
|
|
|
f83012 |
+ }
|
|
|
f83012 |
|
|
|
f83012 |
- if (existing_session != NULL) {
|
|
|
f83012 |
- ssid_to_activate = gdm_session_get_session_id (existing_session);
|
|
|
f83012 |
- if (seat_id != NULL) {
|
|
|
ffa191 |
- res = gdm_activate_session_by_id (manager->priv->connection, seat_id, ssid_to_activate);
|
|
|
f83012 |
- if (! res) {
|
|
|
f83012 |
- g_debug ("GdmManager: unable to activate session: %s", ssid_to_activate);
|
|
|
f83012 |
- goto out;
|
|
|
f83012 |
- }
|
|
|
f83012 |
+ if (!fail_if_already_switched) {
|
|
|
f83012 |
+ session = NULL;
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
- res = session_unlock (manager, ssid_to_activate);
|
|
|
f83012 |
- if (!res) {
|
|
|
f83012 |
- /* this isn't fatal */
|
|
|
f83012 |
- g_debug ("GdmManager: unable to unlock session: %s", ssid_to_activate);
|
|
|
f83012 |
+ existing_session = find_session_for_user_on_seat (manager, username, seat_id, session);
|
|
|
f83012 |
+
|
|
|
f83012 |
+ if (existing_session != NULL) {
|
|
|
f83012 |
+ ssid_to_activate = gdm_session_get_session_id (existing_session);
|
|
|
f83012 |
}
|
|
|
f83012 |
- } else {
|
|
|
f83012 |
+ }
|
|
|
f83012 |
+
|
|
|
f83012 |
+ if (ssid_to_activate == NULL) {
|
|
|
f83012 |
goto out;
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
+ if (seat_id != NULL) {
|
|
|
ffa191 |
+ res = gdm_activate_session_by_id (manager->priv->connection, seat_id, ssid_to_activate);
|
|
|
f83012 |
+ if (! res) {
|
|
|
f83012 |
+ g_debug ("GdmManager: unable to activate session: %s", ssid_to_activate);
|
|
|
f83012 |
+ goto out;
|
|
|
f83012 |
+ }
|
|
|
f83012 |
+ }
|
|
|
f83012 |
+
|
|
|
f83012 |
+ res = session_unlock (manager, ssid_to_activate);
|
|
|
f83012 |
+ if (!res) {
|
|
|
f83012 |
+ /* this isn't fatal */
|
|
|
f83012 |
+ g_debug ("GdmManager: unable to unlock session: %s", ssid_to_activate);
|
|
|
f83012 |
+ }
|
|
|
f83012 |
+
|
|
|
f83012 |
ret = TRUE;
|
|
|
f83012 |
|
|
|
f83012 |
out:
|
|
|
f83012 |
return ret;
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
static GdmDisplay *
|
|
|
f83012 |
get_display_for_user_session (GdmSession *session)
|
|
|
f83012 |
{
|
|
|
f83012 |
return g_object_get_data (G_OBJECT (session), "gdm-display");
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
static GdmSession *
|
|
|
f83012 |
get_user_session_for_display (GdmDisplay *display)
|
|
|
f83012 |
{
|
|
|
f83012 |
if (display == NULL) {
|
|
|
f83012 |
return NULL;
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
return g_object_get_data (G_OBJECT (display), "gdm-user-session");
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
static gboolean
|
|
|
f83012 |
add_session_record (GdmManager *manager,
|
|
|
f83012 |
GdmSession *session,
|
|
|
f83012 |
GPid pid,
|
|
|
f83012 |
SessionRecord record)
|
|
|
f83012 |
{
|
|
|
f83012 |
const char *username;
|
|
|
f83012 |
char *display_name, *hostname, *display_device;
|
|
|
ffa191 |
@@ -1089,92 +1102,114 @@ open_temporary_reauthentication_channel (GdmManager *self,
|
|
|
f83012 |
g_signal_connect (session,
|
|
|
f83012 |
"client-disconnected",
|
|
|
f83012 |
G_CALLBACK (on_reauthentication_client_disconnected),
|
|
|
f83012 |
self);
|
|
|
f83012 |
g_signal_connect (session,
|
|
|
f83012 |
"client-rejected",
|
|
|
f83012 |
G_CALLBACK (on_reauthentication_client_rejected),
|
|
|
f83012 |
self);
|
|
|
f83012 |
g_signal_connect (session,
|
|
|
f83012 |
"cancelled",
|
|
|
f83012 |
G_CALLBACK (on_reauthentication_cancelled),
|
|
|
f83012 |
self);
|
|
|
f83012 |
g_signal_connect (session,
|
|
|
f83012 |
"conversation-started",
|
|
|
f83012 |
G_CALLBACK (on_reauthentication_conversation_started),
|
|
|
f83012 |
self);
|
|
|
f83012 |
g_signal_connect (session,
|
|
|
f83012 |
"conversation-stopped",
|
|
|
f83012 |
G_CALLBACK (on_reauthentication_conversation_stopped),
|
|
|
f83012 |
self);
|
|
|
f83012 |
g_signal_connect (session,
|
|
|
f83012 |
"verification-complete",
|
|
|
f83012 |
G_CALLBACK (on_reauthentication_verification_complete),
|
|
|
f83012 |
self);
|
|
|
f83012 |
|
|
|
f83012 |
address = gdm_session_get_server_address (session);
|
|
|
f83012 |
|
|
|
f83012 |
return g_strdup (address);
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
+static gboolean
|
|
|
f83012 |
+remote_users_can_log_in_more_than_once (GdmManager *manager)
|
|
|
f83012 |
+{
|
|
|
f83012 |
+ gboolean enabled;
|
|
|
f83012 |
+
|
|
|
f83012 |
+ enabled = FALSE;
|
|
|
f83012 |
+
|
|
|
f83012 |
+ gdm_settings_direct_get_boolean (GDM_KEY_ALLOW_MULTIPLE_SESSIONS_PER_USER, &enabled);
|
|
|
f83012 |
+
|
|
|
f83012 |
+ g_debug ("GdmDisplay: Remote users allowed to log in more than once: %s", enabled? "yes" : "no");
|
|
|
f83012 |
+
|
|
|
f83012 |
+ return enabled;
|
|
|
f83012 |
+}
|
|
|
f83012 |
+
|
|
|
f83012 |
static gboolean
|
|
|
f83012 |
gdm_manager_handle_open_reauthentication_channel (GdmDBusManager *manager,
|
|
|
f83012 |
GDBusMethodInvocation *invocation,
|
|
|
f83012 |
const char *username)
|
|
|
f83012 |
{
|
|
|
f83012 |
GdmManager *self = GDM_MANAGER (manager);
|
|
|
f83012 |
const char *sender;
|
|
|
f83012 |
GdmDisplay *display = NULL;
|
|
|
f83012 |
GdmSession *session;
|
|
|
f83012 |
GDBusConnection *connection;
|
|
|
f83012 |
char *seat_id = NULL;
|
|
|
f83012 |
char *session_id = NULL;
|
|
|
f83012 |
GPid pid = 0;
|
|
|
f83012 |
uid_t uid = (uid_t) -1;
|
|
|
f83012 |
gboolean is_login_screen = FALSE;
|
|
|
f83012 |
gboolean is_remote = FALSE;
|
|
|
f83012 |
|
|
|
f83012 |
g_debug ("GdmManager: trying to open reauthentication channel for user %s", username);
|
|
|
f83012 |
|
|
|
f83012 |
sender = g_dbus_method_invocation_get_sender (invocation);
|
|
|
f83012 |
connection = g_dbus_method_invocation_get_connection (invocation);
|
|
|
f83012 |
get_display_and_details_for_bus_sender (self, connection, sender, &display, &seat_id, &session_id, NULL, &pid, &uid, &is_login_screen, &is_remote);
|
|
|
f83012 |
|
|
|
f83012 |
if (session_id == NULL || pid == 0 || uid == (uid_t) -1) {
|
|
|
f83012 |
g_dbus_method_invocation_return_error_literal (invocation,
|
|
|
f83012 |
G_DBUS_ERROR,
|
|
|
f83012 |
G_DBUS_ERROR_ACCESS_DENIED,
|
|
|
f83012 |
_("No session available"));
|
|
|
f83012 |
|
|
|
f83012 |
return TRUE;
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
+ if (is_login_screen && is_remote && remote_users_can_log_in_more_than_once (self)) {
|
|
|
f83012 |
+ g_dbus_method_invocation_return_error_literal (invocation,
|
|
|
f83012 |
+ G_DBUS_ERROR,
|
|
|
f83012 |
+ G_DBUS_ERROR_ACCESS_DENIED,
|
|
|
f83012 |
+ "Login screen creates new sessions for remote connections");
|
|
|
ffa191 |
+ return TRUE;
|
|
|
f83012 |
+ }
|
|
|
f83012 |
+
|
|
|
f83012 |
if (is_login_screen) {
|
|
|
f83012 |
g_debug ("GdmManager: looking for login screen session for user %s on seat %s", username, seat_id);
|
|
|
f83012 |
session = find_session_for_user_on_seat (self,
|
|
|
f83012 |
username,
|
|
|
f83012 |
seat_id,
|
|
|
f83012 |
NULL);
|
|
|
f83012 |
} else {
|
|
|
f83012 |
g_debug ("GdmManager: looking for user session on display");
|
|
|
f83012 |
session = get_user_session_for_display (display);
|
|
|
f83012 |
}
|
|
|
f83012 |
|
|
|
f83012 |
if (session != NULL && gdm_session_is_running (session)) {
|
|
|
f83012 |
gdm_session_start_reauthentication (session, pid, uid);
|
|
|
f83012 |
g_hash_table_insert (self->priv->open_reauthentication_requests,
|
|
|
f83012 |
GINT_TO_POINTER (pid),
|
|
|
f83012 |
invocation);
|
|
|
f83012 |
} else if (is_login_screen) {
|
|
|
f83012 |
g_dbus_method_invocation_return_error_literal (invocation,
|
|
|
f83012 |
G_DBUS_ERROR,
|
|
|
f83012 |
G_DBUS_ERROR_ACCESS_DENIED,
|
|
|
f83012 |
"Login screen only allowed to open reauthentication channels for running sessions");
|
|
|
f83012 |
return TRUE;
|
|
|
f83012 |
} else {
|
|
|
f83012 |
char *address;
|
|
|
f83012 |
address = open_temporary_reauthentication_channel (self,
|
|
|
f83012 |
seat_id,
|
|
|
f83012 |
session_id,
|
|
|
f83012 |
pid,
|
|
|
f83012 |
uid,
|
|
|
f83012 |
is_remote);
|
|
|
ffa191 |
diff --git a/data/gdm.schemas.in b/data/gdm.schemas.in
|
|
|
ffa191 |
index 255bff023..86059c02e 100644
|
|
|
ffa191 |
--- a/data/gdm.schemas.in
|
|
|
ffa191 |
+++ b/data/gdm.schemas.in
|
|
|
ffa191 |
@@ -102,33 +102,38 @@
|
|
|
f83012 |
<schema>
|
|
|
f83012 |
<key>xdmcp/DisplaysPerHost</key>
|
|
|
f83012 |
<signature>i</signature>
|
|
|
f83012 |
<default>1</default>
|
|
|
f83012 |
</schema>
|
|
|
f83012 |
<schema>
|
|
|
f83012 |
<key>xdmcp/Port</key>
|
|
|
f83012 |
<signature>i</signature>
|
|
|
f83012 |
<default>177</default>
|
|
|
f83012 |
</schema>
|
|
|
f83012 |
<schema>
|
|
|
f83012 |
<key>xdmcp/HonorIndirect</key>
|
|
|
f83012 |
<signature>b</signature>
|
|
|
f83012 |
<default>true</default>
|
|
|
f83012 |
</schema>
|
|
|
f83012 |
<schema>
|
|
|
f83012 |
<key>xdmcp/MaxWaitIndirect</key>
|
|
|
f83012 |
<signature>i</signature>
|
|
|
f83012 |
<default>30</default>
|
|
|
f83012 |
</schema>
|
|
|
f83012 |
<schema>
|
|
|
f83012 |
<key>xdmcp/PingIntervalSeconds</key>
|
|
|
f83012 |
<signature>i</signature>
|
|
|
f83012 |
<default>0</default>
|
|
|
f83012 |
</schema>
|
|
|
f83012 |
<schema>
|
|
|
f83012 |
<key>xdmcp/Willing</key>
|
|
|
f83012 |
<signature>s</signature>
|
|
|
f83012 |
<default>@gdmconfdir@/Xwilling</default>
|
|
|
f83012 |
</schema>
|
|
|
f83012 |
+ <schema>
|
|
|
f83012 |
+ <key>xdmcp/AllowMultipleSessionsPerUser</key>
|
|
|
f83012 |
+ <signature>b</signature>
|
|
|
f83012 |
+ <default>false</default>
|
|
|
f83012 |
+ </schema>
|
|
|
f83012 |
</schemalist>
|
|
|
f83012 |
</gdmschemafile>
|
|
|
ffa191 |
|
|
|
f83012 |
--
|
|
|
ffa191 |
2.31.1
|
|
|
f83012 |
|