new telnet from ftp.cray.com. Encryption support ripped out, pending

figuring out what to do about it...
This commit is contained in:
cgd 1994-02-25 03:00:16 +00:00
parent 275855a18f
commit 0582c91393
18 changed files with 948 additions and 741 deletions

View File

@ -30,20 +30,28 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# from: @(#)Makefile 5.6 (Berkeley) 3/5/91
# $Id: Makefile,v 1.2 1993/07/30 23:50:34 mycroft Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
# $Id: Makefile,v 1.3 1994/02/25 03:00:16 cgd Exp $
#
PROG= telnet
CFLAGS+=-DTERMCAP -DKLUDGELINEMODE -DUSE_TERMIO
CFLAGS+=-DENV_HACK
CFLAGS+=-I${.CURDIR}/../../lib
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
# These are the sources that have encryption stuff in them.
CRYPT_SRC= authenc.c commands.c externs.h main.c network.c
CRYPT_SRC+= ring.c ring.h telnet.c terminal.c utilities.c Makefile
NOCRYPT_DIR=${.CURDIR}/Nocrypt
.include <bsd.prog.mk>
nocrypt:
@echo "Encryption code already removed."

View File

@ -1,6 +1,6 @@
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 1991, 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,11 +32,11 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)authenc.c 5.1 (Berkeley) 3/1/91";*/
static char rcsid[] = "$Id: authenc.c,v 1.2 1993/08/01 18:07:26 mycroft Exp $";
/* 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 $";
#endif /* not lint */
#if defined(ENCRYPT) || defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
#include <sys/types.h>
#include <arpa/telnet.h>
#include <libtelnet/encrypt.h>
@ -65,12 +65,6 @@ net_write(str, len)
void
net_encrypt()
{
#if defined(ENCRYPT)
if (encrypt_output)
ring_encrypt(&netoring, encrypt_output);
else
ring_clearto(&netoring);
#endif
}
int
@ -109,4 +103,4 @@ telnet_gets(prompt, result, length, echo)
TerminalNewMode(om);
return(res);
}
#endif
#endif /* defined(AUTHENTICATION) */

View File

