Date: Fri, 6 Dec 96 22:52 CST From: uhclem@nemesis.lonestar.org (Frank Durda IV) To: scrappy@freefall.freebsd.org, freebsd-bugs@freefall.freebsd.org Message-ID: <m0vWEkX-000u4DC@nemesis.lonestar.org>
next in thread | raw e-mail | index | archive | help
Synopsis: 2.x telnetd handles CTRL-M differently than other ttys FDIV044
Return-receipt-to:
Return-receipt-from:
Cc: uhclem
Bcc:
[0]Synopsis: 2.x telnetd handles CTRL-M differently than other ttys FDIV044
[0]
[0]State-Changed-From-To: open-feedback
[0]State-Changed-By: scrappy
[0]State-Changed-When: Mon Oct 21 23:07:38 PDT 1996
[0]State-Changed-Why:
[0]
[0]Dust off the cobwebs - Confirm Status
Confirmed - this problem still exists in 2.1.5 and 2.2-ALPHA. NO CHANGE.
2.1.6 was not re-tested.
Additional information:
The attached program demonstrates the original problem.
1. cc -o chars chars.c
2. ./chars
(follow displayed instructions and note result accuracy - NORMAL)
3. telnet self
4. login
5. ./chars
(follow displayed instructions and note you don't get the
same results - MALFUNCTION)
The routines "chars" invokes are extracted from a package called XMAIL,
and appear to be doing completely valid things, effectively selecting
RAW mode. I have stripped all of the #ifdef SYS3 and other conditionals
so it is easier to view.
I did not write these routines, so a review of their form and function
really isn't needed. I do know that this code works consistently for
both non-telnet and telnet sessions in BSD 4.1, 4.2 4.3, and
FreeBSD up thru 1.1.5.x. It also works correctly on a FreeBSD 2.x system
if you replace telnetd with the telnetd provided with FreeBSD 1.1.5.1
or older.
A related problem: (there should be an open PR on this but I don't see it)
1. Login to stock shell with stock .cshrc/.login (csh with filec
enabled)
2. cd directory where above programs reside.
3. Type [c][CTRL][D]
system should display files that match, including chars.c. NORMAL
4. [CTRL][C].
5. Telnet self
6. login (same csh/filec login used in steps 1-5)
7. cd directory where above programs reside.
8. Type [c][CTRL][D]
system should display files that match, but instead, simply
echos ^D. MALFUNCTION
As above, replacing telnetd with the one shipped with 1.1.5.1 fixes
this problem.
Frank Durda IV <uhclem@nemesis.lonestar.org>|"The Knights who say "LETNi"
or uhclem%nemesis@rwsystr.nkn.net | demand... A SEGMENT REGISTER!!!"
|"A what?"
or ...letni!rwsys!nemesis!uhclem |"LETNi! LETNi! LETNi!" - 1983
-----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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m0vWEkX-000u4DC>
