[Pkg-shadow-devel] Bug#429758: login: why have the default tty settings changed?

Alan Curry pacman at TheWorld.com
Tue Jun 19 22:38:07 UTC 2007


Package: login
Version: 1:4.0.18.1-7
Severity: wishlist
Tags: patch

In previous versions of Debian (for example the 4.0.3-31sarge9 login
package), the default tty settings immediately after login include the
echoctl flag. That's the flag that causes the tty driver to print control
characters in the "caret" form, for example the Escape key is echoed as ^[
(caret left-bracket) and the up arrow key is echoed as ^[[A. Those caret
forms let the user know that his input is going to a program that is not
aware of control keys. It is then possible to use the erase character
(delete/backspace) to correct the mistake.

In the current stable version of login, the default tty flags have changed.
The most noticeable change, to me, has been the absence of echoctl. Without
echoctl, control characters received from the tty are echoed directly back to
the tty. This mode has its own interesting properties (for example, you can
run "cat >/dev/null" and type escape sequences to draw on the screen, and the
arrow keys directly cause cursor motion without any need to be interpreted
since ^[[A is both the up-arrow key on input and the cursor-up directive on
output) but in more realistic usage scenarios, this change has been annoying.

Without echoctl, if you accidentally type an escape-sequence-generating key
in a program that is using the default tty mode, the cursor may end up in the
wrong place, and the erase character can't get it back where it belongs so
you just give up and start over. Or you may type control-N and instead of
seeing "^N" you are now using the alternate character set. If you understand
what's going on, you can type ^O to get back to normal. Then you have to
backspace twice to get both of them out of the input buffer, even though you
can't see them.

The only entry in the upstream ChangeLog that seems relevant to this change
is "* src/login.c (setup_tty): remove dead code." but that code was not dead.
There was some dead code nearby, and it looks like someone just removed a bit
too much of setup_tty(). I can't be sure that's when it happened since
upstream versions are hard to get right now.

This patch restores the 4.0.3-31sarge9 version of setup_tty(), without the
dead code.

--- src/login.c.orig	2007-06-19 16:24:21.000000000 -0500
+++ src/login.c	2007-06-19 15:33:50.000000000 -0500
@@ -175,6 +175,16 @@
 	termio.c_lflag |= ISIG | ICANON | ECHO | ECHOE;
 	termio.c_iflag |= ICRNL;
 
+#if defined(ECHOKE) && defined(ECHOCTL)
+	termio.c_lflag |= ECHOKE | ECHOCTL;
+#endif
+#if defined(ECHOPRT) && defined(NOFLSH) && defined(TOSTOP)
+	termio.c_lflag &= ~(ECHOPRT | NOFLSH | TOSTOP);
+#endif
+#ifdef	ONLCR
+	termio.c_oflag |= ONLCR;
+#endif
+
 	/* leave these values unchanged if not specified in login.defs */
 	termio.c_cc[VERASE] = getdef_num ("ERASECHAR", termio.c_cc[VERASE]);
 	termio.c_cc[VKILL] = getdef_num ("KILLCHAR", termio.c_cc[VKILL]);

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: powerpc (ppc)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.21.1
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages login depends on:
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries

login recommends no packages.

-- no debconf information




More information about the Pkg-shadow-devel mailing list