Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Sep 97 21:39 CDT
From:      uhclem@nemesis.lonestar.org (Frank Durda IV)
To:        phk@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG
Cc:        uhclem.ds3@nemesis.lonestar.org
Subject:   Re: bin/1037
Message-ID:  <m0xCFSf-000tydC@nemesis.lonestar.org>

next in thread | raw e-mail | index | archive | help
[0]Synopsis: 2.x telnetd handles CTRL-M differently than other ttys	FDIV044
[0]State-Changed-From-To: feedback-closed
[0]State-Changed-By: phk
[0]State-Changed-When: Thu Sep 18 23:40:10 PDT 1997
[0]State-Changed-Why: 
[0]
[0]timed out.

Uh, pity you did that without asking.  This item has not been fixed,
despite me providing a one line patch that fixed this and a handfull of
other open PRs (at least two not from me) back in March.   The keeper of
the TCP/IP universe is apparently still sticking to the position that
breaking TELNET clients on many other platforms as well as the one
provided with FreeBSD is OK.

The patch works fine on all releases to date, including engineering
releases as recent as two weeks ago.  I put this patch on every FreeBSD 
system I touch.  I write software for a 43,000 customer ISP and those
machines are being accessed constantly by all sorts of telnet clients, and
the patch seems to solve the problem nicely, and all of those telnet clients
running under Windows, MAC-OS, IRIX, OS/2, and every other brand of UNIX
out there now work just fine, and the keys on their keyboard act as expected.
Without the patch, they ALL screw-up.


Below you will find the mailing list traffic where this specific problem
was last discussed (at least with me being involved).  As of a peek at the
current source tree from two weeks ago, this one line patch has still not
been applied.  Although I can check the change in myself, I would really
rather the keeper of that code address this issue.   I am old fashioned about
scribbling in someone elses code.  But, we are coming up on two years
waiting on this...


Frank Durda IV - only these addresses work:|"The FreeBSD Kevorkian
   <uhclem.ds3%nemesis.lonestar.org>       | PR resolution system:  Ignore
or <uhclem.ds3%rwsystr.nkn.net>            | the fix and then close the PR
These Anti-spam addresses expire Oct. 15th | because it "timed out".


>Date: Tue, 11 Mar 1997 21:30:01 -0800 (PST)
>Message-Id: <199703120530.VAA16850@freefall.freebsd.org>
>To: freebsd-bugs@freefall.freebsd.org
>From: uhclem@nemesis.lonestar.org (Frank Durda IV)
>Subject: re: bin/1037 and bin/771  Patch included
>Reply-To: uhclem@nemesis.lonestar.org (Frank Durda IV)
>Sender: owner-bugs@FreeBSD.ORG
>X-Loop: FreeBSD.org
>Precedence: bulk

The following reply was made to PR bin/1037; it has been noted by GNATS.

