Blame SOURCES/fix-headless.patch

1e501a
diff -up gdm-3.14.2/daemon/gdm-session-worker.c.fix-headless gdm-3.14.2/daemon/gdm-session-worker.c
1e501a
--- gdm-3.14.2/daemon/gdm-session-worker.c.fix-headless        2015-06-23 10:42:17.802937143 -0400
1e501a
+++ gdm-3.14.2/daemon/gdm-session-worker.c        2015-06-23 10:52:26.055317210 -0400
1e501a
@@ -2059,6 +2059,43 @@ fail:
1e501a
 }
1e501a
 #endif
1e501a
 
1e501a
+#ifdef __linux__
1e501a
+static gboolean
1e501a
+set_xdg_vtnr_to_current_vt (GdmSessionWorker *worker)
1e501a
+{
1e501a
+        int fd;
1e501a
+        char vt_string[256];
1e501a
+        struct vt_stat vt_state = { 0 };
1e501a
+
1e501a
+        fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);
1e501a
+
1e501a
+        if (fd < 0) {
1e501a
+                g_debug ("GdmSessionWorker: couldn't open VT master: %m");
1e501a
+                return FALSE;
1e501a
+        }
1e501a
+
1e501a
+        if (ioctl (fd, VT_GETSTATE, &vt_state) < 0) {
1e501a
+                g_debug ("GdmSessionWorker: couldn't get current VT: %m");
1e501a
+                goto fail;
1e501a
+        }
1e501a
+
1e501a
+        close (fd);
1e501a
+        fd = -1;
1e501a
+
1e501a
+        g_snprintf (vt_string, sizeof (vt_string), "%d", vt_state.v_active);
1e501a
+
1e501a
+        gdm_session_worker_set_environment_variable (worker,
1e501a
+                                                     "XDG_VTNR",
1e501a
+                                                     vt_string);
1e501a
+
1e501a
+        return TRUE;
1e501a
+
1e501a
+fail:
1e501a
+        close (fd);
1e501a
+        return FALSE;
1e501a
+}
1e501a
+#endif
1e501a
+
1e501a
 static gboolean
1e501a
 set_up_for_current_vt (GdmSessionWorker  *worker,
1e501a
                        GError           **error)
1e501a
@@ -2124,6 +2161,16 @@ set_up_for_current_vt (GdmSessionWorker
1e501a
                 g_free (pam_xauth);
1e501a
          }
1e501a
 #endif
1e501a
+
1e501a
+#ifdef __linux__
1e501a
+        if (g_strcmp0 (worker->priv->display_seat_id, "seat0") == 0) {
1e501a
+                g_debug ("GdmSessionWorker: setting XDG_VTNR to current vt");
1e501a
+                set_xdg_vtnr_to_current_vt (worker);
1e501a
+        } else {
1e501a
+                g_debug ("GdmSessionWorker: not setting XDG_VTNR since not seat0");
1e501a
+        }
1e501a
+#endif
1e501a
+
1e501a
         return TRUE;
1e501a
 out:
1e501a
         return FALSE;