f3e6c7
diff -uNr telnet/Makefile telnet.obsd-cvs/Makefile
f3e6c7
--- telnet/Makefile	Mon Jul 27 18:25:13 1998
f3e6c7
+++ telnet.obsd-cvs/Makefile	Sat Mar 10 10:54:26 2001
f3e6c7
@@ -36,22 +36,20 @@
f3e6c7
 
f3e6c7
 PROG=	telnet
f3e6c7
 
f3e6c7
-CFLAGS+=-DTERMCAP -DKLUDGELINEMODE -DUSE_TERMIO -DSKEY -Dunix
f3e6c7
-CFLAGS+=-DENV_HACK -D_USE_OLD_CURSES_
f3e6c7
+CFLAGS+=-DKLUDGELINEMODE -DUSE_TERMIO -DENV_HACK -DSKEY -Dunix
f3e6c7
 CFLAGS+=-I${.CURDIR}/../../lib
f3e6c7
-LDADD+=	-locurses -ltelnet
f3e6c7
-DPADD=	${LIBOLDCURSES} ${LIBTELNET}
f3e6c7
+LDADD+=	-lcurses -ltelnet
f3e6c7
+DPADD=	${LIBCURSES} ${LIBTELNET
f3e6c7
 
f3e6c7
 SRCS=	authenc.c commands.c main.c network.c ring.c sys_bsd.c telnet.c \
f3e6c7
 	terminal.c tn3270.c utilities.c
f3e6c7
 
f3e6c7
 .include <bsd.own.mk> # for KERBEROS
f3e6c7
 
f3e6c7
-.if (${KERBEROS} == "yes")
f3e6c7
+.if (${KERBEROS:L} == "yes")
f3e6c7
 CFLAGS+=-DENCRYPTION -DAUTHENTICATION -DKRB4
f3e6c7
 LDADD+= -lkrb -ldes
f3e6c7
 DPADD+= ${LIBDES} ${LIBKRB}
f3e6c7
 .endif
f3e6c7
 
f3e6c7
 .include <bsd.prog.mk>
f3e6c7
-
f3e6c7
diff -uNr telnet/commands.c telnet.obsd-cvs/commands.c
f3e6c7
--- telnet/commands.c	Fri Apr  9 02:30:20 1999
f3e6c7
+++ telnet.obsd-cvs/commands.c	Sat Mar 10 10:51:22 2001
f3e6c7
@@ -1,4 +1,4 @@
f3e6c7
-/*	$OpenBSD: commands.c,v 1.20 1999/01/04 07:55:05 art Exp $	*/
f3e6c7
+/*	$OpenBSD: commands.c,v 1.34 2000/11/08 21:49:44 aaron Exp $	*/
f3e6c7
 /*	$NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $	*/
f3e6c7
 
f3e6c7
 /*
f3e6c7
@@ -69,7 +69,7 @@
f3e6c7
 	int status;
f3e6c7
 
f3e6c7
 	if(argc != 3) {
f3e6c7
-		printf("%s sequence challenge\n", argv[0]);
f3e6c7
+		printf("usage: %s sequence challenge\n", argv[0]);
f3e6c7
 		return 0;
f3e6c7
 	}
f3e6c7
 
f3e6c7
@@ -2175,17 +2175,19 @@
f3e6c7
     int gotmachine = 0;
f3e6c7
     int l1 = strlen(m1);
f3e6c7
     int l2 = strlen(m2);
f3e6c7
-    char m1save[64];
f3e6c7
+    char m1save[MAXHOSTNAMELEN];
f3e6c7
 
f3e6c7
     if (skiprc)
f3e6c7
 	return;
f3e6c7
 
f3e6c7
-    strcpy(m1save, m1);
f3e6c7
+    strncpy(m1save, m1, sizeof(m1save));
f3e6c7
     m1 = m1save;
f3e6c7
 
f3e6c7
     if (rcname[0] == 0) {
f3e6c7
 	char *home = getenv("HOME");
f3e6c7
 
f3e6c7
+	if (home == NULL || *home == '\0')
f3e6c7
+	    return;
f3e6c7
 	snprintf (rcname, sizeof(rcname), "%s/.telnetrc",
f3e6c7
 		  home ? home : "");
f3e6c7
     }
f3e6c7
@@ -2248,15 +2250,9 @@
f3e6c7
     int
f3e6c7
 tn(int argc, char *argv[])
f3e6c7
 {
f3e6c7
-    struct hostent *host = 0, *alias = 0;
f3e6c7
-#if defined(AF_INET6)
f3e6c7
-    struct sockaddr_in6 sin6;
f3e6c7
-#endif
f3e6c7
+    struct addrinfo hints, *res, *res0;
f3e6c7
+    int error;
f3e6c7
     struct sockaddr_in sin;
f3e6c7
-    struct sockaddr_in ladr;
f3e6c7
-    struct sockaddr *sa;
f3e6c7
-    int sa_size;
f3e6c7
-    struct servent *sp = 0;
f3e6c7
     unsigned long temp;
f3e6c7
 #if !defined(__linux__)
f3e6c7
     extern char *inet_ntoa();
f3e6c7
@@ -2266,15 +2262,18 @@
f3e6c7
     int srlen;
f3e6c7
 #endif
f3e6c7
     char *cmd, *hostp = 0, *portp = 0, *user = 0, *aliasp = 0;
f3e6c7
-    int family, port = 0;
f3e6c7
-
f3e6c7
+    int retry;
f3e6c7
+#ifdef NI_WITHSCOPEID
f3e6c7
+    const int niflags = NI_NUMERICHOST | NI_WITHSCOPEID;
f3e6c7
+#else
f3e6c7
+    const int niflags = NI_NUMERICHOST;
f3e6c7
+#endif
f3e6c7
+    
f3e6c7
     /* clear the socket address prior to use */
f3e6c7
     memset((char *)&sin, 0, sizeof(sin));
f3e6c7
 
f3e6c7
     if (connected) {
f3e6c7
 	printf("?Already connected to %s\r\n", hostname);
f3e6c7
-	seteuid(getuid());
f3e6c7
-	setuid(getuid());
f3e6c7
 	return 0;
f3e6c7
     }
f3e6c7
     if (argc < 2) {
f3e6c7
@@ -2324,8 +2323,6 @@
f3e6c7
 	}
f3e6c7
     usage:
f3e6c7
 	printf("usage: %s [-l user] [-a] host-name [port]\r\n", cmd);
f3e6c7
-	seteuid(getuid());
f3e6c7
-	setuid(getuid());
f3e6c7
 	return 0;
f3e6c7
     }
f3e6c7
     if (hostp == 0)
f3e6c7
@@ -2340,185 +2337,80 @@
f3e6c7
 	temp = sourceroute(hostp, &srp, &srlen);
f3e6c7
 	if (temp == 0) {
f3e6c7
 	    herror(srp);
f3e6c7
-	    seteuid(getuid());
f3e6c7
-	    setuid(getuid());
f3e6c7
 	    return 0;
f3e6c7
 	} else if (temp == -1) {
f3e6c7
 	    printf("Bad source route option: %s\r\n", hostp);
f3e6c7
-	    seteuid(getuid());
f3e6c7
-	    setuid(getuid());
f3e6c7
 	    return 0;
f3e6c7
 	} else {
f3e6c7
 	    abort();
f3e6c7
 	}
f3e6c7
-    } else {
f3e6c7
-#endif
f3e6c7
-	memset (&sin, 0, sizeof(sin));
f3e6c7
-#if defined(HAVE_INET_PTON) && defined(AF_INET6)
f3e6c7
-	memset (&sin6, 0, sizeof(sin6));
f3e6c7
-
f3e6c7
-	if(inet_pton(AF_INET6, hostp, &sin6.sin6_addr)) {
f3e6c7
-	    sin6.sin6_family = family = AF_INET6;
f3e6c7
-	    sa = (struct sockaddr *)&sin;;
f3e6c7
-	    sa_size = sizeof(sin6);
f3e6c7
-	    strcpy(_hostname, hostp);
f3e6c7
-	    hostname =_hostname;
f3e6c7
-	} else
f3e6c7
-#endif
f3e6c7
-	    if(inet_aton(hostp, &sin.sin_addr)){
f3e6c7
-		sin.sin_family = family = AF_INET;
f3e6c7
-		sa = (struct sockaddr *)&sin;
f3e6c7
-		sa_size = sizeof(sin);
f3e6c7
-		strcpy(_hostname, hostp);
f3e6c7
-		hostname = _hostname;
f3e6c7
-	    } else {
f3e6c7
-#ifdef HAVE_GETHOSTBYNAME2
f3e6c7
-		host = gethostbyname2(hostp, AF_INET6);
f3e6c7
-		if(host == NULL)
f3e6c7
-		    host = gethostbyname2(hostp, AF_INET);
f3e6c7
-#else
f3e6c7
-		host = gethostbyname(hostp);
f3e6c7
-#endif
f3e6c7
-		if (host) {
f3e6c7
-		    strncpy(_hostname, host->h_name, sizeof(_hostname));
f3e6c7
-		    family = host->h_addrtype;
f3e6c7
-
f3e6c7
-		    switch(family) {
f3e6c7
-		    case AF_INET:
f3e6c7
-			memset(&sin, 0, sizeof(sin));
f3e6c7
-			sa_size = sizeof(sin);
f3e6c7
-			sa = (struct sockaddr *)&sin;
f3e6c7
-			sin.sin_family = family;
f3e6c7
-
f3e6c7
-			memcpy(&sin.sin_addr, *host->h_addr_list, sizeof(struct in_addr));
f3e6c7
-			break;
f3e6c7
-#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6)
f3e6c7
-		    case AF_INET6:
f3e6c7
-			memset(&sin6, 0, sizeof(sin6));
f3e6c7
-			sa_size = sizeof(sin6);
f3e6c7
-			sa = (struct sockaddr *)&sin;;
f3e6c7
-			sin6.sin6_family = family;
f3e6c7
-			memcpy(&sin6.sin6_addr, *host->h_addr_list, sizeof(struct in6_addr));
f3e6c7
-			break;
f3e6c7
-#endif
f3e6c7
-		    default:
f3e6c7
-			fprintf(stderr, "Bad address family: %d\n", family);
f3e6c7
-			return 0;
f3e6c7
-		    }
f3e6c7
-		    
f3e6c7
-		    _hostname[sizeof(_hostname)-1] = '\0';
f3e6c7
-		    hostname = _hostname;
f3e6c7
-		} else {
f3e6c7
-		    herror(hostp);
f3e6c7
-		    seteuid(getuid());
f3e6c7
-		    setuid(getuid());
f3e6c7
-		    return 0;
f3e6c7
-		}
f3e6c7
-	    }
f3e6c7
-#if	defined(IP_OPTIONS) && defined(IPPROTO_IP)
f3e6c7
-    }
f3e6c7
+    } else
f3e6c7
 #endif
