Granting access to the terminal in Plash

Granting a process access to a terminal (tty) has issues similar to those associated with the X Window System (see X11Security), although terminals under Unix are a lot older.

Background

There are two components associated with a terminal:

Kernel tty device

The kernel tty device is a layer between applications and the actual terminal. It provides some translation and buffering of the byte stream between the two. These translations can be switched off. In addition to being a byte stream interface, its state can be read and modified using ioctl() calls.

The tty device can be switched between various modes (raw, rare, cooked). It can provide a simple line editing facility. It implements echoing of characters to the screen. It can add carriage returns after newline characters.

It is connected to the job control system, so characters entered at the terminal cause signals to be sent to processes. e.g. Ctrl-C interrupts processes, Ctrl-Z suspends processes. Processes can be associated with a controlling tty device.

Terminal

The terminal is implemented in user space, and there are many to choose from: xterm, gnome-terminal, rxvt, etc. Historically, it was a physical device, connected via a serial cable. Either way, its interface is a bidirectional stream of bytes. There are no ioctl()s involved.

The terminal almost always interprets ANSI escape codes (which start with ESC, char 27); see http://vt100.net.

Questions

How does Plan 9 handle terminals? It probably uses byte streams without providing ioctl().

TerminalAccess (last edited 2007-03-05 19:04:38 by MarkSeaborn)