From: Michael Terry Date: Tue, 24 Sep 2013 17:26:42 +0000 (-0400) Subject: If we aren't in a multi-seat environment, pass logind XDG_VTNR=0 instead of 1 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/sojka/lightdm.git/commitdiff_plain/db7dfda642bd710a77b6e2bc832a8b5fde00abf7 If we aren't in a multi-seat environment, pass logind XDG_VTNR=0 instead of 1 --- diff --git a/src/seat-surfaceflinger.c b/src/seat-surfaceflinger.c index c0dc0b56..03117305 100644 --- a/src/seat-surfaceflinger.c +++ b/src/seat-surfaceflinger.c @@ -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; } diff --git a/src/vt.c b/src/vt.c index c2b1c0d6..fa0a0448 100644 --- 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) { diff --git a/src/vt.h b/src/vt.h index 4a9c59dd..f57ebb4d 100644 --- a/src/vt.h +++ b/src/vt.h @@ -14,6 +14,8 @@ #include +gboolean vt_can_multi_seat (void); + gint vt_get_active (void); gint vt_get_unused (void);