summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2012-03-19 15:11:26 -0400
committerRay Strode <rstrode@redhat.com>2012-03-19 15:53:07 -0400
commitfb6a3cf203c7fda3a9a33d3e3b4e7a7b868cb43e (patch)
tree4f7b5019dc8a735b59d23d64f731b8984b3b6ea1
parentad7b1851b8d5e1cc5ac9408f931e0b83c9c557c3 (diff)
downloadgdm-fb6a3cf203c7fda3a9a33d3e3b4e7a7b868cb43e.tar.gz
user-switching: fix session migration
It wasn't properly jumping to the correct vt. https://bugzilla.gnome.org/show_bug.cgi?id=655380
-rw-r--r--daemon/gdm-slave.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index a1fded19..f1f4c47f 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -1313,8 +1313,10 @@ gdm_slave_get_primary_session_id_for_user_from_systemd (GdmSlave *slave,
char **sessions;
uid_t uid;
char *primary_ssid;
+ gboolean got_primary_ssid;
primary_ssid = NULL;
+ got_primary_ssid = FALSE;
res = sd_seat_can_multi_session (slave->priv->display_seat_id);
if (res < 0) {
@@ -1342,16 +1344,23 @@ gdm_slave_get_primary_session_id_for_user_from_systemd (GdmSlave *slave,
}
for (i = 0; sessions[i] != NULL; i++) {
+ gboolean is_active;
+ uid_t other;
- if (primary_ssid == NULL) {
- uid_t other;
+ /* Always give preference to non-active sessions,
+ * so we migrate when we can and don't when we can't
+ */
+ is_active = sd_session_is_active (sessions[i]) > 0;
+
+ res = sd_session_get_uid (sessions[i], &other);
+ if (res == 0 && other == uid && !got_primary_ssid) {
+ g_free (primary_ssid);
+ primary_ssid = g_strdup (sessions[i]);
- res = sd_session_get_uid (sessions[i], &other);
- if (res == 0 && other == uid) {
- primary_ssid = g_strdup (sessions[i]);
+ if (!is_active) {
+ got_primary_ssid = TRUE;
}
}
-
free (sessions[i]);
}
@@ -1496,6 +1505,15 @@ activate_session_id_for_systemd (GdmSlave *slave,
ret = FALSE;
reply = NULL;
+ /* Can't activate what's already active. We want this
+ * to fail, because we don't want migration to succeed
+ * if the only active session is the one just created
+ * at the login screen.
+ */
+ if (sd_session_is_active (session_id) > 0) {
+ return FALSE;
+ }
+
dbus_error_init (&local_error);
message = dbus_message_new_method_call ("org.freedesktop.login1",