f3e6c7
-    if (portp) {
f3e6c7
-	if (*portp == '-') {
f3e6c7
-	    portp++;
f3e6c7
-	    telnetport = 1;
f3e6c7
-	} else
f3e6c7
-	    telnetport = 0;
f3e6c7
-	port = atoi(portp);
f3e6c7
-	if (port == 0) {
f3e6c7
-	    sp = getservbyname(portp, "tcp");
f3e6c7
-	    if (sp)
f3e6c7
-		port = sp->s_port;
f3e6c7
-	    else {
f3e6c7
-		printf("%s: bad port number\r\n", portp);
f3e6c7
-		seteuid(getuid());
f3e6c7
-		setuid(getuid());
f3e6c7
-		return 0;
f3e6c7
-	    }
f3e6c7
-	} else {
f3e6c7
-	    port = htons(port);
f3e6c7
-	}
f3e6c7
-    } else {
f3e6c7
-	if (sp == 0) {
f3e6c7
-	    sp = getservbyname("telnet", "tcp");
f3e6c7
-	    if (sp == 0) {
f3e6c7
-		fprintf(stderr, "telnet: tcp/telnet: unknown service\r\n");
f3e6c7
-		seteuid(getuid());
f3e6c7
-		setuid(getuid());
f3e6c7
-		return 0;
f3e6c7
-	    }
f3e6c7
-	    port = sp->s_port;
f3e6c7
+    {
f3e6c7
+	hostname = hostp;
f3e6c7
+	memset(&hints, 0, sizeof(hints));
f3e6c7
+	hints.ai_family = PF_UNSPEC;
f3e6c7
+	hints.ai_socktype = SOCK_STREAM;
f3e6c7
+	hints.ai_flags = AI_CANONNAME;
f3e6c7
+	if (portp == NULL) {
f3e6c7
+		portp = "telnet";
f3e6c7
+	} else if (*portp == '-') {
f3e6c7
+		portp++;
f3e6c7
+		telnetport = 1;
f3e6c7
+	}
f3e6c7
+	h_errno = 0;
f3e6c7
+	error = getaddrinfo(hostp, portp, &hints, &res0);
f3e6c7
+	if (error) {
f3e6c7
+	    if (error == EAI_SERVICE)
f3e6c7
+	        warnx("%s: bad port", portp);
f3e6c7
+	    else
f3e6c7
+		warnx("%s: %s", hostp, gai_strerror(error));
f3e6c7
+	   if (h_errno)
f3e6c7
+		herror(hostp);
f3e6c7
+	   return 0;
f3e6c7
 	}
f3e6c7
-	telnetport = 1;
f3e6c7
     }
f3e6c7
-    switch(family) {
f3e6c7
-    case AF_INET:
f3e6c7
-	sin.sin_port = port;
f3e6c7
-	printf("Trying %s...\r\n", inet_ntoa(sin.sin_addr));
f3e6c7
-	break;
f3e6c7
-#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6)
f3e6c7
-    case AF_INET6: {
f3e6c7
-#ifndef INET6_ADDRSTRLEN
f3e6c7
-#define INET6_ADDRSTRLEN 46 
f3e6c7
-#endif
f3e6c7
 
f3e6c7
-	char buf[INET6_ADDRSTRLEN];
f3e6c7
-
f3e6c7
-	sin6.sin6_port = port;
f3e6c7
-#ifdef HAVE_INET_NTOP
f3e6c7
-	printf("Trying %s...\r\n", inet_ntop(AF_INET6,
f3e6c7
-					     &sin6.sin6_addr,
f3e6c7
-					     buf,
f3e6c7
-					     sizeof(buf)));
f3e6c7
-#endif
f3e6c7
-	break;
f3e6c7
-    }
f3e6c7
-#endif
f3e6c7
-    default:
f3e6c7
-	abort();
f3e6c7
-    }
f3e6c7
-
f3e6c7
-    do {
f3e6c7
-	net = socket(family, SOCK_STREAM, 0);
f3e6c7
-	seteuid(getuid());
f3e6c7
-	setuid(getuid());
f3e6c7
-	if (net < 0) {
f3e6c7
-	    perror("telnet: socket");
f3e6c7
-	    return 0;
f3e6c7
+    net = -1;
f3e6c7
+    retry = 0;
f3e6c7
+    for (res = res0; res; res = res->ai_next) {
f3e6c7
+	if (1 /* retry */) {
f3e6c7
+	    char hbuf[NI_MAXHOST];
f3e6c7
+	    
f3e6c7
+	    if (getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof(hbuf),
f3e6c7
+	            NULL, 0, niflags) != 0) {
f3e6c7
+		strcpy(hbuf, "(invalid)");
f3e6c7
+	    }
f3e6c7
+	    printf("Trying %s...\r\n", hbuf);
f3e6c7
 	}
f3e6c7
+	net = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
f3e6c7
+	if (net < 0)
f3e6c7
+	    continue;
f3e6c7
+	    
f3e6c7
 	if (aliasp) {
f3e6c7
-	    memset ((caddr_t)&ladr, 0, sizeof (ladr));
f3e6c7
-	    temp = inet_addr(aliasp);
f3e6c7
-	    if (temp != INADDR_NONE) {
f3e6c7
-	        ladr.sin_addr.s_addr = temp;
f3e6c7
-	        ladr.sin_family = AF_INET;
f3e6c7
-	        alias = gethostbyaddr((char *)&temp, sizeof(temp), AF_INET);
f3e6c7
-	    } else {
f3e6c7
-	        alias = gethostbyname(aliasp);
f3e6c7
-	        if (alias) {
f3e6c7
-		    ladr.sin_family = alias->h_addrtype;
f3e6c7
-#if	defined(h_addr)		/* In 4.3, this is a #define */
f3e6c7
-		    memmove((caddr_t)&ladr.sin_addr,
f3e6c7
-			alias->h_addr_list[0], alias->h_length);
f3e6c7
-#else	/* defined(h_addr) */
f3e6c7
-		    memmove((caddr_t)&ladr.sin_addr, alias->h_addr,
f3e6c7
-			alias->h_length);
f3e6c7
-#endif	/* defined(h_addr) */
f3e6c7
-	        } else {
f3e6c7
-		    herror(aliasp);
f3e6c7
-		    return 0;
f3e6c7
-	        }
f3e6c7
+	    struct addrinfo ahints, *ares;
f3e6c7
+	    memset(&ahints, 0, sizeof(ahints));
f3e6c7
+	    ahints.ai_family = PF_UNSPEC;
f3e6c7
+	    ahints.ai_socktype = SOCK_STREAM;
f3e6c7
+	    ahints.ai_flags = AI_PASSIVE;
f3e6c7
+	    error = getaddrinfo(aliasp, "0", &ahints, &ares);
f3e6c7
+	    if (error) {
f3e6c7
+	        warn("%s: %s", aliasp, gai_strerror(error));
f3e6c7
+	        close(net);
f3e6c7
+	        freeaddrinfo(ares);
f3e6c7
+	        continue;
f3e6c7
 	    }
f3e6c7
-            ladr.sin_port = htons(0);
f3e6c7
-  
f3e6c7
-            if (bind (net, (struct sockaddr *)&ladr, sizeof(ladr)) < 0) {
f3e6c7
-                perror(aliasp);; 
f3e6c7
+	    if (bind(net, ares->ai_addr, ares->ai_addrlen) < 0) {
f3e6c7
+	        perror(aliasp);
f3e6c7
                 (void) close(net);   /* dump descriptor */
f3e6c7
-		return 0;
f3e6c7
+		freeaddrinfo(ares);
f3e6c7
+		continue;
f3e6c7
             }
f3e6c7
+	    freeaddrinfo(ares);
f3e6c7
         }
f3e6c7
  #if	defined(IP_OPTIONS) && defined(IPPROTO_IP)
f3e6c7
-	if (srp && setsockopt(net, IPPROTO_IP, IP_OPTIONS, (char *)srp, srlen) < 0)
f3e6c7
+	if (srp && res->ai_family == AF_INET
f3e6c7
+	 && setsockopt(net, IPPROTO_IP, IP_OPTIONS, (char *)srp, srlen) < 0)
f3e6c7
 		perror("setsockopt (IP_OPTIONS)");
f3e6c7
 #endif
f3e6c7
 #if	defined(IPPROTO_IP) && defined(IP_TOS)
f3e6c7
@@ -2542,65 +2434,32 @@
f3e6c7
 		perror("setsockopt (SO_DEBUG)");
f3e6c7
 	}
f3e6c7
 
f3e6c7
-	if (connect(net, sa, sa_size) < 0) {
f3e6c7
-	    int retry = 0;
f3e6c7
-
f3e6c7
-	    if (host && host->h_addr_list[1]) {
f3e6c7
-		int oerrno = errno;
f3e6c7
-	        retry = 1;
f3e6c7
-
f3e6c7
-		switch(family) {
f3e6c7
-		case AF_INET :
f3e6c7
-		    fprintf(stderr, "telnet: connect to address %s: ",
f3e6c7
-			    inet_ntoa(sin.sin_addr));
f3e6c7
-		    ++host->h_addr_list;
f3e6c7
-		    memcpy(&sin.sin_addr, *host->h_addr_list, sizeof(struct in_addr));
f3e6c7
-		    break;
f3e6c7
-#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6)
f3e6c7
-		case AF_INET6: {
f3e6c7
-		    char buf[INET6_ADDRSTRLEN];
f3e6c7
-
f3e6c7
-		    fprintf(stderr, "telnet: connect to address %s: ",
f3e6c7
-			    inet_ntop(AF_INET6, &sin6.sin6_addr, buf,
f3e6c7
-				      sizeof(buf)));
f3e6c7
-		    ++host->h_addr_list;
f3e6c7
-		    memcpy(&sin6.sin6_addr, *host->h_addr_list, sizeof(struct in6_addr));
f3e6c7
-		    break;
f3e6c7
-		}
f3e6c7
-#endif
f3e6c7
-		default:
f3e6c7
-		    abort();
f3e6c7
-		}
f3e6c7
-                   
f3e6c7
-		errno = oerrno;
f3e6c7
-		perror(NULL);
f3e6c7
-
f3e6c7
-		switch(family) {
f3e6c7
-		case AF_INET :
f3e6c7
-			printf("Trying %s...\r\n", inet_ntoa(sin.sin_addr));
f3e6c7
-			break;
f3e6c7
-#if defined(AF_INET6) && defined(HAVE_STRUCT_SOCKADDR_IN6)
f3e6c7
-		case AF_INET6: {
f3e6c7
-		    printf("Trying %s...\r\n", inet_ntop(AF_INET6,
f3e6c7
-					     &sin6.sin6_addr,
f3e6c7
-					     buf,
f3e6c7
-					     sizeof(buf)));
f3e6c7
-		    break;
f3e6c7
-		}
f3e6c7
-#endif
f3e6c7
-		}
f3e6c7
-		
f3e6c7
-		(void) NetClose(net);
f3e6c7
-		continue;
f3e6c7
+	if (connect(net, res->ai_addr, res->ai_addrlen) < 0) {
f3e6c7
+	    char hbuf[NI_MAXHOST];
f3e6c7
+	    
f3e6c7
+	    if (getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof(hbuf),
f3e6c7
+		    NULL, 0, NI_NUMERICHOST) != 0) {
f3e6c7
+	        strcpy(hbuf, "(invalid)");
f3e6c7
 	    }
f3e6c7
-	    perror("telnet: Unable to connect to remote host");
f3e6c7
-	    return 0;
f3e6c7
+	    fprintf(stderr, "telnet: connect to address %s: %s\n", hbuf,
f3e6c7
+	        strerror(errno));
f3e6c7
+	
f3e6c7
+	    close(net);
f3e6c7
+	    net = -1;
f3e6c7
+	    retry++;
f3e6c7
+	    continue;
f3e6c7
 	}
f3e6c7
+
f3e6c7
 	connected++;
f3e6c7
 #if	defined(AUTHENTICATION) || defined(ENCRYPTION)
f3e6c7
 	auth_encrypt_connect(connected);
f3e6c7
 #endif	/* defined(AUTHENTICATION) */
f3e6c7
-    } while (connected == 0);
f3e6c7
+	break;
f3e6c7
+    }
f3e6c7
+    freeaddrinfo(res0);
f3e6c7
+    if (net < 0) {
f3e6c7
+        return 0;
f3e6c7
+    }
f3e6c7
     cmdrc(hostp, hostname);
f3e6c7
     if (autologin && user == NULL) {
f3e6c7
 	struct passwd *pw;
f3e6c7
@@ -2652,6 +2511,9 @@
f3e6c7
         encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)",
f3e6c7
 #endif
f3e6c7
 	zhelp[] =	"suspend telnet",
f3e6c7
+#ifdef SKEY
f3e6c7
+	skeyhelp[] =	"compute response to s/key challenge",
f3e6c7
+#endif
f3e6c7
 	shellhelp[] =	"invoke a subshell",
f3e6c7
 	envhelp[] =	"change environment variables ('environ ?' for more)",
f3e6c7
 	modestring[] = "try to enter line or character mode ('mode ?' for more)";
f3e6c7
@@ -2690,7 +2552,7 @@
f3e6c7
 	{ "environ",	envhelp,	env_cmd,	0 },
f3e6c7
 	{ "?",		helphelp,	help,		0 },
f3e6c7
 #if	defined(SKEY)
f3e6c7
-	{ "skey",	NULL,		skey_calc,	0 },
f3e6c7
+	{ "skey",	skeyhelp,	skey_calc,	0 },
f3e6c7
 #endif		
f3e6c7
 	{ 0,		0,		0,		0 }
f3e6c7
 };
f3e6c7
diff -uNr telnet/externs.h telnet.obsd-cvs/externs.h
f3e6c7
--- telnet/externs.h	Mon Feb  8 22:56:11 1999
f3e6c7
+++ telnet.obsd-cvs/externs.h	Sat Mar 10 10:54:35 2001
f3e6c7
@@ -1,4 +1,4 @@
f3e6c7
-/*	$OpenBSD: externs.h,v 1.4 1998/03/12 17:31:32 deraadt Exp $	*/
f3e6c7
+/*	$OpenBSD: externs.h,v 1.5 1998/03/12 2001/01/22 11:03:38 fgsch Exp $	*/
f3e6c7
 /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
f3e6c7
 
f3e6c7
 /*
f3e6c7
@@ -447,7 +447,7 @@
f3e6c7
     *Ibackp,           /* Oldest byte of 3270 data */
f3e6c7
     Ibuf[],            /* 3270 buffer */
f3e6c7
     *Ifrontp,          /* Where next 3270 byte goes */
f3e6c7
-    tline[],
f3e6c7
+    tline[200],
f3e6c7
     *transcom;         /* Transparent command */
f3e6c7
 
f3e6c7
 extern int
f3e6c7
diff -uNr telnet/main.c telnet.obsd-cvs/main.c
f3e6c7
--- telnet/main.c	Wed Apr  7 23:23:35 1999
f3e6c7
+++ telnet.obsd-cvs/main.c	Sat Mar 10 09:59:35 2001
f3e6c7
@@ -1,4 +1,4 @@
f3e6c7
-/*	$OpenBSD: main.c,v 1.7 1998/05/15 03:16:38 art Exp $	*/
f3e6c7
+/*	$OpenBSD: main.c,v 1.10 2001/01/21 22:46:37 aaron Exp $	*/
f3e6c7
 /*	$NetBSD: main.c,v 1.5 1996/02/28 21:04:05 thorpej Exp $	*/
f3e6c7
 
f3e6c7
 /*
f3e6c7
@@ -81,10 +81,10 @@
f3e6c7
 	    prompt,
f3e6c7
 #ifdef	AUTHENTICATION
f3e6c7
 	    "[-8] [-E] [-K] [-L] [-S tos] [-X atype] [-a] [-c] [-d] [-e char]",
f3e6c7
-	    "\n\t[-k realm] [-l user] [-f/-F] [-n tracefile] [-b hostalias ]",
f3e6c7
+	    "\n\t[-k realm] [-l user] [-f/-F] [-n tracefile] [-b hostalias ] ",
f3e6c7
 #else
f3e6c7
 	    "[-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]",
f3e6c7
-	    "\n\t[-n tracefile] [-b hostalias ]",
f3e6c7
+	    "\n\t[-n tracefile] [-b hostalias ] ",
f3e6c7
 #endif
f3e6c7
 #if defined(TN3270) && defined(unix)
f3e6c7
 # ifdef AUTHENTICATION
f3e6c7
@@ -95,13 +95,11 @@
f3e6c7
 #else
f3e6c7
 	    "[-r] ",
f3e6c7
 #endif
f3e6c7
+	    "\n\r "
f3e6c7
 #ifdef ENCRYPTION
f3e6c7
-	    "[-x] [host-name [port]]"
f3e6c7
-#else
f3e6c7
-
f3e6c7
-	    "[host-name [port]]"
f3e6c7
+	    "[-x] " 
f3e6c7
 #endif
f3e6c7
-	);
f3e6c7
+	    "[host-name [port]]");
f3e6c7
 	exit(1);
f3e6c7
 }
f3e6c7
 
f3e6c7
@@ -276,8 +274,8 @@
f3e6c7
 			break;
f3e6c7
 		case 't':
f3e6c7
 #if defined(TN3270) && defined(unix)
f3e6c7
+			(void)strncpy(tline, optarg, sizeof(tline));
f3e6c7
 			transcom = tline;
f3e6c7
-			(void)strcpy(transcom, optarg);
f3e6c7
 #else
f3e6c7
 			fprintf(stderr,
f3e6c7
 			   "%s: Warning: -t ignored, no TN3270 support.\n",
f3e6c7
diff -uNr telnet/sys_bsd.c telnet.obsd-cvs/sys_bsd.c
f3e6c7
--- telnet/sys_bsd.c	Wed Apr  7 21:38:31 1999
f3e6c7
+++ telnet.obsd-cvs/sys_bsd.c	Sat Mar 10 10:55:18 2001
f3e6c7
@@ -1,4 +1,4 @@
f3e6c7
-/*	$OpenBSD: sys_bsd.c,v 1.6 1998/12/28 11:13:51 deraadt Exp $	*/
f3e6c7
+/*	$OpenBSD: sys_bsd.c,v 1.8 2000/10/10 15:41:10 millert Exp $	*/
f3e6c7
 /*	$NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $	*/
f3e6c7
 
f3e6c7
 /*
f3e6c7
@@ -35,6 +35,7 @@
f3e6c7
  */
f3e6c7
 
f3e6c7
 #include "telnet_locl.h"
f3e6c7
+#include <err.h>
f3e6c7
 
f3e6c7
 /*
f3e6c7
  * The following routines try to encapsulate what is system dependent
f3e6c7
@@ -198,9 +199,10 @@
f3e6c7
 TerminalFlushOutput(void)
f3e6c7
 {
f3e6c7
 #ifdef	TIOCFLUSH
f3e6c7
-    (void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0);
f3e6c7
+    int com = FWRITE;
f3e6c7
+    (void) ioctl(fileno(stdout), TIOCFLUSH, (int *) &com);
f3e6c7
 #else
f3e6c7
-    (void) ioctl(fileno(stdout), TCFLSH, (char *) 0);
f3e6c7
+    (void) ioctl(fileno(stdout), TCFLSH, (int *) 0);
f3e6c7
 #endif
f3e6c7
 }
f3e6c7
 
f3e6c7
diff -uNr telnet/telnet.c telnet.obsd-cvs/telnet.c
f3e6c7
--- telnet/telnet.c	Wed Apr  7 23:22:14 1999
f3e6c7
+++ telnet.obsd-cvs/telnet.c	Sat Mar 10 11:02:34 2001
f3e6c7
@@ -1,4 +1,4 @@
f3e6c7
-/*	$OpenBSD: telnet.c,v 1.6 1998/07/27 15:29:29 millert Exp $	*/
f3e6c7
+/*	$OpenBSD: telnet.c,v 1.11 2000/11/10 15:33:13 provos millert Exp $	*/
f3e6c7
 /*	$NetBSD: telnet.c,v 1.7 1996/02/28 21:04:15 thorpej Exp $	*/
f3e6c7
 
f3e6c7
 /*
f3e6c7
@@ -35,6 +35,8 @@
f3e6c7
  */
f3e6c7
 
f3e6c7
 #include "telnet_locl.h"
f3e6c7
+#include <curses.h>
f3e6c7
+#include <term.h>
f3e6c7
 
f3e6c7
 #define        strip(x) (eight ? (x) : ((x) & 0x7f))
f3e6c7
 
f3e6c7
@@ -523,10 +525,9 @@
f3e6c7
 }
f3e6c7
 
f3e6c7
 /*
f3e6c7
- * Given a buffer returned by tgetent(), this routine will turn
f3e6c7
- * the pipe seperated list of names in the buffer into an array
f3e6c7
- * of pointers to null terminated names.  We toss out any bad,
f3e6c7
- * duplicate, or verbose names (names with spaces).
f3e6c7
+ * This routine will turn a pipe seperated list of names in the buffer
f3e6c7
+ * into an array of pointers to NUL terminated names.  We toss out any
f3e6c7
+ * bad, duplicate, or verbose names (names with spaces).
f3e6c7
  */
f3e6c7
 
f3e6c7
 int is_unique P((char *, char **, char **));
f3e6c7
@@ -554,7 +555,7 @@
f3e6c7
 	/*
f3e6c7
 	 * Count up the number of names.
f3e6c7
 	 */
f3e6c7
-	for (n = 1, cp = buf; *cp && *cp != ':'; cp++) {
f3e6c7
+	for (n = 1, cp = buf; *cp; cp++) {
f3e6c7
 		if (*cp == '|')
f3e6c7
 			n++;
f3e6c7
 	}
f3e6c7
@@ -659,25 +660,6 @@
f3e6c7
 	return (1);
f3e6c7
 }
f3e6c7
 
f3e6c7
-static char termbuf[1024];
f3e6c7
-
f3e6c7
-int telnet_setupterm	P((char *tname, int fd, int *errp)); /* XXX move elsewhere */
f3e6c7
-	/*ARGSUSED*/
f3e6c7
-	int
f3e6c7
-telnet_setupterm(char *tname, int fd, int *errp)
f3e6c7
-{
f3e6c7
-	(void)fd;
f3e6c7
-	if (tgetent(termbuf, tname) == 1) {
f3e6c7
-		termbuf[1023] = '\0';
f3e6c7
-		if (errp)
f3e6c7
-			*errp = 1;
f3e6c7
-		return(0);
f3e6c7
-	}
f3e6c7
-	if (errp)
f3e6c7
-		*errp = 0;
f3e6c7
-	return(-1);
f3e6c7
-}
f3e6c7
-
f3e6c7
 int resettermname = 1;
f3e6c7
 
f3e6c7
 char *gettermname P((void));	/* XXX move elsewhere */
f3e6c7
@@ -687,15 +669,15 @@
f3e6c7
 	char *tname;
f3e6c7
 	static char **tnamep = 0;
f3e6c7
 	static char **next;
f3e6c7
-	int err;
f3e6c7
+	int errret;
f3e6c7
 
f3e6c7
 	if (resettermname) {
f3e6c7
 		resettermname = 0;
f3e6c7
 		if (tnamep && tnamep != unknown)
f3e6c7
 			free(tnamep);
f3e6c7
 		if ((tname = (char *)env_getvalue((unsigned char *)"TERM")) &&
f3e6c7
-				(telnet_setupterm(tname, 1, &err) == 0)) {
f3e6c7
-			tnamep = mklist(termbuf, tname);
f3e6c7
+				(setupterm(tname, 1, &errret) == 0)) {
f3e6c7
+			tnamep = mklist(ttytype, tname);
f3e6c7
 		} else {
f3e6c7
 			if (tname && ((int)strlen(tname) <= 40)) {
f3e6c7
 				unknown[0] = tname;
f3e6c7
@@ -1482,10 +1464,15 @@
f3e6c7
 	void
f3e6c7
 env_opt_start(void)
f3e6c7
 {
f3e6c7
-	if (opt_reply)
f3e6c7
-		opt_reply = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE);
f3e6c7
-	else
f3e6c7
-		opt_reply = (unsigned char *)malloc(OPT_REPLY_SIZE);
f3e6c7
+	unsigned char *p;
f3e6c7
+	
f3e6c7
+	if (opt_reply) {
f3e6c7
+		p = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE);
f3e6c7
+		if (p == NULL)
f3e6c7
+			free(opt_reply);
f3e6c7
+	} else
f3e6c7
+		p = (unsigned char *)malloc(OPT_REPLY_SIZE);
f3e6c7
+	opt_reply = p;	
f3e6c7
 	if (opt_reply == NULL) {
f3e6c7
 /*@*/		printf("env_opt_start: malloc()/realloc() failed!!!\n");
f3e6c7
 		opt_reply = opt_replyp = opt_replyend = NULL;
f3e6c7
@@ -1532,9 +1519,13 @@
f3e6c7
 				strlen((char *)ep) + 6 > opt_replyend)
f3e6c7
 	{
f3e6c7
 		int len;
f3e6c7
+		unsigned char *p;
f3e6c7
 		opt_replyend += OPT_REPLY_SIZE;
f3e6c7
 		len = opt_replyend - opt_reply;
f3e6c7
-		opt_reply = (unsigned char *)realloc(opt_reply, len);
f3e6c7
+		p = (unsigned char *)realloc(opt_reply, len);
f3e6c7
+		if (p == NULL)
f3e6c7
+			free(opt_reply);
f3e6c7
+		opt_reply = p;
f3e6c7
 		if (opt_reply == NULL) {
f3e6c7
 /*@*/			printf("env_opt_add: realloc() failed!!!\n");
f3e6c7
 			opt_reply = opt_replyp = opt_replyend = NULL;
f3e6c7
@@ -1945,7 +1936,7 @@
f3e6c7
 				command(0, "z\n", 2);
f3e6c7
 				continue;
f3e6c7
 			}
f3e6c7
-			if (sc == escape) {
f3e6c7
+			if (sc == escape && escape != _POSIX_VDISABLE) {
f3e6c7
 				command(0, (char *)tbp, tcc);
f3e6c7
 				bol = 1;
f3e6c7
 				count += tcc;
f3e6c7
@@ -1962,7 +1953,7 @@
f3e6c7
 		}
f3e6c7
 		if ((sc == '\n') || (sc == '\r'))
f3e6c7
 			bol = 1;
f3e6c7
-	} else if (sc == escape) {
f3e6c7
+	} else if (sc == escape && escape != _POSIX_VDISABLE) {
f3e6c7
 	    /*
f3e6c7
 	     * Double escape is a pass through of a single escape character.
f3e6c7
 	     */
f3e6c7
diff -uNr telnet/telnet_locl.h telnet.obsd-cvs/telnet_locl.h
f3e6c7
--- telnet/telnet_locl.h	Thu Mar 12 06:57:44 1998
f3e6c7
+++ telnet.obsd-cvs/telnet_locl.h	Sat Mar 10 11:12:37 2001
f3e6c7
@@ -1,4 +1,4 @@
f3e6c7
-/*	$OpenBSD: telnet_locl.h,v 1.1 1998/03/12 04:57:44 art Exp $	*/
f3e6c7
+/*	$OpenBSD: telnet_locl.h,v 1.2 1999/12/11 09:08:09 itojun Exp $	*/
f3e6c7
 /* $KTH: telnet_locl.h,v 1.13 1997/11/03 21:37:55 assar Exp $ */
f3e6c7
 
f3e6c7
 /*
f3e6c7
@@ -86,7 +86,5 @@
f3e6c7
 #include "defines.h"
f3e6c7
 #include "types.h"
f3e6c7
 
f3e6c7
-#undef AF_INET6 /* XXX - it has not been tested and it doesn't exist yet */
f3e6c7
-
f3e6c7
 /* prototypes */
f3e6c7
 
f3e6c7
diff -uNr libtelnet/kerberos.c libtelnet.obsd-cvs/kerberos.c
f3e6c7
--- libtelnet/kerberos.c	Mon Feb  8 23:38:17 1999
f3e6c7
+++ libtelnet.obsd-cvs/kerberos.c	Sat Mar 10 11:11:03 2001
f3e6c7
@@ -320,11 +320,10 @@
f3e6c7
 	    char ts[MAXPATHLEN];
f3e6c7
 	    struct passwd *pw = getpwnam(UserNameRequested);
f3e6c7
 
f3e6c7
-	    if(pw){
f3e6c7
+	    if (pw) {
f3e6c7
 		snprintf(ts, sizeof(ts),
f3e6c7
-			 "%s%u",
f3e6c7
-			 TKT_ROOT,
f3e6c7
-			 (unsigned)pw->pw_uid);
f3e6c7
+			"%s%u", TKT_ROOT, (unsigned)pw->pw_uid);
f3e6c7
+		/* XXX allocation failure? */
f3e6c7
 		setenv("KRBTKFILE", ts, 1);
f3e6c7
 	    }
f3e6c7
 	    Data(ap, KRB_ACCEPT, NULL, 0);
f3e6c7
@@ -609,16 +608,26 @@
f3e6c7
 {
f3e6c7
     unsigned char *p = buf;
f3e6c7
     
f3e6c7
-    p += krb_put_nir(cred->service, cred->instance, cred->realm, p);
f3e6c7
+    memcpy (p, cred->service, ANAME_SZ);
f3e6c7
+    p += ANAME_SZ;
f3e6c7
+    memcpy (p, cred->instance, INST_SZ);
f3e6c7
+    p += INST_SZ;
f3e6c7
+    memcpy (p, cred->realm, REALM_SZ);
f3e6c7
+    p += REALM_SZ;
f3e6c7
     memcpy(p, cred->session, 8);
f3e6c7
     p += 8;
f3e6c7
     *p++ = cred->lifetime;
f3e6c7
     *p++ = cred->kvno;
f3e6c7
-    p += krb_put_int(cred->ticket_st.length, p, 4);
f3e6c7
+    p += krb_put_int(cred->ticket_st.length, p, 4, 4);
f3e6c7
     memcpy(p, cred->ticket_st.dat, cred->ticket_st.length);
f3e6c7
     p += cred->ticket_st.length;
f3e6c7
-    p += krb_put_int(cred->issue_date, p, 4);
f3e6c7
-    p += krb_put_nir(cred->pname, cred->pinst, NULL, p);
f3e6c7
+    p += krb_put_int(cred->issue_date, p, 4, 4);
f3e6c7
+    strncpy (cred->pname, p, ANAME_SZ);
f3e6c7
+    cred->pname[ANAME_SZ - 1] = '\0';
f3e6c7
+    p += ANAME_SZ;
f3e6c7
+    strncpy (cred->pinst, p, INST_SZ);
f3e6c7
+    cred->pinst[INST_SZ - 1] = '\0';
f3e6c7
+    p += INST_SZ;
f3e6c7
     return p - buf;
f3e6c7
 }
f3e6c7
 
f3e6c7
@@ -627,7 +636,16 @@
f3e6c7
 {
f3e6c7
     unsigned char *p = buf;
f3e6c7
 
f3e6c7
-    p += krb_get_nir(p, cred->service, cred->instance, cred->realm);
f3e6c7
+    strncpy (cred->service, p, ANAME_SZ);
f3e6c7
+    cred->service[ANAME_SZ - 1] = '\0';
f3e6c7
+    p += ANAME_SZ;
f3e6c7
+    strncpy (cred->instance, p, INST_SZ);
f3e6c7
+    cred->instance[INST_SZ - 1] = '\0';
f3e6c7
+    p += INST_SZ;
f3e6c7
+    strncpy (cred->realm, p, REALM_SZ);
f3e6c7
+    cred->realm[REALM_SZ - 1] = '\0';
f3e6c7
+    p += REALM_SZ;
f3e6c7
+
f3e6c7
     memcpy(cred->session, p, 8);
f3e6c7
     p += 8;
f3e6c7
     cred->lifetime = *p++;
f3e6c7
@@ -636,7 +654,10 @@
f3e6c7
     memcpy(cred->ticket_st.dat, p, cred->ticket_st.length);
f3e6c7
     cred->ticket_st.mbz = 0;
f3e6c7
     p += krb_get_int(p, (u_int32_t *)&cred->issue_date, 4, 0);
f3e6c7
-    p += krb_get_nir(p, cred->pname, cred->pinst, NULL);
f3e6c7
+    p += krb_get_nir(p, 
f3e6c7
+		    cred->pname, sizeof(cred->pname),
f3e6c7
+		    cred->pinst, sizeof(cred->pinst),
f3e6c7
+		    NULL, 0);
f3e6c7
     return 0;
f3e6c7
 }
f3e6c7
 
f3e6c7
--- telnet/telnet.1	Thu Nov 12 01:01:46 1998
f3e6c7
+++ telnet.obsd-cvs/telnet.1	Thu Nov  9 19:52:41 2000
f3e6c7
@@ -1,4 +1,4 @@
f3e6c7
-.\"	$OpenBSD: telnet.1,v 1.14 1998/11/11 23:01:46 aaron Exp $
f3e6c7
+.\"	$OpenBSD: telnet.1,v 1.27 2000/11/09 17:52:41 aaron Exp $
f3e6c7
 .\"	$NetBSD: telnet.1,v 1.5 1996/02/28 21:04:12 thorpej Exp $
f3e6c7
 .\"
f3e6c7
 .\" Copyright (c) 1983, 1990, 1993
f3e6c7
@@ -36,45 +36,34 @@
f3e6c7
 .\"
f3e6c7
 .Dd February 3, 1994
f3e6c7
 .Dt TELNET 1
f3e6c7
-.Os BSD 4.2
f3e6c7
+.Os
f3e6c7
 .Sh NAME
f3e6c7
 .Nm telnet
f3e6c7
-.Nd user interface to the 
f3e6c7
+.Nd user interface to the
f3e6c7
 .Tn TELNET
f3e6c7
 protocol
f3e6c7
 .Sh SYNOPSIS
f3e6c7
 .Nm telnet
f3e6c7
-.Op Fl 8
f3e6c7
-.Op Fl E
f3e6c7
-.Op Fl F
f3e6c7
-.Op Fl K
f3e6c7
-.Op Fl L
f3e6c7
-.Op Fl S Ar tos
f3e6c7
+.Op Fl 8EFKLacdfrx
f3e6c7
 .Op Fl X Ar authtype
f3e6c7
-.Op Fl a
f3e6c7
 .Op Fl b Ar hostalias
f3e6c7
-.Op Fl c
f3e6c7
-.Op Fl d
f3e6c7
 .Op Fl e Ar escapechar
f3e6c7
-.Op Fl f
f3e6c7
 .Op Fl k Ar realm
f3e6c7
 .Op Fl l Ar user
f3e6c7
 .Op Fl n Ar tracefile
f3e6c7
-.Op Fl r
f3e6c7
-.Op Fl x
f3e6c7
 .Oo
f3e6c7
 .Ar host
f3e6c7
 .Op Ar port
f3e6c7
 .Oc
f3e6c7
 .Sh DESCRIPTION
f3e6c7
 The
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 command
f3e6c7
-is used to communicate with another host using the 
f3e6c7
+is used to communicate with another host using the
f3e6c7
 .Tn TELNET
f3e6c7
 protocol.
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is invoked without the
f3e6c7
 .Ar host
f3e6c7
 argument, it enters command mode,
f3e6c7
@@ -85,11 +74,11 @@
f3e6c7
 .Ic open
f3e6c7
 command with those arguments.
f3e6c7
 .Pp
f3e6c7
-Options:
f3e6c7
-.Bl -tag -width indent
f3e6c7
+The options are as follows:
f3e6c7
+.Bl -tag -width Ds
f3e6c7
 .It Fl 8
f3e6c7
-Specifies an 8-bit data path.  This causes an attempt to
f3e6c7
-negotiate the
f3e6c7
+Specifies an 8-bit data path.
f3e6c7
+This causes an attempt to negotiate the
f3e6c7
 .Dv TELNET BINARY
f3e6c7
 option on both input and output.
f3e6c7
 .It Fl E
f3e6c7
@@ -103,18 +92,9 @@
f3e6c7
 .It Fl K
f3e6c7
 Specifies no automatic login to the remote system.
f3e6c7
 .It Fl L
f3e6c7
-Specifies an 8-bit data path on output.  This causes the
f3e6c7
-BINARY option to be negotiated on output.
f3e6c7
-.It Fl S Ar tos
f3e6c7
-Sets the IP type-of-service (TOS) option for the telnet
f3e6c7
-connection to the value
f3e6c7
-.Ar tos ,
f3e6c7
-which can be a numeric TOS value
f3e6c7
-or, on systems that support it, a symbolic
f3e6c7
-TOS name found in the
f3e6c7
-.Pa /etc/iptos
f3e6c7
-file.
f3e6c7
-.It Fl X Ar atype 
f3e6c7
+Specifies an 8-bit data path on output.
f3e6c7
+This causes the BINARY option to be negotiated on output.
f3e6c7
+.It Fl X Ar atype
f3e6c7
 Disables the
f3e6c7
 .Ar atype
f3e6c7
 type of authentication.
f3e6c7
@@ -144,7 +124,8 @@
f3e6c7
 .It Fl c
f3e6c7
 Disables the reading of the user's
f3e6c7
 .Pa \&.telnetrc
f3e6c7
-file.  (See the
f3e6c7
+file.
f3e6c7
+(See the
f3e6c7
 .Ic toggle skiprc
f3e6c7
 command on this man page.)
f3e6c7
 .It Fl d
f3e6c7
@@ -152,7 +133,7 @@
f3e6c7
 .Ic debug
f3e6c7
 toggle to
f3e6c7
 .Dv TRUE .
f3e6c7
-.It Fl e Ar escapechar 
f3e6c7
+.It Fl e Ar escapechar
f3e6c7
 Sets the initial
f3e6c7
 .Nm
f3e6c7
 escape character to
f3e6c7
@@ -169,14 +150,14 @@
f3e6c7
 If Kerberos authentication is being used, the
f3e6c7
 .Fl k
f3e6c7
 option requests that
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 obtain tickets for the remote host in
f3e6c7
 realm
f3e6c7
 .Ar realm
f3e6c7
 instead of the remote host's realm, as determined
f3e6c7
 by
f3e6c7
 .Xr krb_realmofhost 3 .
f3e6c7
-.It Fl l Ar user 
f3e6c7
+.It Fl l Ar user
f3e6c7
 When connecting to the remote system, if the remote system
f3e6c7
 understands the
f3e6c7
 .Ev ENVIRON
f3e6c7
@@ -189,7 +170,7 @@
f3e6c7
 This option may also be used with the
f3e6c7
 .Ic open
f3e6c7
 command.
f3e6c7
-.It Fl n Ar tracefile 
f3e6c7
+.It Fl n Ar tracefile
f3e6c7
 Opens
f3e6c7
 .Ar tracefile
f3e6c7
 for recording trace information.
f3e6c7
@@ -210,35 +191,38 @@
f3e6c7
 Indicates the official name, an alias, or the Internet address
f3e6c7
 of a remote host.
f3e6c7
 .It Ar port
f3e6c7
-Indicates a port number (address of an application).  If a number is
f3e6c7
-not specified, the default
f3e6c7
-.Nm telnet
f3e6c7
+Indicates a port number (address of an application).
f3e6c7
+If a number is not specified, the default
f3e6c7
+.Nm
f3e6c7
 port is used.
f3e6c7
 .El
f3e6c7
 .Pp
f3e6c7
-When in rlogin mode, a line of the form ~.  disconnects from the
f3e6c7
+When in rlogin mode, a line of the form ~.
f3e6c7
+disconnects from the
f3e6c7
 remote host; ~ is the telnet escape character.
f3e6c7
 Similarly, the line ~^Z suspends the telnet session.
f3e6c7
 The line ~^] escapes to the normal telnet escape prompt.
f3e6c7
 .Pp
f3e6c7
 Once a connection has been opened,
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 will attempt to enable the
f3e6c7
 .Dv TELNET LINEMODE
f3e6c7
 option.
f3e6c7
 If this fails,
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 will revert to one of two input modes:
f3e6c7
 either ``character at a time''
f3e6c7
 or ``old line by line''
f3e6c7
 depending on what the remote system supports.
f3e6c7
 .Pp
f3e6c7
-When 
f3e6c7
+When
f3e6c7
 .Dv LINEMODE
f3e6c7
 is enabled, character processing is done on the
f3e6c7
-local system, under the control of the remote system.  When input
f3e6c7
+local system, under the control of the remote system.
f3e6c7
+When input
f3e6c7
 editing or character echoing is to be disabled, the remote system
f3e6c7
-will relay that information.  The remote system will also relay
f3e6c7
+will relay that information.
f3e6c7
+The remote system will also relay
f3e6c7
 changes to any special characters that happen on the remote
f3e6c7
 system, so that they can take effect on the local system.
f3e6c7
 .Pp
f3e6c7
@@ -252,7 +236,7 @@
f3e6c7
 (this would mostly be used to enter passwords
f3e6c7
 without the password being echoed).
f3e6c7
 .Pp
f3e6c7
-If the 
f3e6c7
+If the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option is enabled, or if the
f3e6c7
 .Ic localchars
f3e6c7
@@ -267,7 +251,7 @@
f3e6c7
 characters are trapped locally, and sent as
f3e6c7
 .Tn TELNET
f3e6c7
 protocol sequences to the remote side.
f3e6c7
-If 
f3e6c7
+If
f3e6c7
 .Dv LINEMODE
f3e6c7
 has ever been enabled, then the user's
f3e6c7
 .Ic susp
f3e6c7
@@ -278,9 +262,9 @@
f3e6c7
 protocol sequences,
f3e6c7
 and
f3e6c7
 .Ic quit
f3e6c7
-is sent as a 
f3e6c7
+is sent as a
f3e6c7
 .Dv TELNET ABORT
f3e6c7
-instead of 
f3e6c7
+instead of
f3e6c7
 .Dv BREAK .
f3e6c7
 There are options (see
f3e6c7
 .Ic toggle
f3e6c7
@@ -296,17 +280,26 @@
f3e6c7
 (in the case of
f3e6c7
 .Ic quit
f3e6c7
 and
f3e6c7
-.Ic intr  ) .
f3e6c7
+.Ic intr ) .
f3e6c7
 .Pp
f3e6c7
 While connected to a remote host,
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 command mode may be entered by typing the
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 ``escape character'' (initially ``^]'').
f3e6c7
 When in command mode, the normal terminal editing conventions are available.
f3e6c7
+Note that the escape character will return to the command mode of the initial
f3e6c7
+invocation of
f3e6c7
+.Nm
f3e6c7
+that has the controlling terminal.
f3e6c7
+Use the
f3e6c7
+.Cm send escape
f3e6c7
+command to switch to command mode in subsequent
f3e6c7
+.Nm
f3e6c7
+processes on remote hosts.
f3e6c7
 .Pp
f3e6c7
 The following
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 commands are available.
f3e6c7
 Only enough of each command to uniquely identify it need be typed
f3e6c7
 (this is also true for arguments to the
f3e6c7
@@ -320,26 +313,28 @@
f3e6c7
 .Ic display
f3e6c7
 commands).
f3e6c7
 .Bl -tag -width "mode type"
f3e6c7
-.It Ic auth Ar argument Op Ar ... 
f3e6c7
+.It Ic auth Ar argument Op Ar ...
f3e6c7
 The
f3e6c7
 .Ic auth
f3e6c7
 command manipulates the information sent through the
f3e6c7
 .Dv TELNET AUTHENTICATE
f3e6c7
-option.  Valid arguments for the
f3e6c7
-auth command are as follows:
f3e6c7
+option.
f3e6c7
+Valid arguments for the
f3e6c7
+.Ic auth
f3e6c7
+command are as follows:
f3e6c7
 .Bl -tag -width "disable type"
f3e6c7
 .It Ic disable Ar type
f3e6c7
 Disables the specified
f3e6c7
 .Ar type
f3e6c7
-of authentication.  To
f3e6c7
-obtain a list of available types, use the
f3e6c7
+of authentication.
f3e6c7
+To obtain a list of available types, use the
f3e6c7
 .Ic auth disable \&?
f3e6c7
 command.
f3e6c7
 .It Ic enable Ar type
f3e6c7
 Enables the specified
f3e6c7
 .Ar type
f3e6c7
-of authentication.  To
f3e6c7
-obtain a list of available types, use the
f3e6c7
+of authentication.
f3e6c7
+To obtain a list of available types, use the
f3e6c7
 .Ic auth enable \&?
f3e6c7
 command.
f3e6c7
 .It Ic status
f3e6c7
@@ -350,7 +345,7 @@
f3e6c7
 Close a
f3e6c7
 .Tn TELNET
f3e6c7
 session and return to command mode.
f3e6c7
-.It Ic display Ar argument Op Ar ... 
f3e6c7
+.It Ic display Ar argument Op Ar ...
f3e6c7
 Displays all, or some, of the
f3e6c7
 .Ic set
f3e6c7
 and
f3e6c7
@@ -368,26 +363,27 @@
f3e6c7
 .It Ic disable Ar type Ic [input|output]
f3e6c7
 Disables the specified
f3e6c7
 .Ar type
f3e6c7
-of encryption.  If you
f3e6c7
-omit
f3e6c7
+of encryption.
f3e6c7
+If you omit
f3e6c7
 .Ic input
f3e6c7
 and
f3e6c7
 .Ic output ,
f3e6c7
 both input and output
f3e6c7
-are disabled.  To obtain a list of available
f3e6c7
-types, use the
f3e6c7
+are disabled.
f3e6c7
+To obtain a list of available types, use the
f3e6c7
 .Ic encrypt disable \&?
f3e6c7
 command.
f3e6c7
 .It Ic enable Ar type Ic [input|output]
f3e6c7
 Enables the specified
f3e6c7
 .Ar type
f3e6c7
-of encryption.  If you
f3e6c7
-omit
f3e6c7
+of encryption.
f3e6c7
+If you omit
f3e6c7
 .Ic input
f3e6c7
 and
f3e6c7
 .Ic output ,
f3e6c7
 both input and output are
f3e6c7
-enabled.  To obtain a list of available types, use the
f3e6c7
+enabled.
f3e6c7
+To obtain a list of available types, use the
f3e6c7
 .Ic encrypt enable \&?
f3e6c7
 command.
f3e6c7
 .It Ic input
f3e6c7
@@ -407,18 +403,20 @@
f3e6c7
 .Ic encrypt stop output
f3e6c7
 command.
f3e6c7
 .It Ic start Ic [input|output]
f3e6c7
-Attempts to start encryption.  If you omit
f3e6c7
+Attempts to start encryption.
f3e6c7
+If you omit
f3e6c7
 .Ic input
f3e6c7
 and
f3e6c7
-.Ic output,
f3e6c7
-both input and output are enabled.  To
f3e6c7
-obtain a list of available types, use the
f3e6c7
+.Ic output ,
f3e6c7
+both input and output are enabled.
f3e6c7
+To obtain a list of available types, use the
f3e6c7
 .Ic encrypt enable \&?
f3e6c7
 command.
f3e6c7
 .It Ic status
f3e6c7
 Lists the current status of encryption.
f3e6c7
 .It Ic stop Ic [input|output]
f3e6c7
-Stops encryption.  If you omit
f3e6c7
+Stops encryption.
f3e6c7
+If you omit
f3e6c7
 .Ic input
f3e6c7
 and
f3e6c7
 .Ic output ,
f3e6c7
@@ -431,7 +429,7 @@
f3e6c7
 .Ic encrypt stop
f3e6c7
 commands.
f3e6c7
 .El
f3e6c7
-.It Ic environ Ar arguments Op Ar ... 
f3e6c7
+.It Ic environ Ar arguments Op Ar ...
f3e6c7
 The
f3e6c7
 .Ic environ
f3e6c7
 command is used to manipulate the
f3e6c7
@@ -456,7 +454,7 @@
f3e6c7
 .Ic environ
f3e6c7
 command are:
f3e6c7
 .Bl -tag -width Fl
f3e6c7
-.It Ic define Ar variable value 
f3e6c7
+.It Ic define Ar variable value
f3e6c7
 Define the variable
f3e6c7
 .Ar variable
f3e6c7
 to have a value of
f3e6c7
@@ -466,15 +464,15 @@
f3e6c7
 .Ar value
f3e6c7
 may be enclosed in single or double quotes so
f3e6c7
 that tabs and spaces may be included.
f3e6c7
-.It Ic undefine Ar variable 
f3e6c7
+.It Ic undefine Ar variable
f3e6c7
 Remove
f3e6c7
 .Ar variable
f3e6c7
 from the list of environment variables.
f3e6c7
-.It Ic export Ar variable 
f3e6c7
+.It Ic export Ar variable
f3e6c7
 Mark the variable
f3e6c7
 .Ar variable
f3e6c7
 to be exported to the remote side.
f3e6c7
-.It Ic unexport Ar variable 
f3e6c7
+.It Ic unexport Ar variable
f3e6c7
 Mark the variable
f3e6c7
 .Ar variable
f3e6c7
 to not be exported unless
f3e6c7
@@ -508,7 +506,7 @@
f3e6c7
 suspending a user's session for later reattachment,
f3e6c7
 the logout argument indicates that you
f3e6c7
 should terminate the session immediately.
f3e6c7
-.It Ic mode Ar type 
f3e6c7
+.It Ic mode Ar type
f3e6c7
 .Ar type
f3e6c7
 is one of several options, depending on the state of the
f3e6c7
 .Tn TELNET
f3e6c7
@@ -529,40 +527,40 @@
f3e6c7
 option, or, if the remote side does not understand the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option, then attempt to enter ``old-line-by-line'' mode.
f3e6c7
-.It Ic isig Pq Ic \-isig 
f3e6c7
-Attempt to enable (disable) the 
f3e6c7
+.It Ic isig Pq Ic \-isig
f3e6c7
+Attempt to enable (disable) the
f3e6c7
 .Dv TRAPSIG
f3e6c7
-mode of the 
f3e6c7
+mode of the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option.
f3e6c7
-This requires that the 
f3e6c7
+This requires that the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option be enabled.
f3e6c7
-.It Ic edit Pq Ic \-edit 
f3e6c7
-Attempt to enable (disable) the 
f3e6c7
+.It Ic edit Pq Ic \-edit
f3e6c7
+Attempt to enable (disable) the
f3e6c7
 .Dv EDIT
f3e6c7
-mode of the 
f3e6c7
+mode of the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option.
f3e6c7
-This requires that the 
f3e6c7
+This requires that the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option be enabled.
f3e6c7
-.It Ic softtabs Pq Ic \-softtabs 
f3e6c7
-Attempt to enable (disable) the 
f3e6c7
+.It Ic softtabs Pq Ic \-softtabs
f3e6c7
+Attempt to enable (disable) the
f3e6c7
 .Dv SOFT_TAB
f3e6c7
-mode of the 
f3e6c7
+mode of the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option.
f3e6c7
-This requires that the 
f3e6c7
+This requires that the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option be enabled.
f3e6c7
-.It Ic litecho Pq Ic \-litecho 
f3e6c7
-Attempt to enable (disable) the 
f3e6c7
+.It Ic litecho Pq Ic \-litecho
f3e6c7
+Attempt to enable (disable) the
f3e6c7
 .Dv LIT_ECHO
f3e6c7
-mode of the 
f3e6c7
+mode of the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option.
f3e6c7
-This requires that the 
f3e6c7
+This requires that the
f3e6c7
 .Dv LINEMODE
f3e6c7
 option be enabled.
f3e6c7
 .It Ic \&?
f3e6c7
@@ -579,7 +577,7 @@
f3e6c7
 Open a connection to the named host.
f3e6c7
 If no port number
f3e6c7
 is specified,
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 will attempt to contact a
f3e6c7
 .Tn TELNET
f3e6c7
 server at the default port.
f3e6c7
@@ -594,24 +592,29 @@
f3e6c7
 .Ev ENVIRON
f3e6c7
 option.
f3e6c7
 When connecting to a non-standard port,
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 omits any automatic initiation of
f3e6c7
 .Tn TELNET
f3e6c7
-options.  When the port number is preceded by a minus sign,
f3e6c7
+options.
f3e6c7
+When the port number is preceded by a minus sign,
f3e6c7
 the initial option negotiation is done.
f3e6c7
 After establishing a connection, the file
f3e6c7
 .Pa \&.telnetrc
f3e6c7
 in the
f3e6c7
-user's home directory is opened.  Lines beginning with a ``#'' are
f3e6c7
-comment lines.  Blank lines are ignored.  Lines that begin
f3e6c7
-without white space are the start of a machine entry.  The
f3e6c7
-first thing on the line is the name of the machine that is
f3e6c7
-being connected to.  The rest of the line, and successive
f3e6c7
-lines that begin with white space are assumed to be
f3e6c7
-.Nm telnet
f3e6c7
+user's home directory is opened.
f3e6c7
+Lines beginning with a ``#'' are
f3e6c7
+comment lines.
f3e6c7
+Blank lines are ignored.
f3e6c7
+Lines that begin
f3e6c7
+without whitespace are the start of a machine entry.
f3e6c7
+The first thing on the line is the name of the machine that is
f3e6c7
+being connected to.
f3e6c7
+The rest of the line, and successive
f3e6c7
+lines that begin with whitespace are assumed to be
f3e6c7
+.Nm
f3e6c7
 commands and are processed as if they had been typed
f3e6c7
 in manually to the
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 command prompt.
f3e6c7
 .It Ic quit
f3e6c7
 Close any open
f3e6c7
@@ -619,7 +622,7 @@
f3e6c7
 session and exit
f3e6c7
 .Nm telnet .
f3e6c7
 An end-of-file (in command mode) will also close a session and exit.
f3e6c7
-.It Ic send Ar arguments 
f3e6c7
+.It Ic send Ar arguments
f3e6c7
 Sends one or more special character sequences to the remote host.
f3e6c7
 The following are the arguments which may be specified
f3e6c7
 (more than one argument may be specified at a time):
f3e6c7
@@ -673,7 +676,7 @@
f3e6c7
 sequence.
f3e6c7
 .It Ic escape
f3e6c7
 Sends the current
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 escape character (initially ``^]'').
f3e6c7
 .It Ic ga
f3e6c7
 Sends the
f3e6c7
@@ -788,12 +791,12 @@
f3e6c7
 .Ic send
f3e6c7
 command.
f3e6c7
 .El
f3e6c7
-.It Ic set Ar argument value 
f3e6c7
-.It Ic unset Ar argument value 
f3e6c7
+.It Ic set Ar argument value
f3e6c7
+.It Ic unset Ar argument value
f3e6c7
 The
f3e6c7
 .Ic set
f3e6c7
 command will set any one of a number of
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 variables to a specific value or to
f3e6c7
 .Dv TRUE .
f3e6c7
 The special value
f3e6c7
@@ -811,7 +814,8 @@
f3e6c7
 .Ic display
f3e6c7
 command.
f3e6c7
 The variables which may be set or unset, but not toggled, are
f3e6c7
-listed here.  In addition, any of the variables for the
f3e6c7
+listed here.
f3e6c7
+In addition, any of the variables for the
f3e6c7
 .Ic toggle
f3e6c7
 command may be explicitly set or unset using
f3e6c7
 the
f3e6c7
@@ -832,7 +836,8 @@
f3e6c7
 sequence (see
f3e6c7
 .Ic send ayt
f3e6c7
 preceding) is sent to the
f3e6c7
-remote host.  The initial value for the "Are You There"
f3e6c7
+remote host.
f3e6c7
+The initial value for the "Are You There"
f3e6c7
 character is the terminal's status character.
f3e6c7
 .It Ic echo
f3e6c7
 This is the value (initially ``^E'') which, when in
f3e6c7
@@ -841,7 +846,7 @@
f3e6c7
 echoing of entered characters (for entering, say, a password).
f3e6c7
 .It Ic eof
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is operating in
f3e6c7
 .Dv LINEMODE
f3e6c7
 or ``old line by line'' mode, entering this character
f3e6c7
@@ -854,7 +859,7 @@
f3e6c7
 character.
f3e6c7
 .It Ic erase
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is in
f3e6c7
 .Ic localchars
f3e6c7
 mode (see
f3e6c7
@@ -862,7 +867,7 @@
f3e6c7
 .Ic localchars
f3e6c7
 below),
f3e6c7
 and if
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is operating in ``character at a time'' mode, then when this
f3e6c7
 character is typed, a
f3e6c7
 .Dv TELNET EC
f3e6c7
@@ -879,14 +884,14 @@
f3e6c7
 character.
f3e6c7
 .It Ic escape
f3e6c7
 This is the
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 escape character (initially ``^['') which causes entry
f3e6c7
 into
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 command mode (when connected to a remote system).
f3e6c7
 .It Ic flushoutput
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is in
f3e6c7
 .Ic localchars
f3e6c7
 mode (see
f3e6c7
@@ -916,12 +921,13 @@
f3e6c7
 .Dv LINEMODE ,
f3e6c7
 these are the
f3e6c7
 characters that, when typed, cause partial lines to be
f3e6c7
-forwarded to the remote system.  The initial value for
f3e6c7
+forwarded to the remote system.
f3e6c7
+The initial value for
f3e6c7
 the forwarding characters are taken from the terminal's
f3e6c7
 eol and eol2 characters.
f3e6c7
 .It Ic interrupt
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is in
f3e6c7
 .Ic localchars
f3e6c7
 mode (see
f3e6c7
@@ -945,7 +951,7 @@
f3e6c7
 character.
f3e6c7
 .It Ic kill
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is in
f3e6c7
 .Ic localchars
f3e6c7
 mode (see
f3e6c7
@@ -953,7 +959,7 @@
f3e6c7
 .Ic localchars
f3e6c7
 below),
f3e6c7
 and if
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is operating in ``character at a time'' mode, then when this
f3e6c7
 character is typed, a
f3e6c7
 .Dv TELNET EL
f3e6c7
@@ -970,7 +976,7 @@
f3e6c7
 character.
f3e6c7
 .It Ic lnext
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is operating in
f3e6c7
 .Dv LINEMODE
f3e6c7
 or ``old line by line'' mode, then this character is taken to
f3e6c7
@@ -985,7 +991,7 @@
f3e6c7
 character.
f3e6c7
 .It Ic quit
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is in
f3e6c7
 .Ic localchars
f3e6c7
 mode (see
f3e6c7
@@ -1009,7 +1015,7 @@
f3e6c7
 character.
f3e6c7
 .It Ic reprint
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is operating in
f3e6c7
 .Dv LINEMODE
f3e6c7
 or old line by line'' mode, then this character is taken to
f3e6c7
@@ -1031,8 +1037,9 @@
f3e6c7
 This character, at the beginning of a line, followed by
f3e6c7
 a "." closes the connection; when followed by a ^Z it
f3e6c7
 suspends the
f3e6c7
-.Nm telnet
f3e6c7
-command.  The initial state is to
f3e6c7
+.Nm
f3e6c7
+command.
f3e6c7
+The initial state is to
f3e6c7
 disable the
f3e6c7
 .Ic rlogin
f3e6c7
 escape character.
f3e6c7
@@ -1066,7 +1073,7 @@
f3e6c7
 character.
f3e6c7
 .It Ic susp
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is in
f3e6c7
 .Ic localchars
f3e6c7
 mode, or
f3e6c7
@@ -1093,12 +1100,13 @@
f3e6c7
 .Ic option
f3e6c7
 tracing being
f3e6c7
 .Dv TRUE ,
f3e6c7
-will be written.  If it is set to
f3e6c7
+will be written.
f3e6c7
+If it is set to
f3e6c7
 .Dq Fl ,
f3e6c7
 then tracing information will be written to standard output (the default).
f3e6c7
 .It Ic worderase
f3e6c7
 If
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 is operating in
f3e6c7
 .Dv LINEMODE
f3e6c7
 or ``old line by line'' mode, then this character is taken to
f3e6c7
@@ -1117,25 +1125,32 @@
f3e6c7
 .Pq Ic unset
f3e6c7
 commands.
f3e6c7
 .El
f3e6c7
-.It Ic slc Ar state 
f3e6c7
+.It Ic skey Ar sequence challenge
f3e6c7
+The
f3e6c7
+.Ic skey
f3e6c7
+command computes a response to the S/Key challenge.
f3e6c7
+See
f3e6c7
+.Xr skey 1
f3e6c7
+for more information on the S/Key system.
f3e6c7
+.It Ic slc Ar state
f3e6c7
 The
f3e6c7
 .Ic slc
f3e6c7
 command (Set Local Characters) is used to set
f3e6c7
 or change the state of the special
f3e6c7
-characters when the 
f3e6c7
+characters when the
f3e6c7
 .Dv TELNET LINEMODE
f3e6c7
 option has
f3e6c7
-been enabled.  Special characters are characters that get
f3e6c7
-mapped to 
f3e6c7
+been enabled.
f3e6c7
+Special characters are characters that get mapped to
f3e6c7
 .Tn TELNET
f3e6c7
 commands sequences (like
f3e6c7
 .Ic ip
f3e6c7
 or
f3e6c7
-.Ic quit  )
f3e6c7
+.Ic quit )
f3e6c7
 or line editing characters (like
f3e6c7
 .Ic erase
f3e6c7
 and
f3e6c7
-.Ic kill  ) .
f3e6c7
+.Ic kill ) .
f3e6c7
 By default, the local special characters are exported.
f3e6c7
 .Bl -tag -width Fl
f3e6c7
 .It Ic check
f3e6c7
@@ -1144,15 +1159,15 @@
f3e6c7
 character settings, and if there are any discrepancies with
f3e6c7
 the local side, the local side will switch to the remote value.
f3e6c7
 .It Ic export
f3e6c7
-Switch to the local defaults for the special characters.  The
f3e6c7
-local default characters are those of the local terminal at
f3e6c7
+Switch to the local defaults for the special characters.
f3e6c7
+The local default characters are those of the local terminal at
f3e6c7
 the time when
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 was started.
f3e6c7
 .It Ic import
f3e6c7
 Switch to the remote defaults for the special characters.
f3e6c7
 The remote default characters are those of the remote system
f3e6c7
-at the time when the 
f3e6c7
+at the time when the
f3e6c7
 .Tn TELNET
f3e6c7
 connection was established.
f3e6c7
 .It Ic \&?
f3e6c7
@@ -1165,13 +1180,13 @@
f3e6c7
 .Nm telnet .
f3e6c7
 This includes the peer one is connected to, as well
f3e6c7
 as the current mode.
f3e6c7
-.It Ic toggle Ar arguments Op Ar ... 
f3e6c7
+.It Ic toggle Ar arguments Op Ar ...
f3e6c7
 Toggle (between
f3e6c7
 .Dv TRUE
f3e6c7
 and
f3e6c7
 .Dv FALSE )
f3e6c7
 various flags that control how
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 responds to events.
f3e6c7
 These flags may be set explicitly to
f3e6c7
 .Dv TRUE
f3e6c7
@@ -1206,7 +1221,7 @@
f3e6c7
 sequences; see
f3e6c7
 .Ic set
f3e6c7
 above for details),
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 refuses to display any data on the user's terminal
f3e6c7
 until the remote system acknowledges (via a
f3e6c7
 .Dv TELNET TIMING MARK
f3e6c7
@@ -1220,13 +1235,14 @@
f3e6c7
 done an "stty noflsh", otherwise
f3e6c7
 .Dv FALSE
f3e6c7
 (see
f3e6c7
-.Xr stty  1  ) .
f3e6c7
+.Xr stty 1 ) .
f3e6c7
 .It Ic autodecrypt
f3e6c7
 When the
f3e6c7
 .Dv TELNET ENCRYPT
f3e6c7
 option is negotiated, by
f3e6c7
 default the actual encryption (decryption) of the data
f3e6c7
-stream does not start automatically.  The
f3e6c7
+stream does not start automatically.
f3e6c7
+The
f3e6c7
 .Ic autoencrypt
f3e6c7
 .Pq Ic autodecrypt
f3e6c7
 command states that encryption of the
f3e6c7
@@ -1238,7 +1254,8 @@
f3e6c7
 .Dv TELNET AUTHENTICATION
f3e6c7
 option
f3e6c7
 .Tn TELNET
f3e6c7
-attempts to use it to perform automatic authentication.  If the
f3e6c7
+attempts to use it to perform automatic authentication.
f3e6c7
+If the
f3e6c7
 .Dv AUTHENTICATION
f3e6c7
 option is not supported, the user's login
f3e6c7
 name are propagated through the
f3e6c7
@@ -1314,7 +1331,7 @@
f3e6c7
 The initial value for this toggle is
f3e6c7
 .Dv FALSE .
f3e6c7
 .It Ic debug
f3e6c7
-Toggles socket level debugging (useful only to the super-user).
f3e6c7
+Toggles socket level debugging (useful only to the superuser).
f3e6c7
 The initial value for this toggle is
f3e6c7
 .Dv FALSE .
f3e6c7
 .It Ic encdebug
f3e6c7
@@ -1340,7 +1357,7 @@
f3e6c7
 .Ic brk ,
f3e6c7
 .Ic ec ,
f3e6c7
 and
f3e6c7
-.Ic el  ;
f3e6c7
+.Ic el ;
f3e6c7
 see
f3e6c7
 .Ic send
f3e6c7
 above).
f3e6c7
@@ -1379,7 +1396,7 @@
f3e6c7
 .Dv FALSE .
f3e6c7
 .It Ic options
f3e6c7
 Toggles the display of some internal
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 protocol processing (having to do with
f3e6c7
 .Tn TELNET
f3e6c7
 options).
f3e6c7
@@ -1404,8 +1421,8 @@
f3e6c7
 skips the reading of the
f3e6c7
 .Pa \&.telnetrc
f3e6c7
 file in the user's home
f3e6c7
-directory when connections are opened.  The initial
f3e6c7
-value for this toggle is
f3e6c7
+directory when connections are opened.
f3e6c7
+The initial value for this toggle is
f3e6c7
 .Dv FALSE .
f3e6c7
 .It Ic termdata
f3e6c7
 Toggles the display of all terminal data (in hexadecimal format).
f3e6c7
@@ -1416,9 +1433,10 @@
f3e6c7
 .Ic verbose_encrypt
f3e6c7
 toggle is
f3e6c7
 .Dv TRUE ,
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 prints out a message each time encryption is enabled or
f3e6c7
-disabled.  The initial value for this toggle is
f3e6c7
+disabled.
f3e6c7
+The initial value for this toggle is
f3e6c7
 .Dv FALSE .
f3e6c7
 .It Ic \&?
f3e6c7
 Displays the legal
f3e6c7
@@ -1430,22 +1448,24 @@
f3e6c7
 .Nm telnet .
f3e6c7
 This command only works when the user is using the
f3e6c7
 .Xr csh 1 .
f3e6c7
-.It Ic \&! Op Ar command 
f3e6c7
+.It Ic \&! Op Ar command
f3e6c7
 Execute a single command in a subshell on the local
f3e6c7
-system.  If
f3e6c7
+system.
f3e6c7
+If
f3e6c7
 .Ar command
f3e6c7
 is omitted, then an interactive
f3e6c7
 subshell is invoked.
f3e6c7
-.It Ic \&? Op Ar command 
f3e6c7
-Get help.  With no arguments,
f3e6c7
-.Nm telnet
f3e6c7
+.It Ic \&? Op Ar command
f3e6c7
+Get help.
f3e6c7
+With no arguments,
f3e6c7
+.Nm
f3e6c7
 prints a help summary.
f3e6c7
 If a command is specified,
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 will print the help information for just that command.
f3e6c7
 .El
f3e6c7
 .Sh ENVIRONMENT
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 uses at least the
f3e6c7
 .Ev HOME ,
f3e6c7
 .Ev SHELL ,
f3e6c7
@@ -1464,16 +1484,18 @@
f3e6c7
 .El
f3e6c7
 .Sh HISTORY
f3e6c7
 The
f3e6c7
-.Nm telnet
f3e6c7
+.Nm
f3e6c7
 command appeared in
f3e6c7
 .Bx 4.2 .
f3e6c7
 .Sh NOTES
f3e6c7
 On some remote systems, echo has to be turned off manually when in
f3e6c7
 ``old line by line'' mode.
f3e6c7
 .Pp
f3e6c7
-In ``old line by line'' mode or 
f3e6c7
+In ``old line by line'' mode or
f3e6c7
 .Dv LINEMODE
f3e6c7
 the terminal's
f3e6c7
 .Ic eof
f3e6c7
 character is only recognized (and sent to the remote system)
f3e6c7
 when it is the first character on a line.
f3e6c7
+.Pp
f3e6c7
+Source routing is not supported yet for IPv6.