Subject: Re: telnet problem
To: None <current-users@NetBSD.ORG>
From: Ken Hornstein <kenh@cmf.nrl.navy.mil>
List: current-users
Date: 06/30/1998 01:00:15
(Note: I just finished up a talk session with Bill where I explained
what was going on, but I thought other people would be interested).

>> Is this V4 or V5?  I know there are multiple V4 telnet clients for the
>> Mac, and we have a working V5 one ...
>
>V4, I think. Is there one you'd suggest?

I believe both NiftyTelnet and BetterTelnet do V4 (I'm pretty sure about
NiftyTelnet, not so sure about BetterTelnet).  And then there's the
old reliable NCSA Telnet :-/

>Maybe we enabled BINARY mode negotiation?

Hmmmm .... well, give that man a cigar, because after turning on option
debugging, I see that a post 1.2 telnetd _does_ negotiate binary mode
(but that still means the Mac is doing binary wrong).

Oh, my, I see what's happening here!

The decision to negotiate binary mode happens in termstat.c, inside
of localstat() :

        /*
         * Check for state of BINARY options.
         */
        if (tty_isbinaryin()) {
                if (his_want_state_is_wont(TELOPT_BINARY))
                        send_do(TELOPT_BINARY, 1);
        } else {
                if (his_want_state_is_will(TELOPT_BINARY)) 
                        send_dont(TELOPT_BINARY, 1);
        }

And tty_isbinaryin() is:

tty_isbinaryin()
{
#ifndef USE_TERMIO
        return(termbuf.lflags & LPASS8);
#else 
        return(!(termbuf.c_iflag & ISTRIP));
#endif  
}

And sure enough, my 1.2 system has ISTRIP set on ttys by default,
but my 1.3.x systems do not.  So somewhere along the way, the
terminal defaults were changed so that ISTRIP was not set, which
caused telnetd to start offering to do binary mode negotiation,
which started all of your problems.

Now, I still think your Mac client is broken, but it should be
relatively easy enough to hack telnetd to not offer to do binary
mode, so you can do that for now.  I'm not sure if adding a new
command-line option to telnetd makes sense, but there is precedence
with the linemode and kludge linemode support.

--Ken