]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
If we aren't in a multi-seat environment, pass logind XDG_VTNR=0 instead of 1
authorMichael Terry <michael.terry@canonical.com>
Tue, 24 Sep 2013 17:26:42 +0000 (13:26 -0400)
committerMichael Terry <michael.terry@canonical.com>
Tue, 24 Sep 2013 17:26:42 +0000 (13:26 -0400)
src/seat-surfaceflinger.c
src/vt.c
src/vt.h

index c0dc0b56f871069916df6b050a5cf524e2583e48..03117305bedef2e17ad44311cc66424e5ebd3f07 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "seat-surfaceflinger.h"
 #include "surfaceflinger-server.h"
+#include "vt.h"
 
 G_DEFINE_TYPE (SeatSurfaceflinger, seat_surfaceflinger, SEAT_TYPE);
 
@@ -48,7 +49,7 @@ seat_surfaceflinger_create_greeter_session (Seat *seat)
     session_set_env (SESSION (greeter_session), "XDG_SEAT", xdg_seat);
 
     /* Fake the VT */
-    session_set_env (SESSION (greeter_session), "XDG_VTNR", "1");
+    session_set_env (SESSION (greeter_session), "XDG_VTNR", vt_can_multi_seat() ? "1" : "0");
 
     return greeter_session;
 }
index c2b1c0d662f005ae5b6031e8c2909ed74c887fd4..fa0a0448c3f88cd8c6e56086188d0ca63c88d849 100644 (file)
--- a/src/vt.c
+++ b/src/vt.c
@@ -36,6 +36,20 @@ open_console (void)
     return fd;
 }
 
+gboolean
+vt_can_multi_seat (void)
+{
+    /* Quick check to see if we can multi seat.  This is intentionally the
+       same check logind does, just without actually reading from the files.
+       Existence will prove whether we have CONFIG_VT built into the kernel.
+       (Reading /dev/console like the rest of the code in this file isn't
+       sufficient -- it may still exist if tty0 doesn't and it may not work
+       in situations where tty0 does exist and thus logind will think we are
+       multi seat.) */
+    return access ("/dev/tty0", F_OK) == 0 &&
+           access ("/sys/class/tty/tty0/active", F_OK) == 0;
+}
+
 gint
 vt_get_active (void)
 {
index 4a9c59dd45a31e39b93de8cd9ecab00954ac2fa3..f57ebb4d8b7ebfad7c6218faf672906533e0df70 100644 (file)
--- a/src/vt.h
+++ b/src/vt.h
@@ -14,6 +14,8 @@
 
 #include <glib-object.h>
 
+gboolean vt_can_multi_seat (void);
+
 gint vt_get_active (void);
 
 gint vt_get_unused (void);