login-envuidgid 1 user commands nosh
login-envuidgid login-envuidgid-nopam set UID, GID, GIDLIST, and LOGNAME environment variables from an interactive login dialogue then chain
`login-envuidgid` --cursor-keypad-application-mode --calculator-keypad-application-mode --no-alternate-screen-buffer --inversescreen boolean --tui_level level --verbose next-prog `login-envuidgid-nopam` --cursor-keypad-application-mode --calculator-keypad-application-mode --no-alternate-screen-buffer --inversescreen boolean --tui-level level --verbose --utmpx next-prog

## Description

`login-envuidgid` is a chain-loading utility that presents an interactive login dialogue, upon successful completion of the dialogue sets the `UID`, `GID`, `GIDLIST`, and `LOGNAME` environment variables to the values for the account chosen, and then forks. In the child process it chain loads to next-prog with the execvp 3 function. In the parent process it waits for that child process to terminate and then replicates its exit status.

next-prog may contain its own command line options, which the utility will ignore.

`login-envuidgid` uses PAM, if it was built with PAM support; falling back, if not built with PAM support, to a simple hardwired authentication mechanism and performing direct lookup and password checks against the system account database. `login-envuidgid-nopam` is the same utility but forcibly acting as if built without PAM support.

Forking is required for both the PAM and non-PAM flavours for the same reasons: PAM requires that "user sessions" be opened and closed by a process with a privileged effective user ID; and non-PAM needs write access to the (privileged access) utmpx 3 "active login" table.

If the login dialogue is cancelled, the login authentication fails, there is a PAM problem, or it cannot set the environment variables, it does not chain and exits with status code 111.

### Log-in logs

The --verbose command-line option instructs the utility to log, to standard error, login attempt failure and success messages. Only success messages contain the account name, on the grounds that this is attacker-supplied data and an authentication failure has failed to sanitize it.

In the non-PAM case, the --utmpx command-line option causes `login-envuidgid-nopam` to explicitly write `USER_PROCESS` and `DEAD_PROCESS` records to the utmpx 3 "active login" table for the forked child process. (In the PAM case, this is normally handled by a PAM module.)

On most systems, the log-in log table is not size-limited and the --utmpx option has the potential to generate large files. For best results, use --verbose instead, and run the output of standard error through a size-limiting logger like cyclog 1.

### User interface

The interactive login dialogue is a full-screen TUI. In the PAM case, the login dialogue is entirely determined by PAM, which specifies a series of forms (comprising labels, normal entry fields, obscured entry fields, and text fields) to be presented to the user and returned to PAM after the user has pressed Enter. (There is no hard-coded initial prompt for the user name; PAM is even in charge of that, too.) In the non-PAM case, the login dialogue is a simple single form prompting for account name and password, using as labels the `login_prompt` and `passwd_prompt` string settings configured for the `root` class in login.conf 5 (with hardwired defaults if those settings are not present).

The utility opens its controlling terminal via `/dev/tty`, or whatever is specified by the `TTY` environment variable, and uses that for its user interface, both input and output.

#### Input

Input is always in insert mode, and (unlike "glass-TTY" login programs) allows editing input fields from elsewhere than only their ends. It operates in Unicode, decoding what input it reads from the terminal with the assumption that it is UTF-8, and accepts most non-C0 and non-C1 Unicode characters. The results are transformed into UTF-8 before passing back to PAM (or being directly employed against the system account database).

The user interface responds to some conventional line editing characters and control sequences such as:

ETX (⎈ Control+C)
FS (⎈ Control+\)
EOT (⎈ Control+D)
EM (⎈ Control+Y)
SUB (⎈ Control+Z)

  abort the dialogue

TAB (⇥ Tab/⎈ Control+I)

  move to the next editable field, if any

