Skip to content

Commit

Permalink
Freebsd: Fix session activation
Browse files Browse the repository at this point in the history
On Freebsd (10.3), quite often X11 sessions do not become active.
If they are active, switching the virtual console and then later
return to X causes the X session to be inactive. I believe this
has something to do with how the FreeBSD sc/vt drivers initialize
the devices (and when). I have a patch to fix the issue attached.
This problem is present all the way back to version 0.45. I noticed
that some time ago, someone tried to fix this issue by using
/dev/consolectl, but this device is never used because isatty() is
false on /dev/consolectl. I have an attached patch that gets
ConsoleKit to use /dev/consolectl and now session activation and
VT switching work.
Patch and bug report by Victor Bergman.
#71

Signed-off-by: Eric Koegel <eric.koegel@gmail.com>
  • Loading branch information
EricKoegel committed Jun 30, 2016
1 parent 588ac16 commit 9dab562
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/ck-sysdeps-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ ck_get_socket_peer_credentials (int socket_fd,
*/

gboolean
ck_fd_is_a_console (int fd)
ck_fd_is_a_console (int fd,
const gchar *fnam)
{
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
struct vt_stat vts;
Expand All @@ -185,7 +186,11 @@ ck_fd_is_a_console (int fd)
kb_ok = 1;
#endif

#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined (__DragonFly__)
return ((isatty (fd) || g_strcmp0 (fnam, "/dev/consolectl") == 0) && kb_ok);
#else
return (isatty (fd) && kb_ok);
#endif
}

static int
Expand Down Expand Up @@ -219,7 +224,7 @@ open_a_console (char *fnam)
if (fd < 0)
return -1;

if (! ck_fd_is_a_console (fd)) {
if (! ck_fd_is_a_console (fd, fnam)) {
close (fd);
fd = -1;
}
Expand Down Expand Up @@ -300,7 +305,7 @@ ck_get_a_console_fd (void)
}

for (fd = 0; fd < 3; fd++) {
if (ck_fd_is_a_console (fd)) {
if (ck_fd_is_a_console (fd, "")) {
goto done;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/ck-sysdeps.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ gboolean ck_get_socket_peer_credentials (int socket_fd,

int ck_get_a_console_fd (void);

gboolean ck_fd_is_a_console (int fd);
gboolean ck_fd_is_a_console (int fd,
const gchar *fnam);

gboolean ck_is_root_user (void);

Expand Down
2 changes: 1 addition & 1 deletion src/test-tty-idle-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ is_console (const char *device)
goto out;
}

ret = ck_fd_is_a_console (fd);
ret = ck_fd_is_a_console (fd, device);

close (fd);

Expand Down

0 comments on commit 9dab562

Please sign in to comment.