# Real terminal login

Operating systems provide a range of devices that are real terminals, or things pretending to be real terminals, attached via serial ports (and possibly modems). This package contains tools for running and managing TUI login services on real terminals. It also contains pre-written service bundles for such TUI login services.

Login on real terminals is done with `ttylogin` services, configured to use those devices. In the case of virtual terminals the `ttylogin` services are services in their own right, built up entirely from chain-loading tools in the toolset. But with real terminals, these services are instead always alias names for other services, that are in turn named after the serial-line programs that they employ (such as `getty`, `mgetty`, and `agetty`).

Such a TUI login service is a very simple service, which can be managed just like other ordinary services, started and stopped and enabled and disabled in the usual way. There is one augmentation to ordinary service management: the `preset` command uses the ordinary preset file mechanism, but can also read the `/etc/ttys` file.

Note: Login services for real terminals have to do a lot more than the login services of virtual terminals; from auto-sensing and auto-changing line speed to handling special login diversions for faxmodems, BBSes, PPP, and suchlike. On the one hand, TUI login services for real terminals should not be relying upon any sort of `getty` program any more. The use of `getty` in terminal login has in fact been obsolete since 1988, when one of the earliest service management systems for Unix superseded it with its own mechanisms. On the other hand, the nosh toolset does not provide chain-loading utilities for these extra mechanisms, and current TUI login services for real terminals hence do still employ various `getty` programs. On the gripping hand, the use of faxmodems, BBS "doors", variable speed serial lines to local terminals or to modems, PPP, chat scripts, and suchlike is uncommon in the 21st century. Theoretically, in the future a lot of this could simplify to assuming a hardwired fixed high BPS rate, default line discipline settings, and no special login diversions; and thus even these residual `getty` uses could finally be removed.

## What the service bundle `run` scripts look like

### FreeBSD, DragonFly BSD, and similar

The services are `ttylogin@ttyu0` through to `ttylogin@ttyuf`, matching the operating system's real terminal devices `/dev/ttyu0` to `/dev/ttyuf`. These are aliases for `getty@ttyu0` through to `getty@ttyuf`.

These services invoke the FreeBSD `/usr/libexec/getty` program, with the getty class of `std.9600`. The `run` script for such services is basically this (using `getty@ttyu1` as an example):

>     #!/bin/nosh
>     setsid
>     /usr/libexec/getty std.9600 ttyu1

### OpenBSD

The services are `ttylogin@tty00` through to `ttylogin@tty07` and `ttylogin@ttyU0` through to `ttylogin@ttyU3`, matching the operating system's real terminal devices `/dev/tty00` to `/dev/tty07` and `/dev/ttyU0` to `/dev/ttyU3`. These are aliases for `getty@tty00` through to `getty@tty07` and `getty@ttyU0` through to `getty@ttyU3`.

These services invoke the OpenBSD `/usr/libexec/getty` program, with the getty class of `std.9600`. The `run` script for such services is basically this (using `getty@tty03` as an example):

>     #!/bin/nosh
>     setsid
>     /usr/libexec/getty std.9600 tty03

### Linux-based operating systems

The services are `ttylogin@ttyS0` through to `ttylogin@ttyS3`, matching the operating system's real terminal devices `/dev/ttyS0` to `/dev/ttyS3`. By default, these are aliases for `agetty@ttyS0` through to `agetty@ttyS3`. But they can if one wishes instead be aliased to `mgetty@ttyS0` through to `mgetty@ttyS3`.

The first set of services invokes Wietse Venema's `agetty` program. The `run` script for such services is basically this (using `agetty@ttyS2` as an example):

>     #!/bin/nosh
>     setsid
>     agetty ttyS2

The second set of services invokes Gert Doering's `mgetty` program. The `run` script for such services is basically this (using `mgetty@ttyS0` as an example):

>     #!/bin/nosh
>     mgetty ttyS0

Note: Florian La Roche's `mingetty` program and Felix von Leitner's `fgetty` program are not suitable for use with real terminals attached to serial devices.