From 2fba24e67597bf59ae00db2867df7a348c81b094 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Sat, 8 Dec 2007 23:04:03 -0500 Subject: use VT_GETSTATE and tty0 to identify a console_ioctl on linux ConsoleKit tries to find a valid fd it can issue VT_WAITACTIVE against by iterating across a file list and issuing ioctl(fd, KDGKBTYPE, &arg), then checking the return value. Not all console devices support this ioctl, so in some cases it never finds a valid file descriptor to use, and from then on never marks any session active. We probably ought to be using something like VT_GETSTATE instead of a keyboard ioctl, but that's not sufficient to fix it. One fix that seems to work, though I'm not completely sure if it's the best answer, is to add /dev/tty0 to the list of files to try before /dev/console. --- src/ck-sysdeps-unix.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c index be093b7..e4ab16b 100644 --- a/src/ck-sysdeps-unix.c +++ b/src/ck-sysdeps-unix.c @@ -127,15 +127,15 @@ gboolean ck_fd_is_a_console (int fd) { #ifdef __linux__ - char arg = 0; + struct vt_stat vts; #elif defined(__FreeBSD__) int vers; #endif int kb_ok; + errno = 0; #ifdef __linux__ - kb_ok = (ioctl (fd, KDGKBTYPE, &arg) == 0 - && ((arg == KB_101) || (arg == KB_84))); + kb_ok = (ioctl (fd, VT_GETSTATE, &vts) == 0); #elif defined(__FreeBSD__) kb_ok = (ioctl (fd, CONS_GETVERS, &vers) == 0); #else @@ -196,6 +196,11 @@ ck_get_a_console_fd (void) goto done; } + fd = open_a_console ("/dev/tty0"); + if (fd >= 0) { + goto done; + } + #ifdef _PATH_CONSOLE fd = open_a_console (_PATH_CONSOLE); if (fd >= 0) { @@ -259,7 +264,7 @@ ck_wait_for_active_console_num (int console_fd, #ifdef VT_WAITACTIVE g_debug ("VT_WAITACTIVE for vt %d", num); res = ioctl (console_fd, VT_WAITACTIVE, num); - g_debug ("VT_WAITACTIVE for vt %d returned %d", num, ret); + g_debug ("VT_WAITACTIVE for vt %d returned %d", num, res); #else res = ERROR; errno = ENOTSUP; -- cgit