gogetty

A very slim getty for recent linuxen and possibly other modern Unices. I wrote it because rungetty broke when the linux kernel moved up to session id handling (at least I think this was the reason). It demonstrates the worst of both C (badly designed system library) and UNIX (ioctls, /etc/passwd).

Usage

It can be used to run any program on any terminal (provided you have permission to read and write to the terminal). It'll even let you set (though it gives a warning or two) the "terminal" to a normal file and confuse any program absurdly.

Sample inittab lines

c1:2345:respawn:/sbin/gogetty /dev/tty1
c2:2345:respawn:/sbin/gogetty /dev/tty2
c3:2345:respawn:/sbin/gogetty /dev/tty3
c4:2345:respawn:/sbin/gogetty /dev/tty4

c8:12345:respawn:/sbin/gogetty /dev/tty8 /usr/bin/top
    

Download

Details

I suppose it could serve as an example of how to write a getty wrt session id handling, as agetty (from util-linux 2.10m) doesn't bother with this. On the other hand, gogetty does nothing about terminal attribute or baud settings (fortunately login apparently does everything needed).

How the ids work

This took a long time to figure out (particularly the terminal controlling session details), as it is documented nowhere and agetty doesn't do it.

The reason it gets set correctly on normal systems is that login (from util-linux 2.10m) reopens the tty device. As it has no other tty, it sets session ids, etc. (see linux/drivers/char/tty_io.c::tty_open).

Further information

The glibc info files brush over it. See termios(2), setsid(2), util-linux sources, linux/drivers/char/tty_io.c.