https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285394

--- Comment #12 from Andriy Gapon <a...@freebsd.org> ---
(In reply to Gleb Popov from comment #11)
That's a very interesting finding.
Now things are less mysterious.

Looking at vtterm_ioctl (I assume that we all use vt driver, not sc),
CONS_GETVERS (used by ck_fd_is_a_console) should succeed for any terminal.
So, I wonder if there could be some sort of a race.
E.g., if the controlling terminal is revoked before CONS_GETVERS (or even
before opening /dev/tty[*]) then the ioctl fails and the control flow proceeds
to using /dev/console and everything is okay.
But if /dev/tty is still valid when CONS_GETVERS is issued, then ConsolKit
proceeds to using it, but then it gets revoked and things go bad.

But I am conjecturing now.
Need to do more experiments.

To answer your question, I am sure that /dev/console would work the same or
even better than /dev/ttyv0 that my patch currently forces.
But I am going to test it for 100% confidence.

[*] /dev/tty is implemented as a special "ctty" device, see sys/kern/tty_tty.c.
If a process opening /dev/tty has a controlling terminal, then the opened
device is actually a clone of that terminal device.
If the process does not have a controlling terminal, then the cloned device is
a clone of ctty special device and that device cannot be really opened.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to