lines to "#ifdef ENCRYPTION". This will allow unifdef
to be used to strip out the encryption code for
foreign exports. This also fixes up the usage statement.
SCCS-vsn: usr.bin/telnet/authenc.c 5.3
SCCS-vsn: usr.bin/telnet/externs.h 5.7
SCCS-vsn: usr.bin/telnet/telnet.c 5.56
SCCS-vsn: usr.bin/telnet/network.c 5.4
SCCS-vsn: usr.bin/telnet/terminal.c 5.5
SCCS-vsn: usr.bin/telnet/ring.h 5.4
SCCS-vsn: usr.bin/telnet/main.c 5.6
SCCS-vsn: usr.bin/telnet/sys_bsd.c 5.5
SCCS-vsn: usr.bin/telnet/ring.c 5.4
SCCS-vsn: usr.bin/telnet/commands.c 5.12
SCCS-vsn: usr.bin/telnet/utilities.c 5.8
static char sccsid[] = "@(#)authenc.c 5.3 (Berkeley) %G%";
#endif /* not lint */
static char sccsid[] = "@(#)authenc.c 5.3 (Berkeley) %G%";
#endif /* not lint */
-#if defined(ENCRYPTION) || defined(AUTHENTICATION)
+#if defined(AUTHENTICATION) || defined(ENCRYPTION)
#include <sys/types.h>
#include <arpa/telnet.h>
#include <libtelnet/encrypt.h>
#include <sys/types.h>
#include <arpa/telnet.h>
#include <libtelnet/encrypt.h>
if (encrypt_output)
ring_encrypt(&netoring, encrypt_output);
else
ring_clearto(&netoring);
if (encrypt_output)
ring_encrypt(&netoring, encrypt_output);
else
ring_clearto(&netoring);
TerminalNewMode(om);
return(res);
}
TerminalNewMode(om);
return(res);
}
+#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
#if defined(AUTHENTICATION)
extern int auth_togdebug P((int));
#endif
#if defined(AUTHENTICATION)
extern int auth_togdebug P((int));
#endif
extern int EncryptAutoEnc P((int));
extern int EncryptAutoDec P((int));
extern int EncryptDebug P((int));
extern int EncryptVerbose P((int));
extern int EncryptAutoEnc P((int));
extern int EncryptAutoDec P((int));
extern int EncryptDebug P((int));
extern int EncryptVerbose P((int));
struct togglelist {
char *name; /* name of toggle */
struct togglelist {
char *name; /* name of toggle */
0,
"print authentication debugging information" },
#endif
0,
"print authentication debugging information" },
#endif
{ "autoencrypt",
"automatic encryption of data stream",
EncryptAutoEnc,
{ "autoencrypt",
"automatic encryption of data stream",
EncryptAutoEnc,
EncryptDebug,
0,
"print encryption debugging information" },
EncryptDebug,
0,
"print encryption debugging information" },
{ "skiprc",
"don't read ~/.telnetrc file",
0,
{ "skiprc",
"don't read ~/.telnetrc file",
0,
return 1;
#undef doset
#undef dotog
return 1;
#undef doset
#undef dotog
resettermname = 1;
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
auth_encrypt_connect(connected);
resettermname = 1;
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
auth_encrypt_connect(connected);
+#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
/* reset options */
tninit();
#if defined(TN3270)
/* reset options */
tninit();
#if defined(TN3270)
/*
* The ENCRYPT command.
*/
/*
* The ENCRYPT command.
*/
argc > 1 ? argv[3] : 0,
argc > 2 ? argv[4] : 0));
}
argc > 1 ? argv[3] : 0,
argc > 2 ? argv[4] : 0));
}
#if defined(unix) && defined(TN3270)
static void
#if defined(unix) && defined(TN3270)
static void
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");
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");
}
} else {
printf("No connection.\n");
}
} else {
printf("No connection.\n");
connected++;
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
auth_encrypt_connect(connected);
connected++;
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
auth_encrypt_connect(connected);
+#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
} while (connected == 0);
cmdrc(hostp, hostname);
if (autologin && user == NULL) {
} while (connected == 0);
cmdrc(hostp, hostname);
if (autologin && user == NULL) {
#if defined(AUTHENTICATION)
authhelp[] = "turn on (off) authentication ('auth ?' for more)",
#endif
#if defined(AUTHENTICATION)
authhelp[] = "turn on (off) authentication ('auth ?' for more)",
#endif
encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)",
encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)",
#if defined(unix)
zhelp[] = "suspend telnet",
#endif /* defined(unix) */
#if defined(unix)
zhelp[] = "suspend telnet",
#endif /* defined(unix) */
#if defined(AUTHENTICATION)
{ "auth", authhelp, auth_cmd, 0 },
#endif
#if defined(AUTHENTICATION)
{ "auth", authhelp, auth_cmd, 0 },
#endif
{ "encrypt", encrypthelp, encrypt_cmd, 0 },
{ "encrypt", encrypthelp, encrypt_cmd, 0 },
#if defined(unix)
{ "z", zhelp, suspend, 0 },
#endif /* defined(unix) */
#if defined(unix)
{ "z", zhelp, suspend, 0 },
#endif /* defined(unix) */
#include <stdio.h>
#include <setjmp.h>
#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
#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
#ifdef USE_TERMIO
# ifndef VINTR
# ifdef SYSV_TERMIO
extern int errno; /* outside this world */
extern int errno; /* outside this world */
#if !defined(P)
# ifdef __STDC__
#if !defined(P)
# ifdef __STDC__
wont[],
options[], /* All the little options */
*hostname; /* Who are we connected to? */
wont[],
options[], /* All the little options */
*hostname; /* Who are we connected to? */
extern void (*encrypt_output) P((unsigned char *, int));
extern int (*decrypt_input) P((int));
extern void (*encrypt_output) P((unsigned char *, int));
extern int (*decrypt_input) P((int));
/*
* We keep track of each side of the option negotiation.
/*
* We keep track of each side of the option negotiation.
fprintf(stderr, "Usage: %s %s%s%s%s\n",
prompt,
#ifdef AUTHENTICATION
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] [-n tracefile] ",
+ "[-8] [-E] [-K] [-L] [-S tos] [-X atype] [-a] [-c] [-d] [-e char]",
+ "\n\t[-k realm] [-l user] [-n tracefile] ",
- " [-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
#endif
#if defined(TN3270) && defined(unix)
# ifdef AUTHENTICATION
- "[-noasynch] [-noasynctty] [-noasyncnet]\n\t[-r] [-t transcom] ",
+ "[-noasynch] [-noasynctty]\n\t[-noasyncnet] [-r] [-t transcom] ",
- "[-noasynch] [-noasynctty] [-noasyncnet] [-r] [-t transcom]\n\t",
+ "[-noasynch] [-noasynctty] [-noasyncnet] [-r]\n\t[-t transcom]",
# endif
#else
"[-r] ",
#endif
#ifdef ENCRYPTION
"[-x] [host-name [port]]"
# endif
#else
"[-r] ",
#endif
#ifdef ENCRYPTION
"[-x] [host-name [port]]"
#ifdef ENCRYPTION
encrypt_auto(1);
decrypt_auto(1);
#ifdef ENCRYPTION
encrypt_auto(1);
decrypt_auto(1);
fprintf(stderr,
"%s: Warning: -x ignored, no ENCRYPT support.\n",
prompt);
fprintf(stderr,
"%s: Warning: -x ignored, no ENCRYPT support.\n",
prompt);
break;
case '?':
default:
break;
case '?':
default:
if (encrypt_output)
ring_encrypt(&netoring, encrypt_output);
if (encrypt_output)
ring_encrypt(&netoring, encrypt_output);
if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
if (!ring_at_mark(&netoring)) {
n = send(net, netoring.consume, n, 0); /* normal write */
if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
if (!ring_at_mark(&netoring)) {
n = send(net, netoring.consume, n, 0); /* normal write */
ring->top = ring->bottom+ring->size;
ring->top = ring->bottom+ring->size;
(ring_subtract(ring, ring->mark, ring->consume) < count)) {
ring->mark = 0;
}
(ring_subtract(ring, ring->mark, ring->consume) < count)) {
ring->mark = 0;
}
if (ring->consume < ring->clearto &&
ring->clearto <= ring->consume + count)
ring->clearto = 0;
if (ring->consume < ring->clearto &&
ring->clearto <= ring->consume + count)
ring->clearto = 0;
ring->bottom <= ring->clearto &&
ring->bottom + ((ring->consume + count) - ring->top))
ring->clearto = 0;
ring->bottom <= ring->clearto &&
ring->bottom + ((ring->consume + count) - ring->top))
ring->clearto = 0;
ring->consume = ring_increment(ring, ring->consume, count);
ring->consumetime = ++ring_clock;
/*
ring->consume = ring_increment(ring, ring->consume, count);
ring->consumetime = ++ring_clock;
/*
void
ring_encrypt(ring, encryptor)
Ring *ring;
void
ring_encrypt(ring, encryptor)
Ring *ring;
else
ring->clearto = 0;
}
else
ring->clearto = 0;
}
*bottom, /* lowest address in buffer */
*top, /* highest address+1 in buffer */
*mark; /* marker (user defined) */
*bottom, /* lowest address in buffer */
*top, /* highest address+1 in buffer */
*mark; /* marker (user defined) */
unsigned char *clearto; /* Data to this point is clear text */
unsigned char *encryyptedto; /* Data is encrypted to here */
unsigned char *clearto; /* Data to this point is clear text */
unsigned char *encryyptedto; /* Data is encrypted to here */
int size; /* size in bytes of buffer */
u_long consumetime, /* help us keep straight full, empty, etc. */
supplytime;
int size; /* size in bytes of buffer */
u_long consumetime, /* help us keep straight full, empty, etc. */
supplytime;
ring_full_count P((Ring *ring)),
ring_full_consecutive P((Ring *ring));
ring_full_count P((Ring *ring)),
ring_full_consecutive P((Ring *ring));
extern void
ring_encrypt P((Ring *ring, void (*func)())),
ring_clearto P((Ring *ring));
extern void
ring_encrypt P((Ring *ring, void (*func)())),
ring_clearto P((Ring *ring));
extern void
ring_clear_mark(),
extern void
ring_clear_mark(),
#endif
} else {
#ifdef SIGINFO
#endif
} else {
#ifdef SIGINFO
+ SIG_FUNC_RET ayt_status();
+
(void) signal(SIGINFO, ayt_status);
#endif SIGINFO
#ifdef SIGTSTP
(void) signal(SIGINFO, ayt_status);
#endif SIGINFO
#ifdef SIGTSTP
ClearArray(options);
connected = In3270 = ISend = localflow = donebinarytoggle = 0;
ClearArray(options);
connected = In3270 = ISend = localflow = donebinarytoggle = 0;
-#if defined(ENCRYPTION) || defined(AUTHENTICATION)
+#if defined(AUTHENTICATION) || defined(ENCRYPTION)
auth_encrypt_connect(connected);
auth_encrypt_connect(connected);
+#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
restartany = -1;
SYNCHing = 0;
restartany = -1;
SYNCHing = 0;
#if defined(AUTHENTICATION)
case TELOPT_AUTHENTICATION:
#endif
#if defined(AUTHENTICATION)
case TELOPT_AUTHENTICATION:
#endif
}
}
set_my_state_do(option);
}
}
set_my_state_do(option);
if (option == TELOPT_ENCRYPT)
encrypt_send_support();
if (option == TELOPT_ENCRYPT)
encrypt_send_support();
case TELOPT_TTYPE: /* terminal type option */
case TELOPT_SGA: /* no big deal */
case TELOPT_ENVIRON: /* environment variable option */
case TELOPT_TTYPE: /* terminal type option */
case TELOPT_SGA: /* no big deal */
case TELOPT_ENVIRON: /* environment variable option */
case TELOPT_ENCRYPT: /* encryption variable option */
case TELOPT_ENCRYPT: /* encryption variable option */
new_state_ok = 1;
break;
#if defined(AUTHENTICATION)
new_state_ok = 1;
break;
#if defined(AUTHENTICATION)
case TELOPT_ENCRYPT:
if (SB_EOF())
return;
case TELOPT_ENCRYPT:
if (SB_EOF())
return;
}
c = *sbp++ & 0xff, scc--; count++;
}
c = *sbp++ & 0xff, scc--; count++;
if (decrypt_input)
c = (*decrypt_input)(c);
if (decrypt_input)
c = (*decrypt_input)(c);
*Ifrontp++ = c;
while (scc > 0) {
c = *sbp++ & 0377, scc--; count++;
*Ifrontp++ = c;
while (scc > 0) {
c = *sbp++ & 0377, scc--; count++;
if (decrypt_input)
c = (*decrypt_input)(c);
if (decrypt_input)
c = (*decrypt_input)(c);
if (c == IAC) {
telrcv_state = TS_IAC;
break;
if (c == IAC) {
telrcv_state = TS_IAC;
break;
if ((c == '\r') && my_want_state_is_dont(TELOPT_BINARY)) {
if (scc > 0) {
c = *sbp&0xff;
if ((c == '\r') && my_want_state_is_dont(TELOPT_BINARY)) {
if (scc > 0) {
c = *sbp&0xff;
if (decrypt_input)
c = (*decrypt_input)(c);
if (decrypt_input)
c = (*decrypt_input)(c);
if (c == 0) {
sbp++, scc--; count++;
/* a "true" CR */
if (c == 0) {
sbp++, scc--; count++;
/* a "true" CR */
sbp++, scc--; count++;
TTYADD('\n');
} else {
sbp++, scc--; count++;
TTYADD('\n');
} else {
if (decrypt_input)
(*decrypt_input)(-1);
if (decrypt_input)
(*decrypt_input)(-1);
TTYADD('\r');
if (crmod) {
TTYADD('\r');
if (crmod) {
-#if defined(ENCRYPTION) || defined(AUTHENTICATION)
+#if defined(AUTHENTICATION) || defined(ENCRYPTION)
{
static char local_host[256] = { 0 };
{
static char local_host[256] = { 0 };
auth_encrypt_init(local_host, hostname, "TELNET", 0);
auth_encrypt_user(user);
}
auth_encrypt_init(local_host, hostname, "TELNET", 0);
auth_encrypt_user(user);
}
+#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
# if !defined(TN3270)
if (telnetport) {
#if defined(AUTHENTICATION)
if (autologin)
send_will(TELOPT_AUTHENTICATION, 1);
#endif
# if !defined(TN3270)
if (telnetport) {
#if defined(AUTHENTICATION)
if (autologin)
send_will(TELOPT_AUTHENTICATION, 1);
#endif
send_do(TELOPT_ENCRYPT, 1);
send_will(TELOPT_ENCRYPT, 1);
send_do(TELOPT_ENCRYPT, 1);
send_will(TELOPT_ENCRYPT, 1);
send_do(TELOPT_SGA, 1);
send_will(TELOPT_TTYPE, 1);
send_will(TELOPT_NAWS, 1);
send_do(TELOPT_SGA, 1);
send_will(TELOPT_TTYPE, 1);
send_will(TELOPT_NAWS, 1);
{
#ifdef ENCRYPTION
static int enc_passwd = 0;
{
#ifdef ENCRYPTION
static int enc_passwd = 0;
register int newmode;
newmode = getconnmode()|(force?MODE_FORCE:0);
register int newmode;
newmode = getconnmode()|(force?MODE_FORCE:0);
case TELOPT_ENCRYPT:
fprintf(NetTrace, "ENCRYPT");
if (length < 2) {
case TELOPT_ENCRYPT:
fprintf(NetTrace, "ENCRYPT");
if (length < 2) {
case TELOPT_LINEMODE:
fprintf(NetTrace, "LINEMODE ");
case TELOPT_LINEMODE:
fprintf(NetTrace, "LINEMODE ");