[comp.sys.next] Interpretation of carriage returns

CMH117@psuvm.psu.edu (Charles Hannum) (05/08/90)

If I log on the console of the NeXT and load a Terminal or Shell, carriage
returns seem to be interpreted as :M.  But if I log in remotely, they are
interpreted as :J, which breaks nice things like tn3270.

Could someone please tell me why?


Virtually,
- Charles Martin Hannum II         PennMUD Design Team - (Resident) Programmer
    (That's Charles to you!)       "Those who say a thing cannot be done should
  Please send mail to:              under no circumstances stand in the way of
  hannum@haydn.psu.edu              he who is doing it." - a misquote

eps@toaster.SFSU.EDU (Eric P. Scott) (05/09/90)

In article <90128.025215CMH117@psuvm.psu.edu> CMH117@psuvm.psu.edu
	(Charles Hannum) writes:
>If I log on the console of the NeXT and load a Terminal or Shell, carriage
>returns seem to be interpreted as :M.  But if I log in remotely, they are
>interpreted as :J, which breaks nice things like tn3270.
>
>Could someone please tell me why?

This is a BUG in telnetd.  This is a BUG in the original 4.3 BSD
telnetd that Berkeley fixed long ago.

There are two replacements: one is the telnetd from the 4.3-tahoe
distribution.  It corrects this problem (and a few others), but
still dates from Berkeley's Lousy Code Era (i.e. you have to
compile with -fwritable-strings etc.).  The 90.03.01 is the new
"clean" version, which fixes some grave omissions, and adds some
really nifty functionality.  It also comes with source patches to
the kernel.  A lot of good that does me.  :-(

I can only hope that NeXT looks kindly on its Internet customers
in the future and bundles the kernel support necessary for
traceroute, SLIP, RARP, linemode...  Their competitors WILL (if
they don't already).

					-=EPS=-
P.S. Having sources to things like telnetd and ftpd is essential
if you want to add local security hacks, e.g.

/*
 * Copyright 1990 by Eric P. Scott <eps@cs.sfsu.edu>
 * Redistribution permitted as long as this notice is retained.
 */
void unregistered(f, srca)	/* call if gethostbyaddr() fails */
int f;
struct in_addr srca;
{
	char *index();
	extern char *sys_errlist[];
	struct arpreq ar;
	char buf[BUFSIZ];

	bzero((char *)&ar, sizeof ar);
	ar.arp_pa.sa_family=AF_INET;
	((struct sockaddr_in *)&ar.arp_pa)->sin_addr.s_addr=srca.s_addr;
	if (ioctl(f, SIOCGARP, (caddr_t)&ar)<0) {
		if (errno==ENXIO)
			(void)sprintf(buf, "Access denied to %s\r\n\
Get your Zone Administrator to fix your nameservers.\r\n",
			inet_ntoa(srca));
		else (void)sprintf(buf, "telnetd: %s SIOCGARP error: %s\r\n",
			inet_ntoa(srca), sys_errlist[errno]);
	}
	else {
		if ((ar.arp_flags&ATF_COM)==0)	/* should never happen */
			(void)sprintf(buf, "telnetd: %s (not complete)\r\n",
			inet_ntoa(srca));
		else (void)sprintf(buf,	/* unauthorized Ethernet tap */
			"Access denied to %s at %02X:%02X:%02X:%02X:%02X:%02X\
\r\nPlease contact contact campus Network Support for assistance.\r\n",
			inet_ntoa(srca),
			ar.arp_ha.sa_data[0]&255,
			ar.arp_ha.sa_data[1]&255,
			ar.arp_ha.sa_data[2]&255,
			ar.arp_ha.sa_data[3]&255,
			ar.arp_ha.sa_data[4]&255,
			ar.arp_ha.sa_data[5]&255);
	}
	(void)write(f, buf, strlen(buf));
	if (buf[0]!='A') return;
	*index(buf, '\r')='\0';
	syslog(LOG_NOTICE, "%s\n", buf);	/* if syslogd worked */
	sleep(5);
	exit(1);
}