NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/49392: telnet: bad terminal setup in character + local echo mode



>Number:         49392
>Category:       bin
>Synopsis:       telnet: bad terminal setup in character + local echo mode
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 14 20:40:00 +0000 2014
>Originator:     Stanislav Brabec
>Release:        CVS head
>Organization:
SUSE LINUX
>Environment:
not relevant
>Description:
If the telnet client switches to the character + local echo mode (a non-standard combination) and it runs in a smart terminal capable of doing echo, telnet client configures the terminal to perform the echo. Telnet client itself does no echo.

There is a problem that telnet uses an incorrect combination of flags, which causes End Of Line being displayed as "^M" instead of performing CR+LF.

Current implementation uses following set of flags:
onlcr -icrnl echo

In CRLF mode it first correctly sets 
onlcr icrnl echo
but later in the code it changes flags to
onlcr -icrnl echo

The -icrnl causes echoing of control characters as "^{letter}", including LF displayed as "^M".

According to Werner Fink <werner%suse.com@localhost>, this is a correct behavior of terminal, just the combination of flags used is incorrect.

However the problem was discovered on the Linux system, I believe, that the problem is system independent, and affects all systems. Attached patch seems to fix this issue without breaking any other telnet modes.

As FreeBSD seems to maintain the original BSD code, I am sending this report here.


This problem probably exists from the very first implementation of character echo mode in the BSD telnet (1987), and affects probably all implementations derived from it:
- NetBSD telnet (the original code)
- OpenBSD telnet (branched 1995 from NetBSD)
- netkit-telnet (now in Debian, branched between 1990 and 1993)
- telnet-bsd (Linux port from 1999 created by Thorsten Kukuk  <kukuk%suse.de@localhost>)
- FreeBSD telnet (significantly rewritten, branched between 1993 and 1997)

(Internal SUSE bug reference: bnc#897696)
>How-To-Repeat:
1. Run telnet client in a smart virtual terminal capable of local echo (for example "xterm" or "gnome-terminal")

2. Connect to a telnetd capable properly implementing WONT ECHO.

3. Login to a shell that us capable to work in no echo mode:
- For example "bash --noediting" or call "set +o vi ; set +o emacs" before changing telnet mode.
- You can also reproduce it with "cat" in place of login shell.

4. Set the mode to the local echo using "send dont echo".

Now your telnet session should be in the character local echo mode. (Character mode is the default and we did not change it before switching to the local echo mode.)

Without the fix:
telnet> send dont echo
linux> #hello^Mlinux>

With the fix:
telnet> send dont echo
linux> #hello
linux>

Note: Characters "^M" are generated by mis-configured terminal on the client side. They are not passed to the telnet session. Telnet session correctly gets EOL (LF or CRLF).
>Fix:
--- src/usr.bin/telnet/sys_bsd.c	2012-01-09 17:08:55.000000000 +0100
+++ src/usr.bin/telnet/sys_bsd.c	2014-11-14 21:24:49.540247131 +0100
@@ -355,7 +355,6 @@
 	tmp_tc.c_lflag |= ICANON;
     } else {
 	tmp_tc.c_lflag &= ~ICANON;
-	tmp_tc.c_iflag &= ~ICRNL;
 	tmp_tc.c_cc[VMIN] = 1;
 	tmp_tc.c_cc[VTIME] = 0;
     }



Home | Main Index | Thread Index | Old Index