From owner-freebsd-bugs Mon Feb 19 20:20:06 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA18452 for bugs-outgoing; Mon, 19 Feb 1996 20:20:06 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA18436 Mon, 19 Feb 1996 20:20:02 -0800 (PST) Resent-Date: Mon, 19 Feb 1996 20:20:02 -0800 (PST) Resent-Message-Id: <199602200420.UAA18436@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, uhclem@nemesis.lonestar.org Received: from fw.ast.com (fw.ast.com [165.164.6.25]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id UAA18207 for ; Mon, 19 Feb 1996 20:17:12 -0800 (PST) Received: from nemesis by fw.ast.com with uucp (Smail3.1.29.1 #2) id m0tojRJ-0007zaC; Mon, 19 Feb 96 22:12 CST Received: by nemesis.lonestar.org (Smail3.1.27.1 #20) id m0tojOB-000CiCC; Mon, 19 Feb 96 22:09 WET Message-Id: Date: Mon, 19 Feb 96 22:09 WET From: uhclem@nemesis.lonestar.org Reply-To: uhclem@nemesis.lonestar.org To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/1037: 2.x telnetd handles CTRL-M differently than other ttys FDIV044 Sender: owner-bugs@freebsd.org Precedence: bulk >Number: 1037 >Category: bin >Synopsis: 2.x telnetd handles CTRL-M differently than other ttys FDIV044 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Feb 19 20:20:01 PST 1996 >Last-Modified: >Originator: Frank Durda IV >Organization: That's extra >Release: FreeBSD 2.1-STABLE i386 >Environment: FreeBSD 2.1.0 stock system, using various applications that place tty in character-at-a-time modes. >Description: Some applications that ran correctly under BSD43 on vaxen, and later on SYSIII, SYS5 and 1.1.5.1 PC systems break when used via telnet in 2.0.5 or 2.1.0. When these programs are running, they interactively parse each character received, including [ENTER], which is received as 0x0a when the program is run from the console (syscons), from a terminal attached to a sio port, or when connected using via telnet using telnetd from 1.1.5.1. When the telnetd from 2.0.5 or 2.1.0 is used, instead of a 0x0a, the program receives a 0x0d character, which it does not expect (never sees anywhere else) and treats as an not-valid-here character. >How-To-Repeat: The attached code fragment can be compiled to demonstrate the problem. Simply run it from terminals, the console, and from telnet sessions to see the difference in performance. (I have stripped out the SYS3-specific code, but can provide it if needed.) Follow the instructions in the program source. -----enterbug.c----- /* This program is peeled out of a much larger program called xmail. When run in 2.1.0 over telnet, pressing ENTER is no longer detected by the program as receiving a 0x0a as it did in 1.1.5.1 telnet sessions, or from ttys, or from the console, or on other platforms (BSD43, SYS3, SYSV) that this program has been used on. Start the program, and press at least the following keys: [ENTER] [CTRL][J] [CTRL][M] Press Capital Q to exit. Here is what I see here: (This is a 2.1.0 system) System sio telnetd telnetd console tty 2.1.0 1.1.5.1* [ENTER] 0a 0a **0d** 0a [CTRL][J] 0a 0a 0a 0a [CTRL][M] 0a 0a **0d** 0a * By replacing the 2.1.0 telnetd with the telnetd from 1.1.5.1 (but still running on a 2.1.0 system), the correct character (0x0a) is returned when ENTER is presed. Run this program from the console, from terminals, and then via telnet to see the difference in behavior. */ #include #include #include #include #define TRUE 1 #define FALSE 0 #define EOT '\004' static struct sgttyb old, new; static struct stat ttystatus; static int eof=EOT, killc=CTRL('U'), erase=CTRL('H'), werase=CTRL('W'); char *ttynam_stdout; int stdin_isatty, stdout_isatty; main() { char c; save_tty(); set_tty(); clearerr(stdin); do { c = getchar(); printf("%02x ",c); } while (c != 'Q'); restore_tty(); exit(0); } save_tty() { struct tchars tc; fstat(fileno(stdout), &ttystatus); ttynam_stdout = (char*) ttyname(fileno(stdout)); stdout_isatty = (ioctl(fileno(stdout), TIOCGETP, &old) >= 0); stdin_isatty = (ioctl(fileno(stdin), TIOCGETP, &old) >= 0); printf("stdin is%s a tty\n",stdin_isatty?"":" not"); printf("stdout is%s a tty\n",stdout_isatty?"":" not"); killc = (int)old.sg_kill; erase = (int)old.sg_erase; if (ioctl(fileno(stdin), TIOCGETC, &tc) == 0) eof = (int)tc.t_eofc; new = old; new.sg_flags |= CBREAK; new.sg_flags &= ~ECHO; } set_tty() { ioctl(fileno(stdin), TIOCSETN, &new); } restore_tty() { if (stdout_isatty) chmod(ttynam_stdout, (int)ttystatus.st_mode&0777); if (stdin_isatty) ioctl(fileno(stdin), TIOCSETP, &old); } -----end of enterbug.c----- >Fix: The workaround is to replace the telnetd in 2.1.0 or 2.0.5 with the telnetd from 1.1.5.1. This solves this problem and allows these legacy applications to be used on FreeBSD 2.x. *END* >Audit-Trail: >Unformatted: