hedrick@athos.rutgers.edu (Charles Hedrick) (12/22/87)
The 4.3 telnet and telnetd, as contrasted to the 4.2 versions, implement a much larger subset of the whole telnet spec. However the 4.3 version still doesn't do telnet SYNC. This is the feature needed to clear the output buffer on the local end when it is done on the remote end. That is, the feature needed to make ^C and ^O stop output within a reasonable amount of time. In order to make this work, we have to run the pty in packet mode (as rlogind does). Other than that, the patch is pretty easy. We have a number of changes to telnetd, but it looks like these are the relevant ones. Note that this is to the 4.3 telnetd. The 4.2 version doesn't have the neturg mechanism, so this patch wouldn't work. Of course this telnetd won't accomplish anything unless your telnet handles SYNC correctly. That requires the 4.3 telnet (and a kernel that includes SO_OOBINLINE -- 4.3 telnet tries to simulate it if it isn't defined, but the simulation doesn't seem to work very well). *************** *** 382,387 **** --- 447,453 ---- ioctl(f, FIONBIO, &on); ioctl(p, FIONBIO, &on); + ioctl(p, TIOCPKT, &on); #if defined(SO_OOBINLINE) setsockopt(net, SOL_SOCKET, SO_OOBINLINE, &on, sizeof on); #endif /* defined(SO_OOBINLINE) */ *************** *** 553,559 **** /* * Something to read from the pty... */ ! if (FD_ISSET(p, &ibits)) { pcc = read(p, ptyibuf, BUFSIZ); if (pcc < 0 && errno == EWOULDBLOCK) pcc = 0; --- 619,625 ---- /* * Something to read from the pty... */ ! if (FD_ISSET(p, &ibits) || FD_ISSET(p, &xbits)) { pcc = read(p, ptyibuf, BUFSIZ); if (pcc < 0 && errno == EWOULDBLOCK) pcc = 0; *************** *** 560,566 **** else { if (pcc <= 0) break; ! ptyip = ptyibuf; } } --- 626,640 ---- else { if (pcc <= 0) break; ! if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) { ! ! netclear(); /* clear buffer back */ ! *nfrontp++ = IAC; ! *nfrontp++ = DM; ! neturg = nfrontp-1; /* off by one XXX */ ! } ! pcc--; ! ptyip = ptyibuf+1; } }