>From: uhclem@nemesis.lonestar.org (Frank Durda IV)
>To: mpp@freefall.freebsd.org, bugs@freebsd.org,
>        FreeBSD-gnats-submit@freebsd.org
>Cc: uhclem@nemesis.lonestar.org
>Subject: re: bin/1037 and bin/771  Patch included
>Date: Tue, 11 Mar 97 23:26 CST

 [0]Are you still seeing the problem reported in your FreeBSD problem
 [0]report # 1037?  Have you tried later versions of FreeBSD, such as 
 [0]FreeBSD 2.2 GAMMA or FreeBSD 3.0-current?  Any other information 
 [0]you could provide would be helpful.  If you are still seeing the 
 [0]problem, what version of FreeBSD are you running right now?
 [0]Mike Pritchard
 
 Regarding:
 bin/1037:
 Synopsis:       2.x telnetd handles CTRL-M differently than other ttys	FDIV044
 bin/771:
 Synopsis:	telnet character mode not set and broken when set - FDIV034
 
 
 No, these items remain broken in 2.2-GAMMA, and all releases back to
 at least the 2.1.0-RELEASE.  It worked correctly in 1.1.5.1.
 
 I've been hoping somebody would quit stalling over the religious issues
 here and fix this, but apparently that won't happen after a year on the
 books, so here is a patch that solves the religious issue with a
 technical fix:
 
 
 -----FIX BEGINS-----
 *** telnetd.c.00	Sun Jan 12 15:56:33 1997
 --- telnetd.c	Wed Feb 26 16:07:15 1997
 ***************
 *** 179,184 ****
 --- 179,187 ----
   
   	progname = *argv;
   
 + 	linemode=1;			/*Default to mode that all brands
 + 					  of telnets handle correctly*/
 + 
   #ifdef CRAY
   	/*
   	 * Get number of pty's before trying to process options,
 -----FIX ENDS-----
 
 
 That's it.  The patch works on all telnetds released from 2.1.0
 thru 2.2-GAMMAs and would close bin/771 and bin/1037 if applied.
 It might even resolve bin/1073, but I don't have a way to test that.
 
 
 Discussion
 
 The problem was, is, and apparently will always be that starting with
 2.x, telnetd has wanted to run in LINEMODE by default, because it
 is more efficient in using the TCP/IP transport media than the
 character-at-a-time modes used previously in 1.1.5.1 and earlier
 as well as BSD 4.3.
 
 The problem with that was, is, and will always be that not all TELNET
 clients on all known platforms implement LINEMODE correctly in that
 they don't know about what to do for various action (wakeup)
 control-characters, such as the ones available in csh for command editing
 and completion.  ^D, ^W, ^R, <ESC>, ^U, etc.   These commands break in
 the presence of LINEMODE in various ways.   To demonstrate, try this simple
 test.
 
 Login into a csh session on a FreeBSD target via the console or
 a serial connection and follow this command sequence:
 
 	% set filec
 	% cd /stand
 	% ls i<CTRL-D>		should display
 	ifconfig*
 	% ls i<ESC>		should finish command string:  % ls ifconfig
 	% ls ifconfig<CTRL-W>	should erase "ifconfig": % ls 
 	% ls <CTRL-R>		should redraw on next line: ls
 	ls f<CTRL-D>		should display
 	find* fsck* ft*
 	% ls fs<CTRL-D>		should finish "fsck": % ls fsck
 	% ls fsck<CTRL-U>	should erase: %
 	%
 
 Now telnet into the same system (try "telnet ." if you like and
 see the behavior difference).   Login as the same user and repeat
 the sequence above.
 
 I don't care if you telnet from any FreeBSD 2.x release, SCO UNIX 3.2,
 DEC OSF 3.2G or 4.0B, IRIX V.4, from NETBSD 1.x, Windows '95 TELNET,
 or from NCSA Telnet 2.3.07 (I've tested all of these), they will all
 malfunction telnetting to FreeBSD 2.x, at least until you apply the patch.
 
 The other aspect of the bad behavior of telnetd was shown by two different
 programs provided previously, but I'll repeat one here.  This is code
 pulled from an existing application written in the BSD 4.2/3 days, which
 ran fine on 1.1.5.1 and works on 2.x from the console or serial
 ports, but not via telnet, unless you apply the patch:
 
 -----chars.c-----
 #include <stdio.h>
 #include  <sgtty.h>
 #include <sys/stat.h>
 extern char	*ttyname();
 
 static	struct  stat	ttystatus;
 int	stdin_isatty, stdout_isatty;
 char	*ttynam_stdout;
 static  struct	sgttyb	old, new;
 static	struct  stat	ttystatus;
 int	stdin_isatty, stdout_isatty;
 char	*ttynam_stdout;
 
 #define	EOT	'\004'
 static int	eof=EOT,  killc=CTRL('U'),  erase=CTRL('H'),  werase=CTRL('W');
 
 main()
 {
 	char c;
 	printf("Press these keys  [T] [E] [S] [T] [Enter] [CTRL][J] [CTRL][M] [Esc]\n");
 	save_tty();
 	set_tty();
 
 	while((c=getchar())!=EOF && c!=0x1b) {
 		printf("%02x ",c);
 	}
 
 	restore_tty();
 	printf("\nYou should see 74 65 73 74 0a 0a 0a\n");
 }
 
 
 save_tty()
 {
 	struct tchars	tc;
 	struct ltchars t;
 
 	fstat(fileno(stdout), &ttystatus);
 	ttynam_stdout = ttyname(fileno(stdout));
 	stdout_isatty = (ioctl(fileno(stdout), TIOCGETP, &old) >= 0);
 	stdin_isatty = (ioctl(fileno(stdin), TIOCGETP, &old) >= 0);
 	if (ioctl(fileno(stdin), TIOCGLTC, &t) == 0)
 		werase = (int)t.t_werasc;
 
 	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 chars.c-----
 
 Compile this program on FreeBSD, and then execute it and follow
 the instructions.  Telnetting into FreeBSD 2.x without the above
 patch will give incorrect results in that CTRL-J/CTRL-M entered by
 the telnet user are not read as 0x0a by the program as they are when
 the same program is run on a console or serial session.
 
 Running the program with a telnetd that is patched, OR from the console
 or serial ports will work correctly CTRL-M/CTRL-J both are read as 0x0a.
 
 The program also behaves correctly when compiled and run on
 the other platforms mentioned, demonstrating that the problem is in the
 FreeBSD telnetd because it tries to force a mode that the clients can't
 handle correctly.
 
 
 All the patch does is instruct telnetd to negotiate a character mode by
 default that all of the above telnet clients handle correctly.
 If the user wants additional link efficiency at the cost of the
 problems shown above, then by all means he/she can switch to
 LINEMODE once the telnet connection is started if that mode can be used.
 No feature or capability is taken away by the patch.
 
 Yes, we could simply have everybody using every telnet client
 everywhere have to turn off LINEMODE each time they use telnet
 to a FreeBSD platform in order for existing shells and applications
 to work via telnet.  This is the religious argument that all the
 clients everywhere are broken and the FreeBSD telnetd isn't.
 Sorry, but I don't buy this.  We must fit in with the rest of the
 universe.
 
 It still seems that the default setting should provide maximum
 compatibility, which is the case with this patch installed.
 
 
 I recommend that this change be included in 2.2-RELEASE.
 
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m0xCFSf-000tydC>