@ -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,13 +32,13 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)commands.c 5.5 (Berkeley) 3/22/91";*/
static char rcsid[] = "$Id: commands.c,v 1.4 1993/08/01 18:07:25 mycroft Exp $";
/* from: static char sccsid[] = "@(#)commands.c 8.1 (Berkeley) 6/6/93"; */
static char *rcsid = "$Id: commands.c,v 1.5 1994/02/25 03:00:22 cgd Exp $";
#endif /* not lint */
#if defined(unix)
#include <sys/param.h>
#ifdef CRAY
#if defined(CRAY) || defined(sysV88)
#include <sys/types.h>
#endif
#include <sys/file.h>
@ -58,7 +58,6 @@ static char rcsid[] = "$Id: commands.c,v 1.4 1993/08/01 18:07:25 mycroft Exp $";
#include <varargs.h>
#include <errno.h>
#include <arpa/inet.h>
#include <arpa/telnet.h>
#include "general.h"
@ -69,12 +68,12 @@ static char rcsid[] = "$Id: commands.c,v 1.4 1993/08/01 18:07:25 mycroft Exp $";
#include "defines.h"
#include "types.h"
#ifndef CRAY
#if !defined(CRAY) && !defined(sysV88)
#include <netinet/in_systm.h>
# if (defined(vax) || defined(tahoe) || defined(hp300)) && !defined(ultrix)
# include <machine/endian.h>
# endif /* vax */
#endif /* CRAY */
#endif /* !defined(CRAY) && !defined(sysV88) */
#include <netinet/ip.h>
@ -256,12 +255,6 @@ static int
send_willcmd P((char *)),
send_wontcmd P((char *));
extern int
send_do P((int, int)),
send_dont P((int, int)),
send_will P((int, int)),
send_wont P((int, int));
static struct sendlist Sendlist[] = {
{ "ao", "Send Telnet Abort output", 1, 0, 0, 2, AO },
{ "ayt", "Send Telnet 'Are You There'", 1, 0, 0, 2, AYT },
@ -418,21 +411,23 @@ send_tncmd(func, cmd, name)
{
char **cpp;
extern char *telopts[];
register int val = 0;
if (isprefix(name, "help") || isprefix(name, "?")) {
register int col, len;
printf("Usage: send %s <option>\n", cmd);
printf("Usage: send %s <value|option>\n", cmd);
printf("\"value\" must be from 0 to 255\n");
printf("Valid options are:\n\t");
col = 8;
for (cpp = telopts; *cpp; cpp++) {
len = strlen(*cpp) + 1;
len = strlen(*cpp) + 3;
if (col + len > 65) {
printf("\n\t");
col = 8;
}
printf(" %s", *cpp);
printf(" \"%s\"", *cpp);
col += len;
}
printf("\n");
@ -444,16 +439,31 @@ send_tncmd(func, cmd, name)
name, cmd);
return 0;
}
if (cpp == 0) {
fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\n",
if (cpp) {
val = cpp - telopts;
} else {
register char *cp = name;
while (*cp >= '0' && *cp <= '9') {
val *= 10;
val += *cp - '0';
cp++;
}
if (*cp != 0) {
fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\n",
name, cmd);
return 0;
return 0;
} else if (val < 0 || val > 255) {
fprintf(stderr, "'%s': bad value ('send %s ?' for help).\n",
name, cmd);
return 0;
}
}
if (!connected) {
printf("?Need to be connected first.\n");
return 0;
}
(*func)(cpp - telopts, 1);
(*func)(val, 1);
return 1;
}
@ -607,15 +617,9 @@ togxbinary(val)
static int togglehelp P((void));
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
extern int auth_togdebug P((int));
#endif
#if defined(ENCRYPT)
extern int EncryptAutoEnc P((int));
extern int EncryptAutoDec P((int));
extern int EncryptDebug P((int));
extern int EncryptVerbose P((int));
#endif
struct togglelist {
char *name; /* name of toggle */
@ -636,7 +640,7 @@ static struct togglelist Togglelist[] = {
0,
&autosynch,
"send interrupt characters in urgent mode" },
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
{ "autologin",
"automatic sending of login and/or authentication info",
0,
@ -647,34 +651,12 @@ static struct togglelist Togglelist[] = {
auth_togdebug,
0,
"print authentication debugging information" },
#endif
#if defined(ENCRYPT)
{ "autoencrypt",
"automatic encryption of data stream",
EncryptAutoEnc,
0,
"automatically encrypt output" },
{ "autodecrypt",
"automatic decryption of data stream",
EncryptAutoDec,
0,
"automatically decrypt input" },
{ "verbose_encrypt",
"Toggle verbose encryption output",
EncryptVerbose,
0,
"print verbose encryption output" },
{ "encdebug",
"Toggle encryption debugging",
EncryptDebug,
0,
"print encryption debugging information" },
#endif
{ "skiprc",
"don't read ~/.telnetrc file",
0,
&skiprc,
"read ~/.telnetrc file" },
"skip reading of ~/.telnetrc file" },
{ "binary",
"sending and receiving of binary data",
togbinary,
@ -1287,9 +1269,6 @@ display(argc, argv)
}
}
/*@*/optionstatus();
#if defined(ENCRYPT)
EncryptStatus();
#endif
return 1;
#undef doset
#undef dotog
@ -1350,11 +1329,15 @@ suspend()
{
long oldrows, oldcols, newrows, newcols, err;
err = TerminalWindowSize(&oldrows, &oldcols);
err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
(void) kill(0, SIGTSTP);
err += TerminalWindowSize(&newrows, &newcols);
if (connected && !err &&
((oldrows != newrows) || (oldcols != newcols))) {
/*
* 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
* we are set up for the right window size.
*/
if (TerminalWindowSize(&newrows, &newcols) && connected &&
(err || ((oldrows != newrows) || (oldcols != newcols)))) {
sendnaws();
}
}
@ -1374,7 +1357,11 @@ shell(argc, argv)
int argc;
char *argv[];
{
long oldrows, oldcols, newrows, newcols, err;
setcommandmode();
err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
switch(vfork()) {
case -1:
perror("Fork failed\n");
@ -1404,9 +1391,17 @@ shell(argc, argv)
}
default:
(void)wait((int *)0); /* Wait for the shell to complete */
if (TerminalWindowSize(&newrows, &newcols) && connected &&
(err || ((oldrows != newrows) || (oldcols != newcols)))) {
sendnaws();
}
break;
}
return 1;
}
#else /* !defined(TN3270) */
extern int shell();
#endif /* !defined(TN3270) */
/*VARARGS*/
@ -1423,9 +1418,9 @@ bye(argc, argv)
(void) NetClose(net);
connected = 0;
resettermname = 1;
#if defined(AUTHENTICATE) || defined(ENCRYPT)
#if defined(AUTHENTICATION)
auth_encrypt_connect(connected);
#endif
#endif /* defined(AUTHENTICATION) */
/* reset options */
tninit();
#if defined(TN3270)
@ -1551,6 +1546,9 @@ extern void
env_export P((unsigned char *)),
env_unexport P((unsigned char *)),
env_send P((unsigned char *)),
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
env_varval P((unsigned char *)),
#endif
env_list P((void));
static void
env_help P((void));
@ -1567,6 +1565,10 @@ struct envlist EnvList[] = {
{ "send", "Send an environment variable", env_send, 1 },
{ "list", "List the current environment variables",
env_list, 0 },
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
{ "varval", "Reverse VAR and VALUE (auto, right, wrong, status)",
env_varval, 1 },
#endif
{ "help", 0, env_help, 0 },
{ "?", "Print help information", env_help, 0 },
{ 0 },
@ -1630,10 +1632,11 @@ env_cmd(argc, argv)
struct env_lst {
struct env_lst *next; /* pointer to next structure */
struct env_lst *prev; /* pointer to next structure */
struct env_lst *prev; /* pointer to previous structure */
unsigned char *var; /* pointer to variable name */
unsigned char *value; /* pointer to varialbe value */
unsigned char *value; /* pointer to variable value */
int export; /* 1 -> export with default list of variables */
int welldefined; /* A well defined variable */
};
struct env_lst envlisthead;
@ -1718,6 +1721,7 @@ env_define(var, value)
if (ep->next)
ep->next->prev = ep;
}
ep->welldefined = opt_welldefined(var);
ep->export = 1;
ep->var = (unsigned char *)strdup((char *)var);
ep->value = (unsigned char *)strdup((char *)value);
@ -1768,7 +1772,11 @@ env_send(var)
{
register struct env_lst *ep;
if (my_state_is_wont(TELOPT_ENVIRON)) {
if (my_state_is_wont(TELOPT_NEW_ENVIRON)
#ifdef OLD_ENVIRON
&& my_state_is_wont(TELOPT_OLD_ENVIRON)
#endif
) {
fprintf(stderr,
"Cannot send '%s': Telnet ENVIRON option not enabled\n",
var);
@ -1797,7 +1805,7 @@ env_list()
}
unsigned char *
env_default(init)
env_default(init, welldefined)
int init;
{
static struct env_lst *nep = NULL;
@ -1808,7 +1816,7 @@ env_default(init)
}
if (nep) {
while (nep = nep->next) {
if (nep->export)
if (nep->export && (nep->welldefined == welldefined))
return(nep->var);
}
}
@ -1826,7 +1834,45 @@ env_getvalue(var)
return(NULL);
}
#if defined(AUTHENTICATE)
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
void
env_varval(what)
unsigned char *what;
{
extern int old_env_var, old_env_value, env_auto;
int len = strlen((char *)what);
if (len == 0)
goto unknown;
if (strncasecmp((char *)what, "status", len) == 0) {
if (env_auto)
printf("%s%s", "VAR and VALUE are/will be ",
"determined automatically\n");
if (old_env_var == OLD_ENV_VAR)
printf("VAR and VALUE set to correct definitions\n");
else
printf("VAR and VALUE definitions are reversed\n");
} else if (strncasecmp((char *)what, "auto", len) == 0) {
env_auto = 1;
old_env_var = OLD_ENV_VALUE;
old_env_value = OLD_ENV_VAR;
} else if (strncasecmp((char *)what, "right", len) == 0) {
env_auto = 0;
old_env_var = OLD_ENV_VAR;
old_env_value = OLD_ENV_VALUE;
} else if (strncasecmp((char *)what, "wrong", len) == 0) {
env_auto = 0;
old_env_var = OLD_ENV_VALUE;
old_env_value = OLD_ENV_VAR;
} else {
unknown:
printf("Unknown \"varval\" command. (\"auto\", \"right\", \"wrong\", \"status\")\n");
}
}
#endif
#if defined(AUTHENTICATION)
/*
* The AUTHENTICATE command.
*/
@ -1841,7 +1887,8 @@ struct authlist {
extern int
auth_enable P((int)),
auth_disable P((int)),
auth_status P((void)),
auth_status P((void));
static int
auth_help P((void));
struct authlist AuthList[] = {
@ -1901,122 +1948,8 @@ auth_cmd(argc, argv)
}
#endif
#if defined(ENCRYPT)
/*
* The ENCRYPT command.
*/
struct encryptlist {
char *name;
char *help;
int (*handler)();
int needconnect;
int minarg;
int maxarg;
};
extern int
EncryptEnable P((char *, char *)),
EncryptDisable P((char *, char *)),
EncryptType P((char *, char *)),
EncryptStart P((char *)),
EncryptStartInput P((void)),
EncryptStartOutput P((void)),
EncryptStop P((char *)),
EncryptStopInput P((void)),
EncryptStopOutput P((void)),
EncryptStatus P((void)),
EncryptHelp P((void));
struct encryptlist EncryptList[] = {
{ "enable", "Enable encryption. ('encrypt enable ?' for more)",
EncryptEnable, 1, 1, 2 },
{ "disable", "Disable encryption. ('encrypt enable ?' for more)",
EncryptDisable, 0, 1, 2 },
{ "type", "Set encryptiong type. ('encrypt type ?' for more)",
EncryptType, 0, 1, 1 },
{ "start", "Start encryption. ('encrypt start ?' for more)",
EncryptStart, 1, 0, 1 },
{ "stop", "Stop encryption. ('encrypt stop ?' for more)",
EncryptStop, 1, 0, 1 },
{ "input", "Start encrypting the input stream",
EncryptStartInput, 1, 0, 0 },
{ "-input", "Stop encrypting the input stream",
EncryptStopInput, 1, 0, 0 },
{ "output", "Start encrypting the output stream",
EncryptStartOutput, 1, 0, 0 },
{ "-output", "Stop encrypting the output stream",
EncryptStopOutput, 1, 0, 0 },
{ "status", "Display current status of authentication information",
EncryptStatus, 0, 0, 0 },
{ "help", 0, EncryptHelp, 0, 0, 0 },
{ "?", "Print help information", EncryptHelp, 0, 0, 0 },
{ 0 },
};
static int
EncryptHelp()
{
struct encryptlist *c;
for (c = EncryptList; c->name; c++) {
if (c->help) {
if (*c->help)
printf("%-15s %s\n", c->name, c->help);
else
printf("\n");
}
}
return 0;
}
encrypt_cmd(argc, argv)
int argc;
char *argv[];
{
struct encryptlist *c;
c = (struct encryptlist *)
genget(argv[1], (char **) EncryptList, sizeof(struct encryptlist));
if (c == 0) {
fprintf(stderr, "'%s': unknown argument ('encrypt ?' for help).\n",
argv[1]);
return 0;
}
if (Ambiguous(c)) {
fprintf(stderr, "'%s': ambiguous argument ('encrypt ?' for help).\n",
argv[1]);
return 0;
}
argc -= 2;
if (argc < c->minarg || argc > c->maxarg) {
if (c->minarg == c->maxarg) {
fprintf(stderr, "Need %s%d argument%s ",
c->minarg < argc ? "only " : "", c->minarg,
c->minarg == 1 ? "" : "s");
} else {
fprintf(stderr, "Need %s%d-%d arguments ",
c->maxarg < argc ? "only " : "", c->minarg, c->maxarg);
}
fprintf(stderr, "to 'encrypt %s' command. 'encrypt ?' for help.\n",
c->name);
return 0;
}
if (c->needconnect && !connected) {
if (!(argc && (isprefix(argv[2], "help") || isprefix(argv[2], "?")))) {
printf("?Need to be connected first.\n");
return 0;
}
}
return ((*c->handler)(argc > 0 ? argv[2] : 0,
argc > 1 ? argv[3] : 0,
argc > 2 ? argv[4] : 0));
}
#endif
#if defined(unix) && defined(TN3270)
char *oflgs[] = { "read-only", "write-only", "read-write" };
static void
filestuff(fd)
int fd;
@ -2043,7 +1976,9 @@ filestuff(fd)
perror("fcntl");
return;
}
printf("\tFlags are 0x%x: %s\n", res, oflgs[res]);
#ifdef notdef
printf("\tFlags are 0x%x: %s\n", res, decodeflags(res));
#endif
}
#endif /* defined(unix) && defined(TN3270) */
@ -2079,9 +2014,6 @@ status(argc, argv)
printf("%s character echo\n", (mode&MODE_ECHO) ? "Local" : "Remote");
if (my_want_state_is_will(TELOPT_LFLOW))
printf("%s flow control\n", (mode&MODE_FLOW) ? "Local" : "No");
#if defined(ENCRYPT)
encrypt_display();
#endif
}
} else {
printf("No connection.\n");
@ -2130,6 +2062,8 @@ ayt_status()
}
#endif
unsigned long inet_addr();
int
tn(argc, argv)
int argc;
@ -2265,7 +2199,7 @@ tn(argc, argv)
}
} else {
#if !defined(htons)
u_short htons();
u_short htons P((unsigned short));
#endif /* !defined(htons) */
sin.sin_port = htons(sin.sin_port);
}
@ -2303,7 +2237,8 @@ tn(argc, argv)
if (tos < 0)
tos = 020; /* Low Delay bit */
if (tos
&& (setsockopt(net, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0)
&& (setsockopt(net, IPPROTO_IP, IP_TOS,
(char *)&tos, sizeof(int)) < 0)
&& (errno != ENOPROTOOPT))
perror("telnet: setsockopt (IP_TOS) (ignored)");
}
@ -2333,9 +2268,9 @@ tn(argc, argv)
return 0;
}
connected++;
#if defined(AUTHENTICATE) || defined(ENCRYPT)
#if defined(AUTHENTICATION)
auth_encrypt_connect(connected);
#endif
#endif /* defined(AUTHENTICATION) */
} while (connected == 0);
cmdrc(hostp, hostname);
if (autologin && user == NULL) {
@ -2380,12 +2315,9 @@ static char
#if defined(TN3270) && defined(unix)
transcomhelp[] = "specify Unix command for transparent mode pipe",
#endif /* defined(TN3270) && defined(unix) */
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
authhelp[] = "turn on (off) authentication ('auth ?' for more)",
#endif
#if defined(ENCRYPT)
encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)",
#endif
#if defined(unix)
zhelp[] = "suspend telnet",
#endif /* defined(unix) */
@ -2411,12 +2343,9 @@ static Command cmdtab[] = {
#if defined(TN3270) && defined(unix)
{ "transcom", transcomhelp, settranscom, 0 },
#endif /* defined(TN3270) && defined(unix) */
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
{ "auth", authhelp, auth_cmd, 0 },
#endif
#if defined(ENCRYPT)
{ "encrypt", encrypthelp, encrypt_cmd, 0 },
#endif
#if defined(unix)
{ "z", zhelp, suspend, 0 },
#endif /* defined(unix) */
@ -2722,6 +2651,9 @@ sourceroute(arg, cpp, lenp)
int *lenp;
{
static char lsr[44];
#ifdef sysV88
static IOPTN ipopt;
#endif
char *cp, *cp2, *lsrp, *lsrep;
register int tmp;
struct in_addr sin_addr;
@ -2755,17 +2687,27 @@ sourceroute(arg, cpp, lenp)
* route or a strict source route, and fill in
* the begining of the option.
*/
#ifndef sysV88
if (*cp == '!') {
cp++;
*lsrp++ = IPOPT_SSRR;
} else
*lsrp++ = IPOPT_LSRR;
#else
if (*cp == '!') {
cp++;
ipopt.io_type = IPOPT_SSRR;
} else
ipopt.io_type = IPOPT_LSRR;
#endif
if (*cp != '@')
return((unsigned long)-1);
#ifndef sysV88
lsrp++; /* skip over length, we'll fill it in later */
*lsrp++ = 4;
#endif
cp++;
@ -2815,6 +2757,7 @@ sourceroute(arg, cpp, lenp)
if (lsrp + 4 > lsrep)
return((unsigned long)-1);
}
#ifndef sysV88
if ((*(*cpp+IPOPT_OLEN) = lsrp - *cpp) <= 7) {
*cpp = 0;
*lenp = 0;
@ -2822,6 +2765,16 @@ sourceroute(arg, cpp, lenp)
}
*lsrp++ = IPOPT_NOP; /* 32 bit word align it */
*lenp = lsrp - *cpp;
#else
ipopt.io_len = lsrp - *cpp;
if (ipopt.io_len <= 5) { /* Is 3 better ? */
*cpp = 0;
*lenp = 0;
return((unsigned long)-1);
}
*lenp = sizeof(ipopt);
*cpp = (char *) &ipopt;
#endif
return(sin_addr.s_addr);
}
#endif

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)defines.h 5.1 (Berkeley) 9/14/90
* $Id: defines.h,v 1.2 1993/08/01 18:07:32 mycroft Exp $
* from: @(#)defines.h 8.1 (Berkeley) 6/6/93
* $Id: defines.h,v 1.3 1994/02/25 03:00:24 cgd Exp $
*/
#define settimer(x) clocks.x = clocks.system++

View File

@ -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
@ -30,25 +30,40 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)externs.h 5.3 (Berkeley) 3/22/91
* $Id: externs.h,v 1.2 1993/08/01 18:07:31 mycroft Exp $
* from: @(#)externs.h 8.1 (Berkeley) 6/6/93
* $Id: externs.h,v 1.3 1994/02/25 03:00:25 cgd Exp $
*/
#ifndef BSD
# define BSD 43
#endif
#if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO)
# define USE_TERMIO
/*
* ucb stdio.h defines BSD as something wierd
*/
#if defined(sun) && defined(__svr4__)
#define BSD 43
#endif
#ifndef USE_TERMIO
# if BSD > 43 || defined(SYSV_TERMIO)
# define USE_TERMIO
# endif
#endif
#include <stdio.h>
#include <setjmp.h>
#if defined(CRAY) && !defined(NO_BSD_SETJMP)
#include <bsdsetjmp.h>
#endif
#ifndef FILIO_H
#include <sys/ioctl.h>
#else
#include <sys/filio.h>
#endif
#ifdef CRAY
# include <errno.h>
#endif /* CRAY */
#ifdef USE_TERMIO
# ifndef VINTR
# ifdef SYSV_TERMIO
@ -85,7 +100,9 @@ typedef unsigned char cc_t;
#define SUBBUFSIZE 256
#ifndef CRAY
extern int errno; /* outside this world */
#endif /* !CRAY */
#if !defined(P)
# ifdef __STDC__
@ -105,6 +122,7 @@ extern int
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" */
showoptions,
@ -145,10 +163,6 @@ extern char
wont[],
options[], /* All the little options */
*hostname; /* Who are we connected to? */
#if defined(ENCRYPT)
extern void (*encrypt_output) P((unsigned char *, int));
extern int (*decrypt_input) P((int));
#endif
/*
* We keep track of each side of the option negotiation.
@ -246,6 +260,12 @@ extern void
willoption P((int)),
wontoption P((int));
extern void
send_do P((int, int)),
send_dont P((int, int)),
send_will P((int, int)),
send_wont P((int, int));
extern void
lm_will P((unsigned char *, int)),
lm_wont P((unsigned char *, int)),
@ -276,7 +296,7 @@ extern void
env_opt_end P((int));
extern unsigned char
*env_default P((int)),
*env_default P((int, int)),
*env_getvalue P((unsigned char *));
extern int
@ -450,12 +470,9 @@ extern char
tline[],
*transcom; /* Transparent command */
extern void
extern int
settranscom P((int, char**));
extern int
shell P((int, char**));
extern void
inputAvailable P((void));
inputAvailable P((int));
#endif /* defined(TN3270) */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)fdset.h 5.1 (Berkeley) 9/14/90
* $Id: fdset.h,v 1.2 1993/08/01 18:07:30 mycroft Exp $
* from: @(#)fdset.h 8.1 (Berkeley) 6/6/93
* $Id: fdset.h,v 1.3 1994/02/25 03:00:27 cgd Exp $
*/
/*

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)general.h 5.2 (Berkeley) 3/1/91
* $Id: general.h,v 1.2 1993/08/01 18:07:29 mycroft Exp $
* from: @(#)general.h 8.1 (Berkeley) 6/6/93
* $Id: general.h,v 1.3 1994/02/25 03:00:28 cgd Exp $
*/
/*

View File

@ -38,8 +38,8 @@ char copyright[] =
#endif /* not lint */
#ifndef lint
/*static char sccsid[] = "from: @(#)main.c 5.4 (Berkeley) 3/22/91";*/
static char rcsid[] = "$Id: main.c,v 1.2 1993/08/01 18:07:24 mycroft Exp $";
/* 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 $";
#endif /* not lint */
#include <sys/types.h>
@ -48,6 +48,15 @@ static char rcsid[] = "$Id: main.c,v 1.2 1993/08/01 18:07:24 mycroft Exp $";
#include "externs.h"
#include "defines.h"
/* 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
#if 0
#define FORWARD
#endif
/*
* Initialize variables.
*/
@ -72,15 +81,15 @@ usage()
{
fprintf(stderr, "Usage: %s %s%s%s%s\n",
prompt,
#ifdef AUTHENTICATE
#ifdef AUTHENTICATION
" [-8] [-E] [-K] [-L] [-X atype] [-a] [-d] [-e char] [-k realm]",
"\n\t[-l user] [-n tracefile] ",
"\n\t[-l user] [-f/-F] [-n tracefile] ",
#else
" [-8] [-E] [-L] [-a] [-d] [-e char] [-l user] [-n tracefile]",
"\n\t",
#endif
#if defined(TN3270) && defined(unix)
# ifdef AUTHENTICATE
# ifdef AUTHENTICATION
"[-noasynch] [-noasynctty] [-noasyncnet]\n\t[-r] [-t transcom] ",
# else
"[-noasynch] [-noasynctty] [-noasyncnet] [-r] [-t transcom]\n\t",
@ -88,11 +97,7 @@ usage()
#else
"[-r] ",
#endif
#ifdef ENCRYPT
"[-x] [host-name [port]]"
#else
"[host-name [port]]"
#endif
);
exit(1);
}
@ -110,6 +115,9 @@ main(argc, argv)
extern int optind;
int ch;
char *user, *strrchr();
#ifdef FORWARD
extern int forward_flags;
#endif /* FORWARD */
tninit(); /* Clear out things */
#if defined(CRAY) && !defined(__STDC__)
@ -128,7 +136,7 @@ main(argc, argv)
rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
autologin = -1;
while ((ch = getopt(argc, argv, "8EKLS:X:ade:k:l:n:rt:x")) != EOF) {
while ((ch = getopt(argc, argv, "8EKLS:X:acde:fFk:l:n:rt:x")) != EOF) {
switch(ch) {
case '8':
eight = 3; /* binary output and input */
@ -137,7 +145,7 @@ main(argc, argv)
rlogin = escape = _POSIX_VDISABLE;
break;
case 'K':
#ifdef AUTHENTICATE
#ifdef AUTHENTICATION
autologin = 0;
#endif
break;
@ -162,7 +170,7 @@ main(argc, argv)
}
break;
case 'X':
#ifdef AUTHENTICATE
#ifdef AUTHENTICATION
auth_disable_name(optarg);
#endif
break;
@ -178,8 +186,39 @@ main(argc, argv)
case 'e':
set_escape_char(optarg);
break;
case 'f':
#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
if (forward_flags & OPTS_FORWARD_CREDS) {
fprintf(stderr,
"%s: Only one of -f and -F allowed.\n",
prompt);
usage();
}
forward_flags |= OPTS_FORWARD_CREDS;
#else
fprintf(stderr,
"%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,
"%s: Only one of -f and -F allowed.\n",
prompt);
usage();
}
forward_flags |= OPTS_FORWARD_CREDS;
forward_flags |= OPTS_FORWARDABLE_CREDS;
#else
fprintf(stderr,
"%s: Warning: -F ignored, no Kerberos V5 support.\n",
prompt);
#endif
break;
case 'k':
#if defined(AUTHENTICATE) && defined(KRB4)
#if defined(AUTHENTICATION) && defined(KRB4)
{
extern char *dest_realm, dst_realm_buf[], dst_realm_sz;
dest_realm = dst_realm_buf;
@ -225,14 +264,9 @@ main(argc, argv)
#endif
break;
case 'x':
#ifdef ENCRYPT
encrypt_auto(1);
decrypt_auto(1);
#else
fprintf(stderr,
"%s: Warning: -x ignored, no ENCRYPT support.\n",
prompt);
#endif
break;
case '?':
default:

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)network.c 5.2 (Berkeley) 3/1/91";*/
static char rcsid[] = "$Id: network.c,v 1.2 1993/08/01 18:07:23 mycroft Exp $";
/* 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 $";
#endif /* not lint */
#include <sys/types.h>
@ -129,13 +129,9 @@ netflush()
{
register int n, n1;
#if defined(ENCRYPT)
if (encrypt_output)
ring_encrypt(&netoring, encrypt_output);
#endif
if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
if (!ring_at_mark(&netoring)) {
n = send(net, netoring.consume, n, 0); /* normal write */
n = send(net, (char *)netoring.consume, n, 0); /* normal write */
} else {
/*
* In 4.2 (and 4.3) systems, there is some question about
@ -145,7 +141,7 @@ netflush()
* we really have more the TCP philosophy of urgent data
* rather than the Unix philosophy of OOB data).
*/
n = send(net, netoring.consume, 1, MSG_OOB);/* URGENT data */
n = send(net, (char *)netoring.consume, 1, MSG_OOB);/* URGENT data */
}
}
if (n < 0) {

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)ring.c 5.2 (Berkeley) 3/1/91";*/
static char rcsid[] = "$Id: ring.c,v 1.2 1993/08/01 18:07:22 mycroft Exp $";
/* from: static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 6/6/93"; */
static char *rcsid = "$Id: ring.c,v 1.3 1994/02/25 03:00:34 cgd Exp $";
#endif /* not lint */
/*
@ -113,9 +113,6 @@ Ring *ring;
ring->top = ring->bottom+ring->size;
#if defined(ENCRYPT)
ring->clearto = 0;
#endif
return 1;
}
@ -186,15 +183,6 @@ ring_consumed(ring, count)
(ring_subtract(ring, ring->mark, ring->consume) < count)) {
ring->mark = 0;
}
#if defined(ENCRYPT)
if (ring->consume < ring->clearto &&
ring->clearto <= ring->consume + count)
ring->clearto = 0;
else if (ring->consume + count > ring->top &&
ring->bottom <= ring->clearto &&
ring->bottom + ((ring->consume + count) - ring->top))
ring->clearto = 0;
#endif
ring->consume = ring_increment(ring, ring->consume, count);
ring->consumetime = ++ring_clock;
/*
@ -326,38 +314,3 @@ ring_consume_data(ring, buffer, count)
}
#endif
#if defined(ENCRYPT)
void
ring_encrypt(ring, encryptor)
Ring *ring;
void (*encryptor)();
{
unsigned char *s, *c;
if (ring_empty(ring) || ring->clearto == ring->supply)
return;
if (!(c = ring->clearto))
c = ring->consume;
s = ring->supply;
if (s <= c) {
(*encryptor)(c, ring->top - c);
(*encryptor)(ring->bottom, s - ring->bottom);
} else
(*encryptor)(c, s - c);
ring->clearto = ring->supply;
}
void
ring_clearto(ring)
Ring *ring;
{
if (!ring_empty(ring))
ring->clearto = ring->supply;
else
ring->clearto = 0;
}
#endif

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ring.h 5.2 (Berkeley) 3/1/91
* $Id: ring.h,v 1.2 1993/08/01 18:07:28 mycroft Exp $
* from: @(#)ring.h 8.1 (Berkeley) 6/6/93
* $Id: ring.h,v 1.3 1994/02/25 03:00:36 cgd Exp $
*/
#if defined(P)
@ -60,10 +60,6 @@ typedef struct {
*bottom, /* lowest address in buffer */
*top, /* highest address+1 in buffer */
*mark; /* marker (user defined) */
#if defined(ENCRYPT)
unsigned char *clearto; /* Data to this point is clear text */
unsigned char *encryyptedto; /* Data is encrypted to here */
#endif
int size; /* size in bytes of buffer */
u_long consumetime, /* help us keep straight full, empty, etc. */
supplytime;
@ -95,11 +91,6 @@ extern int
ring_full_count P((Ring *ring)),
ring_full_consecutive P((Ring *ring));
#if defined(ENCRYPT)
extern void
ring_encrypt P((Ring *ring, void (*func)())),
ring_clearto P((Ring *ring));
#endif
extern void
ring_clear_mark(),

View File

@ -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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)sys_bsd.c 5.2 (Berkeley) 3/1/91";*/
static char rcsid[] = "$Id: sys_bsd.c,v 1.4 1993/12/02 22:58:58 mycroft Exp $";
/* from: static char sccsid[] = "@(#)sys_bsd.c 8.1 (Berkeley) 6/6/93"; */
static char *rcsid = "$Id: sys_bsd.c,v 1.5 1994/02/25 03:00:39 cgd Exp $";
#endif /* not lint */
/*
@ -64,6 +64,10 @@ static char rcsid[] = "$Id: sys_bsd.c,v 1.4 1993/12/02 22:58:58 mycroft Exp $";
#define SIG_FUNC_RET int
#endif
#ifdef SIGINFO
extern SIG_FUNC_RET ayt_status();
#endif
int
tout, /* Output file descriptor */
tin, /* Input file descriptor */
@ -106,6 +110,9 @@ extern struct termio new_tc;
# define cfgetispeed(ptr) cfgetospeed(ptr)
# endif
# endif /* TCSANOW */
# ifdef sysV88
# define TIOCFLUSH TC_PX_DRAIN
# endif
#endif /* USE_TERMIO */
static fd_set ibits, obits, xbits;
@ -172,14 +179,12 @@ extern int kludgelinemode;
* 1 Do add this character
*/
void intp(), sendbrk(), sendabort();
extern void xmitAO(), xmitEL(), xmitEC(), intp(), sendbrk();
int
TerminalSpecialChars(c)
int c;
{
void xmitAO(), xmitEL(), xmitEC();
if (c == termIntChar) {
intp();
return 0;
@ -378,7 +383,6 @@ TerminalRestoreState()
* local/no signal mapping
*/
SIG_FUNC_RET ayt_status();
void
TerminalNewMode(f)
@ -469,9 +473,16 @@ TerminalNewMode(f)
tc.t_startc = _POSIX_VDISABLE;
tc.t_stopc = _POSIX_VDISABLE;
#else
tmp_tc.c_iflag &= ~(IXANY|IXOFF|IXON);
tmp_tc.c_iflag &= ~(IXOFF|IXON); /* Leave the IXANY bit alone */
} else {
tmp_tc.c_iflag |= IXANY|IXOFF|IXON;
if (restartany < 0) {
tmp_tc.c_iflag |= IXOFF|IXON; /* Leave the IXANY bit alone */
} else if (restartany > 0) {
tmp_tc.c_iflag |= IXOFF|IXON|IXANY;
} else {
tmp_tc.c_iflag |= IXOFF|IXON;
tmp_tc.c_iflag &= ~IXANY;
}
#endif
}
@ -601,18 +612,18 @@ TerminalNewMode(f)
if (f != -1) {
#ifdef SIGTSTP
static SIG_FUNC_RET susp();
SIG_FUNC_RET susp();
#endif /* SIGTSTP */
#ifdef SIGINFO
static SIG_FUNC_RET ayt();
#endif SIGINFO
SIG_FUNC_RET ayt();
#endif
#ifdef SIGTSTP
(void) signal(SIGTSTP, susp);
#endif /* SIGTSTP */
#ifdef SIGINFO
(void) signal(SIGINFO, ayt);
#endif SIGINFO
#endif
#if defined(USE_TERMIO) && defined(NOKERNINFO)
tmp_tc.c_lflag |= NOKERNINFO;
#endif
@ -653,8 +664,10 @@ TerminalNewMode(f)
#endif
} else {
#ifdef SIGINFO
SIG_FUNC_RET ayt_status();
(void) signal(SIGINFO, ayt_status);
#endif SIGINFO
#endif
#ifdef SIGTSTP
(void) signal(SIGTSTP, SIG_DFL);
(void) sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
@ -679,8 +692,10 @@ TerminalNewMode(f)
#endif
#if (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR))
# if !defined(sysV88)
ioctl(tin, FIONBIO, (char *)&onoff);
ioctl(tout, FIONBIO, (char *)&onoff);
# endif
#endif /* (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR)) */
#if defined(TN3270)
if (noasynchtty == 0) {
@ -690,17 +705,6 @@ TerminalNewMode(f)
}
#if defined(USE_TERMIO) && !defined(SYSV_TERMIO)
void
TerminalSpeeds(ispeed, ospeed)
long *ispeed;
long *ospeed;
{
*ispeed = cfgetispeed(&old_tc);
*ospeed = cfgetospeed(&old_tc);
}
#else /* USE_TERMIO && !SYSV_TERMIO */
#ifndef B19200
# define B19200 B9600
#endif
@ -709,14 +713,6 @@ TerminalSpeeds(ispeed, ospeed)
# define B38400 B19200
#endif
#ifndef B57600
# define B57600 B38400
#endif
#ifndef B115200
# define B115200 B57600
#endif
/*
* This code assumes that the values B0, B50, B75...
* are in ascending order. They do not have to be
@ -726,13 +722,12 @@ 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 }, { 57600, B57600 }, { 115200, B115200 },
{ -1, B115200 }
{ 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 }
};
void
@ -758,7 +753,6 @@ TerminalSpeeds(ispeed, ospeed)
tp++;
*ospeed = tp->speed;
}
#endif /* USE_TERMIO && !SYSV_TERMIO */
int
TerminalWindowSize(rows, cols)
@ -817,7 +811,7 @@ NetSetPgrp(fd)
*/
/* ARGSUSED */
static SIG_FUNC_RET
SIG_FUNC_RET
deadpeer(sig)
int sig;
{
@ -826,7 +820,7 @@ deadpeer(sig)
}
/* ARGSUSED */
static SIG_FUNC_RET
SIG_FUNC_RET
intr(sig)
int sig;
{
@ -839,7 +833,7 @@ intr(sig)
}
/* ARGSUSED */
static SIG_FUNC_RET
SIG_FUNC_RET
intr2(sig)
int sig;
{
@ -856,7 +850,7 @@ intr2(sig)
#ifdef SIGTSTP
/* ARGSUSED */
static SIG_FUNC_RET
SIG_FUNC_RET
susp(sig)
int sig;
{
@ -869,7 +863,7 @@ susp(sig)
#ifdef SIGWINCH
/* ARGSUSED */
static SIG_FUNC_RET
SIG_FUNC_RET
sendwin(sig)
int sig;
{
@ -881,7 +875,7 @@ sendwin(sig)
#ifdef SIGINFO
/* ARGSUSED */
static SIG_FUNC_RET
SIG_FUNC_RET
ayt(sig)
int sig;
{
@ -1120,7 +1114,7 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
}
settimer(didnetreceive);
#else /* !defined(SO_OOBINLINE) */
c = recv(net, netiring.supply, canread, 0);
c = recv(net, (char *)netiring.supply, canread, 0);
#endif /* !defined(SO_OOBINLINE) */
if (c < 0 && errno == EWOULDBLOCK) {
c = 0;

View File

@ -1,5 +1,5 @@
.\" Copyright (c) 1983, 1990 The Regents of the University of California.
.\" All rights reserved.
.\" Copyright (c) 1983, 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
@ -29,25 +29,37 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)telnet.1 6.16 (Berkeley) 7/27/91
.\" $Id: telnet.1,v 1.3 1994/01/11 18:49:16 jtc Exp $
.\" from: @(#)telnet.1 8.4 (Berkeley) 2/3/94
.\" $Id: telnet.1,v 1.4 1994/02/25 03:00:42 cgd Exp $
.\"
.Dd July 27, 1991
.Dd February 3, 1994
.Dt TELNET 1
.Os BSD 4.2
.Sh NAME
.Nm telnet
.Nd User interface to the
.Nd user interface to the
.Tn TELNET
protocol
.Sh SYNOPSIS
.Nm telnet
.Op Fl d
.Op Fl 8
.Op Fl E
.Op Fl F
.Op Fl K
.Op Fl L
.Op Fl S Ar tos
.Op Fl X Ar authtype
.Op Fl a
.Op Fl n Ar tracefile
.Op Fl c
.Op Fl d
.Op Fl e Ar escapechar
.Oo
.Op Fl f
.Op Fl k Ar realm
.Op Fl l Ar user
.Op Fl n Ar tracefile
.Op Fl r
.Op Fl x
.Oo
.Ar host
.Op port
.Oc
@ -72,11 +84,35 @@ command with those arguments.
.Pp
Options:
.Bl -tag -width indent
.It Fl d
Sets the initial value of the
.Ic debug
toggle to
.Dv TRUE
.It Fl 8
Specifies an 8-bit data path. This causes an attempt to
negotiate the
.Dv TELNET BINARY
option on both input and output.
.It Fl E
Stops any character from being recognized as an escape character.
.It Fl F
If Kerberos V5 authentication is being used, the
.Fl F
option allows the local credentials to be forwarded
to the remote system, including any credentials that
have already been forwarded into the local environment.
.It Fl K
Specifies no automatic login to the remote system.
.It Fl L
Specifies an 8-bit data path on output. This causes the
BINARY option to be negotiated on output.
.It Fl S Ar tos
Sets the IP type-of-service (TOS) option for the telnet
connection to the value
.Ar tos,
which can be a numeric TOS value
or, on systems that support it, a symbolic
TOS name found in the /etc/iptos file.
.It Fl X Ar atype
Disables the
.Ar atype
type of authentication.
.It Fl a
Attempt automatic login.
Currently, this sends the user name via the
@ -89,13 +125,38 @@ The name used is that of the current user as returned by
.Xr getlogin 2
if it agrees with the current user ID,
otherwise it is the name associated with the user ID.
.It Fl n Ar tracefile
Opens
.Ar tracefile
for recording trace information.
See the
.Ic set tracefile
command below.
.It Fl c
Disables the reading of the user's
.Pa \&.telnetrc
file. (See the
.Ic toggle skiprc
command on this man page.)
.It Fl d
Sets the initial value of the
.Ic debug
toggle to
.Dv TRUE
.It Fl e Ar escape char
Sets the initial
.Nm
.Nm telnet
escape character to
.Ar escape char.
If
.Ar escape char
is omitted, then
there will be no escape character.
.It Fl f
If Kerberos V5 authentication is being used, the
.Fl f
option allows the local credentials to be forwarded to the remote system.
.It Fl k Ar realm
If Kerberos authentication is being used, the
.Fl k
option requests that telnet obtain tickets for the remote host in
realm realm instead of the remote host's realm, as determined
by
.Xr krb_realmofhost 3 .
.It Fl l Ar user
When connecting to the remote system, if the remote system
understands the
@ -109,16 +170,23 @@ option.
This option may also be used with the
.Ic open
command.
.It Fl e Ar escape char
Sets the initial
.Nm
.Nm telnet
escape character to
.Ar escape char.
If
.Ar escape char
is omitted, then
there will be no escape character.
.It Fl n Ar tracefile
Opens
.Ar tracefile
for recording trace information.
See the
.Ic set tracefile
command below.
.It Fl r
Specifies a user interface similar to
.Xr rlogin 1 .
In this
mode, the escape character is set to the tilde (~) character,
unless modified by the -e option.
.It Fl x
Turns on encryption of the data stream if possible. This
option is not available outside of the United States and
Canada.
.It Ar host
Indicates the official name, an alias, or the Internet address
of a remote host.
@ -129,6 +197,11 @@ not specified, the default
port is used.
.El
.Pp
When in rlogin mode, a line of the form ~. disconnects from the
remote host; ~ is the telnet escape character.
Similarly, the line ~^Z suspends the telnet session.
The line ~^] escapes to the normal telnet escape prompt.
.Pp
Once a connection has been opened,
.Nm telnet
will attempt to enable the
@ -229,6 +302,26 @@ and
commands).
.Pp
.Bl -tag -width "mode type"
.It Ic auth Ar argument ...
The auth command manipulates the information sent through the
.Dv TELNET AUTHENTICATE
option. Valid arguments for the
auth command are as follows:
.Bl -tag -width "disable type"
.It Ic disable Ar type
Disables the specified type of authentication. To
obtain a list of available types, use the
.Ic auth disable \&?
command.
.It Ic enable Ar type
Enables the specified type of authentication. To
obtain a list of available types, use the
.Ic auth enable \&?
command.
.It Ic status
Lists the current status of the various types of
authentication.
.El
.It Ic close
Close a
.Tn TELNET
@ -239,6 +332,145 @@ Displays all, or some, of the
and
.Ic toggle
values (see below).
.It Ic encrypt Ar argument ...
The encrypt command manipulates the information sent through the
.Dv TELNET ENCRYPT
option.
.Pp
Note: Because of export controls, the
.Dv TELNET ENCRYPT
option is not supported outside of the United States and Canada.
.Pp
Valid arguments for the encrypt command are as follows:
.Bl -tag -width Ar
.It Ic disable Ar type Ic [input|output]
Disables the specified type of encryption. If you
omit the input and output, both input and output
are disabled. To obtain a list of available
types, use the
.Ic encrypt disable \&?
command.
.It Ic enable Ar type Ic [input|output]
Enables the specified type of encryption. If you
omit input and output, both input and output are
enabled. To obtain a list of available types, use the
.Ic encrypt enable \&?
command.
.It Ic input
This is the same as the
.Ic encrypt start input
command.
.It Ic -input
This is the same as the
.Ic encrypt stop input
command.
.It Ic output
This is the same as the
.Ic encrypt start output
command.
.It Ic -output
This is the same as the
.Ic encrypt stop output
command.
.It Ic start Ic [input|output]
Attempts to start encryption. If you omit
.Ic input
and
.Ic output,
both input and output are enabled. To
obtain a list of available types, use the
.Ic encrypt enable \&?
command.
.It Ic status
Lists the current status of encryption.
.It Ic stop Ic [input|output]
Stops encryption. If you omit input and output,
encryption is on both input and output.
.It Ic type Ar type
Sets the default type of encryption to be used
with later
.Ic encrypt start
or
.Ic encrypt stop
commands.
.El
.It Ic environ Ar arguments...
The
.Ic environ
command is used to manipulate the
the variables that my be sent through the
.Dv TELNET ENVIRON
option.
The initial set of variables is taken from the users
environment, with only the
.Ev DISPLAY
and
.Ev PRINTER
variables being exported by default.
The
.Ev USER
variable is also exported if the
.Fl a
or
.Fl l
options are used.
.br
Valid arguments for the
.Ic environ
command are:
.Bl -tag -width Fl
.It Ic define Ar variable value
Define the variable
.Ar variable
to have a value of
.Ar value.
Any variables defined by this command are automatically exported.
The
.Ar value
may be enclosed in single or double quotes so
that tabs and spaces may be included.
.It Ic undefine Ar variable
Remove
.Ar variable
from the list of environment variables.
.It Ic export Ar variable
Mark the variable
.Ar variable
to be exported to the remote side.
.It Ic unexport Ar variable
Mark the variable
.Ar variable
to not be exported unless
explicitly asked for by the remote side.
.It Ic list
List the current set of environment variables.
Those marked with a
.Cm *
will be sent automatically,
other variables will only be sent if explicitly requested.
.It Ic \&?
Prints out help information for the
.Ic environ
command.
.El
.It Ic logout
Sends the
.Dv TELNET LOGOUT
option to the remote side.
This command is similar to a
.Ic close
command; however, if the remote side does not support the
.Dv LOGOUT
option, nothing happens.
If, however, the remote side does support the
.Dv LOGOUT
option, this command should cause the remote side to close the
.Tn TELNET
connection.
If the remote side also supports the concept of
suspending a user's session for later reattachment,
the logout argument indicates that you
should terminate the session immediately.
.It Ic mode Ar type
.Ar Type
is one of several options, depending on the state of the
@ -329,17 +561,17 @@ When connecting to a non-standard port,
.Nm telnet
omits any automatic initiation of
.Tn TELNET
options. When the port number is preceeded by a minus sign,
options. When the port number is preceded by a minus sign,
the initial option negotiation is done.
After establishing a connection, the file
.Pa \&.telnetrc
in the
users home directory is opened. Lines beginning with a # are
comment lines. Blank lines are ignored. Lines that begin
without whitespace are the start of a machine entry. The
without white space are the start of a machine entry. The
first thing on the line is the name of the machine that is
being connected to. The rest of the line, and successive
lines that begin with whitespace are assumed to be
lines that begin with white space are assumed to be
.Nm telnet
commands and are processed as if they had been typed
in manually to the
@ -448,6 +680,26 @@ data (and may not work if the remote system is a
.Bx 4.2
system -- if
it doesn't work, a lower case \*(Lqr\*(Rq may be echoed on the terminal).
.It Ic do Ar cmd
.It Ic dont Ar cmd
.It Ic will Ar cmd
.It Ic wont Ar cmd
Sends the
.Dv TELNET DO
.Ar cmd
sequence.
.Ar Cmd
can be either a decimal number between 0 and 255,
or a symbolic name for a specific
.Dv TELNET
command.
.Ar Cmd
can also be either
.Ic help
or
.Ic \&?
to print out help information, including
a list of known symbolic names.
.It Ic \&?
Prints out help information for the
.Ic send
@ -485,6 +737,18 @@ and
.Ic unset
commands.
.Bl -tag -width escape
.It Ic ayt
If
.Tn TELNET
is in localchars mode, or
.Dv LINEMODE
is enabled, and the status character is typed, a
.Dv TELNET AYT
sequence (see
.Ic send ayt
preceding) is sent to the
remote host. The initial value for the "Are You There"
character is the terminal's status character.
.It Ic echo
This is the value (initially \*(Lq^E\*(Rq) which, when in
\*(Lqline by line\*(Rq mode, toggles between doing local echoing
@ -554,6 +818,17 @@ The initial value for the flush character is taken to be
the terminal's
.Ic flush
character.
.It Ic forw1
.It Ic forw2
If
.Tn TELNET
is operating in
.Dv LINEMODE ,
these are the
characters that, when typed, cause partial lines to be
forwarded to the remote system. The initial value for
the forwarding characters are taken from the terminal's
eol and eol2 characters.
.It Ic interrupt
If
.Nm telnet
@ -648,6 +923,16 @@ The initial value for the reprint character is taken to be
the terminal's
.Ic reprint
character.
.It Ic rlogin
This is the rlogin escape character.
If set, the normal
.Tn TELNET
escape character is ignored unless it is
preceded by this character at the beginning of a line.
This character, at the beginning of a line followed by
a "." closes the connection; when followed by a ^Z it
suspends the telnet command. The initial state is to
disable the rlogin escape character.
.It Ic start
If the
.Dv TELNET TOGGLE-FLOW-CONTROL
@ -742,6 +1027,11 @@ and
.Ic kill ) .
By default, the local special characters are exported.
.Bl -tag -width Fl
.It Ic check
Verify the current settings for the current special characters.
The remote side is requested to send all the current special
character settings, and if there are any discrepancies with
the local side, the local side will switch to the remote value.
.It Ic export
Switch to the local defaults for the special characters. The
local default characters are those of the local terminal at
@ -754,75 +1044,16 @@ The remote default characters are those of the remote system
at the time when the
.Tn TELNET
connection was established.
.It Ic check
Verify the current settings for the current special characters.
The remote side is requested to send all the current special
character settings, and if there are any discrepancies with
the local side, the local side will switch to the remote value.
.It Ic \&?
Prints out help information for the
.Ic slc
command.
.El
.It Ic environ Ar arguments...
The
.Ic environ
command is used to manipulate the
the variables that my be sent through the
.Dv TELNET ENVIRON
option.
The initial set of variables is taken from the users
environment, with only the
.Ev DISPLAY
and
.Ev PRINTER
variables being exported by default.
The
.Ev USER
variable is also exported if the
.Fl a
or
.Fl l
options are used.
.br
Valid arguments for the
.Ic environ
command are:
.Bl -tag -width Fl
.It Ic define Ar variable value
Define the variable
.Ar variable
to have a value of
.Ar value.
Any variables defined by this command are automatically exported.
The
.Ar value
may be enclosed in single or double quotes so
that tabs and spaces may be included.
.It Ic undefine Ar variable
Remove
.Ar variable
from the list of environment variables.
.It Ic export Ar variable
Mark the variable
.Ar variable
to be exported to the remote side.
.It Ic unexport Ar variable
Mark the variable
.Ar variable
to not be exported unless
explicitly asked for by the remote side.
.It Ic list
List the current set of environment variables.
Those marked with a
.Cm *
will be sent automatically,
other variables will only be sent if explicitly requested.
.It Ic \&?
Prints out help information for the
.Ic environ
command.
.El
.It Ic status
Show the current status of
.Nm telnet .
This includes the peer one is connected to, as well
as the current mode.
.It Ic toggle Ar arguments ...
Toggle (between
.Dv TRUE
@ -846,6 +1077,8 @@ The state of these flags may be interrogated with the
command.
Valid arguments are:
.Bl -tag -width Ar
.It Ic authdebug
Turns on debugging information for the authentication code.
.It Ic autoflush
If
.Ic autoflush
@ -877,6 +1110,35 @@ done an "stty noflsh", otherwise
.Dv FALSE
(see
.Xr stty 1 ) .
.It Ic autodecrypt
When the
.Dv TELNET ENCRYPT
option is negotiated, by
default the actual encryption (decryption) of the data
stream does not start automatically. The autoencrypt
(autodecrypt) command states that encryption of the
output (input) stream should be enabled as soon as
possible.
.Pp
Note: Because of export controls, the
.Dv TELNET ENCRYPT
option is not supported outside the United States and Canada.
.It Ic autologin
If the remote side supports the
.Dv TELNET AUTHENTICATION
option
.Tn TELNET
attempts to use it to perform automatic authentication. If the
.Dv AUTHENTICATION
option is not supported, the user's login
name are propagated through the
.Dv TELNET ENVIRON
option.
This command is the same as specifying
.Ar a
option on the
.Ic open
command.
.It Ic autosynch
If
.Ic autosynch
@ -946,6 +1208,8 @@ Toggles socket level debugging (useful only to the
.Ic super user ) .
The initial value for this toggle is
.Dv FALSE .
.It Ic encdebug
Turns on debugging information for the encryption code.
.It Ic localchars
If this is
.Dv TRUE ,
@ -1021,7 +1285,32 @@ command will be formatted in a more user readable format.
Spaces are put between each character in the output, and the
beginning of any
.Tn TELNET
escape sequence is preceeded by a '*' to aid in locating them.
escape sequence is preceded by a '*' to aid in locating them.
.It Ic skiprc
When the skiprc toggle is
.Dv TRUE ,
.Tn TELNET
skips the reading of the
.Pa \&.telnetrc
file in the users home
directory when connections are opened. The initial
value for this toggle is
.Dv FALSE.
.It Ic termdata
Toggles the display of all terminal data (in hexadecimal format).
The initial value for this toggle is
.Dv FALSE .
.It Ic verbose_encrypt
When the
.Ic verbose_encrypt
toggle is
.Dv TRUE ,
.Tn TELNET
prints out a message each time encryption is enabled or
disabled. The initial value for this toggle is
.Dv FALSE.
Note: Because of export controls, data encryption
is not supported outside of the United States and Canada.
.It Ic \&?
Displays the legal
.Ic toggle
@ -1038,11 +1327,6 @@ system. If
.Ic command
is omitted, then an interactive
subshell is invoked.
.It Ic status
Show the current status of
.Nm telnet .
This includes the peer one is connected to, as well
as the current mode.
.It Ic \&? Op Ar command
Get help. With no arguments,
.Nm telnet

View File

@ -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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)telnet.c 5.53 (Berkeley) 3/22/91";*/
static char rcsid[] = "$Id: telnet.c,v 1.2 1993/08/01 18:07:19 mycroft Exp $";
/* from: static char sccsid[] = "@(#)telnet.c 8.1 (Berkeley) 6/6/93"; */
static char *rcsid = "$Id: telnet.c,v 1.3 1994/02/25 03:00:46 cgd Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -100,6 +100,7 @@ int
autoflush = 0, /* flush output when interrupting? */
autosynch, /* send interrupt characters with SYNCH? */
localflow, /* we handle flow control locally */
restartany, /* if flow control enabled, restart on any character */
localchars, /* we recognize interrupt/quit */
donelclchars, /* the user has set "localchars" */
donebinarytoggle, /* the user has put us in binary */
@ -128,6 +129,11 @@ cc_t echoc;
#define TS_SE 8 /* looking for sub-option end */
static int telrcv_state;
#ifdef OLD_ENVIRON
unsigned char telopt_environ = TELOPT_NEW_ENVIRON;
#else
# define telopt_environ TELOPT_NEW_ENVIRON
#endif
jmp_buf toplevel = { 0 };
jmp_buf peerdied;
@ -172,9 +178,10 @@ init_telnet()
ClearArray(options);
connected = In3270 = ISend = localflow = donebinarytoggle = 0;
#if defined(ENCRYPT) || defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
auth_encrypt_connect(connected);
#endif
#endif /* defined(AUTHENTICATION) */
restartany = -1;
SYNCHing = 0;
@ -360,11 +367,8 @@ willoption(option)
settimer(modenegotiated);
/* FALL THROUGH */
case TELOPT_STATUS:
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
case TELOPT_AUTHENTICATION:
#endif
#if defined(ENCRYPT)
case TELOPT_ENCRYPT:
#endif
new_state_ok = 1;
break;
@ -395,10 +399,6 @@ willoption(option)
}
}
set_my_state_do(option);
#if defined(ENCRYPT)
if (option == TELOPT_ENCRYPT)
encrypt_send_support();
#endif
}
void
@ -486,13 +486,24 @@ dooption(option)
case TELOPT_LFLOW: /* local flow control */
case TELOPT_TTYPE: /* terminal type option */
case TELOPT_SGA: /* no big deal */
case TELOPT_ENVIRON: /* environment variable option */
#if defined(ENCRYPT)
case TELOPT_ENCRYPT: /* encryption variable option */
new_state_ok = 1;
break;
case TELOPT_NEW_ENVIRON: /* New environment variable option */
#ifdef OLD_ENVIRON
if (my_state_is_will(TELOPT_OLD_ENVIRON))
send_wont(TELOPT_OLD_ENVIRON, 1); /* turn off the old */
goto env_common;
case TELOPT_OLD_ENVIRON: /* Old environment variable option */
if (my_state_is_will(TELOPT_NEW_ENVIRON))
break; /* Don't enable if new one is in use! */
env_common:
telopt_environ = option;
#endif
new_state_ok = 1;
break;
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
case TELOPT_AUTHENTICATION:
if (autologin)
new_state_ok = 1;
@ -565,6 +576,16 @@ dontoption(option)
case TELOPT_LINEMODE:
linemode = 0; /* put us back to the default state */
break;
#ifdef OLD_ENVIRON
case TELOPT_NEW_ENVIRON:
/*
* The new environ option wasn't recognized, try
* the old one.
*/
send_will(TELOPT_OLD_ENVIRON, 1);
telopt_environ = TELOPT_OLD_ENVIRON;
break;
#endif
}
/* we always accept a DONT */
set_my_want_state_wont(option);
@ -782,8 +803,10 @@ gettermname()
static void
suboption()
{
unsigned char subchar;
printsub('<', subbuffer, SB_LEN()+2);
switch (SB_GET()) {
switch (subchar = SB_GET()) {
case TELOPT_TTYPE:
if (my_want_state_is_wont(TELOPT_TTYPE))
return;
@ -841,10 +864,16 @@ suboption()
if (SB_EOF())
return;
switch(SB_GET()) {
case 1:
case LFLOW_RESTART_ANY:
restartany = 1;
break;
case LFLOW_RESTART_XON:
restartany = 0;
break;
case LFLOW_ON:
localflow = 1;
break;
case 0:
case LFLOW_OFF:
localflow = 0;
break;
default:
@ -883,17 +912,20 @@ suboption()
}
break;
case TELOPT_ENVIRON:
#ifdef OLD_ENVIRON
case TELOPT_OLD_ENVIRON:
#endif
case TELOPT_NEW_ENVIRON:
if (SB_EOF())
return;
switch(SB_PEEK()) {
case TELQUAL_IS:
case TELQUAL_INFO:
if (my_want_state_is_dont(TELOPT_ENVIRON))
if (my_want_state_is_dont(subchar))
return;
break;
case TELQUAL_SEND:
if (my_want_state_is_wont(TELOPT_ENVIRON)) {
if (my_want_state_is_wont(subchar)) {
return;
}
break;
@ -932,7 +964,7 @@ suboption()
}
break;
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
case TELOPT_AUTHENTICATION: {
if (!autologin)
break;
@ -962,67 +994,6 @@ suboption()
}
}
break;
#endif
#if defined(ENCRYPT)
case TELOPT_ENCRYPT:
if (SB_EOF())
return;
switch(SB_GET()) {
case ENCRYPT_START:
if (my_want_state_is_dont(TELOPT_ENCRYPT))
return;
encrypt_start(subpointer, SB_LEN());
break;
case ENCRYPT_END:
if (my_want_state_is_dont(TELOPT_ENCRYPT))
return;
encrypt_end();
break;
case ENCRYPT_SUPPORT:
if (my_want_state_is_wont(TELOPT_ENCRYPT))
return;
encrypt_support(subpointer, SB_LEN());
break;
case ENCRYPT_REQSTART:
if (my_want_state_is_wont(TELOPT_ENCRYPT))
return;
encrypt_request_start(subpointer, SB_LEN());
break;
case ENCRYPT_REQEND:
if (my_want_state_is_wont(TELOPT_ENCRYPT))
return;
/*
* We can always send an REQEND so that we cannot
* get stuck encrypting. We should only get this
* if we have been able to get in the correct mode
* anyhow.
*/
encrypt_request_end();
break;
case ENCRYPT_IS:
if (my_want_state_is_dont(TELOPT_ENCRYPT))
return;
encrypt_is(subpointer, SB_LEN());
break;
case ENCRYPT_REPLY:
if (my_want_state_is_wont(TELOPT_ENCRYPT))
return;
encrypt_reply(subpointer, SB_LEN());
break;
case ENCRYPT_ENC_KEYID:
if (my_want_state_is_dont(TELOPT_ENCRYPT))
return;
encrypt_enc_keyid(subpointer, SB_LEN());
break;
case ENCRYPT_DEC_KEYID:
if (my_want_state_is_wont(TELOPT_ENCRYPT))
return;
encrypt_dec_keyid(subpointer, SB_LEN());
break;
default:
break;
}
break;
#endif
default:
break;
@ -1445,6 +1416,26 @@ slc_update()
return(need_update);
}
#ifdef OLD_ENVIRON
# ifdef ENV_HACK
/*
* Earlier version of telnet/telnetd from the BSD code had
* the definitions of VALUE and VAR reversed. To ensure
* maximum interoperability, we assume that the server is
* an older BSD server, until proven otherwise. The newer
* BSD servers should be able to handle either definition,
* so it is better to use the wrong values if we don't
* know what type of server it is.
*/
int env_auto = 1;
int old_env_var = OLD_ENV_VAR;
int old_env_value = OLD_ENV_VALUE;
# else
# define old_env_var OLD_ENV_VAR
# define old_env_value OLD_ENV_VALUE
# endif
#endif
void
env_opt(buf, len)
register unsigned char *buf;
@ -1460,7 +1451,28 @@ env_opt(buf, len)
env_opt_add(NULL);
} else for (i = 1; i < len; i++) {
switch (buf[i]&0xff) {
case ENV_VALUE:
#ifdef OLD_ENVIRON
case OLD_ENV_VAR:
# ifdef ENV_HACK
if (telopt_environ == TELOPT_OLD_ENVIRON
&& env_auto) {
/* Server has the same definitions */
old_env_var = OLD_ENV_VAR;
old_env_value = OLD_ENV_VALUE;
}
/* FALL THROUGH */
# endif
case OLD_ENV_VALUE:
/*
* Although OLD_ENV_VALUE is not legal, we will
* still recognize it, just in case it is an
* old server that has VAR & VALUE mixed up...
*/
/* FALL THROUGH */
#else
case NEW_ENV_VAR:
#endif
case ENV_USERVAR:
if (ep) {
*epc = 0;
env_opt_add(ep);
@ -1475,10 +1487,10 @@ env_opt(buf, len)
*epc++ = buf[i];
break;
}
if (ep) {
*epc = 0;
env_opt_add(ep);
}
}
if (ep) {
*epc = 0;
env_opt_add(ep);
}
env_opt_end(1);
break;
@ -1514,7 +1526,7 @@ env_opt_start()
opt_replyend = opt_reply + OPT_REPLY_SIZE;
*opt_replyp++ = IAC;
*opt_replyp++ = SB;
*opt_replyp++ = TELOPT_ENVIRON;
*opt_replyp++ = telopt_environ;
*opt_replyp++ = TELQUAL_IS;
}
@ -1536,8 +1548,14 @@ env_opt_add(ep)
return; /*XXX*/
if (ep == NULL || *ep == '\0') {
env_default(1);
while (ep = env_default(0))
/* Send user defined variables first. */
env_default(1, 0);
while (ep = env_default(0, 0))
env_opt_add(ep);
/* Now add the list of well know variables. */
env_default(1, 1);
while (ep = env_default(0, 1))
env_opt_add(ep);
return;
}
@ -1557,29 +1575,56 @@ env_opt_add(ep)
opt_replyp = opt_reply + len - (opt_replyend - opt_replyp);
opt_replyend = opt_reply + len;
}
*opt_replyp++ = ENV_VAR;
if (opt_welldefined(ep))
#ifdef OLD_ENVIRON
if (telopt_environ == TELOPT_OLD_ENVIRON)
*opt_replyp++ = old_env_var;
else
#endif
*opt_replyp++ = NEW_ENV_VAR;
else
*opt_replyp++ = ENV_USERVAR;
for (;;) {
while (c = *ep++) {
switch(c&0xff) {
case IAC:
*opt_replyp++ = IAC;
break;
case ENV_VALUE:
case ENV_VAR:
case NEW_ENV_VAR:
case NEW_ENV_VALUE:
case ENV_ESC:
case ENV_USERVAR:
*opt_replyp++ = ENV_ESC;
break;
}
*opt_replyp++ = c;
}
if (ep = vp) {
*opt_replyp++ = ENV_VALUE;
#ifdef OLD_ENVIRON
if (telopt_environ == TELOPT_OLD_ENVIRON)
*opt_replyp++ = old_env_value;
else
#endif
*opt_replyp++ = NEW_ENV_VALUE;
vp = NULL;
} else
break;
}
}
int
opt_welldefined(ep)
char *ep;
{
if ((strcmp(ep, "USER") == 0) ||
(strcmp(ep, "DISPLAY") == 0) ||
(strcmp(ep, "PRINTER") == 0) ||
(strcmp(ep, "SYSTEMTYPE") == 0) ||
(strcmp(ep, "JOB") == 0) ||
(strcmp(ep, "ACCT") == 0))
return(1);
return(0);
}
void
env_opt_end(emptyok)
register int emptyok;
@ -1631,10 +1676,6 @@ telrcv()
}
c = *sbp++ & 0xff, scc--; count++;
#if defined(ENCRYPT)
if (decrypt_input)
c = (*decrypt_input)(c);
#endif
switch (telrcv_state) {
@ -1659,10 +1700,6 @@ telrcv()
*Ifrontp++ = c;
while (scc > 0) {
c = *sbp++ & 0377, scc--; count++;
#if defined(ENCRYPT)
if (decrypt_input)
c = (*decrypt_input)(c);
#endif
if (c == IAC) {
telrcv_state = TS_IAC;
break;
@ -1681,10 +1718,6 @@ telrcv()
if ((c == '\r') && my_want_state_is_dont(TELOPT_BINARY)) {
if (scc > 0) {
c = *sbp&0xff;
#if defined(ENCRYPT)
if (decrypt_input)
c = (*decrypt_input)(c);
#endif
if (c == 0) {
sbp++, scc--; count++;
/* a "true" CR */
@ -1694,10 +1727,6 @@ telrcv()
sbp++, scc--; count++;
TTYADD('\n');
} else {
#if defined(ENCRYPT)
if (decrypt_input)
(*decrypt_input)(-1);
#endif
TTYADD('\r');
if (crmod) {
@ -2134,28 +2163,23 @@ telnet(user)
{
sys_telnet_init();
#if defined(ENCRYPT) || defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
{
static char local_host[256] = { 0 };
int len = sizeof(local_host);
if (!local_host[0]) {
gethostname(local_host, &len);
gethostname(local_host, sizeof(local_host));
local_host[sizeof(local_host)-1] = 0;
}
auth_encrypt_init(local_host, hostname, "TELNET", 0);
auth_encrypt_user(user);
}
#endif
#endif /* defined(AUTHENTICATION) */
# if !defined(TN3270)
if (telnetport) {
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
if (autologin)
send_will(TELOPT_AUTHENTICATION, 1);
#endif
#if defined(ENCRYPT)
send_do(TELOPT_ENCRYPT, 1);
send_will(TELOPT_ENCRYPT, 1);
#endif
send_do(TELOPT_SGA, 1);
send_will(TELOPT_TTYPE, 1);
@ -2163,7 +2187,7 @@ telnet(user)
send_will(TELOPT_TSPEED, 1);
send_will(TELOPT_LFLOW, 1);
send_will(TELOPT_LINEMODE, 1);
send_will(TELOPT_ENVIRON, 1);
send_will(TELOPT_NEW_ENVIRON, 1);
send_do(TELOPT_STATUS, 1);
if (env_getvalue((unsigned char *)"DISPLAY"))
send_will(TELOPT_XDISPLOC, 1);

View File

@ -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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)terminal.c 5.3 (Berkeley) 3/22/91";*/
static char rcsid[] = "$Id: terminal.c,v 1.2 1993/08/01 18:07:17 mycroft Exp $";
/* 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 $";
#endif /* not lint */
#include <arpa/telnet.h>
@ -206,29 +206,12 @@ getconnmode()
setconnmode(force)
int force;
{
#ifdef ENCRYPT
static int enc_passwd = 0;
#endif
register int newmode;
newmode = getconnmode()|(force?MODE_FORCE:0);
TerminalNewMode(newmode);
#ifdef ENCRYPT
if ((newmode & (MODE_ECHO|MODE_EDIT)) == MODE_EDIT) {
if (my_want_state_is_will(TELOPT_ENCRYPT)
&& (enc_passwd == 0) && !encrypt_output) {
encrypt_request_start(0, 0);
enc_passwd = 1;
}
} else {
if (enc_passwd) {
encrypt_request_end();
enc_passwd = 0;
}
}
#endif
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)tn3270.c 5.2 (Berkeley) 3/1/91";*/
static char rcsid[] = "$Id: tn3270.c,v 1.2 1993/08/01 18:07:16 mycroft Exp $";
/* 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 $";
#endif /* not lint */
#include <sys/types.h>
@ -51,7 +51,7 @@ static char rcsid[] = "$Id: tn3270.c,v 1.2 1993/08/01 18:07:16 mycroft Exp $";
#include "../ctlr/screen.h"
#include "../general/globals.h"
#include "../telextrn.h"
#include "../sys_curses/telextrn.h"
#include "../ctlr/externs.h"
#if defined(unix)
@ -165,7 +165,8 @@ DataToNetwork(buffer, count, done)
#if defined(unix)
void
inputAvailable()
inputAvailable(signo)
int signo;
{
HaveInput = 1;
sigiocount++;
@ -385,7 +386,7 @@ tn3270_ttype()
}
#if defined(unix)
void
int
settranscom(argc, argv)
int argc;
char *argv[];
@ -396,7 +397,7 @@ settranscom(argc, argv)
transcom = 0;
}
if (argc == 1) {
return;
return 1;
}
transcom = tline;
(void) strcpy(transcom, argv[1]);
@ -404,6 +405,7 @@ settranscom(argc, argv)
(void) strcat(transcom, " ");
(void) strcat(transcom, argv[i]);
}
return 1;
}
#endif /* defined(unix) */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)types.h 5.1 (Berkeley) 9/14/90
* $Id: types.h,v 1.2 1993/08/01 18:07:27 mycroft Exp $
* from: @(#)types.h 8.1 (Berkeley) 6/6/93
* $Id: types.h,v 1.3 1994/02/25 03:00:49 cgd Exp $
*/
typedef struct {

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1988, 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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)utilities.c 5.3 (Berkeley) 3/22/91";*/
static char rcsid[] = "$Id: utilities.c,v 1.2 1993/08/01 18:07:15 mycroft Exp $";
/* 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 $";
#endif /* not lint */
#define TELOPTS
@ -204,10 +204,12 @@ printoption(direction, cmd, option)
} else
fprintf(NetTrace, "%s %d %d", direction, cmd, option);
}
if (NetTrace == stdout)
if (NetTrace == stdout) {
fprintf(NetTrace, "\r\n");
else
fflush(NetTrace);
} else {
fprintf(NetTrace, "\n");
}
return;
}
@ -329,7 +331,9 @@ printsub(direction, pointer, length)
length -= 2;
}
if (length < 1) {
fprintf(NetTrace, "(Empty suboption???)");
fprintf(NetTrace, "(Empty suboption??\?)");
if (NetTrace == stdout)
fflush(NetTrace);
return;
}
switch (pointer[0]) {
@ -351,7 +355,7 @@ printsub(direction, pointer, length)
case TELOPT_TSPEED:
fprintf(NetTrace, "TERMINAL-SPEED");
if (length < 2) {
fprintf(NetTrace, " (empty suboption???)");
fprintf(NetTrace, " (empty suboption??\?)");
break;
}
switch (pointer[1]) {
@ -373,14 +377,18 @@ printsub(direction, pointer, length)
case TELOPT_LFLOW:
fprintf(NetTrace, "TOGGLE-FLOW-CONTROL");
if (length < 2) {
fprintf(NetTrace, " (empty suboption???)");
fprintf(NetTrace, " (empty suboption??\?)");
break;
}
switch (pointer[1]) {
case 0:
case LFLOW_OFF:
fprintf(NetTrace, " OFF"); break;
case 1:
case LFLOW_ON:
fprintf(NetTrace, " ON"); break;
case LFLOW_RESTART_ANY:
fprintf(NetTrace, " RESTART-ANY"); break;
case LFLOW_RESTART_XON:
fprintf(NetTrace, " RESTART-XON"); break;
default:
fprintf(NetTrace, " %d (unknown)", pointer[1]);
}
@ -391,7 +399,7 @@ printsub(direction, pointer, length)
case TELOPT_NAWS:
fprintf(NetTrace, "NAWS");
if (length < 2) {
fprintf(NetTrace, " (empty suboption???)");
fprintf(NetTrace, " (empty suboption??\?)");
break;
}
if (length == 2) {
@ -412,11 +420,11 @@ printsub(direction, pointer, length)
fprintf(NetTrace, " ?%d?", pointer[i]);
break;
#if defined(AUTHENTICATE)
#if defined(AUTHENTICATION)
case TELOPT_AUTHENTICATION:
fprintf(NetTrace, "AUTHENTICATION");
if (length < 2) {
fprintf(NetTrace, " (empty suboption???)");
fprintf(NetTrace, " (empty suboption??\?)");
break;
}
switch (pointer[1]) {
@ -429,7 +437,7 @@ printsub(direction, pointer, length)
else
fprintf(NetTrace, "%d ", pointer[2]);
if (length < 3) {
fprintf(NetTrace, "(partial suboption???)");
fprintf(NetTrace, "(partial suboption??\?)");
break;
}
fprintf(NetTrace, "%s|%s",
@ -451,7 +459,7 @@ printsub(direction, pointer, length)
else
fprintf(NetTrace, "%d ", pointer[i]);
if (++i >= length) {
fprintf(NetTrace, "(partial suboption???)");
fprintf(NetTrace, "(partial suboption??\?)");
break;
}
fprintf(NetTrace, "%s|%s ",
@ -479,81 +487,11 @@ printsub(direction, pointer, length)
break;
#endif
#if defined(ENCRYPT)
case TELOPT_ENCRYPT:
fprintf(NetTrace, "ENCRYPT");
if (length < 2) {
fprintf(NetTrace, " (empty suboption???)");
break;
}
switch (pointer[1]) {
case ENCRYPT_START:
fprintf(NetTrace, " START");
break;
case ENCRYPT_END:
fprintf(NetTrace, " END");
break;
case ENCRYPT_REQSTART:
fprintf(NetTrace, " REQUEST-START");
break;
case ENCRYPT_REQEND:
fprintf(NetTrace, " REQUEST-END");
break;
case ENCRYPT_IS:
case ENCRYPT_REPLY:
fprintf(NetTrace, " %s ", (pointer[1] == ENCRYPT_IS) ?
"IS" : "REPLY");
if (length < 3) {
fprintf(NetTrace, " (partial suboption???)");
break;
}
if (ENCTYPE_NAME_OK(pointer[2]))
fprintf(NetTrace, "%s ", ENCTYPE_NAME(pointer[2]));
else
fprintf(NetTrace, " %d (unknown)", pointer[2]);
encrypt_printsub(&pointer[1], length - 1, buf, sizeof(buf));
fprintf(NetTrace, "%s", buf);
break;
case ENCRYPT_SUPPORT:
i = 2;
fprintf(NetTrace, " SUPPORT ");
while (i < length) {
if (ENCTYPE_NAME_OK(pointer[i]))
fprintf(NetTrace, "%s ", ENCTYPE_NAME(pointer[i]));
else
fprintf(NetTrace, "%d ", pointer[i]);
i++;
}
break;
case ENCRYPT_ENC_KEYID:
fprintf(NetTrace, " ENC_KEYID ");
goto encommon;
case ENCRYPT_DEC_KEYID:
fprintf(NetTrace, " DEC_KEYID ");
goto encommon;
default:
fprintf(NetTrace, " %d (unknown)", pointer[1]);
encommon:
for (i = 2; i < length; i++)
fprintf(NetTrace, " %d", pointer[i]);
break;
}
break;
#endif
case TELOPT_LINEMODE:
fprintf(NetTrace, "LINEMODE ");
if (length < 2) {
fprintf(NetTrace, " (empty suboption???)");
fprintf(NetTrace, " (empty suboption??\?)");
break;
}
switch (pointer[1]) {
@ -570,7 +508,7 @@ printsub(direction, pointer, length)
fprintf(NetTrace, "DONT ");
common:
if (length < 3) {
fprintf(NetTrace, "(no option???)");
fprintf(NetTrace, "(no option??\?)");
break;
}
switch (pointer[2]) {
@ -623,7 +561,7 @@ printsub(direction, pointer, length)
case LM_MODE:
fprintf(NetTrace, "MODE ");
if (length < 3) {
fprintf(NetTrace, "(no mode???)");
fprintf(NetTrace, "(no mode??\?)");
break;
}
{
@ -744,8 +682,14 @@ printsub(direction, pointer, length)
}
break;
case TELOPT_ENVIRON:
fprintf(NetTrace, "ENVIRON ");
case TELOPT_NEW_ENVIRON:
fprintf(NetTrace, "NEW-ENVIRON ");
#ifdef OLD_ENVIRON
goto env_common1;
case TELOPT_OLD_ENVIRON:
fprintf(NetTrace, "OLD-ENVIRON");
env_common1:
#endif
switch (pointer[1]) {
case TELQUAL_IS:
fprintf(NetTrace, "IS ");
@ -758,17 +702,40 @@ printsub(direction, pointer, length)
env_common:
{
register int noquote = 2;
#if defined(ENV_HACK) && defined(OLD_ENVIRON)
extern int old_env_var, old_env_value;
#endif
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
case ENV_VAR:
if (pointer[1] == TELQUAL_SEND)
goto def_case;
fprintf(NetTrace, "\" VAR " + noquote);
case NEW_ENV_VALUE:
#ifdef OLD_ENVIRON
/* case NEW_ENV_OVAR: */
if (pointer[0] == TELOPT_OLD_ENVIRON) {
# ifdef ENV_HACK
if (old_env_var == OLD_ENV_VALUE)
fprintf(NetTrace, "\" (VALUE) " + noquote);
else
# endif
fprintf(NetTrace, "\" VAR " + noquote);
} else
#endif /* OLD_ENVIRON */
fprintf(NetTrace, "\" VALUE " + noquote);
noquote = 2;
break;
case ENV_VALUE:
fprintf(NetTrace, "\" VALUE " + noquote);
case NEW_ENV_VAR:
#ifdef OLD_ENVIRON
/* case OLD_ENV_VALUE: */
if (pointer[0] == TELOPT_OLD_ENVIRON) {
# ifdef ENV_HACK
if (old_env_value == OLD_ENV_VAR)
fprintf(NetTrace, "\" (VAR) " + noquote);
else
# endif
fprintf(NetTrace, "\" VALUE " + noquote);
} else
#endif /* OLD_ENVIRON */
fprintf(NetTrace, "\" VAR " + noquote);
noquote = 2;
break;
@ -777,6 +744,11 @@ printsub(direction, pointer, length)
noquote = 2;
break;
case ENV_USERVAR:
fprintf(NetTrace, "\" USERVAR " + noquote);
noquote = 2;
break;
default:
def_case:
if (isprint(pointer[i]) && pointer[i] != '"') {
@ -804,7 +776,7 @@ printsub(direction, pointer, length)
if (TELOPT_OK(pointer[0]))
fprintf(NetTrace, "%s (unknown)", TELOPT(pointer[0]));
else
fprintf(NetTrace, "%d (unknown)", pointer[i]);
fprintf(NetTrace, "%d (unknown)", pointer[0]);
for (i = 1; i < length; i++)
fprintf(NetTrace, " %d", pointer[i]);
break;
@ -815,6 +787,8 @@ printsub(direction, pointer, length)
else
fprintf(NetTrace, "\n");
}
if (NetTrace == stdout)
fflush(NetTrace);
}
}