diff --git a/usr.bin/telnet/Makefile b/usr.bin/telnet/Makefile index 4d7577cdaffc..0525da5c6e92 100644 --- a/usr.bin/telnet/Makefile +++ b/usr.bin/telnet/Makefile @@ -31,7 +31,7 @@ # SUCH DAMAGE. # # from: @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $Id: Makefile,v 1.4 1995/04/24 07:39:57 cgd Exp $ +# $NetBSD: Makefile,v 1.5 1996/02/24 01:18:25 jtk Exp $ # PROG= telnet @@ -39,10 +39,10 @@ PROG= telnet CFLAGS+=-DTERMCAP -DKLUDGELINEMODE -DUSE_TERMIO -Dunix CFLAGS+=-DENV_HACK CFLAGS+=-I${.CURDIR}/../../lib - -LDADD= -ltermcap -ltelnet +LDADD+= -ltermcap -ltelnet DPADD= ${LIBTERMCAP} + SRCS= authenc.c commands.c main.c network.c ring.c sys_bsd.c telnet.c \ terminal.c tn3270.c utilities.c diff --git a/usr.bin/telnet/README b/usr.bin/telnet/README index 086c88f29500..f8974f88bf1e 100644 --- a/usr.bin/telnet/README +++ b/usr.bin/telnet/README @@ -1,25 +1,210 @@ - This is a distribution of both client and server telnet. These programs have been compiled on: telnet telnetd - BSD 4.3 Reno X X - UNICOS 5.1 X X - UNICOS 6.0 X X - UNICOS 6.1 X X - UNICOS 7.0 X X - SunOs 3.5 X X (no linemode in server) - SunOs 4.1 X X (no linemode in server) - DYNIX V3.0.17.9 X X (no linemode in server) - Ultrix 3.1 X X (no linemode in server) - Ultrix 4.0 X X (no linemode in server) + 4.4 BSD-Lite x x + 4.3 BSD Reno X X + UNICOS 9.1 X X + UNICOS 9.0 X X + UNICOS 8.0 X X + BSDI 2.0 X X + Solaris 2.4 x x (no linemode in server) + SunOs 4.1.4 X X (no linemode in server) + Ultrix 4.3 X X (no linemode in server) + Ultrix 4.1 X X (no linemode in server) In addition, previous versions have been compiled on the following machines, but were not available for testing this version. telnet telnetd + Next1.0 X X + UNICOS 8.3 X X + UNICOS 7.C X X + UNICOS 7.0 X X SunOs 4.0.3c X X (no linemode in server) - BSD 4.3 X X (no linemode in server) + 4.3 BSD X X (no linemode in server) DYNIX V3.0.12 X X (no linemode in server) + Ultrix 3.1 X X (no linemode in server) + Ultrix 4.0 X X (no linemode in server) + SunOs 3.5 X X (no linemode in server) + SunOs 4.1.3 X X (no linemode in server) + Solaris 2.2 x x (no linemode in server) + Solaris 2.3 x x (no linemode in server) + BSDI 1.0 X X + BSDI 1.1 X X + DYNIX V3.0.17.9 X X (no linemode in server) + HP-UX 8.0 x x (no linemode in server) + +This code should work, but there are no guarantees. + +Oct 23, 1995 + +This is a bugfix release. + + The change in the previous release from using makeutx() to + pututxline() caused problems on SunOS/Solaris. It has been + changed back to using makeutx(). Symptoms include users + getting error messages when logging in about not being able + to open the tty. + + Using memmove() instead of memcpy() caused problems under + SunOS 4.x, since it doesn't have memmove(). Config.generic + has been modified to include mem.o for SunOS 4.x. + + Some new code was added to telnetd to do some enviornment + variable cleanup before execing login. Thanks to Sam Hartman + at MIT for pointing this out. + + A couple of other minor bugfixes. + +May 30, 1995 + +This release represents what is on the 4.4BSD-Lite2 release, which +should be the final BSD release. I will continue to support of +telnet, The code (without encryption) is available via anonymous ftp +from ftp.cray.com, in src/telnet/telnet.YY.MM.DD.NE.tar.Z, where +YY.MM.DD is replaced with the year, month and day of the release. +If you can't find it at one of these places, at some point in the +near future information about the latest releases should be available +from ftp.borman.com. + +In addition, the version with the encryption code is available via +ftp from net-dist.mit.edu, in the directory /pub/telnet. There +is a README file there that gives further information on how +to get the distribution. + +Questions, comments, bug reports and bug fixes can be sent to +one of these addresses: + dab@borman.com + dab@cray.com + dab@bsdi.com + +This release is mainly bug fixes and code cleanup. + + Replace all calls to bcopy()/bzero() with calls to + memmove()/memset() and all calls to index()/rindex() + with calls to strchr()/strrchr(). + + Add some missing diagnostics for option tracing + to telnetd. + + Add support for BSDI 2.0 and Solaris 2.4. + + Add support for UNICOS 8.0 + + Get rid of expanded tabs and trailing white spaces. + + From Paul Vixie: + Fix for telnet going into an endless spin + when the session dies abnormally. + + From Jef Poskanzer: + Changes to allow telnet to compile + under SunOS 3.5. + + From Philip Guenther: + makeutx() doesn't expand utmpx, + use pututxline() instead. + + From Chris Torek: + Add a sleep(1) before execing login + to avoid race condition that can eat + up the login prompt. + Use terminal speed directly if it is + not an encoded value. + + From Steve Parker: + Fix to realloc() call. Fix for execing + login on solaris with no user name. + +January 19, 1994 + +This is a list of some of the changes since the last tar release +of telnet/telnetd. There are probably other changes that aren't +listed here, but this should hit a lot of the main ones. + + General: + Changed #define for AUTHENTICATE to AUTHENTICATION + Changed #define for ENCRYPT to ENCRYPTION + Changed #define for DES_ENCRYPT to DES_ENCRYPTION + + Added support for SPX authentication: -DSPX + + Added support for Kerberos Version 5 authentication: -DKRB5 + + Added support for ANSI C function prototypes + + Added support for the NEW-ENVIRON option (RFC-1572) + including support for USERVAR. + + Made support for the old Environment Option (RFC-1408) + conditional on -DOLD_ENVIRON + + Added #define ENV_HACK - support for RFC 1571 + + The encryption code is removed from the public distributions. + Domestic 4.4 BSD distributions contain the encryption code. + + ENV_HACK: Code to deal with systems that only implement + the old ENVIRON option, and have reversed definitions + of ENV_VAR and ENV_VAL. Also fixes ENV processing in + client to handle things besides just the default set... + + NO_BSD_SETJMP: UNICOS configuration for + UNICOS 6.1/6.0/5.1/5.0 systems. + + STREAMSPTY: Use /dev/ptmx to get a clean pty. This + is for SVr4 derivatives (Like Solaris) + + UTMPX: For systems that have /etc/utmpx. This is for + SVr4 derivatives (Like Solaris) + + Definitions for BSDI 1.0 + + Definitions for 4.3 Reno and 4.4 BSD. + + Definitions for UNICOS 8.0 and UNICOS 7.C + + Definitions for Solaris 2.0 + + Definitions for HP-UX 8.0 + + Latest Copyright notices from Berkeley. + + FLOW-CONTROL: support for RFC-XXXx + + + Client Specific: + + Fix the "send" command to not send garbage... + + Fix status message for "skiprc" + + Make sure to send NAWS after telnet has been suspended + or an external command has been run, if the window size + has changed. + + sysV88 support. + + Server Specific: + + Support flowcontrol option in non-linemode servers. + + -k Server supports Kludge Linemode, but will default to + either single character mode or real Linemode support. + The user will have to explicitly ask to switch into + kludge linemode. ("stty extproc", or escape back to + to telnet and say "mode line".) + + -u Specify the length of the hostname field in the utmp + file. Hostname longer than this length will be put + into the utmp file in dotted decimal notation, rather + than putting in a truncated hostname. + + -U Registered hosts only. If a reverse hostname lookup + fails, the connection will be refused. + + -f/-F + Allows forwarding of credentials for KRB5. Februrary 22, 1991: @@ -30,9 +215,9 @@ Februrary 22, 1991: AUTHENTICATION option is fairly well defined, and an option number has been assigned to it. The ENCRYPTION option is still in a state of flux; an - option number has NOT been assigned to it yet. - The code is provided in this release for experimental - and testing purposes. + option number has been assigned to, but it is still + subject to change. The code is provided in this release + for experimental and testing purposes. The telnet "send" command can now be used to send do/dont/will/wont commands, with any telnet option @@ -50,13 +235,20 @@ Februrary 22, 1991: A new telnet command, "auth" has been added (if AUTHENTICATE is defined). It has four sub-commands, - "status", "debug", "disable", "enable" and "help". + "status", "disable", "enable" and "help". A new telnet command, "encrypt" has been added (if ENCRYPT is defined). It has many sub-commands: "enable", "type", "start", "stop", "input", - "-input", "output", "-output", "status", "auto", - "verbose", "debug", and "help". + "-input", "output", "-output", "status", and "help". + + The LOGOUT option is now supported by both telnet + and telnetd, a new command, "logout", was added + to support this. + + Several new toggle options were added: + "autoencrypt", "autodecrypt", "autologin", "authdebug", + "encdebug", "skiprc", "verbose_encrypt" An "rlogin" interface has been added. If the program is named "rlogin", or the "-r" flag is given, then @@ -477,10 +669,6 @@ telnet.state: with option negotiation loops. The algorithm that is used is described in this file. -tmac.doc: - Macros for use in formatting the man pages on non-4.3Reno - systems. - telnet: This directory contains the client code. No kernel changes are needed to use this code. @@ -496,6 +684,13 @@ libtelnet: arpa: This directory has a new +libtelnet/Makefile.4.4: +telnet/Makefile.4.4: +telnetd/Makefile.4.4: + These are the makefiles that can be used on a 4.3Reno + system when this software is installed in /usr/src/lib/libtelnet, + /usr/src/libexec/telnetd, and /usr/src/usr.bin/telnet. + The following TELNET options are supported: @@ -537,6 +732,8 @@ The following TELNET options are supported: ECHO: As per RFC 857 + LOGOUT: As per RFC 727 + STATUS: The server will send its current status upon request. It does not ask for the clients status. @@ -559,7 +756,7 @@ The following TELNET options are supported: but the definitions for the specific authentication schemes is still in a state of flux. - ENCRYPT: + ENCRYPTION: This option is currently being defined by the IETF Telnet Working Group, and an RFC has not yet been issued. The draft RFC is still in a state of flux, diff --git a/usr.bin/telnet/authenc.c b/usr.bin/telnet/authenc.c index 75880c2eebcf..0771b86942d2 100644 --- a/usr.bin/telnet/authenc.c +++ b/usr.bin/telnet/authenc.c @@ -33,7 +33,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: authenc.c,v 1.3 1994/02/25 03:00:20 cgd Exp $"; +static char rcsid[] = "$NetBSD: authenc.c,v 1.4 1996/02/24 01:18:30 jtk Exp $"; #endif /* not lint */ #if defined(AUTHENTICATION) diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 374bbab4ede5..2053e78f784b 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)commands.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: commands.c,v 1.9 1996/01/05 04:19:30 tls Exp $"; +/* from: static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; */ +static char rcsid[] = "$NetBSD: commands.c,v 1.10 1996/02/24 01:18:33 jtk Exp $"; #endif /* not lint */ #if defined(unix) @@ -59,6 +59,8 @@ static char *rcsid = "$Id: commands.c,v 1.9 1996/01/05 04:19:30 tls Exp $"; #include #include +#include +#define P __P #include "general.h" @@ -77,9 +79,9 @@ static char *rcsid = "$Id: commands.c,v 1.9 1996/01/05 04:19:30 tls Exp $"; #include -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif MAXHOSTNAMELEN +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif MAXHOSTNAMELEN #if defined(IPPROTO_IP) && defined(IP_TOS) int tos = -1; @@ -235,7 +237,7 @@ control(c) * the "send" command. * */ - + struct sendlist { char *name; /* How user refers to it (case independent) */ char *help; /* Help information (0 ==> no help) */ @@ -500,7 +502,7 @@ togdebug() } #else /* NOT43 */ if (debug) { - if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 1) < 0) + if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) perror("setsockopt (SO_DEBUG)"); } else printf("Cannot turn off socket debugging\n"); @@ -1333,7 +1335,7 @@ suspend() (void) kill(0, SIGTSTP); /* * If we didn't get the window size before the SUSPEND, but we - * can get them now (???), then send the NAWS to make sure that + * can get them now (?), then send the NAWS to make sure that * we are set up for the right window size. */ if (TerminalWindowSize(&newrows, &newcols) && connected && @@ -1373,12 +1375,12 @@ shell(argc, argv) * Fire up the shell in the child. */ register char *shellp, *shellname; - extern char *rindex(); + extern char *strrchr(); shellp = getenv("SHELL"); if (shellp == NULL) shellp = "/bin/sh"; - if ((shellname = rindex(shellp, '/')) == 0) + if ((shellname = strrchr(shellp, '/')) == 0) shellname = shellp; else shellname++; @@ -1514,14 +1516,14 @@ slccmd(argc, argv) } c = getslc(argv[1]); if (c == 0) { - fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n", + fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n", argv[1]); - return 0; + return 0; } if (Ambiguous(c)) { - fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n", + fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n", argv[1]); - return 0; + return 0; } (*c->handler)(c->arg); slcstate(); @@ -1610,14 +1612,14 @@ env_cmd(argc, argv) } c = getenvcmd(argv[1]); if (c == 0) { - fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n", + fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n", argv[1]); - return 0; + return 0; } if (Ambiguous(c)) { - fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n", + fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n", argv[1]); - return 0; + return 0; } if (c->narg + 2 != argc) { fprintf(stderr, @@ -1660,10 +1662,10 @@ env_init() extern char **environ; register char **epp, *cp; register struct env_lst *ep; - extern char *index(); + extern char *strchr(); for (epp = environ; *epp; epp++) { - if (cp = index(*epp, '=')) { + if (cp = strchr(*epp, '=')) { *cp = '\0'; ep = env_define((unsigned char *)*epp, (unsigned char *)cp+1); @@ -1678,9 +1680,9 @@ env_init() */ if ((ep = env_find("DISPLAY")) && ((*ep->value == ':') - || (strncmp((char *)ep->value, "unix:", 5) == 0))) { + || (strncmp((char *)ep->value, "unix:", 5) == 0))) { char hbuf[256+1]; - char *cp2 = index((char *)ep->value, ':'); + char *cp2 = strchr((char *)ep->value, ':'); gethostname(hbuf, 256); hbuf[256] = '\0'; @@ -1772,7 +1774,7 @@ env_send(var) { register struct env_lst *ep; - if (my_state_is_wont(TELOPT_NEW_ENVIRON) + if (my_state_is_wont(TELOPT_NEW_ENVIRON) #ifdef OLD_ENVIRON && my_state_is_wont(TELOPT_OLD_ENVIRON) #endif @@ -1885,8 +1887,8 @@ struct authlist { }; extern int - auth_enable P((int)), - auth_disable P((int)), + auth_enable P((char *)), + auth_disable P((char *)), auth_status P((void)); static int auth_help P((void)); @@ -1925,17 +1927,23 @@ auth_cmd(argc, argv) { struct authlist *c; + if (argc < 2) { + fprintf(stderr, + "Need an argument to 'auth' command. 'auth ?' for help.\n"); + return 0; + } + c = (struct authlist *) genget(argv[1], (char **) AuthList, sizeof(struct authlist)); if (c == 0) { - fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n", + fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n", argv[1]); - return 0; + return 0; } if (Ambiguous(c)) { - fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n", + fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n", argv[1]); - return 0; + return 0; } if (c->narg + 2 != argc) { fprintf(stderr, @@ -2081,7 +2089,7 @@ tn(argc, argv) char *cmd, *hostp = 0, *portp = 0, *user = 0; /* clear the socket address prior to use */ - bzero((char *)&sin, sizeof(sin)); + memset((char *)&sin, 0, sizeof(sin)); if (connected) { printf("?Already connected to %s\n", hostname); @@ -2099,7 +2107,7 @@ tn(argc, argv) cmd = *argv; --argc; ++argv; while (argc) { - if (isprefix(*argv, "?")) + if (strcmp(*argv, "help") == 0 || isprefix(*argv, "?")) goto usage; if (strcmp(*argv, "-l") == 0) { --argc; ++argv; @@ -2164,17 +2172,17 @@ tn(argc, argv) if (host) { sin.sin_family = host->h_addrtype; #if defined(h_addr) /* In 4.3, this is a #define */ - memcpy((caddr_t)&sin.sin_addr, + memmove((caddr_t)&sin.sin_addr, host->h_addr_list[0], host->h_length); #else /* defined(h_addr) */ - memcpy((caddr_t)&sin.sin_addr, host->h_addr, host->h_length); + memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length); #endif /* defined(h_addr) */ strncpy(_hostname, host->h_name, sizeof(_hostname)); _hostname[sizeof(_hostname)-1] = '\0'; hostname = _hostname; } else { herror(hostp); - setuid(getuid()); + setuid(getuid()); return 0; } } @@ -2194,7 +2202,7 @@ tn(argc, argv) sin.sin_port = sp->s_port; else { printf("%s: bad port number\n", portp); - setuid(getuid()); + setuid(getuid()); return 0; } } else { @@ -2208,7 +2216,7 @@ tn(argc, argv) sp = getservbyname("telnet", "tcp"); if (sp == 0) { fprintf(stderr, "telnet: tcp/telnet: unknown service\n"); - setuid(getuid()); + setuid(getuid()); return 0; } sin.sin_port = sp->s_port; @@ -2235,7 +2243,7 @@ tn(argc, argv) tos = tp->t_tos; # endif if (tos < 0) - tos = IPTOS_LOWDELAY; + tos = IPTOS_LOWDELAY; /* Low Delay bit */ if (tos && (setsockopt(net, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) @@ -2258,7 +2266,7 @@ tn(argc, argv) errno = oerrno; perror((char *)0); host->h_addr_list++; - memcpy((caddr_t)&sin.sin_addr, + memmove((caddr_t)&sin.sin_addr, host->h_addr_list[0], host->h_length); (void) NetClose(net); continue; @@ -2436,7 +2444,7 @@ command(top, tbuf, cnt) goto getline; *cp = '\0'; if (rlogin == _POSIX_VDISABLE) - printf("%s\n", line); + printf("%s\n", line); } else { getline: if (rlogin != _POSIX_VDISABLE) @@ -2639,10 +2647,10 @@ cmdrc(m1, m2) * *cpp: If *cpp was equal to NULL, it will be filled * in with a pointer to our static area that has * the option filled in. This will be 32bit aligned. - * + * * *lenp: This will be filled in with how long the option * pointed to by *cpp is. - * + * */ unsigned long sourceroute(arg, cpp, lenp) @@ -2736,16 +2744,16 @@ sourceroute(arg, cpp, lenp) sin_addr.s_addr = tmp; } else if (host = gethostbyname(cp)) { #if defined(h_addr) - memcpy((caddr_t)&sin_addr, + memmove((caddr_t)&sin_addr, host->h_addr_list[0], host->h_length); #else - memcpy((caddr_t)&sin_addr, host->h_addr, host->h_length); + memmove((caddr_t)&sin_addr, host->h_addr, host->h_length); #endif } else { *cpp = cp; return(0); } - memcpy(lsrp, (char *)&sin_addr, 4); + memmove(lsrp, (char *)&sin_addr, 4); lsrp += 4; if (cp2) cp = cp2; diff --git a/usr.bin/telnet/defines.h b/usr.bin/telnet/defines.h index 8c75354e9357..b80db0969501 100644 --- a/usr.bin/telnet/defines.h +++ b/usr.bin/telnet/defines.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)defines.h 8.1 (Berkeley) 6/6/93 - * $Id: defines.h,v 1.3 1994/02/25 03:00:24 cgd Exp $ + * $NetBSD: defines.h,v 1.4 1996/02/24 01:18:35 jtk Exp $ */ #define settimer(x) clocks.x = clocks.system++ diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h index d37998741089..7d03b2d0c182 100644 --- a/usr.bin/telnet/externs.h +++ b/usr.bin/telnet/externs.h @@ -30,8 +30,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)externs.h 8.1 (Berkeley) 6/6/93 - * $Id: externs.h,v 1.5 1995/03/17 18:03:06 mycroft Exp $ + * from: @(#)externs.h 8.3 (Berkeley) 5/30/95 + * $NetBSD: externs.h,v 1.6 1996/02/24 01:18:36 jtk Exp $ */ #ifndef BSD @@ -85,8 +85,9 @@ typedef unsigned char cc_t; #ifndef NO_STRING_H #include -#endif +#else #include +#endif #ifndef _POSIX_VDISABLE # ifdef sun @@ -105,13 +106,8 @@ typedef unsigned char cc_t; extern int errno; /* outside this world */ #endif /* !CRAY */ -#if !defined(P) -# ifdef __STDC__ -# define P(x) x -# else -# define P(x) () -# endif -#endif +#include +#define P __P extern int autologin, /* Autologin enabled */ @@ -120,12 +116,12 @@ extern int flushout, /* flush output */ connected, /* Are we connected to the other side? */ globalmode, /* Mode tty should be in */ - In3270, /* Are we in 3270 mode? */ + In3270, /* Are we in 3270 mode? */ telnetport, /* Are we connected to the telnet port? */ localflow, /* Flow control handled locally */ restartany, /* If flow control, restart output on any character */ localchars, /* we recognize interrupt/quit */ - donelclchars, /* the user has set "localchars" */ + donelclchars, /* the user has set "localchars" */ showoptions, net, /* Network file descriptor */ tin, /* Terminal input file descriptor */ @@ -146,8 +142,7 @@ extern int #endif /* defined(TN3270) */ termdata, /* Print out terminal data flow */ #endif /* defined(unix) */ - debug, /* Debug level */ - clienteof; /* Client received EOF */ + debug; /* Debug level */ extern cc_t escape; /* Escape to command mode */ extern cc_t rlogin; /* Rlogin mode escape character */ diff --git a/usr.bin/telnet/fdset.h b/usr.bin/telnet/fdset.h index 5002ba9cb741..05e1d68360c4 100644 --- a/usr.bin/telnet/fdset.h +++ b/usr.bin/telnet/fdset.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)fdset.h 8.1 (Berkeley) 6/6/93 - * $Id: fdset.h,v 1.3 1994/02/25 03:00:27 cgd Exp $ + * $NetBSD: fdset.h,v 1.4 1996/02/24 01:18:38 jtk Exp $ */ /* diff --git a/usr.bin/telnet/general.h b/usr.bin/telnet/general.h index 17edadeddae1..06bc18247cba 100644 --- a/usr.bin/telnet/general.h +++ b/usr.bin/telnet/general.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)general.h 8.1 (Berkeley) 6/6/93 - * $Id: general.h,v 1.3 1994/02/25 03:00:28 cgd Exp $ + * $NetBSD: general.h,v 1.4 1996/02/24 01:18:40 jtk Exp $ */ /* diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c index 75e997320b84..38168a1fb3b8 100644 --- a/usr.bin/telnet/main.c +++ b/usr.bin/telnet/main.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 1988, 1990 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1988, 1990, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,14 +32,14 @@ */ #ifndef lint -char copyright[] = -"@(#) Copyright (c) 1988, 1990 Regents of the University of California.\n\ - All rights reserved.\n"; +static char copyright[] = +"@(#) Copyright (c) 1988, 1990, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -/* from: static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 12/18/92"; */ -static char *rcsid = "$Id: main.c,v 1.3 1994/02/25 03:00:29 cgd Exp $"; +/* from: static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95"; */ +static char rcsid[] = "$NetBSD: main.c,v 1.4 1996/02/24 01:18:41 jtk Exp $"; #endif /* not lint */ #include @@ -50,8 +50,8 @@ static char *rcsid = "$Id: main.c,v 1.3 1994/02/25 03:00:29 cgd Exp $"; /* These values need to be the same as defined in libtelnet/kerberos5.c */ /* Either define them in both places, or put in some common header file. */ -#define OPTS_FORWARD_CREDS 0x00000002 -#define OPTS_FORWARDABLE_CREDS 0x00000001 +#define OPTS_FORWARD_CREDS 0x00000002 +#define OPTS_FORWARDABLE_CREDS 0x00000001 #if 0 #define FORWARD @@ -66,7 +66,7 @@ tninit() init_terminal(); init_network(); - + init_telnet(); init_sys(); @@ -82,17 +82,17 @@ usage() fprintf(stderr, "Usage: %s %s%s%s%s\n", prompt, #ifdef AUTHENTICATION - " [-8] [-E] [-K] [-L] [-X atype] [-a] [-d] [-e char] [-k realm]", - "\n\t[-l user] [-f/-F] [-n tracefile] ", + "[-8] [-E] [-K] [-L] [-S tos] [-X atype] [-a] [-c] [-d] [-e char]", + "\n\t[-k realm] [-l user] [-f/-F] [-n tracefile] ", #else - " [-8] [-E] [-L] [-a] [-d] [-e char] [-l user] [-n tracefile]", - "\n\t", + "[-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]", + "\n\t[-n tracefile]", #endif #if defined(TN3270) && defined(unix) # ifdef AUTHENTICATION - "[-noasynch] [-noasynctty] [-noasyncnet]\n\t[-r] [-t transcom] ", + "[-noasynch] [-noasynctty]\n\t[-noasyncnet] [-r] [-t transcom] ", # else - "[-noasynch] [-noasynctty] [-noasyncnet] [-r] [-t transcom]\n\t", + "[-noasynch] [-noasynctty] [-noasyncnet] [-r]\n\t[-t transcom]", # endif #else "[-r] ", @@ -189,7 +189,7 @@ main(argc, argv) case 'f': #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) if (forward_flags & OPTS_FORWARD_CREDS) { - fprintf(stderr, + fprintf(stderr, "%s: Only one of -f and -F allowed.\n", prompt); usage(); @@ -197,14 +197,14 @@ main(argc, argv) forward_flags |= OPTS_FORWARD_CREDS; #else fprintf(stderr, - "%s: Warning: -f ignored, no Kerberos V5 support.\n", + "%s: Warning: -f ignored, no Kerberos V5 support.\n", prompt); #endif break; case 'F': #if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD) if (forward_flags & OPTS_FORWARD_CREDS) { - fprintf(stderr, + fprintf(stderr, "%s: Only one of -f and -F allowed.\n", prompt); usage(); @@ -213,7 +213,7 @@ main(argc, argv) forward_flags |= OPTS_FORWARDABLE_CREDS; #else fprintf(stderr, - "%s: Warning: -F ignored, no Kerberos V5 support.\n", + "%s: Warning: -F ignored, no Kerberos V5 support.\n", prompt); #endif break; diff --git a/usr.bin/telnet/network.c b/usr.bin/telnet/network.c index 905ebebda263..7a111ff8ca35 100644 --- a/usr.bin/telnet/network.c +++ b/usr.bin/telnet/network.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)network.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: network.c,v 1.3 1994/02/25 03:00:31 cgd Exp $"; +/* from: static char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93"; */ +static char rcsid[] = "$NetBSD: network.c,v 1.4 1996/02/24 01:18:43 jtk Exp $"; #endif /* not lint */ #include diff --git a/usr.bin/telnet/ring.c b/usr.bin/telnet/ring.c index 1e15f6c088a8..9441cf57a02e 100644 --- a/usr.bin/telnet/ring.c +++ b/usr.bin/telnet/ring.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: ring.c,v 1.4 1994/12/24 17:50:06 cgd Exp $"; +/* from: static char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95"; */ +static char rcsid[] = "$NetBSD: ring.c,v 1.5 1996/02/24 01:18:44 jtk Exp $"; #endif /* not lint */ /* @@ -48,10 +48,6 @@ static char *rcsid = "$Id: ring.c,v 1.4 1994/12/24 17:50:06 cgd Exp $"; */ #include -#ifndef NO_STRING_H -#include -#endif -#include #include #ifdef size_t @@ -288,7 +284,7 @@ ring_supply_data(ring, buffer, count) while (count) { i = MIN(count, ring_empty_consecutive(ring)); - memcpy(ring->supply, buffer, i); + memmove(ring->supply, buffer, i); ring_supplied(ring, i); count -= i; buffer += i; @@ -310,7 +306,7 @@ ring_consume_data(ring, buffer, count) while (count) { i = MIN(count, ring_full_consecutive(ring)); - memcpy(buffer, ring->consume, i); + memmove(buffer, ring->consume, i); ring_consumed(ring, i); count -= i; buffer += i; diff --git a/usr.bin/telnet/ring.h b/usr.bin/telnet/ring.h index acc44319f81e..93381d1077ff 100644 --- a/usr.bin/telnet/ring.h +++ b/usr.bin/telnet/ring.h @@ -31,18 +31,11 @@ * SUCH DAMAGE. * * from: @(#)ring.h 8.1 (Berkeley) 6/6/93 - * $Id: ring.h,v 1.3 1994/02/25 03:00:36 cgd Exp $ + * $NetBSD: ring.h,v 1.4 1996/02/24 01:18:45 jtk Exp $ */ -#if defined(P) -# undef P -#endif - -#if defined(__STDC__) || defined(LINT_ARGS) -# define P(x) x -#else -# define P(x) () -#endif +#include +#define P __P /* * This defines a structure for a ring buffer. diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index dc94fd9a20ae..d041f70a290c 100644 --- a/usr.bin/telnet/sys_bsd.c +++ b/usr.bin/telnet/sys_bsd.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)sys_bsd.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: sys_bsd.c,v 1.7 1996/02/15 00:59:16 tls Exp $"; +/* from: static char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95"; */ +static char rcsid[] = "$NetBSD: sys_bsd.c,v 1.8 1996/02/24 01:18:46 jtk Exp $"; #endif /* not lint */ /* @@ -224,7 +224,7 @@ TerminalSpecialChars(c) /* * Flush output to the terminal */ - + void TerminalFlushOutput() { @@ -329,7 +329,7 @@ TerminalDefaultChars() nttyb.sg_kill = ottyb.sg_kill; nttyb.sg_erase = ottyb.sg_erase; #else /* USE_TERMIO */ - memcpy(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc)); + memmove(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc)); # ifndef VDISCARD termFlushChar = CONTROL('O'); # endif @@ -668,7 +668,11 @@ TerminalNewMode(f) #endif #ifdef SIGTSTP (void) signal(SIGTSTP, SIG_DFL); +# ifndef SOLARIS (void) sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1))); +# else SOLARIS + (void) sigrelse(SIGTSTP); +# endif SOLARIS #endif /* SIGTSTP */ #ifndef USE_TERMIO ltc = oltc; @@ -703,14 +707,51 @@ TerminalNewMode(f) } +/* + * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD). + */ +#if B4800 != 4800 +#define DECODE_BAUD +#endif + +#ifdef DECODE_BAUD +#ifndef B7200 +#define B7200 B4800 +#endif + +#ifndef B14400 +#define B14400 B9600 +#endif + #ifndef B19200 -# define B19200 B9600 +# define B19200 B14400 +#endif + +#ifndef B28800 +#define B28800 B19200 #endif #ifndef B38400 -# define B38400 B19200 +# define B38400 B28800 #endif +#ifndef B57600 +#define B57600 B38400 +#endif + +#ifndef B76800 +#define B76800 B57600 +#endif + +#ifndef B115200 +#define B115200 B76800 +#endif + +#ifndef B230400 +#define B230400 B115200 +#endif + + /* * This code assumes that the values B0, B50, B75... * are in ascending order. They do not have to be @@ -720,20 +761,25 @@ struct termspeeds { long speed; long value; } termspeeds[] = { - { 0, B0 }, { 50, B50 }, { 75, B75 }, - { 110, B110 }, { 134, B134 }, { 150, B150 }, - { 200, B200 }, { 300, B300 }, { 600, B600 }, - { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 }, - { 4800, B4800 }, { 9600, B9600 }, { 19200, B19200 }, - { 38400, B38400 }, { -1, B38400 } + { 0, B0 }, { 50, B50 }, { 75, B75 }, + { 110, B110 }, { 134, B134 }, { 150, B150 }, + { 200, B200 }, { 300, B300 }, { 600, B600 }, + { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 }, + { 4800, B4800 }, { 7200, B7200 }, { 9600, B9600 }, + { 14400, B14400 }, { 19200, B19200 }, { 28800, B28800 }, + { 38400, B38400 }, { 57600, B57600 }, { 115200, B115200 }, + { 230400, B230400 }, { -1, B230400 } }; +#endif /* DECODE_BAUD */ void TerminalSpeeds(ispeed, ospeed) long *ispeed; long *ospeed; { +#ifdef DECODE_BAUD register struct termspeeds *tp; +#endif /* DECODE_BAUD */ register long in, out; out = cfgetospeed(&old_tc); @@ -741,6 +787,7 @@ TerminalSpeeds(ispeed, ospeed) if (in == 0) in = out; +#ifdef DECODE_BAUD tp = termspeeds; while ((tp->speed != -1) && (tp->value < in)) tp++; @@ -750,6 +797,10 @@ TerminalSpeeds(ispeed, ospeed) while ((tp->speed != -1) && (tp->value < out)) tp++; *ospeed = tp->speed; +#else /* DECODE_BAUD */ + *ispeed = in; + *ospeed = out; +#endif /* DECODE_BAUD */ } int @@ -945,7 +996,7 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll) if (netout) { FD_SET(net, &obits); - } + } if (ttyout) { FD_SET(tout, &obits); } @@ -1084,7 +1135,7 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll) int i; i = recv(net, netiring.supply + c, canread - c, MSG_OOB); if (i == c && - bcmp(netiring.supply, netiring.supply + c, i) == 0) { + memcmp(netiring.supply, netiring.supply + c, i) == 0) { bogus_oob = 1; first = 0; } else if (i < 0) { @@ -1133,22 +1184,19 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll) if (FD_ISSET(tin, &ibits)) { FD_CLR(tin, &ibits); c = TerminalRead(ttyiring.supply, ring_empty_consecutive(&ttyiring)); + if (c < 0 && errno == EIO) + c = 0; if (c < 0 && errno == EWOULDBLOCK) { c = 0; } else { - if (c < 0) { - return -1; + /* EOF detection for line mode!!!! */ + if ((c == 0) && MODE_LOCAL_CHARS(globalmode) && isatty(tin)) { + /* must be an EOF... */ + *ttyiring.supply = termEofChar; + c = 1; } - if (c == 0) { - /* must be an EOF... */ - if (MODE_LOCAL_CHARS(globalmode) && isatty(tin)) { - *ttyiring.supply = termEofChar; - c = 1; - } else { - clienteof = 1; - shutdown(net, 1); - return 0; - } + if (c <= 0) { + return -1; } if (termdata) { Dump('<', ttyiring.supply, c); diff --git a/usr.bin/telnet/telnet.c b/usr.bin/telnet/telnet.c index 321eefcb7b2a..af3cb9a3ab7f 100644 --- a/usr.bin/telnet/telnet.c +++ b/usr.bin/telnet/telnet.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)telnet.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: telnet.c,v 1.4 1995/03/17 18:03:10 mycroft Exp $"; +/* from: static char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; */ +static char rcsid[] = "$NetBSD: telnet.c,v 1.5 1996/02/24 01:18:48 jtk Exp $"; #endif /* not lint */ #include @@ -58,7 +58,7 @@ static char *rcsid = "$Id: telnet.c,v 1.4 1995/03/17 18:03:10 mycroft Exp $"; #include "general.h" -#define strip(x) ((x)&0x7f) +#define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x)) static unsigned char subbuffer[SUBBUFSIZE], *subpointer, *subend; /* buffer for sub-options */ @@ -105,8 +105,7 @@ int donelclchars, /* the user has set "localchars" */ donebinarytoggle, /* the user has put us in binary */ dontlecho, /* do we suppress local echoing right now? */ - globalmode, - clienteof = 0; + globalmode; char *prompt = 0; @@ -179,7 +178,7 @@ init_telnet() ClearArray(options); connected = In3270 = ISend = localflow = donebinarytoggle = 0; -#if defined(AUTHENTICATION) +#if defined(AUTHENTICATION) auth_encrypt_connect(connected); #endif /* defined(AUTHENTICATION) */ restartany = -1; @@ -615,7 +614,7 @@ mklist(buf, name) register char c, *cp, **argvp, *cp2, **argv, **avt; if (name) { - if (strlen(name) > 40) { + if ((int)strlen(name) > 40) { name = 0; unknown[0] = name_unknown; } else { @@ -681,7 +680,7 @@ mklist(buf, name) else if (islower(c)) *cp = toupper(c); } - + /* * Check for an old V6 2 character name. If the second * name points to the beginning of the buffer, and is @@ -774,7 +773,7 @@ gettermname() (setupterm(tname, 1, &err) == 0)) { tnamep = mklist(termbuf, tname); } else { - if (tname && (strlen(tname) <= 40)) { + if (tname && ((int)strlen(tname) <= 40)) { unknown[0] = tname; upcase(tname); } else @@ -1749,7 +1748,7 @@ telrcv() case TS_IAC: process_iac: switch (c) { - + case WILL: telrcv_state = TS_WILL; continue; @@ -2099,9 +2098,9 @@ Scheduler(block) ttyout = ring_full_count(&ttyoring); #if defined(TN3270) - ttyin = ring_empty_count(&ttyiring) && (clienteof == 0) && (shell_active == 0); + ttyin = ring_empty_count(&ttyiring) && (shell_active == 0); #else /* defined(TN3270) */ - ttyin = ring_empty_count(&ttyiring) && (clienteof == 0); + ttyin = ring_empty_count(&ttyiring); #endif /* defined(TN3270) */ #if defined(TN3270) @@ -2135,7 +2134,7 @@ Scheduler(block) ring_full_consecutive(&ttyiring)); if (c) { returnValue = 1; - ring_consumed(&ttyiring, c); + ring_consumed(&ttyiring, c); } } else { # endif /* defined(TN3270) */ @@ -2164,7 +2163,7 @@ telnet(user) { sys_telnet_init(); -#if defined(AUTHENTICATION) +#if defined(AUTHENTICATION) { static char local_host[256] = { 0 }; @@ -2342,7 +2341,7 @@ netclear() next = nextitem(next); } while (wewant(next) && (nfrontp > next)); length = next-thisitem; - memcpy(good, thisitem, length); + memmove(good, thisitem, length); good += length; thisitem = next; } else { diff --git a/usr.bin/telnet/terminal.c b/usr.bin/telnet/terminal.c index 85da4334b6d7..72dcc019c184 100644 --- a/usr.bin/telnet/terminal.c +++ b/usr.bin/telnet/terminal.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)terminal.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: terminal.c,v 1.3 1994/02/25 03:00:47 cgd Exp $"; +/* from: static char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95"; */ +static char rcsid[] = "$NetBSD: terminal.c,v 1.4 1996/02/24 01:18:50 jtk Exp $"; #endif /* not lint */ #include @@ -141,7 +141,8 @@ ttyflush(drop) n1 = n0 - n; if (!drop) n1 = TerminalWrite(ttyoring.bottom, n1); - n += n1; + if (n1 > 0) + n += n1; } ring_consumed(&ttyoring, n); } diff --git a/usr.bin/telnet/tn3270.c b/usr.bin/telnet/tn3270.c index 555228893b80..b1bef18e99f9 100644 --- a/usr.bin/telnet/tn3270.c +++ b/usr.bin/telnet/tn3270.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)tn3270.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: tn3270.c,v 1.3 1994/02/25 03:00:48 cgd Exp $"; +/* from: static char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95"; */ +static char rcsid[] = "$NetBSD: tn3270.c,v 1.4 1996/02/24 01:18:51 jtk Exp $"; #endif /* not lint */ #include @@ -243,7 +243,7 @@ Push3270() if (save) { if (Ifrontp+save > Ibuf+sizeof Ibuf) { if (Ibackp != Ibuf) { - memcpy(Ibuf, Ibackp, Ifrontp-Ibackp); + memmove(Ibuf, Ibackp, Ifrontp-Ibackp); Ifrontp -= (Ibackp-Ibuf); Ibackp = Ibuf; } diff --git a/usr.bin/telnet/types.h b/usr.bin/telnet/types.h index db45b0ad152e..9b6f986497ec 100644 --- a/usr.bin/telnet/types.h +++ b/usr.bin/telnet/types.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)types.h 8.1 (Berkeley) 6/6/93 - * $Id: types.h,v 1.3 1994/02/25 03:00:49 cgd Exp $ + * $NetBSD: types.h,v 1.4 1996/02/24 01:18:52 jtk Exp $ */ typedef struct { diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c index 0b9ba8b4cfe7..2eb078696ee2 100644 --- a/usr.bin/telnet/utilities.c +++ b/usr.bin/telnet/utilities.c @@ -32,8 +32,8 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/6/93"; */ -static char *rcsid = "$Id: utilities.c,v 1.3 1994/02/25 03:00:51 cgd Exp $"; +/* from: static char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95"; */ +static char rcsid[] = "$NetBSD: utilities.c,v 1.4 1996/02/24 01:18:53 jtk Exp $"; #endif /* not lint */ #define TELOPTS @@ -524,7 +524,7 @@ printsub(direction, pointer, length) break; } break; - + case LM_SLC: fprintf(NetTrace, "SLC"); for (i = 2; i < length - 2; i += 3) { @@ -656,7 +656,7 @@ printsub(direction, pointer, length) fprintf(NetTrace, "\n"); break; - + default: fprintf(NetTrace, " %d", pointer[i]); break;