[Bug 211246] [syscons] console and ttyv0 competing for keystrokes

Bruce Evans brde at optusnet.com.au
Wed Jul 20 21:26:24 UTC 2016


On Thu, 21 Jul 2016, Bruce Evans wrote:

> On Wed, 20 Jul 2016 bugzilla-noreply at freebsd.org wrote:
>
>> ...
>> As an aside, things written to /dev/console invariably appear on the
>> ttyv0-screen on my system, but are never passed on to xconsole.
>
> This seems to be the expected behaviour.  You asked for foot-shooting and
> got it.  This is not a security hole since it requires root privilege.
>
> xconsole without -f should use the correct file.  If not, try /dev/tty or
> $(tty).

It uses the correct file, but still doesn't work...

> xconsole under FreeBSD-11 with a FreeBSD-~5.2 userland and a FreeBSD-4
> ports version of X fails due to permissions problems here, but I saw
> exactly the same behaviour in the simpler setup of logins on ttyv0
> and ttyv1 and a program on ttyv1 grabbing the console using
>
>    int c = 1; ioctl(0, TIOCCONS, &c);".

I forgot to redirect fd 0 from ttyv1 to /dev/console, so this was testing
something different.  Apparently I had /dev/console open somewhere to
get the same symptoms.  But it is not necessary to use TIOCCONS to see
problems.  Simply run "cat /dev/console" on 1 terminal.  This competes
for input with a shell on the device behing the console.  On an SMP
system with 8 CPUs, the sharing of the input was very fair with 3
processes reading it (1 normal, 1 TIOCCONS and 1 /dev/console).

>
> xconsole with no args works correctly under FreeBSD-~5.2.

The permissions problems were just root not being able to read .Xauthority
owned by non-root over nfs (nfs maps root somewhere unusable by default).

The ~5.2 system is UP, so working correctly might have been UP magic
instead of syscons magic.  With 1 cat of /sys/console, the sharing was
very unfair -- the shell on ttyv0 got it all.

So using ttyv0 and console with getty and xconsole is much the same
foot shooting as using them with 2 getty's.  So you must not use ttyv0
if you want to use xconsole!

Not using ttyv0 means not running any program that opens it, starting
with getty (init uses only /dev/console).  There are further
complications for low-level consoles, but using TIOCCONS reduces
complications together with features and bugs in the low-level consoles
by mostly not using them.

Bruce


More information about the freebsd-i386 mailing list