CBT (⇤ BackTab)

  move to the previous editable field, if any

  The FreeBSD console in "teken" and "cons25" modes, and hence console-terminal-emulator 1 when emulating it, employs a mongrel admixture of DEC VT and SCO function key control sequences, and it is impossible to distinguish the DEC VT Backwards TAB control sequence from the SCO Unix Multiscreen virtual terminal shifted function key 2 control sequence. (The sequence as retained in FreeBSD, at any rate. The actual SCO Console used slightly different encodings to what remains of it in FreeBSD, and thus somewhat ironically did not have FreeBSD's amibiguity over backtab.)
CR (⎈ Control+M)
LF (⎈ Control+J)

  complete the dialogue

CUD (⭣ Cursor Down)
CUU (⭡ Cursor Up)

  Move to the previous/next editable field, if any.

CUL (⭠ Cursor Left)
CUR (⭢ Cursor Right)

  Move left and right along the current field.

DEC FNK 7 (⇱ Home)
SOH (⎈ Control+A)

  Move the cursor to the beginning of the editing field.

  The Linux console, and hence console-terminal-emulator 1 when emulating it, uses the wrong DEC FNK number for ⇱ Home. This is recognized as long as `TERM` is set correctly.
DEC FNK 8 (⇲ End)
ENQ (⎈ Control+E)

  Move the cursor to the end of the editing field.

  The Linux console, and hence console-terminal-emulator 1 when emulating it, uses the wrong DEC FNK number for ⇲ End. This is recognized as long as `TERM` is set correctly.
BS (⎈ Control+H)

  "erase" the character to the left

NAK (⎈ Control+U)

  "kill" from the current position back to the beginning of the field

DC2 (⎈ Control+R)
FF (⎈ Control+L)

  repaint the screen

DEC FNK 3 (⌦ Delete)

  "delete" the character to the right

FNK ? 127 (Mute)

  hide/unhide the status bar clock

#### Output

Output operates in Unicode, encoded as UTF-8, and employs Unicode box drawing and Apple IIc MouseText characters to draw pseudo-graphic windows around the input fields, to hide password fields, and to draw a banner with an updating digital clock. The --tui-level command-line option constrains the use of MouseText or Unicode block graphics and line drawing characters in TUI widgets; including the clock and the pseudo-window borders.

The current input field and its prompt are highlighted in boldface. "glass-TTY" login programs render password fields as zero length, and all editing (which can, however, only happen from the end position of the field in such programs) is invisible. Unlike them, `login-envuidgid-nopam` renders all characters in password fields as universally the same glyph, per the convention of GUI password dialogues, because its more flexible editing capabilities that can edit from the middles of fields are visually very difficult to follow otherwise.

Although its behaviour is controlled by the `TERM` 7 environment variable, it does not use terminfo 3 or termcap 3. It instead uses TerminalCapabilities 3. The terminal type determines a few terminal capabilities (such as whether the terminal can actually handle DEC private mode control sequences at all, and its degree of ISO 8613-6/ITU T.416 support), but most processing adheres to the ECMA-48 and ISO 8613-6 de jure standard control sequences and the DEC VT, DTTerm, and AIXTerm de facto standard ones.

The --cursor-keypad-application-mode and --calculator-keypad-application-mode command-line options instruct the utility to switch, respectively, the cursor keypad and the calculator keypad of the realizing terminal into their "application" modes. Otherwise it switches them into their "normal" modes. "application" mode is generally not useful to the utility, since it makes cursor and calculator keys indistinguishable from accelerator keys. The --no-alternate-screen-buffer command-line option instructs the utility to not switch to the alternative screen buffer. This has two uses. First, it allows one to retain visibility of displayed information after the program has exited (although setterm 1 provides access to the alternative screen buffer). Second, it works around problems with some (yet more!) broken terminal emulators that attempt to be and fail at being like XTerm, which forcibly change cursor and editing keys into application mode when the alternative screen buffer is active. The --inversescreen command-line option instructs `login-envuidgid` to switch the DECSCNM ("light"/"dark" screen mode) private mode on or off.

## See also

- envuidgid 1

- userenv-fromenv 1

- setuidgid-fromenv 1

- chdir-home 1

## Author

Jonathan de Boyne Pollard