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