diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 2a0cfc361..361781e0e 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -85,6 +85,11 @@ #include #include "dpmsproc.h" #endif + +#ifdef __linux__ +#include +#include +#endif #include void (*xf86OSPMClose) (void) = NULL; @@ -201,6 +206,17 @@ xf86PrivsElevated(void) return PrivsElevated(); } +Bool +xf86HasTTYs(void) +{ +#ifdef __linux__ + struct stat tty0devAttributes; + return (stat("/dev/tty0", &tty0devAttributes) == 0 && major(tty0devAttributes.st_rdev) == TTY_MAJOR); +#else + return TRUE; +#endif +} + static void xf86AutoConfigOutputDevices(void) { @@ -425,7 +441,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) want_hw_access = TRUE; /* Non-seat0 X servers should not open console */ - if (!(flags & HW_SKIP_CONSOLE) && !ServerIsNotSeat0()) + if (!(flags & HW_SKIP_CONSOLE) && !ServerIsNotSeat0() && xf86HasTTYs()) xorgHWOpenConsole = TRUE; } diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h index dde458327..d5185d8df 100644 --- a/hw/xfree86/common/xf86Priv.h +++ b/hw/xfree86/common/xf86Priv.h @@ -158,6 +158,8 @@ extern _X_EXPORT Bool xf86CallDriverProbe(struct _DriverRec *drv, Bool detect_only); extern _X_EXPORT Bool xf86PrivsElevated(void); +extern _X_EXPORT Bool +xf86HasTTYs(void); #endif /* _NO_XF86_PROTOTYPES */ diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index 93428ba73..9f916aa7b 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -38,6 +38,7 @@ #include "xf86.h" #include "xf86platformBus.h" #include "xf86Xinput.h" +#include "xf86Priv.h" #include "globals.h" #include "systemd-logind.h" @@ -583,7 +584,7 @@ static struct dbus_core_hook core_hook = { int systemd_logind_init(void) { - if (!ServerIsNotSeat0() && linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { + if (!ServerIsNotSeat0() && xf86HasTTYs() && linux_parse_vt_settings(TRUE) && !linux_get_keeptty()) { LogMessage(X_INFO, "systemd-logind: logind integration requires -keeptty and " "-keeptty was not provided, disabling logind integration\n");