8 bit characters on the Linux console lead to input corruption (e.g.
German umlauts). This is easily reproducable by inserting a login name with
umlaut and typing backspace afterwards.
agetty supports tty parity, which leads to getty treating these characters
as a 7bit char with set parity.
This patch by Samuel Thibault adds a new option -8 which disables parity
detection for ttys not used for serial logins.
lamont
>From 6f54ad913191a9ebe7c1bf8c38582d464df88896 Mon Sep 17 00:00:00 2001
From: Moritz Muehlenhoff <[EMAIL PROTECTED]>
Date: Thu, 19 Jul 2007 00:29:13 +0200
Subject: [Debian] 8 bit characters on the Linux console lead to input corruption
8 bit characters on the Linux console lead to input corruption (e.g.
German umlauts). This is easily reproducable by inserting a login name with
umlaut and typing backspace afterwards.
agetty supports tty parity, which leads to getty treating these characters
as a 7bit char with set parity.
This patch by Samuel Thibault adds a new option -8 which disables parity
detection for ttys not used for serial logins.
| Note: With this patch, 8bit characters are just silently dropped (that's
| the expected getty behavior), this is quite neat since you then don't
| even need to backspace your 8bit characters :)
Signed-off-by: LaMont Jones <[EMAIL PROTECTED]>
---
login-utils/agetty.8 | 7 +++++--
login-utils/agetty.c | 13 +++++++++----
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/login-utils/agetty.8 b/login-utils/agetty.8
index b1ade5f..5bde294 100644
--- a/login-utils/agetty.8
+++ b/login-utils/agetty.8
@@ -3,7 +3,7 @@
agetty \- alternative Linux getty
.SH SYNOPSIS
-.BR "agetty " [\-ihLmnw]
+.BR "agetty " [\-8ihLmnw]
.RI "[-f " issue_file ]
.RI "[-l " login_program ]
.RI "[-I " init ]
@@ -13,7 +13,7 @@ agetty \- alternative Linux getty
.I baud_rate,...
.RI [ term ]
.br
-.BR "agetty " [\-ihLmnw]
+.BR "agetty " [\-8ihLmnw]
.RI "[-f " issue_file ]
.RI "[-l " login_program ]
.RI "[-I " init ]
@@ -92,6 +92,9 @@ whatever init(8) may have set, and is inherited by login and the shell.
.fi
.ad
.TP
+\-8
+Assume that the tty is 8-bit clean, hence disable parity detection.
+.TP
\-h
Enable hardware (RTS/CTS) flow control. It is left up to the
application to disable software (XON/XOFF) flow protocol where
diff --git a/login-utils/agetty.c b/login-utils/agetty.c
index 806c3d9..46285b1 100644
--- a/login-utils/agetty.c
+++ b/login-utils/agetty.c
@@ -154,6 +154,7 @@ struct options {
char *issue; /* alternative issue file */
int numspeed; /* number of baud rates to try */
int speeds[MAX_SPEED]; /* baud rates to be tried */
+ int eightbits; /* assume 8bit-clean tty */
};
#define F_PARSE (1<<0) /* process modem status messages */
@@ -411,8 +412,11 @@ parse_args(argc, argv, op)
extern int optind; /* getopt */
int c;
- while (isascii(c = getopt(argc, argv, "I:LH:f:hil:mt:wn"))) {
+ while (isascii(c = getopt(argc, argv, "8I:LH:f:hil:mt:wn"))) {
switch (c) {
+ case '8':
+ op->eightbits = 1;
+ break;
case 'I':
if (!(op->initstring = malloc(strlen(optarg)+1))) {
error(_("can't malloc initstring"));
@@ -1148,10 +1152,11 @@ char *get_logname(op, cp, tp)
if ((c == 0) && op->numspeed > 1)
return (0);
-
/* Do parity bit handling. */
- if (c != (ascval = (c & 0177))) { /* "parity" bit on ? */
+ if (op->eightbits) {
+ ascval = c;
+ } else if (c != (ascval = (c & 0177))) { /* "parity" bit on */
for (bits = 1, mask = 1; mask & 0177; mask <<= 1)
if (mask & ascval)
bits++; /* count "1" bits */
@@ -1312,7 +1317,7 @@ bcode(s)
void
usage()
{
- fprintf(stderr, _("Usage: %s [-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] baud_rate,... line [termtype]\nor\t[-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] line baud_rate,... [termtype]\n"), progname);
+ fprintf(stderr, _("Usage: %s [-8hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] baud_rate,... line [termtype]\nor\t[-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] line baud_rate,... [termtype]\n"), progname);
exit(1);
}
--
1.5.2.3