summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-11-30 21:06:38 +0000
committermarkm <markm@FreeBSD.org>2001-11-30 21:06:38 +0000
commit19fd256fae7c15fbb63128196d5550a72c559ea8 (patch)
tree1caab024c94078fe45902c1c2f8f58e5bdb7d4f4 /crypto
parente92874bd103e4d5462fd2c0013b77afc3d52df05 (diff)
downloadFreeBSD-src-19fd256fae7c15fbb63128196d5550a72c559ea8.zip
FreeBSD-src-19fd256fae7c15fbb63128196d5550a72c559ea8.tar.gz
Very large style makeover.
1) ANSIfy. 2) Clean up ifdefs so that a) ones that never/always apply are appropriately either fully removed, or just the #if junk is removed. b) change #if defined(FOO) for appropiate values of FOO. (currently AUTHENTICATION and ENCRYPTION) 3) WARNS=2 fixing 4) GC other unused stuff This code can now be unifdef(1)ed to make non-crypto telnet.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/telnet/arpa/telnet.h12
-rw-r--r--crypto/telnet/libtelnet/auth-proto.h80
-rw-r--r--crypto/telnet/libtelnet/auth.c188
-rw-r--r--crypto/telnet/libtelnet/auth.h20
-rw-r--r--crypto/telnet/libtelnet/enc-proto.h122
-rw-r--r--crypto/telnet/libtelnet/enc_des.c250
-rw-r--r--crypto/telnet/libtelnet/encrypt.c282
-rw-r--r--crypto/telnet/libtelnet/encrypt.h32
-rw-r--r--crypto/telnet/libtelnet/genget.c9
-rw-r--r--crypto/telnet/libtelnet/getent.c40
-rw-r--r--crypto/telnet/libtelnet/kerberos.c133
-rw-r--r--crypto/telnet/libtelnet/kerberos5.c1223
-rw-r--r--crypto/telnet/libtelnet/key-proto.h18
-rw-r--r--crypto/telnet/libtelnet/krb4encpwd.c26
-rw-r--r--crypto/telnet/libtelnet/misc-proto.h25
-rw-r--r--crypto/telnet/libtelnet/misc.c41
-rw-r--r--crypto/telnet/libtelnet/pk.c23
-rw-r--r--crypto/telnet/libtelnet/pk.h13
-rw-r--r--crypto/telnet/libtelnet/read_password.c1
-rw-r--r--crypto/telnet/libtelnet/rsaencpwd.c22
-rw-r--r--crypto/telnet/libtelnet/spx.c592
-rw-r--r--crypto/telnet/libtelnet/sra.c119
-rw-r--r--crypto/telnet/telnet/authenc.c49
-rw-r--r--crypto/telnet/telnet/commands.c1046
-rw-r--r--crypto/telnet/telnet/defines.h7
-rw-r--r--crypto/telnet/telnet/externs.h106
-rw-r--r--crypto/telnet/telnet/main.c107
-rw-r--r--crypto/telnet/telnet/network.c30
-rw-r--r--crypto/telnet/telnet/ring.c103
-rw-r--r--crypto/telnet/telnet/ring.h7
-rw-r--r--crypto/telnet/telnet/sys_bsd.c275
-rw-r--r--crypto/telnet/telnet/telnet.c687
-rw-r--r--crypto/telnet/telnet/terminal.c43
-rw-r--r--crypto/telnet/telnet/tn3270.c416
-rw-r--r--crypto/telnet/telnet/utilities.c117
-rw-r--r--crypto/telnet/telnetd/authenc.c45
-rw-r--r--crypto/telnet/telnetd/ext.h25
-rw-r--r--crypto/telnet/telnetd/slc.c80
-rw-r--r--crypto/telnet/telnetd/state.c110
-rw-r--r--crypto/telnet/telnetd/sys_term.c800
-rw-r--r--crypto/telnet/telnetd/telnetd.820
-rw-r--r--crypto/telnet/telnetd/telnetd.c291
-rw-r--r--crypto/telnet/telnetd/telnetd.h4
-rw-r--r--crypto/telnet/telnetd/termstat.c33
-rw-r--r--crypto/telnet/telnetd/utility.c114
45 files changed, 2469 insertions, 5317 deletions
diff --git a/crypto/telnet/arpa/telnet.h b/crypto/telnet/arpa/telnet.h
index af85741..079119c 100644
--- a/crypto/telnet/arpa/telnet.h
+++ b/crypto/telnet/arpa/telnet.h
@@ -64,7 +64,7 @@
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
-char *telcmds[] = {
+const char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
@@ -126,7 +126,7 @@ extern char *telcmds[];
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
#ifdef TELOPTS
-char *telopts[NTELOPTS+1] = {
+const char *telopts[NTELOPTS+1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
@@ -226,7 +226,7 @@ char *telopts[NTELOPTS+1] = {
0
#ifdef SLC_NAMES
-char *slc_names[] = {
+const char *slc_names[] = {
SLC_NAMELIST
};
#else
@@ -287,7 +287,7 @@ extern char *slc_names[];
#define AUTHTYPE_TEST 99
#ifdef AUTH_NAMES
-char *authtype_names[] = {
+const char *authtype_names[] = {
"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
0
};
@@ -318,12 +318,12 @@ extern char *authtype_names[];
#define ENCTYPE_CNT 3
#ifdef ENCRYPT_NAMES
-char *encrypt_names[] = {
+const char *encrypt_names[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
0
};
-char *enctype_names[] = {
+const char *enctype_names[] = {
"ANY", "DES_CFB64", "DES_OFB64",
0
};
diff --git a/crypto/telnet/libtelnet/auth-proto.h b/crypto/telnet/libtelnet/auth-proto.h
index e6b8481..0bcc0b6 100644
--- a/crypto/telnet/libtelnet/auth-proto.h
+++ b/crypto/telnet/libtelnet/auth-proto.h
@@ -62,48 +62,58 @@
#endif
#endif
-#if defined(AUTHENTICATION)
-Authenticator *findauthenticator P((int, int));
+#ifdef AUTHENTICATION
-void auth_init P((char *, int));
-int auth_cmd P((int, char **));
-void auth_request P((void));
-void auth_send P((unsigned char *, int));
-void auth_send_retry P((void));
-void auth_is P((unsigned char *, int));
-void auth_reply P((unsigned char *, int));
-void auth_finished P((Authenticator *, int));
-int auth_wait P((char *));
-void auth_disable_name P((char *));
-void auth_gen_printsub P((unsigned char *, int, unsigned char *, int));
-void auth_name P((unsigned char *, int));
-void auth_printsub P((unsigned char *, int, unsigned char *, int));
-int auth_sendname P((unsigned char *, int));
-void auth_encrypt_user P((char *));
+Authenticator *findauthenticator(int, int);
+
+void auth_init(const char *, int);
+int auth_cmd(int, char **);
+void auth_request(void);
+void auth_send(unsigned char *, int);
+void auth_send_retry(void);
+void auth_is(unsigned char *, int);
+void auth_reply(unsigned char *, int);
+void auth_finished(Authenticator *, int);
+int auth_wait(char *);
+void auth_disable_name(char *);
+void auth_gen_printsub(unsigned char *, int, unsigned char *, int);
+void auth_name(unsigned char *, int);
+void auth_printsub(unsigned char *, int, unsigned char *, int);
+int auth_sendname(unsigned char *, int);
+void auth_encrypt_user(char *);
+int auth_disable(char *);
+int auth_enable(char *);
+int auth_togdebug(int);
+int auth_status(void);
+
+int getauthmask(char *, int *);
#ifdef KRB4
-int kerberos4_init P((Authenticator *, int));
-int kerberos4_send P((Authenticator *));
-void kerberos4_is P((Authenticator *, unsigned char *, int));
-void kerberos4_reply P((Authenticator *, unsigned char *, int));
-int kerberos4_status P((Authenticator *, char *, int));
-void kerberos4_printsub P((unsigned char *, int, unsigned char *, int));
+int kerberos4_init(Authenticator *, int);
+int kerberos4_send(Authenticator *);
+void kerberos4_is(Authenticator *, unsigned char *, int);
+void kerberos4_reply(Authenticator *, unsigned char *, int);
+int kerberos4_status(Authenticator *, char *, int);
+void kerberos4_printsub(unsigned char *, int, unsigned char *, int);
#endif
#ifdef KRB5
-int kerberos5_init P((Authenticator *, int));
-int kerberos5_send P((Authenticator *));
-void kerberos5_is P((Authenticator *, unsigned char *, int));
-void kerberos5_reply P((Authenticator *, unsigned char *, int));
-int kerberos5_status P((Authenticator *, char *, int));
-void kerberos5_printsub P((unsigned char *, int, unsigned char *, int));
+int kerberos5_init(Authenticator *, int);
+int kerberos5_send_mutual(Authenticator *);
+int kerberos5_send_oneway(Authenticator *);
+void kerberos5_is(Authenticator *, unsigned char *, int);
+void kerberos5_reply(Authenticator *, unsigned char *, int);
+int kerberos5_status(Authenticator *, char *, int level);
+void kerberos5_printsub(unsigned char *, int, unsigned char *, int);
#endif
+
#ifdef SRA
-int sra_init P((Authenticator *, int));
-int sra_send P((Authenticator *));
-void sra_is P((Authenticator *, unsigned char *, int));
-void sra_reply P((Authenticator *, unsigned char *, int));
-int sra_status P((Authenticator *, char *, int));
-void sra_printsub P((unsigned char *, int, unsigned char *, int));
+int sra_init(Authenticator *, int);
+int sra_send(Authenticator *);
+void sra_is(Authenticator *, unsigned char *, int);
+void sra_reply(Authenticator *, unsigned char *, int);
+int sra_status(Authenticator *, char *, int);
+void sra_printsub(unsigned char *, int, unsigned char *, int);
#endif
+
#endif
diff --git a/crypto/telnet/libtelnet/auth.c b/crypto/telnet/libtelnet/auth.c
index eb1e20c..79d985d 100644
--- a/crypto/telnet/libtelnet/auth.c
+++ b/crypto/telnet/libtelnet/auth.c
@@ -34,6 +34,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -61,28 +62,22 @@ static const char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95";
*/
-#if defined(AUTHENTICATION)
-#include <stdio.h>
+#ifdef AUTHENTICATION
+#define AUTH_NAMES
#include <sys/types.h>
#include <signal.h>
-#define AUTH_NAMES
-#include <arpa/telnet.h>
-#ifdef __STDC__
+#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
#include <string.h>
-#endif
+#include <unistd.h>
+#include <arpa/telnet.h>
#include "encrypt.h"
#include "auth.h"
#include "misc-proto.h"
#include "auth-proto.h"
-#define typemask(x) (1<<((x)-1))
+#define typemask(x) ((x) > 0 ? 1 << ((x)-1) : 0)
#ifdef KRB4_ENCPWD
extern krb4encpwd_init();
@@ -103,7 +98,7 @@ extern rsaencpwd_printsub();
#endif
int auth_debug_mode = 0;
-static char *Name = "Noname";
+static const char *Name = "Noname";
static int Server = 0;
static Authenticator *authenticated = 0;
static int authenticating = 0;
@@ -120,27 +115,11 @@ void auth_encrypt_user(char *name);
* in priority order, i.e. try the first one first.
*/
Authenticator authenticators[] = {
-#ifdef SPX
- { AUTHTYPE_SPX, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL,
- spx_init,
- spx_send,
- spx_is,
- spx_reply,
- spx_status,
- spx_printsub },
- { AUTHTYPE_SPX, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY,
- spx_init,
- spx_send,
- spx_is,
- spx_reply,
- spx_status,
- spx_printsub },
-#endif
#ifdef KRB5
# ifdef ENCRYPTION
{ AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL,
kerberos5_init,
- kerberos5_send,
+ kerberos5_send_mutual,
kerberos5_is,
kerberos5_reply,
kerberos5_status,
@@ -148,7 +127,7 @@ Authenticator authenticators[] = {
# endif /* ENCRYPTION */
{ AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY,
kerberos5_init,
- kerberos5_send,
+ kerberos5_send_oneway,
kerberos5_is,
kerberos5_reply,
kerberos5_status,
@@ -200,18 +179,16 @@ Authenticator authenticators[] = {
sra_printsub },
#endif
- { 0, },
+ { 0, 0, 0, 0, 0, 0, 0, 0 },
};
-static Authenticator NoAuth = { 0 };
+static Authenticator NoAuth = { 0, 0, 0, 0, 0, 0, 0, 0 };
static int i_support = 0;
static int i_wont_support = 0;
- Authenticator *
-findauthenticator(type, way)
- int type;
- int way;
+Authenticator *
+findauthenticator(int type, int way)
{
Authenticator *ap = authenticators;
@@ -220,10 +197,8 @@ findauthenticator(type, way)
return(ap->type ? ap : 0);
}
- void
-auth_init(name, server)
- char *name;
- int server;
+void
+auth_init(const char *name, int server)
{
Authenticator *ap = authenticators;
@@ -248,9 +223,8 @@ auth_init(name, server)
}
}
- void
-auth_disable_name(name)
- char *name;
+void
+auth_disable_name(char *name)
{
int x;
for (x = 0; x < AUTHTYPE_CNT; ++x) {
@@ -261,12 +235,10 @@ auth_disable_name(name)
}
}
- int
-getauthmask(type, maskp)
- char *type;
- int *maskp;
+int
+getauthmask(char *type, int *maskp)
{
- register int x;
+ int x;
if (AUTHTYPE_NAME(0) && !strcasecmp(type, AUTHTYPE_NAME(0))) {
*maskp = -1;
@@ -282,24 +254,20 @@ getauthmask(type, maskp)
return(0);
}
- int
-auth_enable(type)
- char *type;
+int
+auth_enable(char *type)
{
return(auth_onoff(type, 1));
}
- int
-auth_disable(type)
- char *type;
+int
+auth_disable(char *type)
{
return(auth_onoff(type, 0));
}
- int
-auth_onoff(type, on)
- char *type;
- int on;
+int
+auth_onoff(char *type, int on)
{
int i, mask = -1;
Authenticator *ap;
@@ -329,9 +297,8 @@ auth_onoff(type, on)
return(1);
}
- int
-auth_togdebug(on)
- int on;
+int
+auth_togdebug(int on)
{
if (on < 0)
auth_debug_mode ^= 1;
@@ -341,8 +308,8 @@ auth_togdebug(on)
return(1);
}
- int
-auth_status()
+int
+auth_status(void)
{
Authenticator *ap;
int i, mask;
@@ -368,8 +335,8 @@ auth_status()
* This routine is called by the server to start authentication
* negotiation.
*/
- void
-auth_request()
+void
+auth_request(void)
{
static unsigned char str_request[64] = { IAC, SB,
TELOPT_AUTHENTICATION,
@@ -408,10 +375,8 @@ auth_request()
* with KERBEROS instead of LOGIN (which is against what the
* protocol says)) you will have to hack this code...
*/
- void
-auth_send(data, cnt)
- unsigned char *data;
- int cnt;
+void
+auth_send(unsigned char *data, int cnt)
{
Authenticator *ap;
static unsigned char str_none[] = { IAC, SB, TELOPT_AUTHENTICATION,
@@ -435,7 +400,7 @@ auth_send(data, cnt)
*/
if (data < _auth_send_data ||
data > _auth_send_data + sizeof(_auth_send_data)) {
- auth_send_cnt = cnt > sizeof(_auth_send_data)
+ auth_send_cnt = (size_t)cnt > sizeof(_auth_send_data)
? sizeof(_auth_send_data)
: cnt;
memmove((void *)_auth_send_data, (void *)data, auth_send_cnt);
@@ -484,18 +449,10 @@ auth_send(data, cnt)
if (auth_debug_mode)
printf(">>>%s: Sent failure message\r\n", Name);
auth_finished(0, AUTH_REJECT);
-#ifdef KANNAN
- /*
- * We requested strong authentication, however no mechanisms worked.
- * Therefore, exit on client end.
- */
- printf("Unable to securely authenticate user ... exit\n");
- exit(0);
-#endif /* KANNAN */
}
- void
-auth_send_retry()
+void
+auth_send_retry(void)
{
/*
* if auth_send_cnt <= 0 then auth_send will end up rejecting
@@ -504,10 +461,8 @@ auth_send_retry()
auth_send(auth_send_data, auth_send_cnt);
}
- void
-auth_is(data, cnt)
- unsigned char *data;
- int cnt;
+void
+auth_is(unsigned char *data, int cnt)
{
Authenticator *ap;
@@ -527,10 +482,8 @@ auth_is(data, cnt)
Name, *data);
}
- void
-auth_reply(data, cnt)
- unsigned char *data;
- int cnt;
+void
+auth_reply(unsigned char *data, int cnt)
{
Authenticator *ap;
@@ -545,10 +498,8 @@ auth_reply(data, cnt)
Name, *data);
}
- void
-auth_name(data, cnt)
- unsigned char *data;
- int cnt;
+void
+auth_name(unsigned char *data, int cnt)
{
unsigned char savename[256];
@@ -557,7 +508,7 @@ auth_name(data, cnt)
printf(">>>%s: Empty name in NAME\r\n", Name);
return;
}
- if (cnt > sizeof(savename) - 1) {
+ if ((size_t)cnt > sizeof(savename) - 1) {
if (auth_debug_mode)
printf(">>>%s: Name in NAME (%d) exceeds %d length\r\n",
Name, cnt, sizeof(savename)-1);
@@ -570,15 +521,13 @@ auth_name(data, cnt)
auth_encrypt_user(savename);
}
- int
-auth_sendname(cp, len)
- unsigned char *cp;
- int len;
+int
+auth_sendname(unsigned char *cp, int len)
{
static unsigned char str_request[256+6]
= { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, };
- register unsigned char *e = str_request + 4;
- register unsigned char *ee = &str_request[sizeof(str_request)-2];
+ unsigned char *e = str_request + 4;
+ unsigned char *ee = &str_request[sizeof(str_request)-2];
while (--len >= 0) {
if ((*e++ = *cp++) == IAC)
@@ -593,27 +542,23 @@ auth_sendname(cp, len)
return(1);
}
- void
-auth_finished(ap, result)
- Authenticator *ap;
- int result;
+void
+auth_finished(Authenticator *ap, int result)
{
if (!(authenticated = ap))
authenticated = &NoAuth;
validuser = result;
}
- /* ARGSUSED */
- static void
-auth_intr(sig)
- int sig;
+/* ARGSUSED */
+static void
+auth_intr(int sig __unused)
{
auth_finished(0, AUTH_REJECT);
}
- int
-auth_wait(name)
- char *name;
+int
+auth_wait(char *name)
{
if (auth_debug_mode)
printf(">>>%s: in auth_wait.\r\n", Name);
@@ -644,17 +589,8 @@ auth_wait(name)
return(validuser);
}
- void
-auth_debug(mode)
- int mode;
-{
- auth_debug_mode = mode;
-}
-
- void
-auth_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+auth_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
Authenticator *ap;
@@ -664,12 +600,10 @@ auth_printsub(data, cnt, buf, buflen)
auth_gen_printsub(data, cnt, buf, buflen);
}
- void
-auth_gen_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+auth_gen_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
- register unsigned char *cp;
+ unsigned char *cp;
unsigned char tbuf[16];
cnt -= 3;
diff --git a/crypto/telnet/libtelnet/auth.h b/crypto/telnet/libtelnet/auth.h
index 2110f9e..a8ee048 100644
--- a/crypto/telnet/libtelnet/auth.h
+++ b/crypto/telnet/libtelnet/auth.h
@@ -63,23 +63,15 @@
#define AUTH_USER 3 /* We know he name */
#define AUTH_VALID 4 /* We know him, and he needs no password */
-#if !defined(P)
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
typedef struct XauthP {
int type;
int way;
- int (*init) P((struct XauthP *, int));
- int (*send) P((struct XauthP *));
- void (*is) P((struct XauthP *, unsigned char *, int));
- void (*reply) P((struct XauthP *, unsigned char *, int));
- int (*status) P((struct XauthP *, char *, int));
- void (*printsub) P((unsigned char *, int, unsigned char *, int));
+ int (*init)(struct XauthP *, int);
+ int (*send)(struct XauthP *);
+ void (*is)(struct XauthP *, unsigned char *, int);
+ void (*reply)(struct XauthP *, unsigned char *, int);
+ int (*status)(struct XauthP *, char *, int);
+ void (*printsub)(unsigned char *, int, unsigned char *, int);
} Authenticator;
#include "auth-proto.h"
diff --git a/crypto/telnet/libtelnet/enc-proto.h b/crypto/telnet/libtelnet/enc-proto.h
index bbbc07c..a132962 100644
--- a/crypto/telnet/libtelnet/enc-proto.h
+++ b/crypto/telnet/libtelnet/enc-proto.h
@@ -62,68 +62,72 @@
#endif
#ifdef ENCRYPTION
-void encrypt_init P((char *, int));
-Encryptions *findencryption P((int));
-void encrypt_send_supprt P((void));
-void encrypt_auto P((int));
-void decrypt_auto P((int));
-void encrypt_is P((unsigned char *, int));
-void encrypt_reply P((unsigned char *, int));
-void encrypt_start_input P((int));
-void encrypt_session_key P((Session_Key *, int));
-void encrypt_end_input P((void));
-void encrypt_start_output P((int));
-void encrypt_end_output P((void));
-void encrypt_send_request_start P((void));
-void encrypt_send_request_end P((void));
-void encrypt_send_end P((void));
-void encrypt_wait P((void));
-void encrypt_send_support P((void));
-void encrypt_send_keyid P((int, unsigned char *, int, int));
-void encrypt_start P((unsigned char *, int));
-void encrypt_end P((void));
-void encrypt_support P((unsigned char *, int));
-void encrypt_request_start P((unsigned char *, int));
-void encrypt_request_end P((void));
-void encrypt_enc_keyid P((unsigned char *, int));
-void encrypt_dec_keyid P((unsigned char *, int));
-void encrypt_printsub P((unsigned char *, int, unsigned char *, int));
-int net_write P((unsigned char *, int));
+void encrypt_init(const char *, int);
+Encryptions *findencryption(int);
+void encrypt_send_supprt(void);
+void encrypt_auto(int);
+void decrypt_auto(int);
+void encrypt_is(unsigned char *, int);
+void encrypt_reply(unsigned char *, int);
+void encrypt_start_input(int);
+void encrypt_session_key(Session_Key *, int);
+void encrypt_end_input(void);
+void encrypt_start_output(int);
+void encrypt_end_output(void);
+void encrypt_send_request_start(void);
+void encrypt_send_request_end(void);
+void encrypt_send_end(void);
+void encrypt_wait(void);
+void encrypt_send_support(void);
+void encrypt_send_keyid(int, const char *, int, int);
+void encrypt_start(unsigned char *, int);
+void encrypt_end(void);
+void encrypt_support(unsigned char *, int);
+void encrypt_request_start(unsigned char *, int);
+void encrypt_request_end(void);
+void encrypt_enc_keyid(unsigned char *, int);
+void encrypt_dec_keyid(unsigned char *, int);
+void encrypt_printsub(unsigned char *, int, unsigned char *, int);
+void encrypt_gen_printsub(unsigned char *, int, unsigned char *, int);
+void encrypt_display(void);
-#ifndef TELENTD
-int encrypt_cmd P((int, char **));
-void encrypt_display P((void));
-#endif
+void fb64_printsub(unsigned char *, int, unsigned char *, int, const char *);
+
+int EncryptEnable(char *, char *);
+int EncryptDisable(char *, char *);
+int EncryptStatus(void);
+int EncryptDebug(int);
+int EncryptVerbose(int);
+int EncryptAutoEnc(int);
+int EncryptAutoDec(int);
-#ifdef DES_ENCRYPTION
-void krbdes_encrypt P((unsigned char *, int));
-int krbdes_decrypt P((int));
-int krbdes_is P((unsigned char *, int));
-int krbdes_reply P((unsigned char *, int));
-void krbdes_init P((int));
-int krbdes_start P((int, int));
-void krbdes_session P((Session_Key *, int));
-void krbdes_printsub P((unsigned char *, int, unsigned char *, int));
+void krbdes_encrypt(unsigned char *, int);
+int krbdes_decrypt(int);
+int krbdes_is(unsigned char *, int);
+int krbdes_reply(unsigned char *, int);
+void krbdes_init(int);
+int krbdes_start(int, int);
+void krbdes_session(Session_Key *, int);
+void krbdes_printsub(unsigned char *, int, unsigned char *, int);
-void cfb64_encrypt P((unsigned char *, int));
-int cfb64_decrypt P((int));
-void cfb64_init P((int));
-int cfb64_start P((int, int));
-int cfb64_is P((unsigned char *, int));
-int cfb64_reply P((unsigned char *, int));
-void cfb64_session P((Session_Key *, int));
-int cfb64_keyid P((int, unsigned char *, int *));
-void cfb64_printsub P((unsigned char *, int, unsigned char *, int));
+void cfb64_encrypt(unsigned char *, int);
+int cfb64_decrypt(int);
+void cfb64_init(int);
+int cfb64_start(int, int);
+int cfb64_is(unsigned char *, int);
+int cfb64_reply(unsigned char *, int);
+void cfb64_session(Session_Key *, int);
+int cfb64_keyid(int, unsigned char *, int *);
+void cfb64_printsub(unsigned char *, int, unsigned char *, int);
-void ofb64_encrypt P((unsigned char *, int));
-int ofb64_decrypt P((int));
-void ofb64_init P((int));
-int ofb64_start P((int, int));
-int ofb64_is P((unsigned char *, int));
-int ofb64_reply P((unsigned char *, int));
-void ofb64_session P((Session_Key *, int));
-int ofb64_keyid P((int, unsigned char *, int *));
-void ofb64_printsub P((unsigned char *, int, unsigned char *, int));
-#endif /* DES_ENCRYPTION */
+void ofb64_encrypt(unsigned char *, int);
+int ofb64_decrypt(int);
+void ofb64_init(int);
+int ofb64_start(int, int);
+int ofb64_is(unsigned char *, int);
+int ofb64_reply(unsigned char *, int);
+void ofb64_session(Session_Key *, int);
+int ofb64_keyid(int, unsigned char *, int *);
+void ofb64_printsub(unsigned char *, int, unsigned char *, int);
#endif /* ENCRYPTION */
diff --git a/crypto/telnet/libtelnet/enc_des.c b/crypto/telnet/libtelnet/enc_des.c
index 21113e5..93392a7 100644
--- a/crypto/telnet/libtelnet/enc_des.c
+++ b/crypto/telnet/libtelnet/enc_des.c
@@ -34,6 +34,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -42,15 +43,12 @@ static const char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95";
#ifdef ENCRYPTION
# ifdef AUTHENTICATION
-# ifdef DES_ENCRYPTION
#include <arpa/telnet.h>
+#include <openssl/des.h>
#include <stdio.h>
-#ifdef __STDC__
#include <stdlib.h>
-#endif
-
-#include <openssl/des.h>
#include <string.h>
+
#include "encrypt.h"
#include "key-proto.h"
#include "misc-proto.h"
@@ -92,7 +90,7 @@ struct fb {
static struct fb fb[2];
struct keyidlist {
- char *keyid;
+ const char *keyid;
int keyidlen;
char *key;
int keylen;
@@ -127,9 +125,8 @@ static void fb64_session P((Session_Key *, int, struct fb *));
void fb64_stream_key P((Block, struct stinfo *));
int fb64_keyid P((int, unsigned char *, int *, struct fb *));
- void
-cfb64_init(server)
- int server;
+void
+cfb64_init(int server __unused)
{
fb64_init(&fb[CFB]);
fb[CFB].fb_feed[4] = ENCTYPE_DES_CFB64;
@@ -137,9 +134,8 @@ cfb64_init(server)
fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, CFB);
}
- void
-ofb64_init(server)
- int server;
+void
+ofb64_init(int server __unused)
{
fb64_init(&fb[OFB]);
fb[OFB].fb_feed[4] = ENCTYPE_DES_OFB64;
@@ -147,9 +143,8 @@ ofb64_init(server)
fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, OFB);
}
- void
-fb64_init(fbp)
- register struct fb *fbp;
+void
+fb64_init(struct fb *fbp)
{
memset((void *)fbp, 0, sizeof(*fbp));
fbp->state[0] = fbp->state[1] = FAILED;
@@ -167,30 +162,24 @@ fb64_init(fbp)
* 2: Not yet. Other things (like getting the key from
* Kerberos) have to happen before we can continue.
*/
- int
-cfb64_start(dir, server)
- int dir;
- int server;
+int
+cfb64_start(int dir, int server)
{
return(fb64_start(&fb[CFB], dir, server));
}
- int
-ofb64_start(dir, server)
- int dir;
- int server;
+
+int
+ofb64_start(int dir, int server)
{
return(fb64_start(&fb[OFB], dir, server));
}
- static int
-fb64_start(fbp, dir, server)
- struct fb *fbp;
- int dir;
- int server;
+static int
+fb64_start(struct fb *fbp, int dir, int server __unused)
{
- int x;
+ size_t x;
unsigned char *p;
- register int state;
+ int state;
switch (dir) {
case DIR_DECRYPT:
@@ -250,29 +239,23 @@ fb64_start(fbp, dir, server)
* 0: Successful, initial negotiation all done.
* 1: successful, negotiation not done yet.
*/
- int
-cfb64_is(data, cnt)
- unsigned char *data;
- int cnt;
+int
+cfb64_is(unsigned char *data, int cnt)
{
return(fb64_is(data, cnt, &fb[CFB]));
}
- int
-ofb64_is(data, cnt)
- unsigned char *data;
- int cnt;
+
+int
+ofb64_is(unsigned char *data, int cnt)
{
return(fb64_is(data, cnt, &fb[OFB]));
}
- int
-fb64_is(data, cnt, fbp)
- unsigned char *data;
- int cnt;
- struct fb *fbp;
+int
+fb64_is(unsigned char *data, int cnt, struct fb *fbp)
{
unsigned char *p;
- register int state = fbp->state[DIR_DECRYPT-1];
+ int state = fbp->state[DIR_DECRYPT-1];
if (cnt-- < 1)
goto failure;
@@ -339,29 +322,22 @@ fb64_is(data, cnt, fbp)
* 0: Successful, initial negotiation all done.
* 1: successful, negotiation not done yet.
*/
- int
-cfb64_reply(data, cnt)
- unsigned char *data;
- int cnt;
+int
+cfb64_reply(unsigned char *data, int cnt)
{
return(fb64_reply(data, cnt, &fb[CFB]));
}
- int
-ofb64_reply(data, cnt)
- unsigned char *data;
- int cnt;
+
+int
+ofb64_reply(unsigned char *data, int cnt)
{
return(fb64_reply(data, cnt, &fb[OFB]));
}
-
- int
-fb64_reply(data, cnt, fbp)
- unsigned char *data;
- int cnt;
- struct fb *fbp;
+int
+fb64_reply(unsigned char *data, int cnt, struct fb *fbp)
{
- register int state = fbp->state[DIR_ENCRYPT-1];
+ int state = fbp->state[DIR_ENCRYPT-1];
if (cnt-- < 1)
goto failure;
@@ -372,7 +348,7 @@ fb64_reply(data, cnt, fbp)
if (state == FAILED)
state = IN_PROGRESS;
state &= ~NO_RECV_IV;
- encrypt_send_keyid(DIR_ENCRYPT, (unsigned char *)"\0", 1, 1);
+ encrypt_send_keyid(DIR_ENCRYPT, "\0", 1, 1);
break;
case FB64_IV_BAD:
@@ -395,29 +371,21 @@ fb64_reply(data, cnt, fbp)
return(fbp->state[DIR_ENCRYPT-1] = state);
}
- void
-cfb64_session(key, server)
- Session_Key *key;
- int server;
+void
+cfb64_session(Session_Key *key, int server)
{
fb64_session(key, server, &fb[CFB]);
}
- void
-ofb64_session(key, server)
- Session_Key *key;
- int server;
+void
+ofb64_session(Session_Key *key, int server)
{
fb64_session(key, server, &fb[OFB]);
}
- static void
-fb64_session(key, server, fbp)
- Session_Key *key;
- int server;
- struct fb *fbp;
+static void
+fb64_session(Session_Key *key, int server, struct fb *fbp)
{
-
if (!key || key->type != SK_DES) {
if (encrypt_debug_mode)
printf("Can't set krbdes's session key (%d != %d)\r\n",
@@ -449,29 +417,22 @@ fb64_session(key, server, fbp)
* We only accept a keyid of 0. If we get a keyid of
* 0, then mark the state as SUCCESS.
*/
- int
-cfb64_keyid(dir, kp, lenp)
- int dir, *lenp;
- unsigned char *kp;
+int
+cfb64_keyid(int dir, unsigned char *kp, int *lenp)
{
return(fb64_keyid(dir, kp, lenp, &fb[CFB]));
}
- int
-ofb64_keyid(dir, kp, lenp)
- int dir, *lenp;
- unsigned char *kp;
+int
+ofb64_keyid(int dir, unsigned char *kp, int *lenp)
{
return(fb64_keyid(dir, kp, lenp, &fb[OFB]));
}
- int
-fb64_keyid(dir, kp, lenp, fbp)
- int dir, *lenp;
- unsigned char *kp;
- struct fb *fbp;
+int
+fb64_keyid(int dir, unsigned char *kp, int *lenp, struct fb *fbp)
{
- register int state = fbp->state[dir-1];
+ int state = fbp->state[dir-1];
if (*lenp != 1 || (*kp != '\0')) {
*lenp = 0;
@@ -486,13 +447,11 @@ fb64_keyid(dir, kp, lenp, fbp)
return(fbp->state[dir-1] = state);
}
- void
-fb64_printsub(data, cnt, buf, buflen, type)
- unsigned char *data, *buf, *type;
- int cnt, buflen;
+void
+fb64_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen, const char *type)
{
char lbuf[32];
- register int i;
+ int i;
char *cp;
buf[buflen-1] = '\0'; /* make sure it's NULL terminated */
@@ -529,26 +488,20 @@ fb64_printsub(data, cnt, buf, buflen, type)
}
}
- void
-cfb64_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+cfb64_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
fb64_printsub(data, cnt, buf, buflen, "CFB64");
}
- void
-ofb64_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+ofb64_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
fb64_printsub(data, cnt, buf, buflen, "OFB64");
}
- void
-fb64_stream_iv(seed, stp)
- Block seed;
- register struct stinfo *stp;
+void
+fb64_stream_iv(Block seed, struct stinfo *stp)
{
memmove((void *)stp->str_iv, (void *)seed, sizeof(Block));
@@ -559,10 +512,8 @@ fb64_stream_iv(seed, stp)
stp->str_index = sizeof(Block);
}
- void
-fb64_stream_key(key, stp)
- Block key;
- register struct stinfo *stp;
+void
+fb64_stream_key(Block key, struct stinfo *stp)
{
memmove((void *)stp->str_ikey, (void *)key, sizeof(Block));
des_key_sched((Block *)key, stp->str_sched);
@@ -594,37 +545,34 @@ fb64_stream_key(key, stp)
* V(n+1) = DES(On, key)
*/
- void
-cfb64_encrypt(s, c)
- register unsigned char *s;
- int c;
+void
+cfb64_encrypt(unsigned char *s, int c)
{
- register struct stinfo *stp = &fb[CFB].streams[DIR_ENCRYPT-1];
- register int index;
+ struct stinfo *stp = &fb[CFB].streams[DIR_ENCRYPT-1];
+ int idx;
- index = stp->str_index;
+ idx = stp->str_index;
while (c-- > 0) {
- if (index == sizeof(Block)) {
+ if (idx == sizeof(Block)) {
Block b;
des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
- index = 0;
+ idx = 0;
}
/* On encryption, we store (feed ^ data) which is cypher */
- *s = stp->str_output[index] = (stp->str_feed[index] ^ *s);
+ *s = stp->str_output[idx] = (stp->str_feed[idx] ^ *s);
s++;
- index++;
+ idx++;
}
- stp->str_index = index;
+ stp->str_index = idx;
}
- int
-cfb64_decrypt(data)
- int data;
+int
+cfb64_decrypt(int data)
{
- register struct stinfo *stp = &fb[CFB].streams[DIR_DECRYPT-1];
- int index;
+ struct stinfo *stp = &fb[CFB].streams[DIR_DECRYPT-1];
+ int idx;
if (data == -1) {
/*
@@ -637,18 +585,18 @@ cfb64_decrypt(data)
return(0);
}
- index = stp->str_index++;
- if (index == sizeof(Block)) {
+ idx = stp->str_index++;
+ if (idx == sizeof(Block)) {
Block b;
des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
stp->str_index = 1; /* Next time will be 1 */
- index = 0; /* But now use 0 */
+ idx = 0; /* But now use 0 */
}
/* On decryption we store (data) which is cypher. */
- stp->str_output[index] = data;
- return(data ^ stp->str_feed[index]);
+ stp->str_output[idx] = data;
+ return(data ^ stp->str_feed[idx]);
}
/*
@@ -670,34 +618,31 @@ cfb64_decrypt(data)
* V(n+1) = DES(Vn, key)
* On = Dn ^ Vn
*/
- void
-ofb64_encrypt(s, c)
- register unsigned char *s;
- int c;
+void
+ofb64_encrypt(unsigned char *s, int c)
{
- register struct stinfo *stp = &fb[OFB].streams[DIR_ENCRYPT-1];
- register int index;
+ struct stinfo *stp = &fb[OFB].streams[DIR_ENCRYPT-1];
+ int idx;
- index = stp->str_index;
+ idx = stp->str_index;
while (c-- > 0) {
- if (index == sizeof(Block)) {
+ if (idx == sizeof(Block)) {
Block b;
des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
- index = 0;
+ idx = 0;
}
- *s++ ^= stp->str_feed[index];
- index++;
+ *s++ ^= stp->str_feed[idx];
+ idx++;
}
- stp->str_index = index;
+ stp->str_index = idx;
}
- int
-ofb64_decrypt(data)
- int data;
+int
+ofb64_decrypt(int data)
{
- register struct stinfo *stp = &fb[OFB].streams[DIR_DECRYPT-1];
- int index;
+ struct stinfo *stp = &fb[OFB].streams[DIR_DECRYPT-1];
+ int idx;
if (data == -1) {
/*
@@ -710,17 +655,16 @@ ofb64_decrypt(data)
return(0);
}
- index = stp->str_index++;
- if (index == sizeof(Block)) {
+ idx = stp->str_index++;
+ if (idx == sizeof(Block)) {
Block b;
des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
stp->str_index = 1; /* Next time will be 1 */
- index = 0; /* But now use 0 */
+ idx = 0; /* But now use 0 */
}
- return(data ^ stp->str_feed[index]);
+ return(data ^ stp->str_feed[idx]);
}
-# endif /* DES_ENCRYPTION */
# endif /* AUTHENTICATION */
#endif /* ENCRYPTION */
diff --git a/crypto/telnet/libtelnet/encrypt.c b/crypto/telnet/libtelnet/encrypt.c
index d78f904..d57fd7f 100644
--- a/crypto/telnet/libtelnet/encrypt.c
+++ b/crypto/telnet/libtelnet/encrypt.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -63,21 +64,14 @@ static const char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95";
#ifdef ENCRYPTION
#define ENCRYPT_NAMES
-#include <stdio.h>
#include <arpa/telnet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include "encrypt.h"
#include "misc.h"
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
/*
* These functions pointers point to the current routines
* for encrypting and decrypting data.
@@ -93,10 +87,6 @@ int EncryptStartOutput(void);
int EncryptStopInput(void);
int EncryptStopOutput(void);
-int Ambiguous(char **s);
-int isprefix(char *s1, char *s2);
-char **genget(char *name, char **table, int stlen);
-
int encrypt_debug_mode = 0;
static int decrypt_mode = 0;
static int encrypt_mode = 0;
@@ -105,19 +95,15 @@ static int autoencrypt = 0;
static int autodecrypt = 0;
static int havesessionkey = 0;
static int Server = 0;
-static char *Name = "Noname";
+static const char *Name = "Noname";
#define typemask(x) ((x) > 0 ? 1 << ((x)-1) : 0)
static long i_support_encrypt = 0
-#ifdef DES_ENCRYPTION
| typemask(ENCTYPE_DES_CFB64) | typemask(ENCTYPE_DES_OFB64)
-#endif
|0;
static long i_support_decrypt = 0
-#ifdef DES_ENCRYPTION
| typemask(ENCTYPE_DES_CFB64) | typemask(ENCTYPE_DES_OFB64)
-#endif
|0;
static long i_wont_support_encrypt = 0;
@@ -129,7 +115,6 @@ static long remote_supports_encrypt = 0;
static long remote_supports_decrypt = 0;
static Encryptions encryptions[] = {
-#ifdef DES_ENCRYPTION
{ "DES_CFB64", ENCTYPE_DES_CFB64,
cfb64_encrypt,
cfb64_decrypt,
@@ -150,8 +135,7 @@ static Encryptions encryptions[] = {
ofb64_session,
ofb64_keyid,
ofb64_printsub },
-#endif /* DES_ENCRYPTION */
- { 0, },
+ { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};
static unsigned char str_send[64] = { IAC, SB, TELOPT_ENCRYPT,
@@ -160,26 +144,24 @@ static unsigned char str_suplen = 0;
static unsigned char str_start[72] = { IAC, SB, TELOPT_ENCRYPT };
static unsigned char str_end[] = { IAC, SB, TELOPT_ENCRYPT, 0, IAC, SE };
- Encryptions *
-findencryption(type)
- int type;
+Encryptions *
+findencryption(int type)
{
Encryptions *ep = encryptions;
- if (!(I_SUPPORT_ENCRYPT & remote_supports_decrypt & typemask(type)))
+ if (!(I_SUPPORT_ENCRYPT & remote_supports_decrypt & (unsigned)typemask(type)))
return(0);
while (ep->type && ep->type != type)
++ep;
return(ep->type ? ep : 0);
}
- Encryptions *
-finddecryption(type)
- int type;
+static Encryptions *
+finddecryption(int type)
{
Encryptions *ep = encryptions;
- if (!(I_SUPPORT_DECRYPT & remote_supports_encrypt & typemask(type)))
+ if (!(I_SUPPORT_DECRYPT & remote_supports_encrypt & (unsigned)typemask(type)))
return(0);
while (ep->type && ep->type != type)
++ep;
@@ -193,7 +175,7 @@ static struct key_info {
int keylen;
int dir;
int *modep;
- Encryptions *(*getcrypt)();
+ Encryptions *(*getcrypt)(int);
} ki[2] = {
{ { 0 }, 0, DIR_ENCRYPT, &encrypt_mode, findencryption },
{ { 0 }, 0, DIR_DECRYPT, &decrypt_mode, finddecryption },
@@ -201,10 +183,8 @@ static struct key_info {
static void encrypt_keyid(struct key_info *kp, unsigned char *keyid, int len);
- void
-encrypt_init(name, server)
- char *name;
- int server;
+void
+encrypt_init(const char *name, int server)
{
Encryptions *ep = encryptions;
@@ -216,9 +196,6 @@ encrypt_init(name, server)
decrypt_mode = 0;
encrypt_output = 0;
decrypt_input = 0;
-#ifdef notdef
- encrypt_verbose = !server;
-#endif
str_suplen = 4;
@@ -239,8 +216,8 @@ encrypt_init(name, server)
str_send[str_suplen++] = SE;
}
- void
-encrypt_list_types()
+static void
+encrypt_list_types(void)
{
Encryptions *ep = encryptions;
@@ -251,9 +228,8 @@ encrypt_list_types()
}
}
- int
-EncryptEnable(type, mode)
- char *type, *mode;
+int
+EncryptEnable(char *type, char *mode)
{
if (isprefix(type, "help") || isprefix(type, "?")) {
printf("Usage: encrypt enable <type> [input|output]\n");
@@ -265,11 +241,10 @@ EncryptEnable(type, mode)
return(0);
}
- int
-EncryptDisable(type, mode)
- char *type, *mode;
+int
+EncryptDisable(char *type, char *mode)
{
- register Encryptions *ep;
+ Encryptions *ep;
int ret = 0;
if (isprefix(type, "help") || isprefix(type, "?")) {
@@ -299,12 +274,10 @@ EncryptDisable(type, mode)
return(ret);
}
- int
-EncryptType(type, mode)
- char *type;
- char *mode;
+int
+EncryptType(char *type, char *mode)
{
- register Encryptions *ep;
+ Encryptions *ep;
int ret = 0;
if (isprefix(type, "help") || isprefix(type, "?")) {
@@ -332,11 +305,10 @@ EncryptType(type, mode)
return(ret);
}
- int
-EncryptStart(mode)
- char *mode;
+int
+EncryptStart(char *mode)
{
- register int ret = 0;
+ int ret = 0;
if (mode) {
if (isprefix(mode, "input"))
return(EncryptStartInput());
@@ -354,8 +326,8 @@ EncryptStart(mode)
return(ret);
}
- int
-EncryptStartInput()
+int
+EncryptStartInput(void)
{
if (decrypt_mode) {
encrypt_send_request_start();
@@ -365,8 +337,8 @@ EncryptStartInput()
return(0);
}
- int
-EncryptStartOutput()
+int
+EncryptStartOutput(void)
{
if (encrypt_mode) {
encrypt_start_output(encrypt_mode);
@@ -376,9 +348,8 @@ EncryptStartOutput()
return(0);
}
- int
-EncryptStop(mode)
- char *mode;
+int
+EncryptStop(char *mode)
{
int ret = 0;
if (mode) {
@@ -398,22 +369,22 @@ EncryptStop(mode)
return(ret);
}
- int
-EncryptStopInput()
+int
+EncryptStopInput(void)
{
encrypt_send_request_end();
return(1);
}
- int
-EncryptStopOutput()
+int
+EncryptStopOutput(void)
{
encrypt_send_end();
return(1);
}
- void
-encrypt_display()
+void
+encrypt_display(void)
{
if (encrypt_output)
printf("Currently encrypting output with %s\r\n",
@@ -423,8 +394,8 @@ encrypt_display()
ENCTYPE_NAME(decrypt_mode));
}
- int
-EncryptStatus()
+int
+EncryptStatus(void)
{
if (encrypt_output)
printf("Currently encrypting output with %s\r\n",
@@ -445,8 +416,8 @@ EncryptStatus()
return 1;
}
- void
-encrypt_send_support()
+void
+encrypt_send_support(void)
{
if (str_suplen) {
/*
@@ -462,9 +433,8 @@ encrypt_send_support()
}
}
- int
-EncryptDebug(on)
- int on;
+int
+EncryptDebug(int on)
{
if (on < 0)
encrypt_debug_mode ^= 1;
@@ -475,9 +445,8 @@ EncryptDebug(on)
return(1);
}
- int
-EncryptVerbose(on)
- int on;
+int
+EncryptVerbose(int on)
{
if (on < 0)
encrypt_verbose ^= 1;
@@ -488,9 +457,8 @@ EncryptVerbose(on)
return(1);
}
- int
-EncryptAutoEnc(on)
- int on;
+int
+EncryptAutoEnc(int on)
{
encrypt_auto(on);
printf("Automatic encryption of output is %s\r\n",
@@ -498,9 +466,8 @@ EncryptAutoEnc(on)
return(1);
}
- int
-EncryptAutoDec(on)
- int on;
+int
+EncryptAutoDec(int on)
{
decrypt_auto(on);
printf("Automatic decryption of input is %s\r\n",
@@ -511,12 +478,10 @@ EncryptAutoDec(on)
/*
* Called when ENCRYPT SUPPORT is received.
*/
- void
-encrypt_support(typelist, cnt)
- unsigned char *typelist;
- int cnt;
+void
+encrypt_support(unsigned char *typelist, int cnt)
{
- register int type, use_type = 0;
+ int type, use_type = 0;
Encryptions *ep;
/*
@@ -553,13 +518,11 @@ encrypt_support(typelist, cnt)
}
}
- void
-encrypt_is(data, cnt)
- unsigned char *data;
- int cnt;
+void
+encrypt_is(unsigned char *data, int cnt)
{
Encryptions *ep;
- register int type, ret;
+ int type, ret;
if (--cnt < 0)
return;
@@ -599,13 +562,11 @@ encrypt_is(data, cnt)
}
}
- void
-encrypt_reply(data, cnt)
- unsigned char *data;
- int cnt;
+void
+encrypt_reply(unsigned char *data, int cnt)
{
Encryptions *ep;
- register int ret, type;
+ int ret, type;
if (--cnt < 0)
return;
@@ -649,10 +610,8 @@ encrypt_reply(data, cnt)
/*
* Called when a ENCRYPT START command is received.
*/
- void
-encrypt_start(data, cnt)
- unsigned char *data;
- int cnt;
+void
+encrypt_start(unsigned char *data __unused, int cnt __unused)
{
Encryptions *ep;
@@ -687,10 +646,8 @@ encrypt_start(data, cnt)
}
}
- void
-encrypt_session_key(key, server)
- Session_Key *key;
- int server;
+void
+encrypt_session_key( Session_Key *key, int server)
{
Encryptions *ep = encryptions;
@@ -699,12 +656,6 @@ encrypt_session_key(key, server)
while (ep->type) {
if (ep->session)
(*ep->session)(key, server);
-#ifdef notdef
- if (!encrypt_output && autoencrypt && !server)
- encrypt_start_output(ep->type);
- if (!decrypt_input && autodecrypt && !server)
- encrypt_send_request_start();
-#endif
++ep;
}
}
@@ -712,8 +663,8 @@ encrypt_session_key(key, server)
/*
* Called when ENCRYPT END is received.
*/
- void
-encrypt_end()
+void
+encrypt_end(void)
{
decrypt_input = 0;
if (encrypt_debug_mode)
@@ -725,8 +676,8 @@ encrypt_end()
/*
* Called when ENCRYPT REQUEST-END is received.
*/
- void
-encrypt_request_end()
+void
+encrypt_request_end(void)
{
encrypt_send_end();
}
@@ -737,10 +688,8 @@ encrypt_request_end()
* other side wants us to start encrypting data as soon as we
* can.
*/
- void
-encrypt_request_start(data, cnt)
- unsigned char *data;
- int cnt;
+void
+encrypt_request_start(unsigned char *data __unused, int cnt __unused)
{
if (encrypt_mode == 0) {
if (Server)
@@ -752,31 +701,24 @@ encrypt_request_start(data, cnt)
static unsigned char str_keyid[(MAXKEYLEN*2)+5] = { IAC, SB, TELOPT_ENCRYPT };
- void
-encrypt_enc_keyid(keyid, len)
- unsigned char *keyid;
- int len;
+void
+encrypt_enc_keyid(unsigned char *keyid, int len)
{
encrypt_keyid(&ki[1], keyid, len);
}
- void
-encrypt_dec_keyid(keyid, len)
- unsigned char *keyid;
- int len;
+void
+encrypt_dec_keyid(unsigned char *keyid, int len)
{
encrypt_keyid(&ki[0], keyid, len);
}
- void
-encrypt_keyid(kp, keyid, len)
- struct key_info *kp;
- unsigned char *keyid;
- int len;
+void
+encrypt_keyid(struct key_info *kp, unsigned char *keyid, int len)
{
Encryptions *ep;
int dir = kp->dir;
- register int ret = 0;
+ int ret = 0;
if (!(ep = (*kp->getcrypt)(*kp->modep))) {
if (len == 0)
@@ -812,12 +754,8 @@ encrypt_keyid(kp, keyid, len)
encrypt_send_keyid(dir, kp->keyid, kp->keylen, 0);
}
- void
-encrypt_send_keyid(dir, keyid, keylen, saveit)
- int dir;
- unsigned char *keyid;
- int keylen;
- int saveit;
+void
+encrypt_send_keyid(int dir, const char *keyid, int keylen, int saveit)
{
unsigned char *strp;
@@ -839,9 +777,8 @@ encrypt_send_keyid(dir, keyid, keylen, saveit)
printsub('>', &str_keyid[2], strp - str_keyid - 2);
}
- void
-encrypt_auto(on)
- int on;
+void
+encrypt_auto(int on)
{
if (on < 0)
autoencrypt ^= 1;
@@ -849,9 +786,8 @@ encrypt_auto(on)
autoencrypt = on ? 1 : 0;
}
- void
-decrypt_auto(on)
- int on;
+void
+decrypt_auto(int on)
{
if (on < 0)
autodecrypt ^= 1;
@@ -859,13 +795,12 @@ decrypt_auto(on)
autodecrypt = on ? 1 : 0;
}
- void
-encrypt_start_output(type)
- int type;
+void
+encrypt_start_output(int type)
{
Encryptions *ep;
- register unsigned char *p;
- register int i;
+ unsigned char *p;
+ int i;
if (!(ep = findencryption(type))) {
if (encrypt_debug_mode) {
@@ -916,8 +851,8 @@ encrypt_start_output(type)
ENCTYPE_NAME(type));
}
- void
-encrypt_send_end()
+void
+encrypt_send_end(void)
{
if (!encrypt_output)
return;
@@ -937,11 +872,11 @@ encrypt_send_end()
printf("[ Output is now clear text ]\r\n");
}
- void
-encrypt_send_request_start()
+void
+encrypt_send_request_start(void)
{
- register unsigned char *p;
- register int i;
+ unsigned char *p;
+ int i;
p = &str_start[3];
*p++ = ENCRYPT_REQSTART;
@@ -957,8 +892,8 @@ encrypt_send_request_start()
printf(">>>%s: Request input to be encrypted\r\n", Name);
}
- void
-encrypt_send_request_end()
+void
+encrypt_send_request_end(void)
{
str_end[3] = ENCRYPT_REQEND;
net_write(str_end, sizeof(str_end));
@@ -968,8 +903,8 @@ encrypt_send_request_end()
printf(">>>%s: Request input to be clear text\r\n", Name);
}
- void
-encrypt_wait()
+void
+encrypt_wait(void)
{
if (encrypt_debug_mode)
printf(">>>%s: in encrypt_wait\r\n", Name);
@@ -980,17 +915,8 @@ encrypt_wait()
return;
}
- void
-encrypt_debug(mode)
- int mode;
-{
- encrypt_debug_mode = mode;
-}
-
- void
-encrypt_gen_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+encrypt_gen_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
char tbuf[16], *cp;
@@ -1009,13 +935,11 @@ encrypt_gen_printsub(data, cnt, buf, buflen)
*buf = '\0';
}
- void
-encrypt_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+encrypt_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
Encryptions *ep;
- register int type = data[1];
+ int type = data[1];
for (ep = encryptions; ep->type && ep->type != type; ep++)
;
diff --git a/crypto/telnet/libtelnet/encrypt.h b/crypto/telnet/libtelnet/encrypt.h
index 869ad75..eda8d57 100644
--- a/crypto/telnet/libtelnet/encrypt.h
+++ b/crypto/telnet/libtelnet/encrypt.h
@@ -81,26 +81,18 @@ typedef struct {
unsigned char *data;
} Session_Key;
-# if !defined(P)
-# ifdef __STDC__
-# define P(x) x
-# else
-# define P(x) ()
-# endif
-# endif
-
typedef struct {
- char *name;
+ const char *name;
int type;
- void (*output) P((unsigned char *, int));
- int (*input) P((int));
- void (*init) P((int));
- int (*start) P((int, int));
- int (*is) P((unsigned char *, int));
- int (*reply) P((unsigned char *, int));
- void (*session) P((Session_Key *, int));
- int (*keyid) P((int, unsigned char *, int *));
- void (*printsub) P((unsigned char *, int, unsigned char *, int));
+ void (*output)(unsigned char *, int);
+ int (*input)(int);
+ void (*init)(int);
+ int (*start)(int, int);
+ int (*is)(unsigned char *, int);
+ int (*reply)(unsigned char *, int);
+ void (*session)(Session_Key *, int);
+ int (*keyid)(int, unsigned char *, int *);
+ void (*printsub)(unsigned char *, int, unsigned char *, int);
} Encryptions;
#define SK_DES 1 /* Matched Kerberos v5 KEYTYPE_DES */
@@ -108,7 +100,7 @@ typedef struct {
#include "enc-proto.h"
extern int encrypt_debug_mode;
-extern int (*decrypt_input) P((int));
-extern void (*encrypt_output) P((unsigned char *, int));
+extern int (*decrypt_input)(int);
+extern void (*encrypt_output)(unsigned char *, int);
# endif /* __ENCRYPTION__ */
#endif /* ENCRYPTION */
diff --git a/crypto/telnet/libtelnet/genget.c b/crypto/telnet/libtelnet/genget.c
index e46b1cb..e24bb44 100644
--- a/crypto/telnet/libtelnet/genget.c
+++ b/crypto/telnet/libtelnet/genget.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -43,6 +44,8 @@ static const char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95";
#include <ctype.h>
+#include "misc-proto.h"
+
#define LOWER(x) (isupper(x) ? tolower(x) : (x))
/*
* The prefix function returns 0 if *s1 is not a prefix
@@ -51,7 +54,7 @@ static const char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95";
* the length of *s1 is returned.
*/
int
-isprefix(char *s1, char *s2)
+isprefix(char *s1, const char *s2)
{
char *os1;
char c1, c2;
@@ -98,7 +101,7 @@ genget(char *name, char **table, int stlen)
* Function call version of Ambiguous()
*/
int
-Ambiguous(char *s)
+Ambiguous(char **s)
{
- return((char **)s == &ambiguous);
+ return(s == &ambiguous);
}
diff --git a/crypto/telnet/libtelnet/getent.c b/crypto/telnet/libtelnet/getent.c
index ee6f03f..d6e8d9c 100644
--- a/crypto/telnet/libtelnet/getent.c
+++ b/crypto/telnet/libtelnet/getent.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -40,37 +41,36 @@ static char sccsid[] = "@(#)getent.c 8.2 (Berkeley) 12/15/93";
#endif
#endif /* not lint */
-#ifdef HAS_CGETENT
#include <stdlib.h>
-#endif
+#include <string.h>
+
+#include "misc-proto.h"
static char *area;
+static char gettytab[] = "/etc/gettytab";
/*ARGSUSED*/
int
-getent(char *cp, char *name)
+getent(char *cp __unused, const char *name)
{
-#ifdef HAS_CGETENT
- char *dba[2];
+ int retval;
+ char *tempnam, *dba[2] = { gettytab, NULL };
- dba[0] = "/etc/gettytab";
- dba[1] = 0;
- return((cgetent(&area, dba, name) == 0) ? 1 : 0);
-#else
- return(0);
-#endif
+ tempnam = strdup(name);
+ retval = cgetent(&area, dba, tempnam) == 0 ? 1 : 0;
+ free(tempnam);
+ return(retval);
}
-#ifndef SOLARIS
/*ARGSUSED*/
char *
-Getstr(char *id, char **cpp)
+Getstr(const char *id, char **cpp __unused)
{
-# ifdef HAS_CGETENT
- char *answer;
- return((cgetstr(area, id, &answer) > 0) ? answer : 0);
-# else
- return(0);
-# endif
+ int retval;
+ char *answer, *tempid;
+
+ tempid = strdup(id);
+ retval = cgetstr(area, tempid, &answer);
+ free(tempid);
+ return((retval > 0) ? answer : NULL);
}
-#endif
diff --git a/crypto/telnet/libtelnet/kerberos.c b/crypto/telnet/libtelnet/kerberos.c
index d7628e3..a6805b8 100644
--- a/crypto/telnet/libtelnet/kerberos.c
+++ b/crypto/telnet/libtelnet/kerberos.c
@@ -29,11 +29,10 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -63,17 +62,11 @@ static const char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95";
#ifdef KRB4
#include <sys/types.h>
#include <arpa/telnet.h>
-#include <stdio.h>
#include <openssl/des.h> /* BSD wont include this in krb.h, so we do it here */
#include <krb.h>
-#ifdef __STDC__
+#include <stdio.h>
#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
#include <string.h>
-#endif
#include "encrypt.h"
#include "auth.h"
@@ -82,7 +75,7 @@ static const char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95";
int kerberos4_cksum P((unsigned char *, int));
int kuserok P((AUTH_DAT *, char *));
-extern auth_debug_mode;
+extern int auth_debug_mode;
static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
AUTHTYPE_KERBEROS_V4, };
@@ -93,29 +86,26 @@ static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
#define KRB_CHALLENGE 3 /* Challenge for mutual auth. */
#define KRB_RESPONSE 4 /* Response for mutual auth. */
-#define KRB_SERVICE_NAME "rcmd"
-
static KTEXT_ST auth;
static char name[ANAME_SZ];
-static AUTH_DAT adat = { 0 };
+static AUTH_DAT adat = { 0, "", "", "", 0, {}, 0, 0, 0, { 0, "", 0 } };
#ifdef ENCRYPTION
static Block session_key = { 0 };
static des_key_schedule sched;
static Block challenge = { 0 };
#endif /* ENCRYPTION */
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- void *d;
- int c;
+static char krb_service_name[] = "rcmd";
+static char empty[] = "";
+
+static int
+Data(Authenticator *ap, int type, const unsigned char *d, int c)
{
unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
+ const unsigned char *cd = d;
if (c == -1)
- c = strlen((char *)cd);
+ c = strlen(cd);
if (auth_debug_mode) {
printf("%s:%d: [%d] (%d)",
@@ -139,10 +129,8 @@ Data(ap, type, d, c)
return(net_write(str_data, p - str_data));
}
- int
-kerberos4_init(ap, server)
- Authenticator *ap;
- int server;
+int
+kerberos4_init(Authenticator *ap __unused, int server)
{
FILE *fp;
@@ -160,15 +148,12 @@ kerberos4_init(ap, server)
char dst_realm_buf[REALM_SZ], *dest_realm = NULL;
int dst_realm_sz = REALM_SZ;
- int
-kerberos4_send(ap)
- Authenticator *ap;
+int
+kerberos4_send(Authenticator *ap)
{
- KTEXT_ST auth;
+ KTEXT_ST lauth;
char instance[INST_SZ];
char *realm;
- char *krb_realmofhost();
- char *krb_get_phost();
CREDENTIALS cred;
int r;
@@ -193,11 +178,11 @@ kerberos4_send(ap)
printf("Kerberos V4: no realm for %s\r\n", RemoteHostName);
return(0);
}
- if ((r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0L))) {
+ if ((r = krb_mk_req(&lauth, krb_service_name, instance, realm, 0L))) {
printf("mk_req failed: %s\r\n", krb_err_txt[r]);
return(0);
}
- if ((r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred))) {
+ if ((r = krb_get_cred(krb_service_name, instance, realm, &cred))) {
printf("get_cred failed: %s\r\n", krb_err_txt[r]);
return(0);
}
@@ -207,8 +192,8 @@ kerberos4_send(ap)
return(0);
}
if (auth_debug_mode)
- printf("Sent %d bytes of authentication data\r\n", auth.length);
- if (!Data(ap, KRB_AUTH, (void *)auth.dat, auth.length)) {
+ printf("Sent %d bytes of authentication data\r\n", lauth.length);
+ if (!Data(ap, KRB_AUTH, (void *)lauth.dat, lauth.length)) {
if (auth_debug_mode)
printf("Not enough room for authentication data\r\n");
return(0);
@@ -242,19 +227,16 @@ kerberos4_send(ap)
#endif /* ENCRYPTION */
if (auth_debug_mode) {
- printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length));
- printd(auth.dat, auth.length);
+ printf("CK: %d:", kerberos4_cksum(lauth.dat, lauth.length));
+ printd(lauth.dat, lauth.length);
printf("\r\n");
printf("Sent Kerberos V4 credentials to server\r\n");
}
return(1);
}
- void
-kerberos4_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
+void
+kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
{
#ifdef ENCRYPTION
Session_Key skey;
@@ -269,7 +251,7 @@ kerberos4_is(ap, data, cnt)
switch (*data++) {
case KRB_AUTH:
if (krb_get_lrealm(realm, 1) != KSUCCESS) {
- Data(ap, KRB_REJECT, (void *)"No local V4 Realm.", -1);
+ Data(ap, KRB_REJECT, "No local V4 Realm.", -1);
auth_finished(ap, AUTH_REJECT);
if (auth_debug_mode)
printf("No local realm\r\n");
@@ -283,11 +265,11 @@ kerberos4_is(ap, data, cnt)
printf("\r\n");
}
instance[0] = '*'; instance[1] = 0;
- if ((r = krb_rd_req(&auth, KRB_SERVICE_NAME,
- instance, 0, &adat, ""))) {
+ if ((r = krb_rd_req(&auth, krb_service_name,
+ instance, 0, &adat, empty))) {
if (auth_debug_mode)
printf("Kerberos failed him as %s\r\n", name);
- Data(ap, KRB_REJECT, (void *)krb_err_txt[r], -1);
+ Data(ap, KRB_REJECT, krb_err_txt[r], -1);
auth_finished(ap, AUTH_REJECT);
return;
}
@@ -297,16 +279,15 @@ kerberos4_is(ap, data, cnt)
krb_kntoln(&adat, name);
if (UserNameRequested && !kuserok(&adat, UserNameRequested))
- Data(ap, KRB_ACCEPT, (void *)0, 0);
+ Data(ap, KRB_ACCEPT, NULL, 0);
else
- Data(ap, KRB_REJECT,
- (void *)"user is not authorized", -1);
+ Data(ap, KRB_REJECT, "user is not authorized", -1);
auth_finished(ap, AUTH_USER);
break;
case KRB_CHALLENGE:
#ifndef ENCRYPTION
- Data(ap, KRB_RESPONSE, (void *)0, 0);
+ Data(ap, KRB_RESPONSE, NULL, 0);
#else /* ENCRYPTION */
if (!VALIDKEY(session_key)) {
/*
@@ -314,7 +295,7 @@ kerberos4_is(ap, data, cnt)
* send back a response with an empty session
* key.
*/
- Data(ap, KRB_RESPONSE, (void *)0, 0);
+ Data(ap, KRB_RESPONSE, NULL, 0);
break;
}
@@ -348,23 +329,20 @@ kerberos4_is(ap, data, cnt)
break;
}
des_ecb_encrypt(&challenge, &challenge, sched, 1);
- Data(ap, KRB_RESPONSE, (void *)challenge, sizeof(challenge));
+ Data(ap, KRB_RESPONSE, challenge, sizeof(challenge));
#endif /* ENCRYPTION */
break;
default:
if (auth_debug_mode)
printf("Unknown Kerberos option %d\r\n", data[-1]);
- Data(ap, KRB_REJECT, 0, 0);
+ Data(ap, KRB_REJECT, NULL, 0);
break;
}
}
- void
-kerberos4_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
+void
+kerberos4_reply(Authenticator *ap, unsigned char *data, int cnt)
{
#ifdef ENCRYPTION
Session_Key skey;
@@ -388,9 +366,9 @@ kerberos4_reply(ap, data, cnt)
* Send over the encrypted challenge.
*/
#ifndef ENCRYPTION
- Data(ap, KRB_CHALLENGE, (void *)0, 0);
+ Data(ap, KRB_CHALLENGE, NULL, 0);
#else /* ENCRYPTION */
- Data(ap, KRB_CHALLENGE, (void *)session_key,
+ Data(ap, KRB_CHALLENGE, session_key,
sizeof(session_key));
des_ecb_encrypt(&session_key, &session_key, sched, 1);
skey.type = SK_DES;
@@ -428,17 +406,14 @@ kerberos4_reply(ap, data, cnt)
}
}
- int
-kerberos4_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
+int
+kerberos4_status(Authenticator *ap __unused, char *nam, int level)
{
if (level < AUTH_USER)
return(level);
if (UserNameRequested && !kuserok(&adat, UserNameRequested)) {
- strcpy(name, UserNameRequested);
+ strcpy(nam, UserNameRequested);
return(AUTH_VALID);
} else
return(AUTH_USER);
@@ -447,10 +422,8 @@ kerberos4_status(ap, name, level)
#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
- void
-kerberos4_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+kerberos4_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
char lbuf[32];
register int i;
@@ -502,10 +475,8 @@ kerberos4_printsub(data, cnt, buf, buflen)
}
}
- int
-kerberos4_cksum(d, n)
- unsigned char *d;
- int n;
+int
+kerberos4_cksum(unsigned char *d, int n)
{
int ck = 0;
@@ -539,17 +510,3 @@ kerberos4_cksum(d, n)
return(ck);
}
#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/crypto/telnet/libtelnet/kerberos5.c b/crypto/telnet/libtelnet/kerberos5.c
index f3b3e70..392978c 100644
--- a/crypto/telnet/libtelnet/kerberos5.c
+++ b/crypto/telnet/libtelnet/kerberos5.c
@@ -1,12 +1,3 @@
-/*
- * $Source: /mit/krb5/.cvsroot/src/appl/telnet/libtelnet/kerberos5.c,v $
- * $Author: tytso $
- * $Id: kerberos5.c,v 1.1 1997/09/04 06:11:15 markm Exp $
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,10 +31,6 @@ __FBSDID("$FreeBSD$");
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
@@ -64,28 +51,28 @@ static const char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
* or implied warranty.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
#ifdef KRB5
+
#include <arpa/telnet.h>
-#include <com_err.h>
-#include <ctype.h>
-#include <krb5.h>
-#include <krb5_asn1.h>
-#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-/* kerberos 5 include files (ext-proto.h) will get an appropriate stdlib.h
- and string.h/strings.h */
+#include <unistd.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <pwd.h>
+#define Authenticator k5_Authenticator
+#include <krb5.h>
+#undef Authenticator
#include "encrypt.h"
#include "auth.h"
#include "misc.h"
-extern int auth_debug_mode;
-
-#ifdef FORWARD
int forward_flags = 0; /* Flags get set in telnet/main.c on -f and -F */
/* These values need to be the same as those defined in telnet/main.c. */
@@ -93,666 +80,722 @@ int forward_flags = 0; /* Flags get set in telnet/main.c on -f and -F */
#define OPTS_FORWARD_CREDS 0x00000002
#define OPTS_FORWARDABLE_CREDS 0x00000001
-void kerberos5_forward();
-
-#endif /* FORWARD */
+void kerberos5_forward (Authenticator *);
static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
AUTHTYPE_KERBEROS_V5, };
-/*static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION,
- TELQUAL_NAME, };*/
#define KRB_AUTH 0 /* Authentication data follows */
#define KRB_REJECT 1 /* Rejected (reason might follow) */
#define KRB_ACCEPT 2 /* Accepted */
#define KRB_RESPONSE 3 /* Response for mutual auth. */
-#ifdef FORWARD
#define KRB_FORWARD 4 /* Forwarded credentials follow */
#define KRB_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */
#define KRB_FORWARD_REJECT 6 /* Forwarded credentials rejected */
-#endif /* FORWARD */
static krb5_data auth;
- /* telnetd gets session key from here */
-static krb5_tkt_authent *authdat = NULL;
-/* telnet matches the AP_REQ and AP_REP with this */
-static krb5_authenticator authenticator;
-
-/* some compilers can't hack void *, so we use the Kerberos krb5_pointer,
- which is either void * or char *, depending on the compiler. */
+static krb5_ticket *ticket;
-#define Voidptr krb5_pointer
+static krb5_context context;
+static krb5_auth_context auth_context;
-Block session_key;
-
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- Voidptr d;
- int c;
+static int
+Data(Authenticator *ap, int type, const char *d, int c)
{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (auth_debug_mode) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - &str_data[2]);
- return(net_write(str_data, p - str_data));
+ unsigned char *p = str_data + 4;
+ const unsigned char *cd = d;
+
+ if (c == -1)
+ c = strlen(cd);
+
+ if (auth_debug_mode) {
+ printf("%s:%d: [%d] (%d)",
+ str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
+ str_data[3],
+ type, c);
+ printd(d, c);
+ printf("\r\n");
+ }
+ *p++ = ap->type;
+ *p++ = ap->way;
+ *p++ = type;
+ while (c-- > 0) {
+ if ((*p++ = *cd++) == IAC)
+ *p++ = IAC;
+ }
+ *p++ = IAC;
+ *p++ = SE;
+ if (str_data[3] == TELQUAL_IS)
+ printsub('>', &str_data[2], p - &str_data[2]);
+ return(net_write(str_data, p - str_data));
}
- int
-kerberos5_init(ap, server)
- Authenticator *ap;
- int server;
+int
+kerberos5_init(Authenticator *ap __unused, int server)
{
- if (server)
- str_data[3] = TELQUAL_REPLY;
- else
- str_data[3] = TELQUAL_IS;
- krb5_init_ets();
- return(1);
+ krb5_error_code ret;
+
+ ret = krb5_init_context(&context);
+ if (ret)
+ return 0;
+ if (server) {
+ krb5_keytab kt;
+ krb5_kt_cursor cursor;
+
+ ret = krb5_kt_default(context, &kt);
+ if (ret)
+ return 0;
+
+ ret = krb5_kt_start_seq_get (context, kt, &cursor);
+ if (ret) {
+ krb5_kt_close (context, kt);
+ return 0;
+ }
+ krb5_kt_end_seq_get (context, kt, &cursor);
+ krb5_kt_close (context, kt);
+
+ str_data[3] = TELQUAL_REPLY;
+ } else
+ str_data[3] = TELQUAL_IS;
+ return(1);
}
- int
-kerberos5_send(ap)
- Authenticator *ap;
+extern int net;
+
+static int
+kerberos5_send(const char *name, Authenticator *ap)
{
- char **realms;
- char *name;
- char *p1, *p2;
- krb5_checksum ksum;
- krb5_octet sum[CRC32_CKSUM_LENGTH];
- krb5_principal server;
- krb5_error_code r;
- krb5_ccache ccache;
- krb5_creds creds; /* telnet gets session key from here */
- extern krb5_flags krb5_kdc_default_options;
- int ap_opts;
-
-#ifdef ENCRYPTION
- krb5_keyblock *newkey = 0;
-#endif /* ENCRYPTION */
-
- ksum.checksum_type = CKSUMTYPE_CRC32;
- ksum.contents = sum;
- ksum.length = sizeof(sum);
- memset((Voidptr )sum, 0, sizeof(sum));
-
- if (!UserNameRequested) {
- if (auth_debug_mode) {
- printf("Kerberos V5: no user name supplied\r\n");
- }
- return(0);
+ krb5_error_code ret;
+ krb5_ccache ccache;
+ int ap_opts;
+ krb5_data cksum_data;
+ char foo[2];
+
+ if (!UserNameRequested) {
+ if (auth_debug_mode) {
+ printf("Kerberos V5: no user name supplied\r\n");
}
-
- if (r = krb5_cc_default(&ccache)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: could not get default ccache\r\n");
- }
- return(0);
+ return(0);
+ }
+
+ ret = krb5_cc_default(context, &ccache);
+ if (ret) {
+ if (auth_debug_mode) {
+ printf("Kerberos V5: could not get default ccache: %s\r\n",
+ krb5_get_err_text (context, ret));
}
-
- if ((name = malloc(strlen(RemoteHostName)+1)) == NULL) {
- if (auth_debug_mode)
- printf("Out of memory for hostname in Kerberos V5\r\n");
- return(0);
+ return 0;
+ }
+
+ if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL)
+ ap_opts = AP_OPTS_MUTUAL_REQUIRED;
+ else
+ ap_opts = 0;
+
+ ret = krb5_auth_con_init (context, &auth_context);
+ if (ret) {
+ if (auth_debug_mode) {
+ printf("Kerberos V5: krb5_auth_con_init failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
}
+ return(0);
+ }
- if (r = krb5_get_host_realm(RemoteHostName, &realms)) {
- if (auth_debug_mode)
- printf("Kerberos V5: no realm for %s\r\n", RemoteHostName);
- free(name);
- return(0);
+ ret = krb5_auth_con_setaddrs_from_fd (context,
+ auth_context,
+ &net);
+ if (ret) {
+ if (auth_debug_mode) {
+ printf ("Kerberos V5:"
+ " krb5_auth_con_setaddrs_from_fd failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
}
+ return(0);
+ }
+
+ krb5_auth_setkeytype (context, auth_context, KEYTYPE_DES);
+
+ foo[0] = ap->type;
+ foo[1] = ap->way;
+
+ cksum_data.length = sizeof(foo);
+ cksum_data.data = foo;
- p1 = RemoteHostName;
- p2 = name;
- while (*p2 = *p1++) {
- if (isupper(*p2))
- *p2 |= 040;
- ++p2;
+ {
+ krb5_principal service;
+ char sname[128];
+
+
+ ret = krb5_sname_to_principal (context,
+ RemoteHostName,
+ NULL,
+ KRB5_NT_SRV_HST,
+ &service);
+ if(ret) {
+ if (auth_debug_mode) {
+ printf ("Kerberos V5:"
+ " krb5_sname_to_principal(%s) failed (%s)\r\n",
+ RemoteHostName, krb5_get_err_text(context, ret));
+ }
+ return 0;
}
+ ret = krb5_unparse_name_fixed(context, service, sname, sizeof(sname));
+ if(ret) {
+ if (auth_debug_mode) {
+ printf ("Kerberos V5:"
+ " krb5_unparse_name_fixed failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
+ }
+ return 0;
+ }
+ printf("[ Trying %s (%s)... ]\r\n", name, sname);
+ ret = krb5_mk_req_exact(context, &auth_context, ap_opts,
+ service,
+ &cksum_data, ccache, &auth);
+ krb5_free_principal (context, service);
- if (r = krb5_build_principal_ext(&server,
- strlen(realms[0]), realms[0],
- 4, "host",
- p2 - name, name,
- 0)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: failure setting up principal (%s)\r\n",
- error_message(r));
- }
- free(name);
- krb5_free_host_realm(realms);
- return(0);
+ }
+ if (ret) {
+ if (1 || auth_debug_mode) {
+ printf("Kerberos V5: mk_req failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
}
+ return(0);
+ }
+ if (!auth_sendname((unsigned char *)UserNameRequested,
+ strlen(UserNameRequested))) {
+ if (auth_debug_mode)
+ printf("Not enough room for user name\r\n");
+ return(0);
+ }
+ if (!Data(ap, KRB_AUTH, auth.data, auth.length)) {
+ if (auth_debug_mode)
+ printf("Not enough room for authentication data\r\n");
+ return(0);
+ }
+ if (auth_debug_mode) {
+ printf("Sent Kerberos V5 credentials to server\r\n");
+ }
+ return(1);
+}
- memset((char *)&creds, 0, sizeof(creds));
- creds.server = server;
+int
+kerberos5_send_mutual(Authenticator *ap)
+{
+ return kerberos5_send("mutual KERBEROS5", ap);
+}
- if (r = krb5_cc_get_principal(ccache, &creds.client)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: failure on principal (%s)\r\n",
- error_message(r));
- }
- free(name);
- krb5_free_principal(server);
- krb5_free_host_realm(realms);
- return(0);
- }
+int
+kerberos5_send_oneway(Authenticator *ap)
+{
+ return kerberos5_send("KERBEROS5", ap);
+}
- if (r = krb5_get_credentials(krb5_kdc_default_options, ccache, &creds)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: failure on credentials(%d)\r\n",r);
- }
- free(name);
- krb5_free_host_realm(realms);
- krb5_free_principal(server);
- return(0);
+void
+kerberos5_is(Authenticator *ap, unsigned char *data, int cnt)
+{
+ krb5_error_code ret;
+ krb5_data outbuf;
+ krb5_keyblock *key_block;
+ char *name;
+ krb5_principal server;
+ int zero = 0;
+
+ if (cnt-- < 1)
+ return;
+ switch (*data++) {
+ case KRB_AUTH:
+ auth.data = (char *)data;
+ auth.length = cnt;
+
+ auth_context = NULL;
+
+ ret = krb5_auth_con_init (context, &auth_context);
+ if (ret) {
+ Data(ap, KRB_REJECT, "krb5_auth_con_init failed", -1);
+ auth_finished(ap, AUTH_REJECT);
+ if (auth_debug_mode)
+ printf("Kerberos V5: krb5_auth_con_init failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
+ return;
}
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL)
- ap_opts = AP_OPTS_MUTUAL_REQUIRED;
- else
- ap_opts = 0;
-
- r = krb5_mk_req_extended(ap_opts, &ksum, krb5_kdc_default_options, 0,
-#ifdef ENCRYPTION
- &newkey,
-#else /* ENCRYPTION */
- 0,
-#endif /* ENCRYPTION */
- ccache, &creds, &authenticator, &auth);
- /* don't let the key get freed if we clean up the authenticator */
- authenticator.subkey = 0;
-
- free(name);
- krb5_free_host_realm(realms);
- krb5_free_principal(server);
-#ifdef ENCRYPTION
- if (newkey) {
- /* keep the key in our private storage, but don't use it
- yet---see kerberos5_reply() below */
- if (newkey->keytype != KEYTYPE_DES) {
- if (creds.keyblock.keytype == KEYTYPE_DES)
- /* use the session key in credentials instead */
- memmove((char *)session_key,
- (char *)creds.keyblock.contents, sizeof(Block));
- else
- /* XXX ? */;
- } else {
- memmove((char *)session_key, (char *)newkey->contents,
- sizeof(Block));
- }
- krb5_free_keyblock(newkey);
+ ret = krb5_auth_con_setaddrs_from_fd (context,
+ auth_context,
+ &zero);
+ if (ret) {
+ Data(ap, KRB_REJECT, "krb5_auth_con_setaddrs_from_fd failed", -1);
+ auth_finished(ap, AUTH_REJECT);
+ if (auth_debug_mode)
+ printf("Kerberos V5: "
+ "krb5_auth_con_setaddrs_from_fd failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
+ return;
}
-#endif /* ENCRYPTION */
- if (r) {
- if (auth_debug_mode) {
- printf("Kerberos V5: mk_req failed (%s)\r\n",
- error_message(r));
- }
- return(0);
+
+ ret = krb5_sock_to_principal (context,
+ 0,
+ "host",
+ KRB5_NT_SRV_HST,
+ &server);
+ if (ret) {
+ Data(ap, KRB_REJECT, "krb5_sock_to_principal failed", -1);
+ auth_finished(ap, AUTH_REJECT);
+ if (auth_debug_mode)
+ printf("Kerberos V5: "
+ "krb5_sock_to_principal failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
+ return;
}
- if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
- if (auth_debug_mode)
- printf("Not enough room for user name\r\n");
- return(0);
+ ret = krb5_rd_req(context,
+ &auth_context,
+ &auth,
+ server,
+ NULL,
+ NULL,
+ &ticket);
+
+ krb5_free_principal (context, server);
+ if (ret) {
+ char *errbuf;
+
+ asprintf(&errbuf,
+ "Read req failed: %s",
+ krb5_get_err_text(context, ret));
+ Data(ap, KRB_REJECT, errbuf, -1);
+ if (auth_debug_mode)
+ printf("%s\r\n", errbuf);
+ free (errbuf);
+ return;
}
- if (!Data(ap, KRB_AUTH, auth.data, auth.length)) {
+
+ {
+ char foo[2];
+
+ foo[0] = ap->type;
+ foo[1] = ap->way;
+
+ ret = krb5_verify_authenticator_checksum(context,
+ auth_context,
+ foo,
+ sizeof(foo));
+
+ if (ret) {
+ char *errbuf;
+ asprintf(&errbuf, "Bad checksum: %s",
+ krb5_get_err_text(context, ret));
+ Data(ap, KRB_REJECT, errbuf, -1);
if (auth_debug_mode)
- printf("Not enough room for authentication data\r\n");
- return(0);
+ printf ("%s\r\n", errbuf);
+ free(errbuf);
+ return;
+ }
}
- if (auth_debug_mode) {
- printf("Sent Kerberos V5 credentials to server\r\n");
+ ret = krb5_auth_con_getremotesubkey (context,
+ auth_context,
+ &key_block);
+
+ if (ret) {
+ Data(ap, KRB_REJECT, "krb5_auth_con_getremotesubkey failed", -1);
+ auth_finished(ap, AUTH_REJECT);
+ if (auth_debug_mode)
+ printf("Kerberos V5: "
+ "krb5_auth_con_getremotesubkey failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
+ return;
}
- return(1);
-}
-
- void
-kerberos5_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- int r;
- struct hostent *hp;
- char *p1, *p2;
- static char *realm = NULL;
- krb5_principal server;
- krb5_ap_rep_enc_part reply;
- krb5_data outbuf;
-#ifdef ENCRYPTION
- Session_Key skey;
-#endif /* ENCRYPTION */
- char *name;
- char *getenv();
- krb5_data inbuf;
- if (cnt-- < 1)
+ if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
+ ret = krb5_mk_rep(context, auth_context, &outbuf);
+ if (ret) {
+ Data(ap, KRB_REJECT,
+ "krb5_mk_rep failed", -1);
+ auth_finished(ap, AUTH_REJECT);
+ if (auth_debug_mode)
+ printf("Kerberos V5: "
+ "krb5_mk_rep failed (%s)\r\n",
+ krb5_get_err_text(context, ret));
return;
- switch (*data++) {
- case KRB_AUTH:
- auth.data = (char *)data;
- auth.length = cnt;
-
- if (!(hp = gethostbyname(LocalHostName))) {
- if (auth_debug_mode)
- printf("Cannot resolve local host name\r\n");
- Data(ap, KRB_REJECT, "Unknown local hostname.", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- if (!realm && (krb5_get_default_realm(&realm))) {
- if (auth_debug_mode)
- printf("Could not get default realm\r\n");
- Data(ap, KRB_REJECT, "Could not get default realm.", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- if ((name = malloc(strlen(hp->h_name)+1)) == NULL) {
- if (auth_debug_mode)
- printf("Out of memory for hostname in Kerberos V5\r\n");
- Data(ap, KRB_REJECT, "Out of memory.", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- p1 = hp->h_name;
- p2 = name;
-
- while (*p2 = *p1++) {
- if (isupper(*p2))
- *p2 |= 040;
- ++p2;
- }
-
- if (authdat)
- krb5_free_tkt_authent(authdat);
-
- r = krb5_build_principal_ext(&server,
- strlen(realm), realm,
- 4, "host",
- p2 - name, name,
- 0);
- if (!r) {
- r = krb5_rd_req_simple(&auth, server, 0, &authdat);
- krb5_free_principal(server);
- }
- if (r) {
- char errbuf[128];
-
- errout:
- authdat = 0;
- (void) strcpy(errbuf, "Read req failed: ");
- (void) strcat(errbuf, error_message(r));
- Data(ap, KRB_REJECT, errbuf, -1);
- if (auth_debug_mode)
- printf("%s\r\n", errbuf);
- return;
- }
- free(name);
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- /* do ap_rep stuff here */
- reply.ctime = authdat->authenticator->ctime;
- reply.cusec = authdat->authenticator->cusec;
- reply.subkey = 0; /* use the one he gave us, so don't
- need to return one here */
- reply.seq_number = 0; /* we don't do seq #'s. */
-
- if (r = krb5_mk_rep(&reply,
- authdat->authenticator->subkey ?
- authdat->authenticator->subkey :
- authdat->ticket->enc_part2->session,
- &outbuf)) {
- goto errout;
- }
- Data(ap, KRB_RESPONSE, outbuf.data, outbuf.length);
- }
- if (krb5_unparse_name(authdat->ticket->enc_part2 ->client,
- &name))
- name = 0;
- Data(ap, KRB_ACCEPT, name, name ? -1 : 0);
- if (auth_debug_mode) {
- printf("Kerberos5 identifies him as ``%s''\r\n",
- name ? name : "");
- }
- auth_finished(ap, AUTH_USER);
-
- free(name);
- if (authdat->authenticator->subkey &&
- authdat->authenticator->subkey->keytype == KEYTYPE_DES) {
- memmove((Voidptr )session_key,
- (Voidptr )authdat->authenticator->subkey->contents,
- sizeof(Block));
- } else if (authdat->ticket->enc_part2->session->keytype ==
- KEYTYPE_DES) {
- memmove((Voidptr )session_key,
- (Voidptr )authdat->ticket->enc_part2->session->contents,
- sizeof(Block));
- } else
- break;
-
-#ifdef ENCRYPTION
+ }
+ Data(ap, KRB_RESPONSE, outbuf.data, outbuf.length);
+ }
+ if (krb5_unparse_name(context, ticket->client, &name))
+ name = 0;
+
+ if(UserNameRequested && krb5_kuserok(context,
+ ticket->client,
+ UserNameRequested)) {
+ Data(ap, KRB_ACCEPT, name, name ? -1 : 0);
+ if (auth_debug_mode) {
+ printf("Kerberos5 identifies him as ``%s''\r\n",
+ name ? name : "");
+ }
+
+ if(key_block->keytype == ETYPE_DES_CBC_MD5 ||
+ key_block->keytype == ETYPE_DES_CBC_MD4 ||
+ key_block->keytype == ETYPE_DES_CBC_CRC) {
+ Session_Key skey;
+
skey.type = SK_DES;
skey.length = 8;
- skey.data = session_key;
- encrypt_session_key(&skey, 1);
-#endif /* ENCRYPTION */
- break;
-#ifdef FORWARD
- case KRB_FORWARD:
- inbuf.data = (char *)data;
- inbuf.length = cnt;
- if (r = rd_and_store_for_creds(&inbuf, authdat->ticket,
- UserNameRequested)) {
- char errbuf[128];
-
- (void) strcpy(errbuf, "Read forwarded creds failed: ");
- (void) strcat(errbuf, error_message(r));
- Data(ap, KRB_FORWARD_REJECT, errbuf, -1);
- if (auth_debug_mode)
- printf("Could not read forwarded credentials\r\n");
- }
- else
- Data(ap, KRB_FORWARD_ACCEPT, 0, 0);
- if (auth_debug_mode)
- printf("Forwarded credentials obtained\r\n");
- break;
-#endif /* FORWARD */
- default:
- if (auth_debug_mode)
- printf("Unknown Kerberos option %d\r\n", data[-1]);
- Data(ap, KRB_REJECT, 0, 0);
- break;
+ skey.data = key_block->keyvalue.data;
+ encrypt_session_key(&skey, 0);
+ }
+
+ } else {
+ char *msg;
+
+ asprintf (&msg, "user `%s' is not authorized to "
+ "login as `%s'",
+ name ? name : "<unknown>",
+ UserNameRequested ? UserNameRequested : "<nobody>");
+ if (msg == NULL)
+ Data(ap, KRB_REJECT, NULL, 0);
+ else {
+ Data(ap, KRB_REJECT, (void *)msg, -1);
+ free(msg);
+ }
+ auth_finished (ap, AUTH_REJECT);
+ krb5_free_keyblock_contents(context, key_block);
+ break;
+ }
+ auth_finished(ap, AUTH_USER);
+ krb5_free_keyblock_contents(context, key_block);
+
+ break;
+ case KRB_FORWARD: {
+ struct passwd *pwd;
+ char ccname[1024]; /* XXX */
+ krb5_data inbuf;
+ krb5_ccache ccache;
+ inbuf.data = (char *)data;
+ inbuf.length = cnt;
+
+ pwd = getpwnam (UserNameRequested);
+ if (pwd == NULL)
+ break;
+
+ snprintf (ccname, sizeof(ccname),
+ "FILE:/tmp/krb5cc_%u", pwd->pw_uid);
+
+ ret = krb5_cc_resolve (context, ccname, &ccache);
+ if (ret) {
+ if (auth_debug_mode)
+ printf ("Kerberos V5: could not get ccache: %s\r\n",
+ krb5_get_err_text(context, ret));
+ break;
+ }
+
+ ret = krb5_cc_initialize (context,
+ ccache,
+ ticket->client);
+ if (ret) {
+ if (auth_debug_mode)
+ printf ("Kerberos V5: could not init ccache: %s\r\n",
+ krb5_get_err_text(context, ret));
+ break;
}
+
+#if defined(DCE)
+ esetenv("KRB5CCNAME", ccname, 1);
+#endif
+ ret = krb5_rd_cred2 (context,
+ auth_context,
+ ccache,
+ &inbuf);
+ if(ret) {
+ char *errbuf;
+
+ asprintf (&errbuf,
+ "Read forwarded creds failed: %s",
+ krb5_get_err_text (context, ret));
+ if(errbuf == NULL)
+ Data(ap, KRB_FORWARD_REJECT, NULL, 0);
+ else
+ Data(ap, KRB_FORWARD_REJECT, errbuf, -1);
+ if (auth_debug_mode)
+ printf("Could not read forwarded credentials: %s\r\n",
+ errbuf);
+ free (errbuf);
+ } else {
+ Data(ap, KRB_FORWARD_ACCEPT, 0, 0);
+#if defined(DCE)
+ dfsfwd = 1;
+#endif
+ }
+ chown (ccname + 5, pwd->pw_uid, -1);
+ if (auth_debug_mode)
+ printf("Forwarded credentials obtained\r\n");
+ break;
+ }
+ default:
+ if (auth_debug_mode)
+ printf("Unknown Kerberos option %d\r\n", data[-1]);
+ Data(ap, KRB_REJECT, 0, 0);
+ break;
+ }
}
- void
-kerberos5_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
+void
+kerberos5_reply(Authenticator *ap, unsigned char *data, int cnt)
{
- Session_Key skey;
- static int mutual_complete = 0;
+ static int mutual_complete = 0;
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case KRB_REJECT:
- if (cnt > 0) {
- printf("[ Kerberos V5 refuses authentication because %.*s ]\r\n",
- cnt, data);
- } else
- printf("[ Kerberos V5 refuses authentication ]\r\n");
- auth_send_retry();
- return;
- case KRB_ACCEPT:
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL &&
- !mutual_complete) {
- printf("[ Kerberos V5 accepted you, but didn't provide mutual authentication! ]\n");
- auth_send_retry();
- return;
- }
- if (cnt)
- printf("[ Kerberos V5 accepts you as ``%.*s'' ]\n", cnt, data);
- else
- printf("[ Kerberos V5 accepts you ]\n");
- auth_finished(ap, AUTH_USER);
-#ifdef FORWARD
- if (forward_flags & OPTS_FORWARD_CREDS)
- kerberos5_forward(ap);
-#endif /* FORWARD */
- break;
- case KRB_RESPONSE:
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- /* the rest of the reply should contain a krb_ap_rep */
- krb5_ap_rep_enc_part *reply;
- krb5_data inbuf;
- krb5_error_code r;
- krb5_keyblock tmpkey;
-
- inbuf.length = cnt;
- inbuf.data = (char *)data;
-
- tmpkey.keytype = KEYTYPE_DES;
- tmpkey.contents = session_key;
- tmpkey.length = sizeof(Block);
-
- if (r = krb5_rd_rep(&inbuf, &tmpkey, &reply)) {
- printf("[ Mutual authentication failed: %s ]\n",
- error_message(r));
- auth_send_retry();
- return;
- }
- if (reply->ctime != authenticator.ctime ||
- reply->cusec != authenticator.cusec) {
- printf("[ Mutual authentication failed (mismatched KRB_AP_REP) ]\n");
- auth_send_retry();
- return;
- }
- krb5_free_ap_rep_enc_part(reply);
-#ifdef ENCRYPTION
- skey.type = SK_DES;
- skey.length = 8;
- skey.data = session_key;
- encrypt_session_key(&skey, 0);
-#endif /* ENCRYPTION */
- mutual_complete = 1;
- }
- return;
-#ifdef FORWARD
- case KRB_FORWARD_ACCEPT:
- printf("[ Kerberos V5 accepted forwarded credentials ]\n");
- return;
- case KRB_FORWARD_REJECT:
- printf("[ Kerberos V5 refuses forwarded credentials because %.*s ]\r\n",
- cnt, data);
- return;
-#endif /* FORWARD */
- default:
- if (auth_debug_mode)
- printf("Unknown Kerberos option %d\r\n", data[-1]);
- return;
+ if (cnt-- < 1)
+ return;
+ switch (*data++) {
+ case KRB_REJECT:
+ if (cnt > 0) {
+ printf("[ Kerberos V5 refuses authentication because %.*s ]\r\n",
+ cnt, data);
+ } else
+ printf("[ Kerberos V5 refuses authentication ]\r\n");
+ auth_send_retry();
+ return;
+ case KRB_ACCEPT: {
+ krb5_error_code ret;
+ Session_Key skey;
+ krb5_keyblock *keyblock;
+
+ if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL &&
+ !mutual_complete) {
+ printf("[ Kerberos V5 accepted you, but didn't provide mutual authentication! ]\r\n");
+ auth_send_retry();
+ return;
}
+ if (cnt)
+ printf("[ Kerberos V5 accepts you as ``%.*s'' ]\r\n", cnt, data);
+ else
+ printf("[ Kerberos V5 accepts you ]\r\n");
+
+ ret = krb5_auth_con_getlocalsubkey (context,
+ auth_context,
+ &keyblock);
+ if (ret)
+ ret = krb5_auth_con_getkey (context,
+ auth_context,
+ &keyblock);
+ if(ret) {
+ printf("[ krb5_auth_con_getkey: %s ]\r\n",
+ krb5_get_err_text(context, ret));
+ auth_send_retry();
+ return;
+ }
+
+ skey.type = SK_DES;
+ skey.length = 8;
+ skey.data = keyblock->keyvalue.data;
+ encrypt_session_key(&skey, 0);
+ krb5_free_keyblock_contents (context, keyblock);
+ auth_finished(ap, AUTH_USER);
+ if (forward_flags & OPTS_FORWARD_CREDS)
+ kerberos5_forward(ap);
+ break;
+ }
+ case KRB_RESPONSE:
+ if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
+ /* the rest of the reply should contain a krb_ap_rep */
+ krb5_ap_rep_enc_part *reply;
+ krb5_data inbuf;
+ krb5_error_code ret;
+
+ inbuf.length = cnt;
+ inbuf.data = (char *)data;
+
+ ret = krb5_rd_rep(context, auth_context, &inbuf, &reply);
+ if (ret) {
+ printf("[ Mutual authentication failed: %s ]\r\n",
+ krb5_get_err_text (context, ret));
+ auth_send_retry();
+ return;
+ }
+ krb5_free_ap_rep_enc_part(context, reply);
+ mutual_complete = 1;
+ }
+ return;
+ case KRB_FORWARD_ACCEPT:
+ printf("[ Kerberos V5 accepted forwarded credentials ]\r\n");
+ return;
+ case KRB_FORWARD_REJECT:
+ printf("[ Kerberos V5 refuses forwarded credentials because %.*s ]\r\n",
+ cnt, data);
+ return;
+ default:
+ if (auth_debug_mode)
+ printf("Unknown Kerberos option %d\r\n", data[-1]);
+ return;
+ }
}
- int
-kerberos5_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
+int
+kerberos5_status(Authenticator *ap __unused, char *name, int level)
{
- if (level < AUTH_USER)
- return(level);
+ if (level < AUTH_USER)
+ return(level);
- if (UserNameRequested &&
- krb5_kuserok(authdat->ticket->enc_part2->client, UserNameRequested))
+ if (UserNameRequested &&
+ krb5_kuserok(context,
+ ticket->client,
+ UserNameRequested))
{
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
+ strcpy(name, UserNameRequested);
+ return(AUTH_VALID);
} else
- return(AUTH_USER);
+ return(AUTH_USER);
}
#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
- void
-kerberos5_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
+void
+kerberos5_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
- case KRB_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case KRB_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
-
- case KRB_AUTH: /* Authentication data follows */
- strncpy((char *)buf, " AUTH", buflen);
- goto common2;
-
- case KRB_RESPONSE:
- strncpy((char *)buf, " RESPONSE", buflen);
- goto common2;
-
-#ifdef FORWARD
- case KRB_FORWARD: /* Forwarded credentials follow */
- strncpy((char *)buf, " FORWARD", buflen);
- goto common2;
-
- case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */
- strncpy((char *)buf, " FORWARD_ACCEPT", buflen);
- goto common2;
-
- case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */
- /* (reason might follow) */
- strncpy((char *)buf, " FORWARD_REJECT", buflen);
- goto common2;
-#endif /* FORWARD */
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
+ int i;
+
+ buf[buflen-1] = '\0'; /* make sure its NULL terminated */
+ buflen -= 1;
+
+ switch(data[3]) {
+ case KRB_REJECT: /* Rejected (reason might follow) */
+ strlcpy((char *)buf, " REJECT ", buflen);
+ goto common;
+
+ case KRB_ACCEPT: /* Accepted (name might follow) */
+ strlcpy((char *)buf, " ACCEPT ", buflen);
+ common:
+ BUMP(buf, buflen);
+ if (cnt <= 4)
+ break;
+ ADDC(buf, buflen, '"');
+ for (i = 4; i < cnt; i++)
+ ADDC(buf, buflen, data[i]);
+ ADDC(buf, buflen, '"');
+ ADDC(buf, buflen, '\0');
+ break;
+
+
+ case KRB_AUTH: /* Authentication data follows */
+ strlcpy((char *)buf, " AUTH", buflen);
+ goto common2;
+
+ case KRB_RESPONSE:
+ strlcpy((char *)buf, " RESPONSE", buflen);
+ goto common2;
+
+ case KRB_FORWARD: /* Forwarded credentials follow */
+ strlcpy((char *)buf, " FORWARD", buflen);
+ goto common2;
+
+ case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */
+ strlcpy((char *)buf, " FORWARD_ACCEPT", buflen);
+ goto common2;
+
+ case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */
+ /* (reason might follow) */
+ strlcpy((char *)buf, " FORWARD_REJECT", buflen);
+ goto common2;
+
+ default:
+ snprintf(buf, buflen, " %d (unknown)", data[3]);
+ common2:
+ BUMP(buf, buflen);
+ for (i = 4; i < cnt; i++) {
+ snprintf(buf, buflen, " %d", data[i]);
+ BUMP(buf, buflen);
}
+ break;
+ }
}
-#ifdef FORWARD
- void
-kerberos5_forward(ap)
- Authenticator *ap;
+void
+kerberos5_forward(Authenticator *ap)
{
- struct hostent *hp;
- krb5_creds *local_creds;
- krb5_error_code r;
- krb5_data forw_creds;
- extern krb5_cksumtype krb5_kdc_req_sumtype;
- krb5_ccache ccache;
- int i;
-
- if (!(local_creds = (krb5_creds *)
- calloc(1, sizeof(*local_creds)))) {
+ krb5_error_code ret;
+ krb5_ccache ccache;
+ krb5_creds creds;
+ krb5_kdc_flags flags;
+ krb5_data out_data;
+ krb5_principal principal;
+
+ ret = krb5_cc_default (context, &ccache);
+ if (ret) {
if (auth_debug_mode)
- printf("Kerberos V5: could not allocate memory for credentials\r\n");
+ printf ("KerberosV5: could not get default ccache: %s\r\n",
+ krb5_get_err_text (context, ret));
return;
}
- if (r = krb5_sname_to_principal(RemoteHostName, "host", 1,
- &local_creds->server)) {
+ ret = krb5_cc_get_principal (context, ccache, &principal);
+ if (ret) {
if (auth_debug_mode)
- printf("Kerberos V5: could not build server name - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
+ printf ("KerberosV5: could not get principal: %s\r\n",
+ krb5_get_err_text (context, ret));
return;
}
- if (r = krb5_cc_default(&ccache)) {
- if (auth_debug_mode)
- printf("Kerberos V5: could not get default ccache - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
- return;
- }
+ memset (&creds, 0, sizeof(creds));
- if (r = krb5_cc_get_principal(ccache, &local_creds->client)) {
- if (auth_debug_mode)
- printf("Kerberos V5: could not get default principal - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
- return;
- }
+ creds.client = principal;
+
+ ret = krb5_build_principal (context,
+ &creds.server,
+ strlen(principal->realm),
+ principal->realm,
+ "krbtgt",
+ principal->realm,
+ NULL);
- /* Get ticket from credentials cache */
- if (r = krb5_get_credentials(KRB5_GC_CACHED, ccache, local_creds)) {
+ if (ret) {
if (auth_debug_mode)
- printf("Kerberos V5: could not obtain credentials - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
+ printf ("KerberosV5: could not get principal: %s\r\n",
+ krb5_get_err_text (context, ret));
return;
}
- if (r = get_for_creds(ETYPE_DES_CBC_CRC,
- krb5_kdc_req_sumtype,
- RemoteHostName,
- local_creds->client,
- &local_creds->keyblock,
- forward_flags & OPTS_FORWARDABLE_CREDS,
- &forw_creds)) {
+ creds.times.endtime = 0;
+
+ flags.i = 0;
+ flags.b.forwarded = 1;
+ if (forward_flags & OPTS_FORWARDABLE_CREDS)
+ flags.b.forwardable = 1;
+
+ ret = krb5_get_forwarded_creds (context,
+ auth_context,
+ ccache,
+ flags.i,
+ RemoteHostName,
+ &creds,
+ &out_data);
+ if (ret) {
if (auth_debug_mode)
- printf("Kerberos V5: error getting forwarded creds - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
+ printf ("Kerberos V5: error getting forwarded creds: %s\r\n",
+ krb5_get_err_text (context, ret));
return;
}
- /* Send forwarded credentials */
- if (!Data(ap, KRB_FORWARD, forw_creds.data, forw_creds.length)) {
+ if(!Data(ap, KRB_FORWARD, out_data.data, out_data.length)) {
if (auth_debug_mode)
- printf("Not enough room for authentication data\r\n");
- }
- else {
+ printf("Not enough room for authentication data\r\n");
+ } else {
if (auth_debug_mode)
- printf("Forwarded local Kerberos V5 credentials to server\r\n");
+ printf("Forwarded local Kerberos V5 credentials to server\r\n");
}
+}
- krb5_free_creds(local_creds);
+#if defined(DCE)
+/* if this was a K5 authentication try and join a PAG for the user. */
+void
+kerberos5_dfspag(void)
+{
+ if (dfsk5ok) {
+ dfspag = krb5_dfs_pag(context, dfsfwd, ticket->client,
+ UserNameRequested);
+ }
}
-#endif /* FORWARD */
+#endif
#endif /* KRB5 */
diff --git a/crypto/telnet/libtelnet/key-proto.h b/crypto/telnet/libtelnet/key-proto.h
index 9668a77..2f3f346 100644
--- a/crypto/telnet/libtelnet/key-proto.h
+++ b/crypto/telnet/libtelnet/key-proto.h
@@ -51,21 +51,15 @@
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
+ *
+ * $FreeBSD$
*/
#ifndef __KEY_PROTO__
#define __KEY_PROTO__
-#if !defined(P)
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
-int key_file_exists P((void));
-void key_lookup P((unsigned char *, Block));
-void key_stream_init P((Block, Block, int));
-unsigned char key_stream P((int, int));
+int key_file_exists(void);
+void key_lookup(unsigned char *, Block);
+void key_stream_init(Block, Block, int);
+unsigned char key_stream(int, int);
#endif
diff --git a/crypto/telnet/libtelnet/krb4encpwd.c b/crypto/telnet/libtelnet/krb4encpwd.c
index d0d2b48..8b21def 100644
--- a/crypto/telnet/libtelnet/krb4encpwd.c
+++ b/crypto/telnet/libtelnet/krb4encpwd.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -74,20 +75,13 @@ static char sccsid[] = "@(#)krb4encpwd.c 8.3 (Berkeley) 5/30/95";
*/
#include <sys/types.h>
+#include <openssl/des.h>
#include <arpa/telnet.h>
+#include <krb.h>
#include <pwd.h>
#include <stdio.h>
-
-#include <openssl/des.h>
-#include <krb.h>
-#ifdef __STDC__
#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
#include <string.h>
-#endif
#include "encrypt.h"
#include "auth.h"
@@ -432,17 +426,3 @@ char *name, *passwd;
}
#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/crypto/telnet/libtelnet/misc-proto.h b/crypto/telnet/libtelnet/misc-proto.h
index c0d2068..5f4f9fc 100644
--- a/crypto/telnet/libtelnet/misc-proto.h
+++ b/crypto/telnet/libtelnet/misc-proto.h
@@ -65,17 +65,24 @@
#endif
#endif
-void auth_encrypt_init P((char *, char *, char *, int));
-void auth_encrypt_connect P((int));
-void printd P((unsigned char *, int));
+void auth_encrypt_init(char *, char *, const char *, int);
+void auth_encrypt_connect(int);
+void printd(const unsigned char *, int);
+
+int isprefix(char *, const char *);
+char **genget(char *, char **, int);
+int Ambiguous(char **);
+
+int getent(char *, const char *);
+char *Getstr(const char *, char **);
/*
* These functions are imported from the application
*/
-int net_write P((unsigned char *, int));
-void net_encrypt P((void));
-int telnet_spin P((void));
-char *telnet_getenv P((char *));
-char *telnet_gets P((char *, char *, int, int));
-void printsub P((int, unsigned char *, int));
+int net_write(unsigned char *, int);
+void net_encrypt(void);
+int telnet_spin(void);
+char *telnet_getenv(char *);
+char *telnet_gets(const char *, char *, int, int);
+void printsub(char, unsigned char *, int);
#endif
diff --git a/crypto/telnet/libtelnet/misc.c b/crypto/telnet/libtelnet/misc.c
index c9ebec7..e9e7957 100644
--- a/crypto/telnet/libtelnet/misc.c
+++ b/crypto/telnet/libtelnet/misc.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -42,8 +43,10 @@ static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93";
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
#include "misc.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include "auth.h"
#endif
#ifdef ENCRYPTION
@@ -55,16 +58,18 @@ char *LocalHostName;
char *UserNameRequested = 0;
int ConnectedCount = 0;
- void
-auth_encrypt_init(local, remote, name, server)
- char *local;
- char *remote;
- char *name;
- int server;
+#ifndef AUTHENTICATION
+#define undef1 __unused
+#else
+#define undef1
+#endif
+
+void
+auth_encrypt_init(char *local, char *remote, const char *name undef1, int server undef1)
{
RemoteHostName = remote;
LocalHostName = local;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
auth_init(name, server);
#endif
#ifdef ENCRYPTION
@@ -76,27 +81,23 @@ auth_encrypt_init(local, remote, name, server)
}
}
- void
-auth_encrypt_user(name)
- char *name;
+#ifdef ENCRYPTION
+void
+auth_encrypt_user(char *name)
{
- extern char *strdup();
-
if (UserNameRequested)
free(UserNameRequested);
UserNameRequested = name ? strdup(name) : 0;
}
- void
-auth_encrypt_connect(cnt)
- int cnt;
+void
+auth_encrypt_connect(int cnt __unused)
{
}
+#endif /* ENCRYPTION */
- void
-printd(data, cnt)
- unsigned char *data;
- int cnt;
+void
+printd(const unsigned char *data, int cnt)
{
if (cnt > 16)
cnt = 16;
diff --git a/crypto/telnet/libtelnet/pk.c b/crypto/telnet/libtelnet/pk.c
index 51ad927..fc41aed 100644
--- a/crypto/telnet/libtelnet/pk.c
+++ b/crypto/telnet/libtelnet/pk.c
@@ -28,6 +28,10 @@
*
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
/* public key routines */
/* functions:
genkeys(char *public, char *secret)
@@ -39,19 +43,15 @@
char secret[HEXKEYBYTES + 1];
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/time.h>
#include <openssl/des.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+
#include "mp.h"
#include "pk.h"
-#if defined(SOLARIS2) || defined(LINUX) || defined(__FreeBSD__)
-#include <stdlib.h>
-#endif
static void adjust(char keyout[HEXKEYBYTES+1], char *keyin);
@@ -129,11 +129,7 @@ common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
pow(public, secret, modulus, common);
extractdeskey(common, deskey);
extractideakey(common, ideakey);
-#if DES_OSTHOLM
- des_fixup_key_parity(deskey);
-#else
des_set_odd_parity(deskey);
-#endif
mfree(common);
mfree(secret);
mfree(public);
@@ -143,7 +139,7 @@ common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
/*
* Generate a seed
*/
-void
+static void
getseed(char *seed, int seedsize)
{
int i;
@@ -160,7 +156,7 @@ getseed(char *seed, int seedsize)
void
genkeys(char *public, char *secret)
{
- int i;
+ size_t i;
# define BASEBITS (8*sizeof(short) - 1)
# define BASE (1 << BASEBITS)
@@ -247,7 +243,8 @@ pk_decode(char *in, char *out, DesData *key)
char buf[256];
DesData i;
des_key_schedule k;
- int l,n1,n2,op;
+ int n1,n2,op;
+ size_t l;
memset(&i,0,sizeof(i));
memset(buf,0,sizeof(buf));
diff --git a/crypto/telnet/libtelnet/pk.h b/crypto/telnet/libtelnet/pk.h
index b0bbe57..555d8eb 100644
--- a/crypto/telnet/libtelnet/pk.h
+++ b/crypto/telnet/libtelnet/pk.h
@@ -32,23 +32,11 @@
/* header for the des routines that we will use */
typedef unsigned char byte, DesData[ 8], IdeaData[16];
-#if 0
-typedef unsigned long word, DesKeys[32];
-#else
#define DesKeys des_key_schedule
-#endif
#define DES_DECRYPT 0
#define DES_ENCRYPT 1
-#if 0
-extern void des_fixup_key_parity(); /* (DesData *key) */
-extern int des_key_sched(); /* (DesData *key, DesKeys *m) */
-extern int des_ecb_encrypt(); /* (DesData *src, *dst, DesKeys *m, int mode) */
-extern int des_cbc_encrypt(); /* (char *src, *dst, int length,
- DesKeys *m, DesData *init, int mode) */
-#endif
-
/* public key routines */
/* functions:
genkeys(char *public, char *secret)
@@ -69,4 +57,3 @@ extern void common_key(char *secret, char *public, IdeaData *common,
DesData *deskey);
extern void pk_encode(char *in, char *out, DesData *deskey);
extern void pk_decode(char *in, char *out, DesData *deskey);
-
diff --git a/crypto/telnet/libtelnet/read_password.c b/crypto/telnet/libtelnet/read_password.c
index f2a85cd..badf214 100644
--- a/crypto/telnet/libtelnet/read_password.c
+++ b/crypto/telnet/libtelnet/read_password.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
diff --git a/crypto/telnet/libtelnet/rsaencpwd.c b/crypto/telnet/libtelnet/rsaencpwd.c
index fa6043c..fba0c6b 100644
--- a/crypto/telnet/libtelnet/rsaencpwd.c
+++ b/crypto/telnet/libtelnet/rsaencpwd.c
@@ -32,6 +32,7 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifndef lint
@@ -77,15 +78,8 @@ static char sccsid[] = "@(#)rsaencpwd.c 8.3 (Berkeley) 5/30/95";
#include <arpa/telnet.h>
#include <pwd.h>
#include <stdio.h>
-
-#ifdef __STDC__
#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
#include <string.h>
-#endif
#include "encrypt.h"
#include "auth.h"
@@ -479,17 +473,3 @@ char *name, *passwd;
}
#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/crypto/telnet/libtelnet/spx.c b/crypto/telnet/libtelnet/spx.c
deleted file mode 100644
index ad1eca4..0000000
--- a/crypto/telnet/libtelnet/spx.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/*-
- * Copyright (c) 1992, 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)spx.c 8.2 (Berkeley) 5/30/95";
-#endif
-#endif /* not lint */
-
-#ifdef SPX
-/*
- * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION
- * ALL RIGHTS RESERVED
- *
- * "Digital Equipment Corporation authorizes the reproduction,
- * distribution and modification of this software subject to the following
- * restrictions:
- *
- * 1. Any partial or whole copy of this software, or any modification
- * thereof, must include this copyright notice in its entirety.
- *
- * 2. This software is supplied "as is" with no warranty of any kind,
- * expressed or implied, for any purpose, including any warranty of fitness
- * or merchantibility. DIGITAL assumes no responsibility for the use or
- * reliability of this software, nor promises to provide any form of
- * support for it on any basis.
- *
- * 3. Distribution of this software is authorized only if no profit or
- * remuneration of any kind is received in exchange for such distribution.
- *
- * 4. This software produces public key authentication certificates
- * bearing an expiration date established by DIGITAL and RSA Data
- * Security, Inc. It may cease to generate certificates after the expiration
- * date. Any modification of this software that changes or defeats
- * the expiration date or its effect is unauthorized.
- *
- * 5. Software that will renew or extend the expiration date of
- * authentication certificates produced by this software may be obtained
- * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA
- * 94065, (415)595-8782, or from DIGITAL"
- *
- */
-
-#include <sys/types.h>
-#include <arpa/telnet.h>
-#include <stdio.h>
-#include "gssapi_defs.h"
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-#include <pwd.h>
-#include "encrypt.h"
-#include "auth.h"
-#include "misc.h"
-
-extern auth_debug_mode;
-
-static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
- AUTHTYPE_SPX, };
-static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION,
- TELQUAL_NAME, };
-
-#define SPX_AUTH 0 /* Authentication data follows */
-#define SPX_REJECT 1 /* Rejected (reason might follow) */
-#define SPX_ACCEPT 2 /* Accepted */
-
-#ifdef ENCRYPTION
-static Block session_key = { 0 };
-#endif /* ENCRYPTION */
-static Block challenge = { 0 };
-
-
-/*******************************************************************/
-
-gss_OID_set actual_mechs;
-gss_OID actual_mech_type, output_name_type;
-int major_status, status, msg_ctx = 0, new_status;
-int req_flags = 0, ret_flags, lifetime_rec;
-gss_cred_id_t gss_cred_handle;
-gss_ctx_id_t actual_ctxhandle, context_handle;
-gss_buffer_desc output_token, input_token, input_name_buffer;
-gss_buffer_desc status_string;
-gss_name_t desired_targname, src_name;
-gss_channel_bindings input_chan_bindings;
-char lhostname[GSS_C_MAX_PRINTABLE_NAME];
-char targ_printable[GSS_C_MAX_PRINTABLE_NAME];
-int to_addr=0, from_addr=0;
-char *address;
-gss_buffer_desc fullname_buffer;
-gss_OID fullname_type;
-gss_cred_id_t gss_delegated_cred_handle;
-
-/*******************************************************************/
-
-
-
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- void *d;
- int c;
-{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (0) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - (&str_data[2]));
- return(net_write(str_data, p - str_data));
-}
-
- int
-spx_init(ap, server)
- Authenticator *ap;
- int server;
-{
- gss_cred_id_t tmp_cred_handle;
-
- if (server) {
- str_data[3] = TELQUAL_REPLY;
- gethostname(lhostname, sizeof(lhostname));
- strcpy(targ_printable, "SERVICE:rcmd@");
- strcat(targ_printable, lhostname);
- input_name_buffer.length = strlen(targ_printable);
- input_name_buffer.value = targ_printable;
- major_status = gss_import_name(&status,
- &input_name_buffer,
- GSS_C_NULL_OID,
- &desired_targname);
- major_status = gss_acquire_cred(&status,
- desired_targname,
- 0,
- GSS_C_NULL_OID_SET,
- GSS_C_ACCEPT,
- &tmp_cred_handle,
- &actual_mechs,
- &lifetime_rec);
- if (major_status != GSS_S_COMPLETE) return(0);
- } else {
- str_data[3] = TELQUAL_IS;
- }
- return(1);
-}
-
- int
-spx_send(ap)
- Authenticator *ap;
-{
- Block enckey;
- int r;
-
- gss_OID actual_mech_type, output_name_type;
- int msg_ctx = 0, new_status, status;
- int req_flags = 0, ret_flags, lifetime_rec, major_status;
- gss_buffer_desc output_token, input_token, input_name_buffer;
- gss_buffer_desc output_name_buffer, status_string;
- gss_name_t desired_targname;
- gss_channel_bindings input_chan_bindings;
- char targ_printable[GSS_C_MAX_PRINTABLE_NAME];
- int from_addr=0, to_addr=0, myhostlen, j;
- int deleg_flag=1, mutual_flag=0, replay_flag=0, seq_flag=0;
- char *address;
-
- printf("[ Trying SPX ... ]\n");
- strcpy(targ_printable, "SERVICE:rcmd@");
- strcat(targ_printable, RemoteHostName);
-
- input_name_buffer.length = strlen(targ_printable);
- input_name_buffer.value = targ_printable;
-
- if (!UserNameRequested) {
- return(0);
- }
-
- major_status = gss_import_name(&status,
- &input_name_buffer,
- GSS_C_NULL_OID,
- &desired_targname);
-
-
- major_status = gss_display_name(&status,
- desired_targname,
- &output_name_buffer,
- &output_name_type);
-
- printf("target is '%s'\n", output_name_buffer.value); fflush(stdout);
-
- major_status = gss_release_buffer(&status, &output_name_buffer);
-
- input_chan_bindings = (gss_channel_bindings)
- malloc(sizeof(gss_channel_bindings_desc));
-
- input_chan_bindings->initiator_addrtype = GSS_C_AF_INET;
- input_chan_bindings->initiator_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->initiator_address.value = (char *) address;
- address[0] = ((from_addr & 0xff000000) >> 24);
- address[1] = ((from_addr & 0xff0000) >> 16);
- address[2] = ((from_addr & 0xff00) >> 8);
- address[3] = (from_addr & 0xff);
- input_chan_bindings->acceptor_addrtype = GSS_C_AF_INET;
- input_chan_bindings->acceptor_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->acceptor_address.value = (char *) address;
- address[0] = ((to_addr & 0xff000000) >> 24);
- address[1] = ((to_addr & 0xff0000) >> 16);
- address[2] = ((to_addr & 0xff00) >> 8);
- address[3] = (to_addr & 0xff);
- input_chan_bindings->application_data.length = 0;
-
- req_flags = 0;
- if (deleg_flag) req_flags = req_flags | 1;
- if (mutual_flag) req_flags = req_flags | 2;
- if (replay_flag) req_flags = req_flags | 4;
- if (seq_flag) req_flags = req_flags | 8;
-
- major_status = gss_init_sec_context(&status, /* minor status */
- GSS_C_NO_CREDENTIAL, /* cred handle */
- &actual_ctxhandle, /* ctx handle */
- desired_targname, /* target name */
- GSS_C_NULL_OID, /* mech type */
- req_flags, /* req flags */
- 0, /* time req */
- input_chan_bindings, /* chan binding */
- GSS_C_NO_BUFFER, /* input token */
- &actual_mech_type, /* actual mech */
- &output_token, /* output token */
- &ret_flags, /* ret flags */
- &lifetime_rec); /* time rec */
-
- if ((major_status != GSS_S_COMPLETE) &&
- (major_status != GSS_S_CONTINUE_NEEDED)) {
- gss_display_status(&new_status,
- status,
- GSS_C_MECH_CODE,
- GSS_C_NULL_OID,
- &msg_ctx,
- &status_string);
- printf("%s\n", status_string.value);
- return(0);
- }
-
- if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
- return(0);
- }
-
- if (!Data(ap, SPX_AUTH, (void *)output_token.value, output_token.length)) {
- return(0);
- }
-
- return(1);
-}
-
- void
-spx_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
- Block datablock;
- int r;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case SPX_AUTH:
- input_token.length = cnt;
- input_token.value = (char *) data;
-
- gethostname(lhostname, sizeof(lhostname));
-
- strcpy(targ_printable, "SERVICE:rcmd@");
- strcat(targ_printable, lhostname);
-
- input_name_buffer.length = strlen(targ_printable);
- input_name_buffer.value = targ_printable;
-
- major_status = gss_import_name(&status,
- &input_name_buffer,
- GSS_C_NULL_OID,
- &desired_targname);
-
- major_status = gss_acquire_cred(&status,
- desired_targname,
- 0,
- GSS_C_NULL_OID_SET,
- GSS_C_ACCEPT,
- &gss_cred_handle,
- &actual_mechs,
- &lifetime_rec);
-
- major_status = gss_release_name(&status, desired_targname);
-
- input_chan_bindings = (gss_channel_bindings)
- malloc(sizeof(gss_channel_bindings_desc));
-
- input_chan_bindings->initiator_addrtype = GSS_C_AF_INET;
- input_chan_bindings->initiator_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->initiator_address.value = (char *) address;
- address[0] = ((from_addr & 0xff000000) >> 24);
- address[1] = ((from_addr & 0xff0000) >> 16);
- address[2] = ((from_addr & 0xff00) >> 8);
- address[3] = (from_addr & 0xff);
- input_chan_bindings->acceptor_addrtype = GSS_C_AF_INET;
- input_chan_bindings->acceptor_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->acceptor_address.value = (char *) address;
- address[0] = ((to_addr & 0xff000000) >> 24);
- address[1] = ((to_addr & 0xff0000) >> 16);
- address[2] = ((to_addr & 0xff00) >> 8);
- address[3] = (to_addr & 0xff);
- input_chan_bindings->application_data.length = 0;
-
- major_status = gss_accept_sec_context(&status,
- &context_handle,
- gss_cred_handle,
- &input_token,
- input_chan_bindings,
- &src_name,
- &actual_mech_type,
- &output_token,
- &ret_flags,
- &lifetime_rec,
- &gss_delegated_cred_handle);
-
-
- if (major_status != GSS_S_COMPLETE) {
-
- major_status = gss_display_name(&status,
- src_name,
- &fullname_buffer,
- &fullname_type);
- Data(ap, SPX_REJECT, (void *)"auth failed", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- major_status = gss_display_name(&status,
- src_name,
- &fullname_buffer,
- &fullname_type);
-
-
- Data(ap, SPX_ACCEPT, (void *)output_token.value, output_token.length);
- auth_finished(ap, AUTH_USER);
- break;
-
- default:
- Data(ap, SPX_REJECT, 0, 0);
- break;
- }
-}
-
-
- void
-spx_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case SPX_REJECT:
- if (cnt > 0) {
- printf("[ SPX refuses authentication because %.*s ]\r\n",
- cnt, data);
- } else
- printf("[ SPX refuses authentication ]\r\n");
- auth_send_retry();
- return;
- case SPX_ACCEPT:
- printf("[ SPX accepts you ]\n");
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- /*
- * Send over the encrypted challenge.
- */
- input_token.value = (char *) data;
- input_token.length = cnt;
-
- major_status = gss_init_sec_context(&status, /* minor stat */
- GSS_C_NO_CREDENTIAL, /* cred handle */
- &actual_ctxhandle, /* ctx handle */
- desired_targname, /* target name */
- GSS_C_NULL_OID, /* mech type */
- req_flags, /* req flags */
- 0, /* time req */
- input_chan_bindings, /* chan binding */
- &input_token, /* input token */
- &actual_mech_type, /* actual mech */
- &output_token, /* output token */
- &ret_flags, /* ret flags */
- &lifetime_rec); /* time rec */
-
- if (major_status != GSS_S_COMPLETE) {
- gss_display_status(&new_status,
- status,
- GSS_C_MECH_CODE,
- GSS_C_NULL_OID,
- &msg_ctx,
- &status_string);
- printf("[ SPX mutual response fails ... '%s' ]\r\n",
- status_string.value);
- auth_send_retry();
- return;
- }
- }
- auth_finished(ap, AUTH_USER);
- return;
-
- default:
- return;
- }
-}
-
- int
-spx_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
-{
-
- gss_buffer_desc fullname_buffer, acl_file_buffer;
- gss_OID fullname_type;
- char acl_file[160], fullname[160];
- int major_status, status = 0;
- struct passwd *pwd;
-
- /*
- * hard code fullname to
- * "SPX:/C=US/O=Digital/OU=LKG/OU=Sphinx/OU=Users/CN=Kannan Alagappan"
- * and acl_file to "~kannan/.sphinx"
- */
-
- pwd = getpwnam(UserNameRequested);
- if (pwd == NULL) {
- return(AUTH_USER); /* not authenticated */
- }
-
- strcpy(acl_file, pwd->pw_dir);
- strcat(acl_file, "/.sphinx");
- acl_file_buffer.value = acl_file;
- acl_file_buffer.length = strlen(acl_file);
-
- major_status = gss_display_name(&status,
- src_name,
- &fullname_buffer,
- &fullname_type);
-
- if (level < AUTH_USER)
- return(level);
-
- major_status = gss__check_acl(&status, &fullname_buffer,
- &acl_file_buffer);
-
- if (major_status == GSS_S_COMPLETE) {
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
- } else {
- return(AUTH_USER);
- }
-
-}
-
-#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
-#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-
- void
-spx_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
- case SPX_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case SPX_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
- case SPX_AUTH: /* Authentication data follows */
- strncpy((char *)buf, " AUTH", buflen);
- goto common2;
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
- }
-}
-
-#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/crypto/telnet/libtelnet/sra.c b/crypto/telnet/libtelnet/sra.c
index 8a94951..cf53fd7 100644
--- a/crypto/telnet/libtelnet/sra.c
+++ b/crypto/telnet/libtelnet/sra.c
@@ -29,38 +29,33 @@
*/
#include <sys/cdefs.h>
+
__FBSDID("$FreeBSD$");
#ifdef SRA
+#ifdef ENCRYPTION
#include <sys/types.h>
#include <arpa/telnet.h>
+#include <pwd.h>
#include <stdio.h>
-#ifdef __STDC__
#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
#include <string.h>
-#endif
+#include <syslog.h>
+#include <ttyent.h>
-#if !defined(NOPAM)
+#ifndef NOPAM
#include <security/pam_appl.h>
#else
#include <unistd.h>
#endif
-#include <pwd.h>
-#include <syslog.h>
-#include <ttyent.h>
-
#include "auth.h"
#include "misc.h"
#include "encrypt.h"
#include "pk.h"
char pka[HEXKEYBYTES+1], ska[HEXKEYBYTES+1], pkb[HEXKEYBYTES+1];
-char *user,*pass,*xuser,*xpass;
+char *user, *pass, *xuser, *xpass;
DesData ck;
IdeaData ik;
@@ -80,7 +75,7 @@ static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
#define SRA_ACCEPT 4
#define SRA_REJECT 5
-static int check_user(const char *, const char *);
+static int check_user(char *, char *);
/* support routine to send out authentication message */
static int
@@ -115,7 +110,7 @@ Data(Authenticator *ap, int type, void *d, int c)
}
int
-sra_init(Authenticator *ap, int server)
+sra_init(Authenticator *ap __unused, int server)
{
if (server)
str_data[3] = TELQUAL_REPLY;
@@ -212,12 +207,10 @@ sra_is(Authenticator *ap, unsigned char *data, int cnt)
if(valid) {
Data(ap, SRA_ACCEPT, (void *)0, 0);
-#ifdef DES_ENCRYPTION
skey.data = ck;
skey.type = SK_DES;
skey.length = 8;
encrypt_session_key(&skey, 1);
-#endif
sra_valid = 1;
auth_finished(ap, AUTH_VALID);
@@ -252,10 +245,9 @@ bad:
void
sra_reply(Authenticator *ap, unsigned char *data, int cnt)
{
- extern char *telnet_gets();
char uprompt[256],tuser[256];
Session_Key skey;
- int i;
+ size_t i;
if (cnt-- < 1)
return;
@@ -333,12 +325,10 @@ sra_reply(Authenticator *ap, unsigned char *data, int cnt)
case SRA_ACCEPT:
printf("[ SRA accepts you ]\r\n");
-#ifdef DES_ENCRYPTION
skey.data = ck;
skey.type = SK_DES;
skey.length = 8;
encrypt_session_key(&skey, 0);
-#endif
auth_finished(ap, AUTH_VALID);
return;
@@ -350,7 +340,7 @@ sra_reply(Authenticator *ap, unsigned char *data, int cnt)
}
int
-sra_status(Authenticator *ap, char *name, int level)
+sra_status(Authenticator *ap __unused, char *name, int level)
{
if (level < AUTH_USER)
return(level);
@@ -368,7 +358,7 @@ void
sra_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
char lbuf[32];
- register int i;
+ int i;
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
buflen -= 1;
@@ -423,70 +413,14 @@ sra_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
}
}
-struct passwd *pw;
-
-/*
- * Helper function for sgetpwnam().
- */
-char *
-sgetsave(char *s)
-{
- char *new = malloc((unsigned) strlen(s) + 1);
-
- if (new == NULL) {
- return(NULL);
- }
- (void) strcpy(new, s);
- return (new);
-}
-
-struct passwd *
-sgetpwnam(char *name)
-{
- static struct passwd save;
- register struct passwd *p;
- char *sgetsave();
-
- if ((p = getpwnam(name)) == NULL)
- return (p);
- if (save.pw_name) {
- free(save.pw_name);
- free(save.pw_passwd);
- free(save.pw_gecos);
- free(save.pw_dir);
- free(save.pw_shell);
- }
- save = *p;
- save.pw_name = sgetsave(p->pw_name);
- save.pw_passwd = sgetsave(p->pw_passwd);
- save.pw_gecos = sgetsave(p->pw_gecos);
- save.pw_dir = sgetsave(p->pw_dir);
- save.pw_shell = sgetsave(p->pw_shell);
-#if 0
-syslog(LOG_WARNING,"%s\n",save.pw_name);
-syslog(LOG_WARNING,"%s\n",save.pw_passwd);
-syslog(LOG_WARNING,"%s\n",save.pw_gecos);
-syslog(LOG_WARNING,"%s\n",save.pw_dir);
-#endif
-#ifdef USE_SHADOW
- {
- struct spwd *sp;
- sp = getspnam(name);
- free(save.pw_passwd);
- save.pw_passwd = sgetsave(sp->sp_pwdp);
- }
-#endif
- return (&save);
-}
-
static int
-isroot(const char *user)
+isroot(const char *usr)
{
- struct passwd *pw;
+ struct passwd *pwd;
- if ((pw=getpwnam(user))==NULL)
+ if ((pwd=getpwnam(usr))==NULL)
return 0;
- return (!pw->pw_uid);
+ return (!pwd->pw_uid);
}
static int
@@ -499,9 +433,9 @@ rootterm(char *ttyn)
#ifdef NOPAM
static int
-check_user(const char *name, const char *pass)
+check_user(char *name, char *cred)
{
- register char *cp;
+ char *cp;
char *xpasswd, *salt;
if (isroot(name) && !rootterm(line))
@@ -517,7 +451,7 @@ check_user(const char *name, const char *pass)
}
salt = pw->pw_passwd;
- xpasswd = crypt(pass, salt);
+ xpasswd = crypt(cred, salt);
/* The strcmp does not catch null passwords! */
if (pw == NULL || *pw->pw_passwd == '\0' ||
strcmp(xpasswd, pw->pw_passwd)) {
@@ -545,9 +479,8 @@ struct cred_t {
};
typedef struct cred_t cred_t;
-int
-auth_conv(int num_msg, const struct pam_message **msg,
- struct pam_response **resp, void *appdata)
+static int
+auth_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata)
{
int i;
cred_t *cred = (cred_t *) appdata;
@@ -588,13 +521,13 @@ auth_conv(int num_msg, const struct pam_message **msg,
* The PAM version as a side effect may put a new username in *name.
*/
static int
-check_user(const char *name, const char *pass)
+check_user(char *name, char *cred)
{
pam_handle_t *pamh = NULL;
const void *item;
int rval;
int e;
- cred_t auth_cred = { name, pass };
+ cred_t auth_cred = { name, cred };
struct pam_conv conv = { &auth_conv, &auth_cred };
e = pam_start("telnetd", name, &conv, &pamh);
@@ -634,7 +567,7 @@ check_user(const char *name, const char *pass)
*/
if ((e = pam_get_item(pamh, PAM_USER, &item)) ==
PAM_SUCCESS) {
- strcpy((char *) name, (const char *) item);
+ strcpy(name, item);
} else
syslog(LOG_ERR, "Couldn't get PAM_USER: %s",
pam_strerror(pamh, e));
@@ -665,5 +598,5 @@ check_user(const char *name, const char *pass)
#endif
-#endif
-
+#endif /* ENCRYPTION */
+#endif /* SRA */
diff --git a/crypto/telnet/telnet/authenc.c b/crypto/telnet/telnet/authenc.c
index 47b242f..718ab84 100644
--- a/crypto/telnet/telnet/authenc.c
+++ b/crypto/telnet/telnet/authenc.c
@@ -31,18 +31,20 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
#include <sys/types.h>
#include <arpa/telnet.h>
+#include <pwd.h>
+#include <unistd.h>
#include <libtelnet/encrypt.h>
#include <libtelnet/misc.h>
@@ -52,10 +54,8 @@ static const char rcsid[] =
#include "defines.h"
#include "types.h"
- int
-net_write(str, len)
- unsigned char *str;
- int len;
+int
+net_write(unsigned char *str, int len)
{
if (NETROOM() > len) {
ring_supply_data(&netoring, str, len);
@@ -66,8 +66,8 @@ net_write(str, len)
return(0);
}
- void
-net_encrypt()
+void
+net_encrypt(void)
{
#ifdef ENCRYPTION
if (encrypt_output)
@@ -77,40 +77,35 @@ net_encrypt()
#endif /* ENCRYPTION */
}
- int
-telnet_spin()
+int
+telnet_spin(void)
{
return(-1);
}
- char *
-telnet_getenv(val)
- char *val;
+char *
+telnet_getenv(char *val)
{
return((char *)env_getvalue((unsigned char *)val));
}
- char *
-telnet_gets(prompt, result, length, echo)
- char *prompt;
- char *result;
- int length;
- int echo;
+char *
+telnet_gets(const char *prom, char *result, int length, int echo)
{
- extern char *getpass();
extern int globalmode;
int om = globalmode;
char *res;
TerminalNewMode(-1);
if (echo) {
- printf("%s", prompt);
+ printf("%s", prom);
res = fgets(result, length, stdin);
- } else if ((res = getpass(prompt))) {
+ } else if ((res = getpass(prom))) {
strncpy(result, res, length);
res = result;
}
TerminalNewMode(om);
return(res);
}
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
+#endif /* ENCRYPTION */
+#endif /* AUTHENTICATION */
diff --git a/crypto/telnet/telnet/commands.c b/crypto/telnet/telnet/commands.c
index 33c2bba..8b30e36 100644
--- a/crypto/telnet/telnet/commands.c
+++ b/crypto/telnet/telnet/commands.c
@@ -29,33 +29,32 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
-#endif /* not lint */
+#endif
-#if defined(unix)
#include <sys/param.h>
#include <sys/un.h>
#include <sys/file.h>
-#else
-#include <sys/types.h>
-#endif /* defined(unix) */
#include <sys/socket.h>
#include <netinet/in.h>
-#include <string.h>
-#include <signal.h>
-#include <netdb.h>
#include <ctype.h>
-#include <pwd.h>
-#include <varargs.h>
+#include <err.h>
#include <errno.h>
-#include <unistd.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdarg.h>
#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <arpa/telnet.h>
#include <arpa/inet.h>
@@ -67,18 +66,16 @@ static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
#include "externs.h"
#include "defines.h"
#include "types.h"
+#include "misc.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
#include <netinet/in_systm.h>
-# if (defined(vax) || defined(tahoe) || defined(hp300)) && !defined(ultrix)
-# include <machine/endian.h>
-# endif /* vax */
#include <netinet/ip.h>
#include <netinet/ip6.h>
@@ -86,6 +83,17 @@ static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
#define MAXHOSTNAMELEN 256
#endif MAXHOSTNAMELEN
+typedef int (*intrtn_t)(int, char **);
+
+#ifdef AUTHENTICATION
+extern int auth_togdebug P((int));
+#endif
+#ifdef ENCRYPTION
+extern int EncryptAutoEnc P((int));
+extern int EncryptAutoDec P((int));
+extern int EncryptDebug P((int));
+extern int EncryptVerbose P((int));
+#endif /* ENCRYPTION */
#if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1;
#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */
@@ -93,22 +101,21 @@ int tos = -1;
char *hostname;
static char _hostname[MAXHOSTNAMELEN];
-extern char *getenv();
-
-extern int isprefix();
-extern char **genget();
-extern int Ambiguous();
-
-static int help(int argc, char *argv[]);
-static int call();
-static void cmdrc(char *m1, char *m2);
-static int switch_af(struct addrinfo **aip);
-int quit(void);
+static int help(int, char **);
+static int call(intrtn_t, ...);
+static void cmdrc(char *, char *);
+static int switch_af(struct addrinfo **);
+static int togglehelp(void);
+static int send_tncmd(void (*)(int, int), const char *, char *);
+static int setmod(int);
+static int clearmode(int);
+static int modehelp(void);
+static int sourceroute(struct addrinfo *, char *, char **, int *, int *, int *);
typedef struct {
- char *name; /* command name */
- char *help; /* help string (NULL for no help) */
- int (*handler)(); /* routine which executes command */
+ const char *name; /* command name */
+ const char *help; /* help string (NULL for no help) */
+ int (*handler)(int, char **); /* routine which executes command */
int needconnect; /* Do we need to be connected to execute? */
} Command;
@@ -117,19 +124,17 @@ static char saveline[256];
static int margc;
static char *margv[20];
-#if defined(OPIE)
+#ifdef OPIE
#include <sys/wait.h>
#define PATH_OPIEKEY "/usr/bin/opiekey"
- int
-opie_calc(argc, argv)
- int argc;
- char **argv;
+static int
+opie_calc(int argc, char *argv[])
{
int status;
if(argc != 3) {
printf("%s sequence challenge\n", argv[0]);
- return;
+ return (0);
}
switch(fork()) {
@@ -143,27 +148,27 @@ opie_calc(argc, argv)
(void) wait(&status);
if (WIFEXITED(status))
return (WEXITSTATUS(status));
- return (0);
}
+ return (0);
}
#endif
- static void
-makeargv()
+static void
+makeargv(void)
{
- register char *cp, *cp2, c;
- register char **argp = margv;
+ char *cp, *cp2, c;
+ char **argp = margv;
margc = 0;
cp = line;
if (*cp == '!') { /* Special case shell escape */
strcpy(saveline, line); /* save for shell command */
- *argp++ = "!"; /* No room in string to get this */
+ *argp++ = strdup("!"); /* No room in string to get this */
margc++;
cp++;
}
while ((c = *cp)) {
- register int inquote = 0;
+ int inquote = 0;
while (isspace(c))
c = *++cp;
if (c == '\0')
@@ -205,11 +210,10 @@ makeargv()
* Todo: 1. Could take random integers (12, 0x12, 012, 0b1).
*/
- static int
-special(s)
- register char *s;
+static int
+special(char *s)
{
- register char c;
+ char c;
char b;
switch (*s) {
@@ -232,9 +236,8 @@ special(s)
* Construct a control character sequence
* for a special character.
*/
- static char *
-control(c)
- register cc_t c;
+static const char *
+control(cc_t c)
{
static char buf[5];
/*
@@ -244,7 +247,7 @@ control(c)
* was to assign "c" to an unsigned int variable...
* Arggg....
*/
- register unsigned int uic = (unsigned int)c;
+ unsigned int uic = (unsigned int)c;
if (uic == 0x7f)
return ("^?");
@@ -268,8 +271,6 @@ control(c)
return (buf);
}
-
-
/*
* The following are data structures and routines for
* the "send" command.
@@ -277,11 +278,11 @@ control(c)
*/
struct sendlist {
- char *name; /* How user refers to it (case independent) */
- char *help; /* Help information (0 ==> no help) */
+ const char *name; /* How user refers to it (case independent) */
+ const char *help; /* Help information (0 ==> no help) */
int needconnect; /* Need to be connected */
int narg; /* Number of arguments */
- int (*handler)(); /* Routine to perform (for special ops) */
+ int (*handler)(char *, ...); /* Routine to perform (for special ops) */
int nbyte; /* Number of bytes to send this command */
int what; /* Character to be sent (<0 ==> special) */
};
@@ -296,41 +297,39 @@ static int
send_wontcmd P((char *));
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 },
- { "brk", "Send Telnet Break", 1, 0, 0, 2, BREAK },
- { "break", 0, 1, 0, 0, 2, BREAK },
- { "ec", "Send Telnet Erase Character", 1, 0, 0, 2, EC },
- { "el", "Send Telnet Erase Line", 1, 0, 0, 2, EL },
- { "escape", "Send current escape character", 1, 0, send_esc, 1, 0 },
- { "ga", "Send Telnet 'Go Ahead' sequence", 1, 0, 0, 2, GA },
- { "ip", "Send Telnet Interrupt Process", 1, 0, 0, 2, IP },
- { "intp", 0, 1, 0, 0, 2, IP },
- { "interrupt", 0, 1, 0, 0, 2, IP },
- { "intr", 0, 1, 0, 0, 2, IP },
- { "nop", "Send Telnet 'No operation'", 1, 0, 0, 2, NOP },
- { "eor", "Send Telnet 'End of Record'", 1, 0, 0, 2, EOR },
- { "abort", "Send Telnet 'Abort Process'", 1, 0, 0, 2, ABORT },
- { "susp", "Send Telnet 'Suspend Process'", 1, 0, 0, 2, SUSP },
- { "eof", "Send Telnet End of File Character", 1, 0, 0, 2, xEOF },
- { "synch", "Perform Telnet 'Synch operation'", 1, 0, dosynch, 2, 0 },
- { "getstatus", "Send request for STATUS", 1, 0, get_status, 6, 0 },
- { "?", "Display send options", 0, 0, send_help, 0, 0 },
- { "help", 0, 0, 0, send_help, 0, 0 },
- { "do", 0, 0, 1, send_docmd, 3, 0 },
- { "dont", 0, 0, 1, send_dontcmd, 3, 0 },
- { "will", 0, 0, 1, send_willcmd, 3, 0 },
- { "wont", 0, 0, 1, send_wontcmd, 3, 0 },
- { 0 }
+ { "ao", "Send Telnet Abort output", 1, 0, NULL, 2, AO },
+ { "ayt", "Send Telnet 'Are You There'", 1, 0, NULL, 2, AYT },
+ { "brk", "Send Telnet Break", 1, 0, NULL, 2, BREAK },
+ { "break", NULL, 1, 0, NULL, 2, BREAK },
+ { "ec", "Send Telnet Erase Character", 1, 0, NULL, 2, EC },
+ { "el", "Send Telnet Erase Line", 1, 0, NULL, 2, EL },
+ { "escape", "Send current escape character",1, 0, (int (*)(char *, ...))send_esc, 1, 0 },
+ { "ga", "Send Telnet 'Go Ahead' sequence", 1, 0, NULL, 2, GA },
+ { "ip", "Send Telnet Interrupt Process",1, 0, NULL, 2, IP },
+ { "intp", NULL, 1, 0, NULL, 2, IP },
+ { "interrupt", NULL, 1, 0, NULL, 2, IP },
+ { "intr", NULL, 1, 0, NULL, 2, IP },
+ { "nop", "Send Telnet 'No operation'", 1, 0, NULL, 2, NOP },
+ { "eor", "Send Telnet 'End of Record'", 1, 0, NULL, 2, EOR },
+ { "abort", "Send Telnet 'Abort Process'", 1, 0, NULL, 2, ABORT },
+ { "susp", "Send Telnet 'Suspend Process'",1, 0, NULL, 2, SUSP },
+ { "eof", "Send Telnet End of File Character", 1, 0, NULL, 2, xEOF },
+ { "synch", "Perform Telnet 'Synch operation'", 1, 0, (int (*)(char *, ...))dosynch, 2, 0 },
+ { "getstatus", "Send request for STATUS", 1, 0, (int (*)(char *, ...))get_status, 6, 0 },
+ { "?", "Display send options", 0, 0, (int (*)(char *, ...))send_help, 0, 0 },
+ { "help", NULL, 0, 0, (int (*)(char *, ...))send_help, 0, 0 },
+ { "do", NULL, 0, 1, (int (*)(char *, ...))send_docmd, 3, 0 },
+ { "dont", NULL, 0, 1, (int (*)(char *, ...))send_dontcmd, 3, 0 },
+ { "will", NULL, 0, 1, (int (*)(char *, ...))send_willcmd, 3, 0 },
+ { "wont", NULL, 0, 1, (int (*)(char *, ...))send_wontcmd, 3, 0 },
+ { NULL, NULL, 0, 0, NULL, 0, 0 }
};
#define GETSEND(name) ((struct sendlist *) genget(name, (char **) Sendlist, \
sizeof(struct sendlist)))
- static int
-sendcmd(argc, argv)
- int argc;
- char **argv;
+static int
+sendcmd(int argc, char *argv[])
{
int count; /* how many bytes we are going to need to send */
int i;
@@ -356,7 +355,7 @@ sendcmd(argc, argv)
printf("Unknown send argument '%s'\n'send ?' for help.\n",
argv[i]);
return 0;
- } else if (Ambiguous(s)) {
+ } else if (Ambiguous((void *)s)) {
printf("Ambiguous send argument '%s'\n'send ?' for help.\n",
argv[i]);
return 0;
@@ -368,7 +367,7 @@ sendcmd(argc, argv)
return 0;
}
count += s->nbyte;
- if (s->handler == send_help) {
+ if ((void *)s->handler == (void *)send_help) {
send_help();
return 0;
}
@@ -394,7 +393,7 @@ sendcmd(argc, argv)
for (i = 1; i < argc; i++) {
if ((s = GETSEND(argv[i])) == 0) {
fprintf(stderr, "Telnet 'send' error - argument disappeared!\n");
- (void) quit();
+ quit();
/*NOTREACHED*/
}
if (s->handler) {
@@ -410,50 +409,47 @@ sendcmd(argc, argv)
return (count == success);
}
- static int
-send_esc()
+static int
+send_esc(void)
{
NETADD(escape);
return 1;
}
- static int
-send_docmd(name)
- char *name;
+static int
+send_docmd(char *name)
{
return(send_tncmd(send_do, "do", name));
}
- static int
+static int
send_dontcmd(name)
char *name;
{
return(send_tncmd(send_dont, "dont", name));
}
- static int
-send_willcmd(name)
- char *name;
+
+static int
+send_willcmd(char *name)
{
return(send_tncmd(send_will, "will", name));
}
- static int
-send_wontcmd(name)
- char *name;
+
+static int
+send_wontcmd(char *name)
{
return(send_tncmd(send_wont, "wont", name));
}
- int
-send_tncmd(func, cmd, name)
- void (*func)();
- char *cmd, *name;
+static int
+send_tncmd(void (*func)(int, int), const char *cmd, char *name)
{
char **cpp;
extern char *telopts[];
- register int val = 0;
+ int val = 0;
if (isprefix(name, "help") || isprefix(name, "?")) {
- register int col, len;
+ int col, len;
printf("Usage: send %s <value|option>\n", cmd);
printf("\"value\" must be from 0 to 255\n");
@@ -481,7 +477,7 @@ send_tncmd(func, cmd, name)
if (cpp) {
val = cpp - telopts;
} else {
- register char *cp = name;
+ char *cp = name;
while (*cp >= '0' && *cp <= '9') {
val *= 10;
@@ -506,8 +502,8 @@ send_tncmd(func, cmd, name)
return 1;
}
- static int
-send_help()
+static int
+send_help(void)
{
struct sendlist *s; /* pointer to current command */
for (s = Sendlist; s->name; s++) {
@@ -522,15 +518,15 @@ send_help()
* to by the arguments to the "toggle" command.
*/
- static int
-lclchars()
+static int
+lclchars(void)
{
donelclchars = 1;
return 1;
}
- static int
-togdebug()
+static int
+togdebug(void)
{
#ifndef NOT43
if (net > 0 &&
@@ -548,8 +544,8 @@ togdebug()
}
- static int
-togcrlf()
+static int
+togcrlf(void)
{
if (crlf) {
printf("Will send carriage returns as telnet <CR><LF>.\n");
@@ -561,9 +557,8 @@ togcrlf()
int binmode;
- static int
-togbinary(val)
- int val;
+static int
+togbinary(int val)
{
donebinarytoggle = 1;
@@ -600,9 +595,8 @@ togbinary(val)
return 1;
}
- static int
-togrbinary(val)
- int val;
+static int
+togrbinary(int val)
{
donebinarytoggle = 1;
@@ -627,9 +621,8 @@ togrbinary(val)
return 1;
}
- static int
-togxbinary(val)
- int val;
+static int
+togxbinary(int val)
{
donebinarytoggle = 1;
@@ -654,24 +647,12 @@ togxbinary(val)
return 1;
}
-
-static int togglehelp P((void));
-#if defined(AUTHENTICATION)
-extern int auth_togdebug P((int));
-#endif
-#ifdef ENCRYPTION
-extern int EncryptAutoEnc P((int));
-extern int EncryptAutoDec P((int));
-extern int EncryptDebug P((int));
-extern int EncryptVerbose P((int));
-#endif /* ENCRYPTION */
-
struct togglelist {
- char *name; /* name of toggle */
- char *help; /* help message */
- int (*handler)(); /* routine to do actual setting */
+ const char *name; /* name of toggle */
+ const char *help; /* help message */
+ int (*handler)(int); /* routine to do actual setting */
int *variable;
- char *actionexplanation;
+ const char *actionexplanation;
};
static struct togglelist Togglelist[] = {
@@ -685,7 +666,7 @@ static struct togglelist Togglelist[] = {
0,
&autosynch,
"send interrupt characters in urgent mode" },
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
{ "autologin",
"automatic sending of login and/or authentication info",
0,
@@ -741,7 +722,7 @@ static struct togglelist Togglelist[] = {
0 },
{ "crlf",
"sending carriage returns as telnet <CR><LF>",
- togcrlf,
+ (int (*)(int))togcrlf,
&crlf,
0 },
{ "crmod",
@@ -751,25 +732,13 @@ static struct togglelist Togglelist[] = {
"map carriage return on output" },
{ "localchars",
"local recognition of certain control characters",
- lclchars,
+ (int (*)(int))lclchars,
&localchars,
"recognize certain control characters" },
- { " ", "", 0 }, /* empty line */
-#if defined(unix) && defined(TN3270)
- { "apitrace",
- "(debugging) toggle tracing of API transactions",
- 0,
- &apitrace,
- "trace API transactions" },
- { "cursesdata",
- "(debugging) toggle printing of hexadecimal curses data",
- 0,
- &cursesdata,
- "print hexadecimal representation of curses data" },
-#endif /* defined(unix) && defined(TN3270) */
+ { " ", "", NULL, NULL, NULL }, /* empty line */
{ "debug",
"debugging",
- togdebug,
+ (int (*)(int))togdebug,
&debug,
"turn on socket level debugging" },
{ "netdata",
@@ -787,24 +756,27 @@ static struct togglelist Togglelist[] = {
0,
&showoptions,
"show option processing" },
-#if defined(unix)
{ "termdata",
"(debugging) toggle printing of hexadecimal terminal data",
0,
&termdata,
"print hexadecimal representation of terminal traffic" },
-#endif /* defined(unix) */
{ "?",
- 0,
- togglehelp },
+ NULL,
+ (int (*)(int))togglehelp,
+ NULL,
+ NULL },
+ { NULL, NULL, NULL, NULL, NULL },
{ "help",
- 0,
- togglehelp },
- { 0 }
+ NULL,
+ (int (*)(int))togglehelp,
+ NULL,
+ NULL },
+ { NULL, NULL, NULL, NULL, NULL }
};
- static int
-togglehelp()
+static int
+togglehelp(void)
{
struct togglelist *c;
@@ -821,9 +793,8 @@ togglehelp()
return 0;
}
- static void
-settogglehelp(set)
- int set;
+static void
+settogglehelp(int set)
{
struct togglelist *c;
@@ -841,10 +812,8 @@ settogglehelp(set)
#define GETTOGGLE(name) (struct togglelist *) \
genget(name, (char **) Togglelist, sizeof(struct togglelist))
- static int
-toggle(argc, argv)
- int argc;
- char *argv[];
+static int
+toggle(int argc, char *argv[])
{
int retval = 1;
char *name;
@@ -860,7 +829,7 @@ toggle(argc, argv)
while (argc--) {
name = *argv++;
c = GETTOGGLE(name);
- if (Ambiguous(c)) {
+ if (Ambiguous((void *)c)) {
fprintf(stderr, "'%s': ambiguous argument ('toggle ?' for help).\n",
name);
return 0;
@@ -889,56 +858,54 @@ toggle(argc, argv)
*/
#ifdef USE_TERMIO
-struct termio new_tc = { 0 };
+struct termio new_tc = { 0, 0, 0, 0, {}, 0, 0 };
#endif
struct setlist {
- char *name; /* name */
- char *help; /* help information */
- void (*handler)();
+ const char *name; /* name */
+ const char *help; /* help information */
+ void (*handler)(char *);
cc_t *charp; /* where it is located at */
};
static struct setlist Setlist[] = {
#ifdef KLUDGELINEMODE
- { "echo", "character to toggle local echoing on/off", 0, &echoc },
+ { "echo", "character to toggle local echoing on/off", NULL, &echoc },
#endif
- { "escape", "character to escape back to telnet command mode", 0, &escape },
+ { "escape", "character to escape back to telnet command mode", NULL, &escape },
{ "rlogin", "rlogin escape character", 0, &rlogin },
{ "tracefile", "file to write trace information to", SetNetTrace, (cc_t *)NetTraceFile},
- { " ", "" },
- { " ", "The following need 'localchars' to be toggled true", 0, 0 },
- { "flushoutput", "character to cause an Abort Output", 0, termFlushCharp },
- { "interrupt", "character to cause an Interrupt Process", 0, termIntCharp },
- { "quit", "character to cause an Abort process", 0, termQuitCharp },
- { "eof", "character to cause an EOF ", 0, termEofCharp },
- { " ", "" },
- { " ", "The following are for local editing in linemode", 0, 0 },
- { "erase", "character to use to erase a character", 0, termEraseCharp },
- { "kill", "character to use to erase a line", 0, termKillCharp },
- { "lnext", "character to use for literal next", 0, termLiteralNextCharp },
- { "susp", "character to cause a Suspend Process", 0, termSuspCharp },
- { "reprint", "character to use for line reprint", 0, termRprntCharp },
- { "worderase", "character to use to erase a word", 0, termWerasCharp },
- { "start", "character to use for XON", 0, termStartCharp },
- { "stop", "character to use for XOFF", 0, termStopCharp },
- { "forw1", "alternate end of line character", 0, termForw1Charp },
- { "forw2", "alternate end of line character", 0, termForw2Charp },
- { "ayt", "alternate AYT character", 0, termAytCharp },
- { 0 }
+ { " ", "", NULL, NULL },
+ { " ", "The following need 'localchars' to be toggled true", NULL, NULL },
+ { "flushoutput", "character to cause an Abort Output", NULL, termFlushCharp },
+ { "interrupt", "character to cause an Interrupt Process", NULL, termIntCharp },
+ { "quit", "character to cause an Abort process", NULL, termQuitCharp },
+ { "eof", "character to cause an EOF ", NULL, termEofCharp },
+ { " ", "", NULL, NULL },
+ { " ", "The following are for local editing in linemode", NULL, NULL },
+ { "erase", "character to use to erase a character", NULL, termEraseCharp },
+ { "kill", "character to use to erase a line", NULL, termKillCharp },
+ { "lnext", "character to use for literal next", NULL, termLiteralNextCharp },
+ { "susp", "character to cause a Suspend Process", NULL, termSuspCharp },
+ { "reprint", "character to use for line reprint", NULL, termRprntCharp },
+ { "worderase", "character to use to erase a word", NULL, termWerasCharp },
+ { "start", "character to use for XON", NULL, termStartCharp },
+ { "stop", "character to use for XOFF", NULL, termStopCharp },
+ { "forw1", "alternate end of line character", NULL, termForw1Charp },
+ { "forw2", "alternate end of line character", NULL, termForw2Charp },
+ { "ayt", "alternate AYT character", NULL, termAytCharp },
+ { NULL, NULL, NULL, NULL }
};
- static struct setlist *
-getset(name)
- char *name;
+static struct setlist *
+getset(char *name)
{
return (struct setlist *)
genget(name, (char **) Setlist, sizeof(struct setlist));
}
- void
-set_escape_char(s)
- char *s;
+void
+set_escape_char(char *s)
{
if (rlogin != _POSIX_VDISABLE) {
rlogin = (s && *s) ? special(s) : _POSIX_VDISABLE;
@@ -950,10 +917,8 @@ set_escape_char(s)
}
}
- static int
-setcmd(argc, argv)
- int argc;
- char *argv[];
+static int
+setcmd(int argc, char *argv[])
{
int value;
struct setlist *ct;
@@ -979,7 +944,7 @@ setcmd(argc, argv)
fprintf(stderr, "'%s': unknown argument ('set ?' for help).\n",
argv[1]);
return 0;
- } else if (Ambiguous(c)) {
+ } else if (Ambiguous((void *)c)) {
fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\n",
argv[1]);
return 0;
@@ -1003,7 +968,7 @@ setcmd(argc, argv)
} else if (argc != 3) {
printf("Format is 'set Name Value'\n'set ?' for help.\n");
return 0;
- } else if (Ambiguous(ct)) {
+ } else if (Ambiguous((void *)ct)) {
fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\n",
argv[1]);
return 0;
@@ -1023,14 +988,12 @@ setcmd(argc, argv)
return 1;
}
- static int
-unsetcmd(argc, argv)
- int argc;
- char *argv[];
+static int
+unsetcmd(int argc, char *argv[])
{
struct setlist *ct;
struct togglelist *c;
- register char *name;
+ char *name;
if (argc < 2) {
fprintf(stderr,
@@ -1057,7 +1020,7 @@ unsetcmd(argc, argv)
fprintf(stderr, "'%s': unknown argument ('unset ?' for help).\n",
name);
return 0;
- } else if (Ambiguous(c)) {
+ } else if (Ambiguous((void *)c)) {
fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\n",
name);
return 0;
@@ -1071,7 +1034,7 @@ unsetcmd(argc, argv)
}
if (c->handler)
(*c->handler)(0);
- } else if (Ambiguous(ct)) {
+ } else if (Ambiguous((void *)ct)) {
fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\n",
name);
return 0;
@@ -1093,8 +1056,8 @@ unsetcmd(argc, argv)
#ifdef KLUDGELINEMODE
extern int kludgelinemode;
- static int
-dokludgemode()
+static int
+dokludgemode(void)
{
kludgelinemode = 1;
send_wont(TELOPT_LINEMODE, 1);
@@ -1104,8 +1067,8 @@ dokludgemode()
}
#endif
- static int
-dolinemode()
+static int
+dolinemode(void)
{
#ifdef KLUDGELINEMODE
if (kludgelinemode)
@@ -1116,8 +1079,8 @@ dolinemode()
return 1;
}
- static int
-docharmode()
+static int
+docharmode(void)
{
#ifdef KLUDGELINEMODE
if (kludgelinemode)
@@ -1129,9 +1092,8 @@ docharmode()
return 1;
}
- static int
-dolmmode(bit, on)
- int bit, on;
+static int
+dolmmode(int bit, int on)
{
unsigned char c;
extern int linemode;
@@ -1150,39 +1112,37 @@ dolmmode(bit, on)
return 1;
}
- int
-setmod(bit)
+static int
+setmod(int bit)
{
return dolmmode(bit, 1);
}
- int
-clearmode(bit)
+static int
+clearmode(int bit)
{
return dolmmode(bit, 0);
}
struct modelist {
- char *name; /* command name */
- char *help; /* help string */
- int (*handler)(); /* routine which executes command */
+ const char *name; /* command name */
+ const char *help; /* help string */
+ int (*handler)(int);/* routine which executes command */
int needconnect; /* Do we need to be connected to execute? */
int arg1;
};
-extern int modehelp();
-
static struct modelist ModeList[] = {
- { "character", "Disable LINEMODE option", docharmode, 1 },
+ { "character", "Disable LINEMODE option", (int (*)(int))docharmode, 1, 0 },
#ifdef KLUDGELINEMODE
- { "", "(or disable obsolete line-by-line mode)", 0 },
+ { "", "(or disable obsolete line-by-line mode)", NULL, 0, 0 },
#endif
- { "line", "Enable LINEMODE option", dolinemode, 1 },
+ { "line", "Enable LINEMODE option", (int (*)(int))dolinemode, 1, 0 },
#ifdef KLUDGELINEMODE
- { "", "(or enable obsolete line-by-line mode)", 0 },
+ { "", "(or enable obsolete line-by-line mode)", NULL, 0, 0 },
#endif
- { "", "", 0 },
- { "", "These require the LINEMODE option to be enabled", 0 },
+ { "", "", NULL, 0, 0 },
+ { "", "These require the LINEMODE option to be enabled", NULL, 0, 0 },
{ "isig", "Enable signal trapping", setmod, 1, MODE_TRAPSIG },
{ "+isig", 0, setmod, 1, MODE_TRAPSIG },
{ "-isig", "Disable signal trapping", clearmode, 1, MODE_TRAPSIG },
@@ -1195,18 +1155,18 @@ static struct modelist ModeList[] = {
{ "litecho", "Enable literal character echo", setmod, 1, MODE_LIT_ECHO },
{ "+litecho", 0, setmod, 1, MODE_LIT_ECHO },
{ "-litecho", "Disable literal character echo", clearmode, 1, MODE_LIT_ECHO },
- { "help", 0, modehelp, 0 },
+ { "help", 0, (int (*)(int))modehelp, 0, 0 },
#ifdef KLUDGELINEMODE
- { "kludgeline", 0, dokludgemode, 1 },
+ { "kludgeline", 0, (int (*)(int))dokludgemode, 1, 0 },
#endif
- { "", "", 0 },
- { "?", "Print help information", modehelp, 0 },
- { 0 },
+ { "", "", NULL, 0, 0 },
+ { "?", "Print help information", (int (*)(int))modehelp, 0, 0 },
+ { NULL, NULL, NULL, 0, 0 },
};
- int
-modehelp()
+static int
+modehelp(void)
{
struct modelist *mt;
@@ -1225,10 +1185,8 @@ modehelp()
#define GETMODECMD(name) (struct modelist *) \
genget(name, (char **) ModeList, sizeof(struct modelist))
- static int
-modecmd(argc, argv)
- int argc;
- char *argv[];
+static int
+modecmd(int argc, char *argv[])
{
struct modelist *mt;
@@ -1237,7 +1195,7 @@ modecmd(argc, argv)
printf("'mode ?' for help.\n");
} else if ((mt = GETMODECMD(argv[1])) == 0) {
fprintf(stderr, "Unknown mode '%s' ('mode ?' for help).\n", argv[1]);
- } else if (Ambiguous(mt)) {
+ } else if (Ambiguous((void *)mt)) {
fprintf(stderr, "Ambiguous mode '%s' ('mode ?' for help).\n", argv[1]);
} else if (mt->needconnect && !connected) {
printf("?Need to be connected first.\n");
@@ -1253,10 +1211,8 @@ modecmd(argc, argv)
* "display" command.
*/
- static int
-display(argc, argv)
- int argc;
- char *argv[];
+static int
+display(int argc, char *argv[])
{
struct togglelist *tl;
struct setlist *sl;
@@ -1291,7 +1247,7 @@ display(argc, argv)
for (i = 1; i < argc; i++) {
sl = getset(argv[i]);
tl = GETTOGGLE(argv[i]);
- if (Ambiguous(sl) || Ambiguous(tl)) {
+ if (Ambiguous((void *)sl) || Ambiguous((void *)tl)) {
printf("?Ambiguous argument '%s'.\n", argv[i]);
return 0;
} else if (!sl && !tl) {
@@ -1324,12 +1280,10 @@ display(argc, argv)
/*
* Set the escape character.
*/
- static int
-setescape(argc, argv)
- int argc;
- char *argv[];
+static int
+setescape(int argc, char *argv[])
{
- register char *arg;
+ char *arg;
char buf[50];
printf(
@@ -1344,16 +1298,12 @@ setescape(argc, argv)
}
if (arg[0] != '\0')
escape = arg[0];
- if (!In3270) {
- printf("Escape character is '%s'.\n", control(escape));
- }
(void) fflush(stdout);
return 1;
}
- /*VARARGS*/
- static int
-togcrmod()
+static int
+togcrmod(void)
{
crmod = !crmod;
printf("Deprecated usage - please use 'toggle crmod' in the future.\n");
@@ -1362,16 +1312,15 @@ togcrmod()
return 1;
}
- /*VARARGS*/
- int
-suspend()
+static int
+suspend(void)
{
#ifdef SIGTSTP
setcommandmode();
{
- long oldrows, oldcols, newrows, newcols, err;
+ long oldrows, oldcols, newrows, newcols, err_;
- err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
+ err_ = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
(void) kill(0, SIGTSTP);
/*
* If we didn't get the window size before the SUSPEND, but we
@@ -1379,7 +1328,7 @@ suspend()
* we are set up for the right window size.
*/
if (TerminalWindowSize(&newrows, &newcols) && connected &&
- (err || ((oldrows != newrows) || (oldcols != newcols)))) {
+ (err_ || ((oldrows != newrows) || (oldcols != newcols)))) {
sendnaws();
}
}
@@ -1392,18 +1341,14 @@ suspend()
return 1;
}
-#if !defined(TN3270)
- /*ARGSUSED*/
- int
-shell(argc, argv)
- int argc;
- char *argv[];
+static int
+shell(int argc, char *argv[] __unused)
{
- long oldrows, oldcols, newrows, newcols, err;
+ long oldrows, oldcols, newrows, newcols, err_;
setcommandmode();
- err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
+ err_ = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
switch(vfork()) {
case -1:
perror("Fork failed\n");
@@ -1414,7 +1359,7 @@ shell(argc, argv)
/*
* Fire up the shell in the child.
*/
- register char *shellp, *shellname;
+ const char *shellp, *shellname;
shellp = getenv("SHELL");
if (shellp == NULL)
@@ -1434,22 +1379,16 @@ shell(argc, argv)
(void)wait((int *)0); /* Wait for the shell to complete */
if (TerminalWindowSize(&newrows, &newcols) && connected &&
- (err || ((oldrows != newrows) || (oldcols != newcols)))) {
+ (err_ || ((oldrows != newrows) || (oldcols != newcols)))) {
sendnaws();
}
break;
}
return 1;
}
-#else /* !defined(TN3270) */
-extern int shell();
-#endif /* !defined(TN3270) */
- /*VARARGS*/
- static int
-bye(argc, argv)
- int argc; /* Number of arguments */
- char *argv[]; /* arguments */
+static int
+bye(int argc, char *argv[])
{
extern int resettermname;
@@ -1459,14 +1398,13 @@ bye(argc, argv)
(void) NetClose(net);
connected = 0;
resettermname = 1;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
auth_encrypt_connect(connected);
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
+#endif
+#endif
/* reset options */
tninit();
-#if defined(TN3270)
- SetIn3270(); /* Get out of 3270 mode */
-#endif /* defined(TN3270) */
}
if ((argc != 2) || (strcmp(argv[1], "fromquit") != 0)) {
longjmp(toplevel, 1);
@@ -1475,18 +1413,15 @@ bye(argc, argv)
return 1; /* Keep lint, etc., happy */
}
-/*VARARGS*/
- int
-quit()
+void
+quit(void)
{
(void) call(bye, "bye", "fromquit", 0);
Exit(0);
- /*NOTREACHED*/
}
-/*VARARGS*/
- int
-logout()
+static int
+logout(void)
{
send_do(TELOPT_LOGOUT, 1);
(void) netflush();
@@ -1499,28 +1434,28 @@ logout()
*/
struct slclist {
- char *name;
- char *help;
- void (*handler)();
+ const char *name;
+ const char *help;
+ void (*handler)(int);
int arg;
};
-static void slc_help();
+static void slc_help(void);
struct slclist SlcList[] = {
{ "export", "Use local special character definitions",
- slc_mode_export, 0 },
+ (void (*)(int))slc_mode_export, 0 },
{ "import", "Use remote special character definitions",
slc_mode_import, 1 },
{ "check", "Verify remote special character definitions",
slc_mode_import, 0 },
- { "help", 0, slc_help, 0 },
- { "?", "Print help information", slc_help, 0 },
- { 0 },
+ { "help", NULL, (void (*)(int))slc_help, 0 },
+ { "?", "Print help information", (void (*)(int))slc_help, 0 },
+ { NULL, NULL, NULL, 0 },
};
- static void
-slc_help()
+static void
+slc_help(void)
{
struct slclist *c;
@@ -1534,18 +1469,15 @@ slc_help()
}
}
- static struct slclist *
-getslc(name)
- char *name;
+static struct slclist *
+getslc(char *name)
{
return (struct slclist *)
genget(name, (char **) SlcList, sizeof(struct slclist));
}
- static int
-slccmd(argc, argv)
- int argc;
- char *argv[];
+static int
+slccmd(int argc, char *argv[])
{
struct slclist *c;
@@ -1560,7 +1492,7 @@ slccmd(argc, argv)
argv[1]);
return 0;
}
- if (Ambiguous(c)) {
+ if (Ambiguous((void *)c)) {
fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n",
argv[1]);
return 0;
@@ -1575,18 +1507,18 @@ slccmd(argc, argv)
*/
struct envlist {
- char *name;
- char *help;
- void (*handler)();
+ const char *name;
+ const char *help;
+ void (*handler)(unsigned char *, unsigned char *);
int narg;
};
extern struct env_lst *
- env_define P((unsigned char *, unsigned char *));
+ env_define P((const unsigned char *, unsigned char *));
extern void
env_undefine P((unsigned char *)),
- env_export P((unsigned char *)),
- env_unexport P((unsigned char *)),
+ env_export P((const unsigned char *)),
+ env_unexport P((const unsigned char *)),
env_send P((unsigned char *)),
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
env_varval P((unsigned char *)),
@@ -1597,27 +1529,27 @@ static void
struct envlist EnvList[] = {
{ "define", "Define an environment variable",
- (void (*)())env_define, 2 },
+ (void (*)(unsigned char *, unsigned char *))env_define, 2 },
{ "undefine", "Undefine an environment variable",
- env_undefine, 1 },
+ (void (*)(unsigned char *, unsigned char *))env_undefine, 1 },
{ "export", "Mark an environment variable for automatic export",
- env_export, 1 },
+ (void (*)(unsigned char *, unsigned char *))env_export, 1 },
{ "unexport", "Don't mark an environment variable for automatic export",
- env_unexport, 1 },
- { "send", "Send an environment variable", env_send, 1 },
+ (void (*)(unsigned char *, unsigned char *))env_unexport, 1 },
+ { "send", "Send an environment variable", (void (*)(unsigned char *, unsigned char *))env_send, 1 },
{ "list", "List the current environment variables",
- env_list, 0 },
+ (void (*)(unsigned char *, unsigned char *))env_list, 0 },
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
{ "varval", "Reverse VAR and VALUE (auto, right, wrong, status)",
- env_varval, 1 },
+ (void (*)(unsigned char *, unsigned char *))env_varval, 1 },
#endif
- { "help", 0, env_help, 0 },
- { "?", "Print help information", env_help, 0 },
- { 0 },
+ { "help", NULL, (void (*)(unsigned char *, unsigned char *))env_help, 0 },
+ { "?", "Print help information", (void (*)(unsigned char *, unsigned char *))env_help, 0 },
+ { NULL, NULL, NULL, 0 },
};
- static void
-env_help()
+static void
+env_help(void)
{
struct envlist *c;
@@ -1631,18 +1563,15 @@ env_help()
}
}
- static struct envlist *
-getenvcmd(name)
- char *name;
+static struct envlist *
+getenvcmd(char *name)
{
return (struct envlist *)
genget(name, (char **) EnvList, sizeof(struct envlist));
}
- int
-env_cmd(argc, argv)
- int argc;
- char *argv[];
+static int
+env_cmd(int argc, char *argv[])
{
struct envlist *c;
@@ -1657,7 +1586,7 @@ env_cmd(argc, argv)
argv[1]);
return 0;
}
- if (Ambiguous(c)) {
+ if (Ambiguous((void *)c)) {
fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n",
argv[1]);
return 0;
@@ -1684,25 +1613,24 @@ struct env_lst {
struct env_lst envlisthead;
- struct env_lst *
-env_find(var)
- unsigned char *var;
+static struct env_lst *
+env_find(const unsigned char *var)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
for (ep = envlisthead.next; ep; ep = ep->next) {
- if (strcmp((char *)ep->var, (char *)var) == 0)
+ if (strcmp(ep->var, var) == 0)
return(ep);
}
return(NULL);
}
- void
-env_init()
+void
+env_init(void)
{
extern char **environ;
- register char **epp, *cp;
- register struct env_lst *ep;
+ char **epp, *cp;
+ struct env_lst *ep;
for (epp = environ; *epp; epp++) {
if ((cp = strchr(*epp, '='))) {
@@ -1737,18 +1665,17 @@ env_init()
* don't export the USER variable.
*/
if ((env_find("USER") == NULL) && (ep = env_find("LOGNAME"))) {
- env_define((unsigned char *)"USER", ep->value);
- env_unexport((unsigned char *)"USER");
+ env_define("USER", ep->value);
+ env_unexport("USER");
}
- env_export((unsigned char *)"DISPLAY");
- env_export((unsigned char *)"PRINTER");
+ env_export("DISPLAY");
+ env_export("PRINTER");
}
- struct env_lst *
-env_define(var, value)
- unsigned char *var, *value;
+struct env_lst *
+env_define(const unsigned char *var, unsigned char *value)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
if ((ep = env_find(var))) {
if (ep->var)
@@ -1765,16 +1692,15 @@ env_define(var, value)
}
ep->welldefined = opt_welldefined(var);
ep->export = 1;
- ep->var = (unsigned char *)strdup((char *)var);
- ep->value = (unsigned char *)strdup((char *)value);
+ ep->var = strdup(var);
+ ep->value = strdup(value);
return(ep);
}
- void
-env_undefine(var)
- unsigned char *var;
+void
+env_undefine(unsigned char *var)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
if ((ep = env_find(var))) {
ep->prev->next = ep->next;
@@ -1788,31 +1714,28 @@ env_undefine(var)
}
}
- void
-env_export(var)
- unsigned char *var;
+void
+env_export(const unsigned char *var)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
if ((ep = env_find(var)))
ep->export = 1;
}
- void
-env_unexport(var)
- unsigned char *var;
+void
+env_unexport(const unsigned char *var)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
if ((ep = env_find(var)))
ep->export = 0;
}
- void
-env_send(var)
- unsigned char *var;
+void
+env_send(unsigned char *var)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
if (my_state_is_wont(TELOPT_NEW_ENVIRON)
#ifdef OLD_ENVIRON
@@ -1835,10 +1758,10 @@ env_send(var)
env_opt_end(0);
}
- void
-env_list()
+void
+env_list(void)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
for (ep = envlisthead.next; ep; ep = ep->next) {
printf("%c %-20s %s\n", ep->export ? '*' : ' ',
@@ -1846,9 +1769,8 @@ env_list()
}
}
- unsigned char *
-env_default(init, welldefined)
- int init;
+unsigned char *
+env_default(int init, int welldefined)
{
static struct env_lst *nep = NULL;
@@ -1865,11 +1787,10 @@ env_default(init, welldefined)
return(NULL);
}
- unsigned char *
-env_getvalue(var)
- unsigned char *var;
+unsigned char *
+env_getvalue(const unsigned char *var)
{
- register struct env_lst *ep;
+ struct env_lst *ep;
if ((ep = env_find(var)))
return(ep->value);
@@ -1877,9 +1798,8 @@ env_getvalue(var)
}
#if defined(OLD_ENVIRON) && defined(ENV_HACK)
- void
-env_varval(what)
- unsigned char *what;
+void
+env_varval(unsigned char *what)
{
extern int old_env_var, old_env_value, env_auto;
int len = strlen((char *)what);
@@ -1914,15 +1834,15 @@ unknown:
}
#endif
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
/*
* The AUTHENTICATE command.
*/
struct authlist {
- char *name;
- char *help;
- int (*handler)();
+ const char *name;
+ const char *help;
+ int (*handler)(char *);
int narg;
};
@@ -1935,18 +1855,18 @@ static int
struct authlist AuthList[] = {
{ "status", "Display current status of authentication information",
- auth_status, 0 },
+ (int (*)(char *))auth_status, 0 },
{ "disable", "Disable an authentication type ('auth disable ?' for more)",
auth_disable, 1 },
{ "enable", "Enable an authentication type ('auth enable ?' for more)",
auth_enable, 1 },
- { "help", 0, auth_help, 0 },
- { "?", "Print help information", auth_help, 0 },
- { 0 },
+ { "help", NULL, (int (*)(char *))auth_help, 0 },
+ { "?", "Print help information", (int (*)(char *))auth_help, 0 },
+ { NULL, NULL, NULL, 0 },
};
- static int
-auth_help()
+static int
+auth_help(void)
{
struct authlist *c;
@@ -1961,10 +1881,8 @@ auth_help()
return 0;
}
- int
-auth_cmd(argc, argv)
- int argc;
- char *argv[];
+int
+auth_cmd(int argc, char *argv[])
{
struct authlist *c;
@@ -1981,7 +1899,7 @@ auth_cmd(argc, argv)
argv[1]);
return 0;
}
- if (Ambiguous(c)) {
+ if (Ambiguous((void *)c)) {
fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n",
argv[1]);
return 0;
@@ -1993,7 +1911,7 @@ auth_cmd(argc, argv)
c->narg, c->narg == 1 ? "" : "s", c->name);
return 0;
}
- return((*c->handler)(argv[2], argv[3]));
+ return((*c->handler)(argv[2]));
}
#endif
@@ -2003,9 +1921,9 @@ auth_cmd(argc, argv)
*/
struct encryptlist {
- char *name;
- char *help;
- int (*handler)();
+ const char *name;
+ const char *help;
+ int (*handler)(char *, char *);
int needconnect;
int minarg;
int maxarg;
@@ -2033,27 +1951,27 @@ struct encryptlist EncryptList[] = {
{ "type", "Set encryption type. ('encrypt type ?' for more)",
EncryptType, 0, 1, 1 },
{ "start", "Start encryption. ('encrypt start ?' for more)",
- EncryptStart, 1, 0, 1 },
+ (int (*)(char *, char *))EncryptStart, 1, 0, 1 },
{ "stop", "Stop encryption. ('encrypt stop ?' for more)",
- EncryptStop, 1, 0, 1 },
+ (int (*)(char *, char *))EncryptStop, 1, 0, 1 },
{ "input", "Start encrypting the input stream",
- EncryptStartInput, 1, 0, 0 },
+ (int (*)(char *, char *))EncryptStartInput, 1, 0, 0 },
{ "-input", "Stop encrypting the input stream",
- EncryptStopInput, 1, 0, 0 },
+ (int (*)(char *, char *))EncryptStopInput, 1, 0, 0 },
{ "output", "Start encrypting the output stream",
- EncryptStartOutput, 1, 0, 0 },
+ (int (*)(char *, char *))EncryptStartOutput, 1, 0, 0 },
{ "-output", "Stop encrypting the output stream",
- EncryptStopOutput, 1, 0, 0 },
+ (int (*)(char *, char *))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 },
+ (int (*)(char *, char *))EncryptStatus, 0, 0, 0 },
+ { "help", NULL, (int (*)(char *, char *))EncryptHelp, 0, 0, 0 },
+ { "?", "Print help information", (int (*)(char *, char *))EncryptHelp, 0, 0, 0 },
+ { NULL, NULL, NULL, 0, 0, 0 },
};
- static int
-EncryptHelp()
+static int
+EncryptHelp(void)
{
struct encryptlist *c;
@@ -2068,10 +1986,8 @@ EncryptHelp()
return 0;
}
- int
-encrypt_cmd(argc, argv)
- int argc;
- char *argv[];
+static int
+encrypt_cmd(int argc, char *argv[])
{
struct encryptlist *c;
@@ -2088,7 +2004,7 @@ encrypt_cmd(argc, argv)
argv[1]);
return 0;
}
- if (Ambiguous(c)) {
+ if (Ambiguous((void *)c)) {
fprintf(stderr, "'%s': ambiguous argument ('encrypt ?' for help).\n",
argv[1]);
return 0;
@@ -2114,52 +2030,16 @@ encrypt_cmd(argc, argv)
}
}
return ((*c->handler)(argc > 0 ? argv[2] : 0,
- argc > 1 ? argv[3] : 0,
- argc > 2 ? argv[4] : 0));
+ argc > 1 ? argv[3] : 0));
}
#endif /* ENCRYPTION */
-#if defined(unix) && defined(TN3270)
- static void
-filestuff(fd)
- int fd;
-{
- int res;
-
-#ifdef F_GETOWN
- setconnmode(0);
- res = fcntl(fd, F_GETOWN, 0);
- setcommandmode();
-
- if (res == -1) {
- perror("fcntl");
- return;
- }
- printf("\tOwner is %d.\n", res);
-#endif
-
- setconnmode(0);
- res = fcntl(fd, F_GETFL, 0);
- setcommandmode();
-
- if (res == -1) {
- perror("fcntl");
- return;
- }
-#ifdef notdef
- printf("\tFlags are 0x%x: %s\n", res, decodeflags(res));
-#endif
-}
-#endif /* defined(unix) && defined(TN3270) */
-
/*
* Print status about the connection.
*/
- /*ARGSUSED*/
- static int
-status(argc, argv)
- int argc;
- char *argv[];
+/*ARGSUSED*/
+static int
+status(int argc, char *argv[])
{
if (connected) {
printf("Connected to %s.\n", hostname);
@@ -2191,37 +2071,8 @@ status(argc, argv)
} else {
printf("No connection.\n");
}
-# if !defined(TN3270)
printf("Escape character is '%s'.\n", control(escape));
(void) fflush(stdout);
-# else /* !defined(TN3270) */
- if ((!In3270) && ((argc < 2) || strcmp(argv[1], "notmuch"))) {
- printf("Escape character is '%s'.\n", control(escape));
- }
-# if defined(unix)
- if ((argc >= 2) && !strcmp(argv[1], "everything")) {
- printf("SIGIO received %d time%s.\n",
- sigiocount, (sigiocount == 1)? "":"s");
- if (In3270) {
- printf("Process ID %d, process group %d.\n",
- getpid(), getpgrp(getpid()));
- printf("Terminal input:\n");
- filestuff(tin);
- printf("Terminal output:\n");
- filestuff(tout);
- printf("Network socket:\n");
- filestuff(net);
- }
- }
- if (In3270 && transcom) {
- printf("Transparent mode command is '%s'.\n", transcom);
- }
-# endif /* defined(unix) */
- (void) fflush(stdout);
- if (In3270) {
- return 0;
- }
-# endif /* defined(TN3270) */
return 1;
}
@@ -2229,16 +2080,15 @@ status(argc, argv)
/*
* Function that gets called when SIGINFO is received.
*/
- void
-ayt_status()
+void
+ayt_status(void)
{
(void) call(status, "status", "notmuch", 0);
}
#endif
static const char *
-sockaddr_ntop(sa)
- struct sockaddr *sa;
+sockaddr_ntop(struct sockaddr *sa)
{
void *addr;
static char addrbuf[INET6_ADDRSTRLEN];
@@ -2264,10 +2114,7 @@ sockaddr_ntop(sa)
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
static int
-setpolicy(net, res, policy)
- int net;
- struct addrinfo *res;
- char *policy;
+setpolicy(int lnet, struct addrinfo *res, char *policy)
{
char *buf;
int level;
@@ -2283,12 +2130,13 @@ setpolicy(net, res, policy)
}
level = res->ai_family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6;
optname = res->ai_family == AF_INET ? IP_IPSEC_POLICY : IPV6_IPSEC_POLICY;
- if (setsockopt(net, level, optname, buf, ipsec_get_policylen(buf)) < 0){
+ if (setsockopt(lnet, level, optname, buf, ipsec_get_policylen(buf)) < 0){
perror("setsockopt");
return -1;
}
free(buf);
+ return 0;
}
#endif
@@ -2299,8 +2147,7 @@ setpolicy(net, res, policy)
* Return 1, if retry with another af is OK. Else, return 0.
*/
static int
-switch_af(aip)
- struct addrinfo **aip;
+switch_af(struct addrinfo **aip)
{
int nextaf;
struct addrinfo *ai;
@@ -2318,14 +2165,12 @@ switch_af(aip)
}
#endif
- int
-tn(argc, argv)
- int argc;
- char *argv[];
+int
+tn(int argc, char *argv[])
{
char *srp = 0;
int proto, opt;
- int sourceroute(), srlen;
+ int srlen;
int srcroute = 0, result;
char *cmd, *hostp = 0, *portp = 0, *user = 0;
char *src_addr = NULL;
@@ -2419,7 +2264,7 @@ tn(argc, argv)
memset(&su, 0, sizeof su);
su.sun_family = AF_UNIX;
strncpy(su.sun_path, hostp, sizeof su.sun_path);
- printf("Trying %s...\n", &su.sun_path);
+ printf("Trying %s...\n", hostp);
net = socket(PF_UNIX, SOCK_STREAM, 0);
if ( net < 0) {
perror("socket");
@@ -2444,7 +2289,7 @@ tn(argc, argv)
hostname = hostp;
if (!portp) {
telnetport = 1;
- portp = "telnet";
+ portp = strdup("telnet");
} else if (*portp == '-') {
portp++;
telnetport = 1;
@@ -2606,9 +2451,11 @@ tn(argc, argv)
goto fail;
}
connected++;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
auth_encrypt_connect(connected);
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
+#endif
+#endif
} while (connected == 0);
freeaddrinfo(res0);
if (src_res0 != NULL)
@@ -2628,8 +2475,8 @@ tn(argc, argv)
}
}
if (user) {
- env_define((unsigned char *)"USER", (unsigned char *)user);
- env_export((unsigned char *)"USER");
+ env_define("USER", user);
+ env_export("USER");
}
(void) call(status, "status", "notmuch", 0);
if (setjmp(peerdied) == 0)
@@ -2660,19 +2507,14 @@ static char
togglestring[] ="toggle operating parameters ('toggle ?' for more)",
slchelp[] = "change state of special charaters ('slc ?' for more)",
displayhelp[] = "display operating parameters",
-#if defined(TN3270) && defined(unix)
- transcomhelp[] = "specify Unix command for transparent mode pipe",
-#endif /* defined(TN3270) && defined(unix) */
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
authhelp[] = "turn on (off) authentication ('auth ?' for more)",
#endif
#ifdef ENCRYPTION
encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)",
#endif /* ENCRYPTION */
-#if defined(unix)
zhelp[] = "suspend telnet",
-#endif /* defined(unix) */
-#if defined(OPIE)
+#ifdef OPIE
opiehelp[] = "compute response to OPIE challenge",
#endif
shellhelp[] = "invoke a subshell",
@@ -2681,41 +2523,32 @@ static char
static Command cmdtab[] = {
{ "close", closehelp, bye, 1 },
- { "logout", logouthelp, logout, 1 },
+ { "logout", logouthelp, (int (*)(int, char **))logout, 1 },
{ "display", displayhelp, display, 0 },
{ "mode", modestring, modecmd, 0 },
{ "telnet", openhelp, tn, 0 },
{ "open", openhelp, tn, 0 },
- { "quit", quithelp, quit, 0 },
+ { "quit", quithelp, (int (*)(int, char **))quit, 0 },
{ "send", sendhelp, sendcmd, 0 },
{ "set", sethelp, setcmd, 0 },
{ "unset", unsethelp, unsetcmd, 0 },
{ "status", statushelp, status, 0 },
{ "toggle", togglestring, toggle, 0 },
{ "slc", slchelp, slccmd, 0 },
-#if defined(TN3270) && defined(unix)
- { "transcom", transcomhelp, settranscom, 0 },
-#endif /* defined(TN3270) && defined(unix) */
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
{ "auth", authhelp, auth_cmd, 0 },
#endif
#ifdef ENCRYPTION
{ "encrypt", encrypthelp, encrypt_cmd, 0 },
#endif /* ENCRYPTION */
-#if defined(unix)
- { "z", zhelp, suspend, 0 },
-#endif /* defined(unix) */
-#if defined(TN3270)
+ { "z", zhelp, (int (*)(int, char **))suspend, 0 },
{ "!", shellhelp, shell, 1 },
-#else
- { "!", shellhelp, shell, 0 },
-#endif
{ "environ", envhelp, env_cmd, 0 },
{ "?", helphelp, help, 0 },
-#if defined(OPIE)
+#ifdef OPIE
{ "opie", opiehelp, opie_calc, 0 },
#endif
- { 0, 0, 0, 0 }
+ { NULL, NULL, NULL, 0 }
};
static char crmodhelp[] = "deprecated command -- use 'toggle crmod' instead";
@@ -2724,8 +2557,8 @@ static char escapehelp[] = "deprecated command -- use 'set escape' instead";
static Command cmdtab2[] = {
{ "help", 0, help, 0 },
{ "escape", escapehelp, setescape, 0 },
- { "crmod", crmodhelp, togcrmod, 0 },
- { 0, 0, 0, 0 }
+ { "crmod", crmodhelp, (int (*)(int, char **))togcrmod, 0 },
+ { NULL, NULL, NULL, 0 }
};
@@ -2733,30 +2566,22 @@ static Command cmdtab2[] = {
* Call routine with argc, argv set from args (terminated by 0).
*/
- /*VARARGS1*/
- static int
-call(va_alist)
- va_dcl
+static int
+call(intrtn_t routine, ...)
{
va_list ap;
- typedef int (*intrtn_t)();
- intrtn_t routine;
char *args[100];
int argno = 0;
- va_start(ap);
- routine = (va_arg(ap, intrtn_t));
- while ((args[argno++] = va_arg(ap, char *)) != 0) {
- ;
- }
+ va_start(ap, routine);
+ while ((args[argno++] = va_arg(ap, char *)) != 0);
va_end(ap);
return (*routine)(argno-1, args);
}
- static Command *
-getcmd(name)
- char *name;
+static Command *
+getcmd(char *name)
{
Command *cm;
@@ -2765,28 +2590,23 @@ getcmd(name)
return (Command *) genget(name, (char **) cmdtab2, sizeof(Command));
}
- void
-command(top, tbuf, cnt)
- int top;
- char *tbuf;
- int cnt;
+void
+command(int top, const char *tbuf, int cnt)
{
- register Command *c;
+ Command *c;
setcommandmode();
if (!top) {
putchar('\n');
-#if defined(unix)
} else {
(void) signal(SIGINT, SIG_DFL);
(void) signal(SIGQUIT, SIG_DFL);
-#endif /* defined(unix) */
}
for (;;) {
if (rlogin == _POSIX_VDISABLE)
printf("%s> ", prompt);
if (tbuf) {
- register char *cp;
+ char *cp;
cp = line;
while (cnt > 0 && (*cp++ = *tbuf++) != '\n')
cnt--;
@@ -2815,7 +2635,7 @@ command(top, tbuf, cnt)
break;
}
c = getcmd(margv[0]);
- if (Ambiguous(c)) {
+ if (Ambiguous((void *)c)) {
printf("?Ambiguous command\n");
continue;
}
@@ -2836,25 +2656,17 @@ command(top, tbuf, cnt)
longjmp(toplevel, 1);
/*NOTREACHED*/
}
-#if defined(TN3270)
- if (shell_active == 0) {
- setconnmode(0);
- }
-#else /* defined(TN3270) */
setconnmode(0);
-#endif /* defined(TN3270) */
}
}
/*
* Help command.
*/
- static int
-help(argc, argv)
- int argc;
- char *argv[];
+static int
+help(int argc, char *argv[])
{
- register Command *c;
+ Command *c;
if (argc == 1) {
printf("Commands may be abbreviated. Commands are:\n\n");
@@ -2866,10 +2678,10 @@ help(argc, argv)
return 0;
}
else while (--argc > 0) {
- register char *arg;
+ char *arg;
arg = *++argv;
c = getcmd(arg);
- if (Ambiguous(c))
+ if (Ambiguous((void *)c))
printf("?Ambiguous help command %s\n", arg);
else if (c == (Command *)0)
printf("?Invalid help command %s\n", arg);
@@ -2882,11 +2694,10 @@ help(argc, argv)
static char *rcname = 0;
static char rcbuf[128];
- void
-cmdrc(m1, m2)
- char *m1, *m2;
+void
+cmdrc(char *m1, char *m2)
{
- register Command *c;
+ Command *c;
FILE *rcfile;
int gotmachine = 0;
int l1 = strlen(m1);
@@ -2943,7 +2754,7 @@ cmdrc(m1, m2)
if (margv[0] == 0)
continue;
c = getcmd(margv[0]);
- if (Ambiguous(c)) {
+ if (Ambiguous((void *)c)) {
printf("?Ambiguous command: %s\n", margv[0]);
continue;
}
@@ -3020,27 +2831,17 @@ cmdrc(m1, m2)
* *optp: This will be filled in with appropriate option for
* setsockopt, as socket protocol family.
*/
-int
-sourceroute(ai, arg, cpp, lenp, protop, optp)
- struct addrinfo *ai;
- char *arg;
- char **cpp;
- int *lenp;
- int *protop;
- int *optp;
+static int
+sourceroute(struct addrinfo *ai, char *arg, char **cpp, int *lenp, int *protop, int *optp)
{
static char buf[1024 + ALIGNBYTES]; /*XXX*/
struct cmsghdr *cmsg;
-#ifdef sysV88
- static IOPTN ipopt;
-#endif
char *cp, *cp2, *lsrp, *ep;
- register int tmp;
- struct sockaddr_in *sin;
+ struct sockaddr_in *_sin;
struct sockaddr_in6 *sin6;
struct addrinfo hints, *res;
int error;
- register char c;
+ char c;
/*
* Verify the arguments, and make sure we have
@@ -3056,7 +2857,7 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
break;
#ifdef INET6
case AF_INET6:
- if (*lenp < CMSG_SPACE(sizeof(struct ip6_rthdr) +
+ if (*lenp < (int)CMSG_SPACE(sizeof(struct ip6_rthdr) +
sizeof(struct in6_addr)))
return -1;
break;
@@ -3092,27 +2893,17 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
* 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 -1;
-#ifndef sysV88
lsrp++; /* skip over length, we'll fill it in later */
*lsrp++ = 4;
-#endif
*protop = IPPROTO_IP;
*optp = IP_OPTIONS;
}
@@ -3170,8 +2961,8 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
} else
#endif
{
- sin = (struct sockaddr_in *)res->ai_addr;
- memcpy(lsrp, (char *)&sin->sin_addr, 4);
+ _sin = (struct sockaddr_in *)res->ai_addr;
+ memcpy(lsrp, (char *)&_sin->sin_addr, 4);
lsrp += 4;
}
if (cp2)
@@ -3201,7 +2992,6 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
} else
#endif
{
-#ifndef sysV88
if ((*(*cpp+IPOPT_OLEN) = lsrp - *cpp) <= 7) {
*cpp = 0;
*lenp = 0;
@@ -3209,16 +2999,6 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
}
*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 -1;
- }
- *lenp = sizeof(ipopt);
- *cpp = (char *) &ipopt;
-#endif
}
freeaddrinfo(res);
return 1;
diff --git a/crypto/telnet/telnet/defines.h b/crypto/telnet/telnet/defines.h
index 0978173..840666d 100644
--- a/crypto/telnet/telnet/defines.h
+++ b/crypto/telnet/telnet/defines.h
@@ -31,16 +31,11 @@
* SUCH DAMAGE.
*
* @(#)defines.h 8.1 (Berkeley) 6/6/93
+ * $FreeBSD$
*/
#define settimer(x) clocks.x = clocks.system++
-#if !defined(TN3270)
-
-#define SetIn3270()
-
-#endif /* !defined(TN3270) */
-
#define NETADD(c) { *netoring.supply = c; ring_supplied(&netoring, 1); }
#define NET2ADD(c1,c2) { NETADD(c1); NETADD(c2); }
#define NETBYTES() (ring_full_count(&netoring))
diff --git a/crypto/telnet/telnet/externs.h b/crypto/telnet/telnet/externs.h
index e117dd2..c8ea02c 100644
--- a/crypto/telnet/telnet/externs.h
+++ b/crypto/telnet/telnet/externs.h
@@ -53,21 +53,13 @@
#include <stdio.h>
#include <setjmp.h>
-#ifndef FILIO_H
#include <sys/ioctl.h>
-#else
-#include <sys/filio.h>
-#endif
-# include <errno.h>
+#include <errno.h>
#ifdef USE_TERMIO
# ifndef VINTR
-# ifdef SYSV_TERMIO
-# include <sys/termio.h>
-# else
-# include <sys/termios.h>
-# define termio termios
-# endif
+# include <sys/termios.h>
# endif
+# define termio termios
#endif
#if defined(NO_CC_T) || !defined(USE_TERMIO)
# if !defined(USE_TERMIO)
@@ -77,11 +69,7 @@ typedef unsigned char cc_t;
# endif
#endif
-#ifndef NO_STRING_H
#include <string.h>
-#else
-#include <strings.h>
-#endif
#if defined(IPSEC)
#include <netinet6/ipsec.h>
@@ -120,7 +108,6 @@ 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? */
telnetport, /* Are we connected to the telnet port? */
localflow, /* Flow control handled locally */
restartany, /* If flow control, restart output on any character */
@@ -139,13 +126,7 @@ extern int
crmod,
netdata, /* Print out network data flow */
prettydump, /* Print "netdata" output in user readable format */
-#if defined(unix)
-#if defined(TN3270)
- cursesdata, /* Print out curses data flow */
- apitrace, /* Trace API transactions */
-#endif /* defined(TN3270) */
termdata, /* Print out terminal data flow */
-#endif /* defined(unix) */
debug, /* Debug level */
doaddrlookup, /* do a reverse lookup? */
clienteof; /* Client received EOF */
@@ -233,6 +214,16 @@ extern int (*decrypt_input) P((int));
#define set_his_want_state_dont set_my_want_state_wont
#define set_his_want_state_wont set_my_want_state_dont
+#if defined(USE_TERMIO)
+#define SIG_FUNC_RET void
+#else
+#define SIG_FUNC_RET int
+#endif
+
+#ifdef SIGINFO
+extern SIG_FUNC_RET
+ ayt_status P((void));
+#endif
extern FILE
*NetTrace; /* Where debugging output goes */
@@ -246,23 +237,40 @@ extern jmp_buf
toplevel; /* For error conditions. */
extern void
- command P((int, char *, int)),
- Dump P((int, unsigned char *, int)),
- ExitString P((char *, int)),
- init_3270 P((void)),
- printoption P((char *, int, int)),
- printsub P((int, unsigned char *, int)),
+ command P((int, const char *, int)),
+ Dump P((char, unsigned char *, int)),
+ env_init P((void)),
+ Exit P((int)),
+ ExitString P((const char *, int)),
+ init_network P((void)),
+ init_sys P((void)),
+ init_telnet P((void)),
+ init_terminal P((void)),
+ intp P((void)),
+ optionstatus P((void)),
+ printoption P((const char *, int, int)),
+ printsub P((char, unsigned char *, int)),
+ quit P((void)),
+ sendabort P((void)),
+ sendbrk P((void)),
+ sendeof P((void)),
+ sendsusp P((void)),
sendnaws P((void)),
+ sendayt P((void)),
setconnmode P((int)),
setcommandmode P((void)),
+ set_escape_char P((char *s)),
setneturg P((void)),
sys_telnet_init P((void)),
telnet P((char *)),
tel_enter_binary P((int)),
+ tel_leave_binary P((int)),
TerminalFlushOutput P((void)),
TerminalNewMode P((int)),
TerminalRestoreState P((void)),
TerminalSaveState P((void)),
+ TerminalDefaultChars P((void)),
+ TerminalSpeeds P((long *, long *)),
tninit P((void)),
upcase P((char *)),
willoption P((int)),
@@ -291,16 +299,25 @@ extern void
slc P((unsigned char *, int)),
slc_check P((void)),
slc_start_reply P((void)),
- slc_add_reply P((int, int, int)),
+ slc_add_reply P((unsigned char, unsigned char, cc_t)),
slc_end_reply P((void));
extern int
+ getconnmode P((void)),
+ opt_welldefined P((const char *)),
NetClose P((int)),
netflush P((void)),
+ process_rings P((int, int, int, int, int, int)),
+ rlogin_susp P((void)),
SetSockOpt P((int, int, int, int)),
slc_update P((void)),
+ stilloob P((void)),
telrcv P((void)),
+ TerminalRead P((char *, int)),
TerminalWrite P((char *, int)),
TerminalAutoFlush P((void)),
+ TerminalWindowSize P((long *, long *)),
+ TerminalSpecialChars P((int)),
+ tn P((int, char **)),
ttyflush P((int));
extern void
@@ -312,11 +329,11 @@ extern void
extern unsigned char
*env_default P((int, int)),
- *env_getvalue P((unsigned char *));
+ *env_getvalue P((const unsigned char *));
extern int
- get_status P((void)),
- dosynch P((void));
+ get_status P((char *)),
+ dosynch P((char *));
extern cc_t
*tcval P((int));
@@ -468,26 +485,7 @@ extern Ring
ttyoring,
ttyiring;
-/* Tn3270 section */
-#if defined(TN3270)
-
-extern int
- HaveInput, /* Whether an asynchronous I/O indication came in */
- noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
- noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
- sigiocount, /* Count of SIGIO receptions */
- shell_active; /* Subshell is active */
-
-extern char
- *Ibackp, /* Oldest byte of 3270 data */
- Ibuf[], /* 3270 buffer */
- *Ifrontp, /* Where next 3270 byte goes */
- tline[],
- *transcom; /* Transparent command */
-
-extern int
- settranscom P((int, char**));
-
extern void
- inputAvailable P((int));
-#endif /* defined(TN3270) */
+ xmitAO P((void)),
+ xmitEC P((void)),
+ xmitEL P((void));
diff --git a/crypto/telnet/telnet/main.c b/crypto/telnet/telnet/main.c
index b9f9c93..af58d32 100644
--- a/crypto/telnet/telnet/main.c
+++ b/crypto/telnet/telnet/main.c
@@ -29,19 +29,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
#ifndef lint
static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
+#endif
#include <sys/types.h>
#include <sys/socket.h>
@@ -53,10 +49,10 @@ static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
#include "externs.h"
#include "defines.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -69,12 +65,6 @@ static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
#define FORWARD
#endif
-void init_terminal(void);
-void init_network(void);
-void init_telnet(void);
-void init_sys(void);
-void init_3270(void);
-
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
char *ipsec_policy_in = NULL;
char *ipsec_policy_out = NULL;
@@ -85,8 +75,8 @@ int family = AF_UNSPEC;
/*
* Initialize variables.
*/
- void
-tninit()
+void
+tninit(void)
{
init_terminal();
@@ -95,14 +85,10 @@ tninit()
init_telnet();
init_sys();
-
-#if defined(TN3270)
- init_3270();
-#endif
}
- void
-usage()
+static void
+usage(void)
{
fprintf(stderr, "Usage: %s %s%s%s%s\n",
prompt,
@@ -113,12 +99,7 @@ usage()
"[-4] [-6] [-8] [-E] [-L] [-N] [-S tos] [-c] [-d]",
"\n\t[-e char] [-l user] [-n tracefile] ",
#endif
-#if defined(TN3270) && defined(unix)
- "[-noasynch] [-noasynctty] [-noasyncnet] [-r]\n\t"
- "[-s src_addr] [-t transcom] ",
-#else
"[-r] [-s src_addr] [-u] ",
-#endif
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
"[-P policy] "
#endif
@@ -135,10 +116,8 @@ usage()
* main. Parse arguments, invoke the protocol or command parser.
*/
- int
-main(argc, argv)
- int argc;
- char *argv[];
+int
+main(int argc, char *argv[])
{
int ch;
char *user;
@@ -165,7 +144,7 @@ main(argc, argv)
autologin = -1;
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
encrypt_auto(1);
decrypt_auto(1);
#endif
@@ -244,7 +223,8 @@ main(argc, argv)
set_escape_char(optarg);
break;
case 'f':
-#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
+#ifdef AUTHENTICATION
+#if defined(KRB5) && defined(FORWARD)
if (forward_flags & OPTS_FORWARD_CREDS) {
fprintf(stderr,
"%s: Only one of -f and -F allowed.\n",
@@ -257,9 +237,15 @@ main(argc, argv)
"%s: Warning: -f ignored, no Kerberos V5 support.\n",
prompt);
#endif
+#else
+ fprintf(stderr,
+ "%s: Warning: -f ignored, no Kerberos V5 support.\n",
+ prompt);
+#endif
break;
case 'F':
-#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
+#ifdef AUTHENTICATION
+#if defined(KRB5) && defined(FORWARD)
if (forward_flags & OPTS_FORWARD_CREDS) {
fprintf(stderr,
"%s: Only one of -f and -F allowed.\n",
@@ -273,9 +259,15 @@ main(argc, argv)
"%s: Warning: -F ignored, no Kerberos V5 support.\n",
prompt);
#endif
+#else
+ fprintf(stderr,
+ "%s: Warning: -F ignored, no Kerberos V5 support.\n",
+ prompt);
+#endif
break;
case 'k':
-#if defined(AUTHENTICATION) && defined(KRB4)
+#ifdef AUTHENTICATION
+#if defined(KRB4)
{
extern char *dest_realm, dst_realm_buf[], dst_realm_sz;
dest_realm = dst_realm_buf;
@@ -286,6 +278,11 @@ main(argc, argv)
"%s: Warning: -k ignored, no Kerberos V4 support.\n",
prompt);
#endif
+#else
+ fprintf(stderr,
+ "%s: Warning: -k ignored, no Kerberos V4 support.\n",
+ prompt);
+#endif
break;
case 'l':
#ifdef AUTHENTICATION
@@ -296,19 +293,6 @@ main(argc, argv)
user = optarg;
break;
case 'n':
-#if defined(TN3270) && defined(unix)
- /* distinguish between "-n oasynch" and "-noasynch" */
- if (argv[optind - 1][0] == '-' && argv[optind - 1][1]
- == 'n' && argv[optind - 1][2] == 'o') {
- if (!strcmp(optarg, "oasynch")) {
- noasynchtty = 1;
- noasynchnet = 1;
- } else if (!strcmp(optarg, "oasynchtty"))
- noasynchtty = 1;
- else if (!strcmp(optarg, "oasynchnet"))
- noasynchnet = 1;
- } else
-#endif /* defined(TN3270) && defined(unix) */
SetNetTrace(optarg);
break;
case 'r':
@@ -317,23 +301,11 @@ main(argc, argv)
case 's':
src_addr = optarg;
break;
- case 't':
-#if defined(TN3270) && defined(unix)
- transcom = tline;
- (void)strcpy(transcom, optarg);
-#else
- fprintf(stderr,
- "%s: Warning: -t ignored, no TN3270 support.\n",
- prompt);
-#endif
- break;
case 'u':
family = AF_UNIX;
break;
case 'x':
-#ifdef ENCRYPTION
- /* This is the default now, so ignore it */
-#else
+#ifndef ENCRYPTION
fprintf(stderr,
"%s: Warning: -x ignored, no ENCRYPT support.\n",
prompt);
@@ -378,11 +350,11 @@ main(argc, argv)
usage();
*argp++ = prompt;
if (user) {
- *argp++ = "-l";
+ *argp++ = strdup("-l");
*argp++ = user;
}
if (src_addr) {
- *argp++ = "-s";
+ *argp++ = strdup("-s");
*argp++ = src_addr;
}
*argp++ = argv[0]; /* host */
@@ -399,11 +371,6 @@ main(argc, argv)
}
(void)setjmp(toplevel);
for (;;) {
-#ifdef TN3270
- if (shell_active)
- shell_continue();
- else
-#endif
command(1, 0, 0);
}
return 0;
diff --git a/crypto/telnet/telnet/network.c b/crypto/telnet/telnet/network.c
index 17fff47..049f54f 100644
--- a/crypto/telnet/telnet/network.c
+++ b/crypto/telnet/telnet/network.c
@@ -31,14 +31,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
#include <sys/types.h>
#include <sys/socket.h>
@@ -62,8 +61,8 @@ unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ];
* Initialize internal network data structures.
*/
- void
-init_network()
+void
+init_network(void)
{
if (ring_init(&netoring, netobuf, sizeof netobuf) != 1) {
exit(1);
@@ -80,10 +79,10 @@ init_network()
* Telnet "synch" processing).
*/
- int
-stilloob()
+int
+stilloob(void)
{
- static struct timeval timeout = { 0 };
+ static struct timeval timeout = { 0, 0 };
fd_set excepts;
int value;
@@ -112,8 +111,8 @@ stilloob()
* Sets "neturg" to the current location.
*/
- void
-setneturg()
+void
+setneturg(void)
{
ring_mark(&netoring);
}
@@ -128,11 +127,10 @@ setneturg()
* useful work.
*/
-
- int
-netflush()
+int
+netflush(void)
{
- register int n, n1;
+ int n, n1;
#ifdef ENCRYPTION
if (encrypt_output)
diff --git a/crypto/telnet/telnet/ring.c b/crypto/telnet/telnet/ring.c
index 065888b..8fd14a7 100644
--- a/crypto/telnet/telnet/ring.c
+++ b/crypto/telnet/telnet/ring.c
@@ -31,14 +31,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
/*
* This defines a structure for a ring buffer.
@@ -99,17 +98,10 @@ static u_long ring_clock = 0;
#define ring_full(d) (((d)->supply == (d)->consume) && \
((d)->supplytime > (d)->consumetime))
-
-
-
-
/* Buffer state transition routines */
- int
-ring_init(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
+int
+ring_init(Ring *ring, unsigned char *buffer, int count)
{
memset((char *)ring, 0, sizeof *ring);
@@ -132,9 +124,8 @@ ring_init(ring, buffer, count)
* Mark the most recently supplied byte.
*/
- void
-ring_mark(ring)
- Ring *ring;
+void
+ring_mark(Ring *ring)
{
ring->mark = ring_decrement(ring, ring->supply, 1);
}
@@ -143,9 +134,8 @@ ring_mark(ring)
* Is the ring pointing to the mark?
*/
- int
-ring_at_mark(ring)
- Ring *ring;
+int
+ring_at_mark(Ring *ring)
{
if (ring->mark == ring->consume) {
return 1;
@@ -158,9 +148,8 @@ ring_at_mark(ring)
* Clear any mark set on the ring.
*/
- void
-ring_clear_mark(ring)
- Ring *ring;
+void
+ring_clear_mark(Ring *ring)
{
ring->mark = 0;
}
@@ -168,10 +157,8 @@ ring_clear_mark(ring)
/*
* Add characters from current segment to ring buffer.
*/
- void
-ring_supplied(ring, count)
- Ring *ring;
- int count;
+void
+ring_supplied(Ring *ring, int count)
{
ring->supply = ring_increment(ring, ring->supply, count);
ring->supplytime = ++ring_clock;
@@ -180,10 +167,8 @@ ring_supplied(ring, count)
/*
* We have just consumed "c" bytes.
*/
- void
-ring_consumed(ring, count)
- Ring *ring;
- int count;
+void
+ring_consumed(Ring *ring, int count)
{
if (count == 0) /* don't update anything */
return;
@@ -217,9 +202,8 @@ ring_consumed(ring, count)
/* Number of bytes that may be supplied */
- int
-ring_empty_count(ring)
- Ring *ring;
+int
+ring_empty_count(Ring *ring)
{
if (ring_empty(ring)) { /* if empty */
return ring->size;
@@ -229,9 +213,8 @@ ring_empty_count(ring)
}
/* number of CONSECUTIVE bytes that may be supplied */
- int
-ring_empty_consecutive(ring)
- Ring *ring;
+int
+ring_empty_consecutive(Ring *ring)
{
if ((ring->consume < ring->supply) || ring_empty(ring)) {
/*
@@ -251,9 +234,8 @@ ring_empty_consecutive(ring)
* (but don't give more than enough to get to cross over set mark)
*/
- int
-ring_full_count(ring)
- Ring *ring;
+int
+ring_full_count(Ring *ring)
{
if ((ring->mark == 0) || (ring->mark == ring->consume)) {
if (ring_full(ring)) {
@@ -270,9 +252,8 @@ ring_full_count(ring)
* Return the number of CONSECUTIVE bytes available for consuming.
* However, don't return more than enough to cross over set mark.
*/
- int
-ring_full_consecutive(ring)
- Ring *ring;
+int
+ring_full_consecutive(Ring *ring)
{
if ((ring->mark == 0) || (ring->mark == ring->consume)) {
if ((ring->supply < ring->consume) || ring_full(ring)) {
@@ -292,11 +273,8 @@ ring_full_consecutive(ring)
/*
* Move data into the "supply" portion of of the ring buffer.
*/
- void
-ring_supply_data(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
+void
+ring_supply_data(Ring *ring, unsigned char *buffer, int count)
{
int i;
@@ -309,34 +287,9 @@ ring_supply_data(ring, buffer, count)
}
}
-#ifdef notdef
-
-/*
- * Move data from the "consume" portion of the ring buffer
- */
- void
-ring_consume_data(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
-{
- int i;
-
- while (count) {
- i = MIN(count, ring_full_consecutive(ring));
- memcpy(buffer, ring->consume, i);
- ring_consumed(ring, i);
- count -= i;
- buffer += i;
- }
-}
-#endif
-
#ifdef ENCRYPTION
- void
-ring_encrypt(ring, encryptor)
- Ring *ring;
- void (*encryptor)();
+void
+ring_encrypt(Ring *ring, void (*encryptor)(unsigned char *, int))
{
unsigned char *s, *c;
diff --git a/crypto/telnet/telnet/ring.h b/crypto/telnet/telnet/ring.h
index dc5cbc4..48606e5 100644
--- a/crypto/telnet/telnet/ring.h
+++ b/crypto/telnet/telnet/ring.h
@@ -90,6 +90,7 @@ extern void
/* Buffer state query routines */
extern int
+ ring_at_mark P((Ring *)),
ring_empty_count P((Ring *ring)),
ring_empty_consecutive P((Ring *ring)),
ring_full_count P((Ring *ring)),
@@ -97,10 +98,10 @@ extern int
#ifdef ENCRYPTION
extern void
- ring_encrypt P((Ring *ring, void (*func)())),
+ ring_encrypt P((Ring *ring, void (*func)(unsigned char *, int))),
ring_clearto P((Ring *ring));
#endif /* ENCRYPTION */
extern void
- ring_clear_mark P((Ring *)),
- ring_mark P((Ring *));
+ ring_clear_mark P((Ring *)),
+ ring_mark P((Ring *));
diff --git a/crypto/telnet/telnet/sys_bsd.c b/crypto/telnet/telnet/sys_bsd.c
index 7935821..bcb302c 100644
--- a/crypto/telnet/telnet/sys_bsd.c
+++ b/crypto/telnet/telnet/sys_bsd.c
@@ -31,48 +31,34 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
/*
* The following routines try to encapsulate what is system dependent
* (at least between 4.x and dos) which is used in telnet.c.
*/
-
-#include <fcntl.h>
#include <sys/types.h>
-#include <sys/time.h>
#include <sys/socket.h>
-#include <signal.h>
+#include <sys/time.h>
#include <errno.h>
-#include <arpa/telnet.h>
+#include <fcntl.h>
+#include <signal.h>
#include <unistd.h>
+#include <arpa/telnet.h>
#include "ring.h"
-
#include "fdset.h"
-
#include "defines.h"
#include "externs.h"
#include "types.h"
-#if defined(USE_TERMIO) && !defined(SYSV_TERMIO)
-#define SIG_FUNC_RET void
-#else
-#define SIG_FUNC_RET int
-#endif
-
-#ifdef SIGINFO
-extern SIG_FUNC_RET ayt_status();
-#endif
-
int
tout, /* Output file descriptor */
tin, /* Input file descriptor */
@@ -88,8 +74,7 @@ int olmode = 0;
# define old_tc ottyb
#else /* USE_TERMIO */
-struct termio old_tc = { 0 };
-extern struct termio new_tc;
+struct termio old_tc = { 0, 0, 0, 0, {}, 0, 0 };
# ifndef TCSANOW
# ifdef TCSETS
@@ -122,9 +107,21 @@ extern struct termio new_tc;
static fd_set ibits, obits, xbits;
+#ifdef SIGINT
+static SIG_FUNC_RET intr(int);
+#endif /* SIGINT */
+#ifdef SIGQUIT
+static SIG_FUNC_RET intr2(int);
+#endif /* SIGQUIT */
+#ifdef SIGTSTP
+static SIG_FUNC_RET susp(int);
+#endif /* SIGTSTP */
+#ifdef SIGINFO
+static SIG_FUNC_RET ayt(int);
+#endif
- void
-init_sys()
+void
+init_sys(void)
{
tout = fileno(stdout);
tin = fileno(stdin);
@@ -135,19 +132,14 @@ init_sys()
errno = 0;
}
-
- int
-TerminalWrite(buf, n)
- char *buf;
- int n;
+int
+TerminalWrite(char *buf, int n)
{
return write(tout, buf, n);
}
- int
-TerminalRead(buf, n)
- char *buf;
- int n;
+int
+TerminalRead(char *buf, int n)
{
return read(tin, buf, n);
}
@@ -156,8 +148,8 @@ TerminalRead(buf, n)
*
*/
- int
-TerminalAutoFlush()
+int
+TerminalAutoFlush(void)
{
#if defined(LNOFLSH)
int flush;
@@ -184,11 +176,8 @@ extern int kludgelinemode;
* 1 Do add this character
*/
-extern void xmitAO(), xmitEL(), xmitEC(), intp(), sendbrk();
-
- int
-TerminalSpecialChars(c)
- int c;
+int
+TerminalSpecialChars(int c)
{
if (c == termIntChar) {
intp();
@@ -230,8 +219,8 @@ TerminalSpecialChars(c)
* Flush output to the terminal
*/
- void
-TerminalFlushOutput()
+void
+TerminalFlushOutput(void)
{
#ifdef TIOCFLUSH
(void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0);
@@ -240,8 +229,8 @@ TerminalFlushOutput()
#endif
}
- void
-TerminalSaveState()
+void
+TerminalSaveState(void)
{
#ifndef USE_TERMIO
ioctl(0, TIOCGETP, (char *)&ottyb);
@@ -282,9 +271,8 @@ TerminalSaveState()
#endif /* USE_TERMIO */
}
- cc_t *
-tcval(func)
- register int func;
+cc_t *
+tcval(int func)
{
switch(func) {
case SLC_IP: return(&termIntChar);
@@ -325,8 +313,8 @@ tcval(func)
}
}
- void
-TerminalDefaultChars()
+void
+TerminalDefaultChars(void)
{
#ifndef USE_TERMIO
ntc = otc;
@@ -359,13 +347,6 @@ TerminalDefaultChars()
#endif /* USE_TERMIO */
}
-#ifdef notdef
-void
-TerminalRestoreState()
-{
-}
-#endif
-
/*
* TerminalNewMode - set up terminal to a specific mode.
* MODE_ECHO: do local terminal echo
@@ -388,10 +369,8 @@ TerminalRestoreState()
* local/no signal mapping
*/
-
- void
-TerminalNewMode(f)
- register int f;
+void
+TerminalNewMode(int f)
{
static int prevmode = 0;
#ifndef USE_TERMIO
@@ -466,10 +445,6 @@ TerminalNewMode(f)
#else
tmp_tc.c_lflag &= ~ECHO;
tmp_tc.c_oflag &= ~ONLCR;
-# ifdef notdef
- if (crlf)
- tmp_tc.c_iflag &= ~ICRNL;
-# endif
#endif
}
@@ -616,19 +591,6 @@ TerminalNewMode(f)
}
if (f != -1) {
-#ifdef SIGINT
- SIG_FUNC_RET intr();
-#endif /* SIGINT */
-#ifdef SIGQUIT
- SIG_FUNC_RET intr2();
-#endif /* SIGQUIT */
-#ifdef SIGTSTP
- SIG_FUNC_RET susp();
-#endif /* SIGTSTP */
-#ifdef SIGINFO
- SIG_FUNC_RET ayt();
-#endif
-
#ifdef SIGINT
(void) signal(SIGINT, intr);
#endif
@@ -681,9 +643,7 @@ TerminalNewMode(f)
#endif
} else {
#ifdef SIGINFO
- SIG_FUNC_RET ayt_status();
-
- (void) signal(SIGINFO, ayt_status);
+ (void) signal(SIGINFO, (void (*)(int))ayt_status);
#endif
#ifdef SIGINT
(void) signal(SIGINT, SIG_DFL);
@@ -718,17 +678,8 @@ TerminalNewMode(f)
tcsetattr(tin, TCSANOW, &tmp_tc);
#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) {
- ioctl(tin, FIOASYNC, (char *)&onoff);
- }
-#endif /* defined(TN3270) */
}
@@ -797,15 +748,13 @@ struct termspeeds {
};
#endif /* DECODE_BAUD */
- void
-TerminalSpeeds(ispeed, ospeed)
- long *ispeed;
- long *ospeed;
+void
+TerminalSpeeds(long *ispeed, long *ospeed)
{
#ifdef DECODE_BAUD
- register struct termspeeds *tp;
+ struct termspeeds *tp;
#endif /* DECODE_BAUD */
- register long in, out;
+ long in, out;
out = cfgetospeed(&old_tc);
in = cfgetispeed(&old_tc);
@@ -828,9 +777,8 @@ TerminalSpeeds(ispeed, ospeed)
#endif /* DECODE_BAUD */
}
- int
-TerminalWindowSize(rows, cols)
- long *rows, *cols;
+int
+TerminalWindowSize(long *rows, long *cols)
{
#ifdef TIOCGWINSZ
struct winsize ws;
@@ -844,59 +792,34 @@ TerminalWindowSize(rows, cols)
return 0;
}
- int
-NetClose(fd)
- int fd;
+int
+NetClose(int fd)
{
return close(fd);
}
-
- void
-NetNonblockingIO(fd, onoff)
- int fd;
- int onoff;
+static void
+NetNonblockingIO(int fd, int onoff)
{
ioctl(fd, FIONBIO, (char *)&onoff);
}
-#if defined(TN3270)
- void
-NetSigIO(fd, onoff)
- int fd;
- int onoff;
-{
- ioctl(fd, FIOASYNC, (char *)&onoff); /* hear about input */
-}
-
- void
-NetSetPgrp(fd)
- int fd;
-{
- int myPid;
-
- myPid = getpid();
- fcntl(fd, F_SETOWN, myPid);
-}
-#endif /*defined(TN3270)*/
/*
* Various signal handling routines.
*/
- /* ARGSUSED */
- SIG_FUNC_RET
-deadpeer(sig)
- int sig;
+/* ARGSUSED */
+static SIG_FUNC_RET
+deadpeer(int sig __unused)
{
setcommandmode();
longjmp(peerdied, -1);
}
- /* ARGSUSED */
- SIG_FUNC_RET
-intr(sig)
- int sig;
+/* ARGSUSED */
+SIG_FUNC_RET
+intr(int sig __unused)
{
if (localchars) {
intp();
@@ -906,10 +829,9 @@ intr(sig)
longjmp(toplevel, -1);
}
- /* ARGSUSED */
- SIG_FUNC_RET
-intr2(sig)
- int sig;
+/* ARGSUSED */
+SIG_FUNC_RET
+intr2(int sig __unused)
{
if (localchars) {
#ifdef KLUDGELINEMODE
@@ -923,10 +845,9 @@ intr2(sig)
}
#ifdef SIGTSTP
- /* ARGSUSED */
- SIG_FUNC_RET
-susp(sig)
- int sig;
+/* ARGSUSED */
+SIG_FUNC_RET
+susp(int sig __unused)
{
if ((rlogin != _POSIX_VDISABLE) && rlogin_susp())
return;
@@ -936,10 +857,9 @@ susp(sig)
#endif
#ifdef SIGWINCH
- /* ARGSUSED */
- SIG_FUNC_RET
-sendwin(sig)
- int sig;
+/* ARGSUSED */
+static SIG_FUNC_RET
+sendwin(int sig __unused)
{
if (connected) {
sendnaws();
@@ -948,10 +868,9 @@ sendwin(sig)
#endif
#ifdef SIGINFO
- /* ARGSUSED */
- SIG_FUNC_RET
-ayt(sig)
- int sig;
+/* ARGSUSED */
+SIG_FUNC_RET
+ayt(int sig __unused)
{
if (connected)
sendayt();
@@ -961,8 +880,8 @@ ayt(sig)
#endif
- void
-sys_telnet_init()
+void
+sys_telnet_init(void)
{
(void) signal(SIGINT, intr);
(void) signal(SIGQUIT, intr2);
@@ -981,13 +900,6 @@ sys_telnet_init()
NetNonblockingIO(net, 1);
-#if defined(TN3270)
- if (noasynchnet == 0) { /* DBX can't handle! */
- NetSigIO(net, 1);
- NetSetPgrp(net);
- }
-#endif /* defined(TN3270) */
-
#if defined(SO_OOBINLINE)
if (SetSockOpt(net, SOL_SOCKET, SO_OOBINLINE, 1) == -1) {
perror("SetSockOpt");
@@ -1006,18 +918,12 @@ sys_telnet_init()
* The return value is 1 if something happened, 0 if not.
*/
- int
-process_rings(netin, netout, netex, ttyin, ttyout, poll)
- int poll; /* If 0, then block until something to do */
+int
+process_rings(int netin, int netout, int netex, int ttyin, int ttyout, int poll)
{
- register int c;
- /* One wants to be a bit careful about setting returnValue
- * to one, since a one implies we did some useful work,
- * and therefore probably won't be called to block next
- * time (TN3270 mode only).
- */
+ int c;
int returnValue = 0;
- static struct timeval TimeValue = { 0 };
+ static struct timeval TimeValue = { 0, 0 };
if (netout) {
FD_SET(net, &obits);
@@ -1025,24 +931,12 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
if (ttyout) {
FD_SET(tout, &obits);
}
-#if defined(TN3270)
if (ttyin) {
FD_SET(tin, &ibits);
}
-#else /* defined(TN3270) */
- if (ttyin) {
- FD_SET(tin, &ibits);
- }
-#endif /* defined(TN3270) */
-#if defined(TN3270)
- if (netin) {
- FD_SET(net, &ibits);
- }
-# else /* !defined(TN3270) */
if (netin) {
FD_SET(net, &ibits);
}
-# endif /* !defined(TN3270) */
if (netex) {
FD_SET(net, &xbits);
}
@@ -1057,23 +951,6 @@ process_rings(netin, netout, netex, ttyin, ttyout, poll)
if (errno == EINTR) {
return 0;
}
-# if defined(TN3270)
- /*
- * we can get EBADF if we were in transparent
- * mode, and the transcom process died.
- */
- if (errno == EBADF) {
- /*
- * zero the bits (even though kernel does it)
- * to make sure we are selecting on the right
- * ones.
- */
- FD_ZERO(&ibits);
- FD_ZERO(&obits);
- FD_ZERO(&xbits);
- return 0;
- }
-# endif /* defined(TN3270) */
/* I don't like this, does it ever happen? */
printf("sleep(5) from telnet, after select: %s\r\n", strerror(errno));
sleep(5);
diff --git a/crypto/telnet/telnet/telnet.c b/crypto/telnet/telnet/telnet.c
index 2135b24..4644531 100644
--- a/crypto/telnet/telnet/telnet.c
+++ b/crypto/telnet/telnet/telnet.c
@@ -29,33 +29,30 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
#include <sys/types.h>
-#if defined(unix)
-#include <signal.h>
/* By the way, we need to include curses.h before telnet.h since,
* among other things, telnet.h #defines 'DO', which is a variable
* declared in curses.h.
*/
-#endif /* defined(unix) */
-#include <arpa/telnet.h>
#include <ctype.h>
+#include <curses.h>
+#include <signal.h>
#include <stdlib.h>
+#include <term.h>
#include <unistd.h>
+#include <arpa/telnet.h>
#include "ring.h"
@@ -64,10 +61,10 @@ static const char rcsid[] =
#include "types.h"
#include "general.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
#include <libtelnet/misc.h>
@@ -97,17 +94,11 @@ int
skiprc = 0,
connected,
showoptions,
- In3270, /* Are we in 3270 mode? */
ISend, /* trying to send network data in */
debug = 0,
crmod,
netdata, /* Print out network data flow */
crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
-#if defined(TN3270)
- noasynchtty = 0,/* User specified "-noasynch" on command line */
- noasynchnet = 0,/* User specified "-noasynch" on command line */
- askedSGA = 0, /* We have talked about suppress go ahead */
-#endif /* defined(TN3270) */
telnetport,
SYNCHing, /* we are in TELNET SYNCH mode */
flushout, /* flush output */
@@ -154,7 +145,7 @@ unsigned char telopt_environ = TELOPT_NEW_ENVIRON;
# define telopt_environ TELOPT_NEW_ENVIRON
#endif
-jmp_buf toplevel = { 0 };
+jmp_buf toplevel;
jmp_buf peerdied;
int flushline;
@@ -164,6 +155,8 @@ int linemode;
int kludgelinemode = 1;
#endif
+static int is_unique(char *, char **, char **);
+
/*
* The following are some clocks used to decide how to interpret
* the relationship between various variables.
@@ -171,35 +164,24 @@ int kludgelinemode = 1;
Clocks clocks;
-#ifdef notdef
-Modelist modelist[] = {
- { "telnet command mode", COMMAND_LINE },
- { "character-at-a-time mode", 0 },
- { "character-at-a-time mode (local echo)", LOCAL_ECHO|LOCAL_CHARS },
- { "line-by-line mode (remote echo)", LINE | LOCAL_CHARS },
- { "line-by-line mode", LINE | LOCAL_ECHO | LOCAL_CHARS },
- { "line-by-line mode (local echoing suppressed)", LINE | LOCAL_CHARS },
- { "3270 mode", 0 },
-};
-#endif
-
-
/*
* Initialize telnet environment.
*/
- void
-init_telnet()
+void
+init_telnet(void)
{
env_init();
SB_CLEAR();
ClearArray(options);
- connected = In3270 = ISend = localflow = donebinarytoggle = 0;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+ connected = ISend = localflow = donebinarytoggle = 0;
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
auth_encrypt_connect(connected);
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
+#endif
+#endif
restartany = -1;
SYNCHing = 0;
@@ -217,56 +199,6 @@ init_telnet()
}
-#ifdef notdef
-#include <varargs.h>
-
- /*VARARGS*/
- static void
-printring(va_alist)
- va_dcl
-{
- va_list ap;
- char buffer[100]; /* where things go */
- char *ptr;
- char *format;
- char *string;
- Ring *ring;
- int i;
-
- va_start(ap);
-
- ring = va_arg(ap, Ring *);
- format = va_arg(ap, char *);
- ptr = buffer;
-
- while ((i = *format++) != 0) {
- if (i == '%') {
- i = *format++;
- switch (i) {
- case 'c':
- *ptr++ = va_arg(ap, int);
- break;
- case 's':
- string = va_arg(ap, char *);
- ring_supply_data(ring, buffer, ptr-buffer);
- ring_supply_data(ring, string, strlen(string));
- ptr = buffer;
- break;
- case 0:
- ExitString("printring: trailing %%.\n", 1);
- /*NOTREACHED*/
- default:
- ExitString("printring: unknown format character.\n", 1);
- /*NOTREACHED*/
- }
- } else {
- *ptr++ = i;
- }
- }
- ring_supply_data(ring, buffer, ptr-buffer);
-}
-#endif
-
/*
* These routines are in charge of sending option negotiations
* to the other side.
@@ -275,9 +207,8 @@ printring(va_alist)
* is in disagreement as to what the current state should be.
*/
- void
-send_do(c, init)
- register int c, init;
+void
+send_do(int c, int init)
{
if (init) {
if (((do_dont_resp[c] == 0) && my_state_is_do(c)) ||
@@ -291,9 +222,8 @@ send_do(c, init)
printoption("SENT", DO, c);
}
- void
-send_dont(c, init)
- register int c, init;
+void
+send_dont(int c, int init)
{
if (init) {
if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) ||
@@ -307,9 +237,8 @@ send_dont(c, init)
printoption("SENT", DONT, c);
}
- void
-send_will(c, init)
- register int c, init;
+void
+send_will(int c, int init)
{
if (init) {
if (((will_wont_resp[c] == 0) && my_state_is_will(c)) ||
@@ -323,9 +252,8 @@ send_will(c, init)
printoption("SENT", WILL, c);
}
- void
-send_wont(c, init)
- register int c, init;
+void
+send_wont(int c, int init)
{
if (init) {
if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) ||
@@ -339,10 +267,8 @@ send_wont(c, init)
printoption("SENT", WONT, c);
}
-
- void
-willoption(option)
- int option;
+void
+willoption(int option)
{
int new_state_ok = 0;
@@ -357,36 +283,12 @@ willoption(option)
switch (option) {
case TELOPT_ECHO:
-# if defined(TN3270)
- /*
- * The following is a pain in the rear-end.
- * Various IBM servers (some versions of Wiscnet,
- * possibly Fibronics/Spartacus, and who knows who
- * else) will NOT allow us to send "DO SGA" too early
- * in the setup proceedings. On the other hand,
- * 4.2 servers (telnetd) won't set SGA correctly.
- * So, we are stuck. Empirically (but, based on
- * a VERY small sample), the IBM servers don't send
- * out anything about ECHO, so we postpone our sending
- * "DO SGA" until we see "WILL ECHO" (which 4.2 servers
- * DO send).
- */
- {
- if (askedSGA == 0) {
- askedSGA = 1;
- if (my_want_state_is_dont(TELOPT_SGA))
- send_do(TELOPT_SGA, 1);
- }
- }
- /* Fall through */
- case TELOPT_EOR:
-#endif /* defined(TN3270) */
case TELOPT_BINARY:
case TELOPT_SGA:
settimer(modenegotiated);
/* FALL THROUGH */
case TELOPT_STATUS:
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
#endif
#ifdef ENCRYPTION
@@ -427,9 +329,8 @@ willoption(option)
#endif /* ENCRYPTION */
}
- void
-wontoption(option)
- int option;
+void
+wontoption(int option)
{
if (do_dont_resp[option]) {
--do_dont_resp[option];
@@ -476,9 +377,8 @@ wontoption(option)
set_my_state_dont(option);
}
- static void
-dooption(option)
- int option;
+static void
+dooption(int option)
{
int new_state_ok = 0;
@@ -503,9 +403,6 @@ dooption(option)
set_my_state_wont(TELOPT_TM);
return;
-# if defined(TN3270)
- case TELOPT_EOR: /* end of record */
-# endif /* defined(TN3270) */
case TELOPT_BINARY: /* binary mode */
case TELOPT_NAWS: /* window size */
case TELOPT_TSPEED: /* terminal speed */
@@ -532,7 +429,7 @@ dooption(option)
new_state_ok = 1;
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
if (autologin)
new_state_ok = 1;
@@ -540,7 +437,7 @@ dooption(option)
#endif
case TELOPT_XDISPLOC: /* X Display location */
- if (env_getvalue((unsigned char *)"DISPLAY"))
+ if (env_getvalue("DISPLAY"))
new_state_ok = 1;
break;
@@ -589,9 +486,8 @@ dooption(option)
set_my_state_will(option);
}
- static void
-dontoption(option)
- int option;
+static void
+dontoption(int option)
{
if (will_wont_resp[option]) {
@@ -632,15 +528,14 @@ dontoption(option)
* duplicate, or verbose names (names with spaces).
*/
-static char *name_unknown = "UNKNOWN";
-static char *unknown[] = { 0, 0 };
+static const char *name_unknown = "UNKNOWN";
+static const char *unknown[] = { NULL, NULL };
- char **
-mklist(buf, name)
- char *buf, *name;
+static const char **
+mklist(char *buf, char *name)
{
- register int n;
- register char c, *cp, **argvp, *cp2, **argv, **avt;
+ int n;
+ char c, *cp, **argvp, *cp2, **argv, **avt;
if (name) {
if (strlen(name) > 40) {
@@ -741,17 +636,16 @@ mklist(buf, name)
}
}
if (*argv)
- return(argv);
+ return((const char **)argv);
else
return(unknown);
}
- int
-is_unique(name, as, ae)
- register char *name, **as, **ae;
+static int
+is_unique(char *name, char **as, char **ae)
{
- register char **ap;
- register int n;
+ char **ap;
+ int n;
n = strlen(name) + 1;
for (ap = as; ap < ae; ap++)
@@ -763,11 +657,9 @@ is_unique(name, as, ae)
#ifdef TERMCAP
char termbuf[1024];
- /*ARGSUSED*/
- int
-setupterm(tname, fd, errp)
- char *tname;
- int fd, *errp;
+/*ARGSUSED*/
+static int
+setupterm(char *tname, int fd, int *errp)
{
if (tgetent(termbuf, tname) == 1) {
termbuf[1023] = '\0';
@@ -786,19 +678,19 @@ extern char ttytype[];
int resettermname = 1;
- char *
-gettermname()
+static const char *
+gettermname(void)
{
char *tname;
- static char **tnamep = 0;
- static char **next;
+ static const char **tnamep = 0;
+ static const char **next;
int err;
if (resettermname) {
resettermname = 0;
if (tnamep && tnamep != unknown)
free(tnamep);
- if ((tname = (char *)env_getvalue((unsigned char *)"TERM")) &&
+ if ((tname = env_getvalue("TERM")) &&
(setupterm(tname, 1, &err) == 0)) {
tnamep = mklist(termbuf, tname);
} else {
@@ -829,8 +721,8 @@ gettermname()
* Linemode
*/
- static void
-suboption()
+static void
+suboption(void)
{
unsigned char subchar;
@@ -842,19 +734,14 @@ suboption()
if (SB_EOF() || SB_GET() != TELQUAL_SEND) {
return;
} else {
- char *name;
+ const char *name;
unsigned char temp[50];
int len;
-#if defined(TN3270)
- if (tn3270_ttype()) {
- return;
- }
-#endif /* defined(TN3270) */
name = gettermname();
len = strlen(name) + 4 + 2;
if (len < NETROOM()) {
- sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE,
+ sprintf(temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE,
TELQUAL_IS, name, IAC, SE);
ring_supply_data(&netoring, temp, len);
printsub('>', &temp[2], len-2);
@@ -973,7 +860,7 @@ suboption()
unsigned char temp[50], *dp;
int len;
- if ((dp = env_getvalue((unsigned char *)"DISPLAY")) == NULL ||
+ if ((dp = env_getvalue("DISPLAY")) == NULL ||
strlen(dp) > sizeof(temp) - 7) {
/*
* Something happened, we no longer have a DISPLAY
@@ -982,7 +869,7 @@ suboption()
send_wont(TELOPT_XDISPLOC, 1);
break;
}
- snprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", IAC, SB,
+ snprintf(temp, sizeof(temp), "%c%c%c%c%s%c%c", IAC, SB,
TELOPT_XDISPLOC, TELQUAL_IS, dp, IAC, SE);
len = strlen((char *)temp+4) + 4; /* temp[3] is 0 ... */
@@ -994,7 +881,7 @@ suboption()
}
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION: {
if (!autologin)
break;
@@ -1093,10 +980,8 @@ suboption()
static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE };
- void
-lm_will(cmd, len)
- unsigned char *cmd;
- int len;
+void
+lm_will(unsigned char *cmd, int len)
{
if (len < 1) {
/*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */
@@ -1107,7 +992,7 @@ lm_will(cmd, len)
default:
str_lm[3] = DONT;
str_lm[4] = cmd[0];
- if (NETROOM() > sizeof(str_lm)) {
+ if (NETROOM() > (int)sizeof(str_lm)) {
ring_supply_data(&netoring, str_lm, sizeof(str_lm));
printsub('>', &str_lm[2], sizeof(str_lm)-2);
}
@@ -1116,10 +1001,8 @@ lm_will(cmd, len)
}
}
- void
-lm_wont(cmd, len)
- unsigned char *cmd;
- int len;
+void
+lm_wont(unsigned char *cmd, int len)
{
if (len < 1) {
/*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */
@@ -1133,10 +1016,8 @@ lm_wont(cmd, len)
}
}
- void
-lm_do(cmd, len)
- unsigned char *cmd;
- int len;
+void
+lm_do(unsigned char *cmd, int len)
{
if (len < 1) {
/*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */
@@ -1147,7 +1028,7 @@ lm_do(cmd, len)
default:
str_lm[3] = WONT;
str_lm[4] = cmd[0];
- if (NETROOM() > sizeof(str_lm)) {
+ if (NETROOM() > (int)sizeof(str_lm)) {
ring_supply_data(&netoring, str_lm, sizeof(str_lm));
printsub('>', &str_lm[2], sizeof(str_lm)-2);
}
@@ -1156,10 +1037,8 @@ lm_do(cmd, len)
}
}
- void
-lm_dont(cmd, len)
- unsigned char *cmd;
- int len;
+void
+lm_dont(unsigned char *cmd, int len)
{
if (len < 1) {
/*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */
@@ -1177,10 +1056,8 @@ static unsigned char str_lm_mode[] = {
IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE
};
- void
-lm_mode(cmd, len, init)
- unsigned char *cmd;
- int len, init;
+void
+lm_mode(unsigned char *cmd, int len, int init)
{
if (len != 1)
return;
@@ -1192,7 +1069,7 @@ lm_mode(cmd, len, init)
str_lm_mode[4] = linemode;
if (!init)
str_lm_mode[4] |= MODE_ACK;
- if (NETROOM() > sizeof(str_lm_mode)) {
+ if (NETROOM() > (int)sizeof(str_lm_mode)) {
ring_supply_data(&netoring, str_lm_mode, sizeof(str_lm_mode));
printsub('>', &str_lm_mode[2], sizeof(str_lm_mode)-2);
}
@@ -1219,10 +1096,10 @@ struct spc {
#define SLC_RVALUE 2
static int slc_mode = SLC_EXPORT;
- void
-slc_init()
+void
+slc_init(void)
{
- register struct spc *spcp;
+ struct spc *spcp;
localchars = 1;
for (spcp = spc_data; spcp < &spc_data[NSLC+1]; spcp++) {
@@ -1281,8 +1158,8 @@ slc_init()
}
- void
-slcstate()
+void
+slcstate(void)
{
printf("Special characters are %s values\n",
slc_mode == SLC_IMPORT ? "remote default" :
@@ -1290,17 +1167,16 @@ slcstate()
"remote");
}
- void
-slc_mode_export()
+void
+slc_mode_export(void)
{
slc_mode = SLC_EXPORT;
if (my_state_is_will(TELOPT_LINEMODE))
slc_export();
}
- void
-slc_mode_import(def)
- int def;
+void
+slc_mode_import(int def)
{
slc_mode = def ? SLC_IMPORT : SLC_RVALUE;
if (my_state_is_will(TELOPT_LINEMODE))
@@ -1314,11 +1190,10 @@ unsigned char slc_import_def[] = {
IAC, SB, TELOPT_LINEMODE, LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE
};
- void
-slc_import(def)
- int def;
+void
+slc_import(int def)
{
- if (NETROOM() > sizeof(slc_import_val)) {
+ if (NETROOM() > (int)sizeof(slc_import_val)) {
if (def) {
ring_supply_data(&netoring, slc_import_def, sizeof(slc_import_def));
printsub('>', &slc_import_def[2], sizeof(slc_import_def)-2);
@@ -1330,10 +1205,10 @@ slc_import(def)
/*@*/ else printf("slc_import: not enough room\n");
}
- void
-slc_export()
+void
+slc_export(void)
{
- register struct spc *spcp;
+ struct spc *spcp;
TerminalDefaultChars();
@@ -1354,13 +1229,11 @@ slc_export()
setconnmode(1); /* Make sure the character values are set */
}
- void
-slc(cp, len)
- register unsigned char *cp;
- int len;
+void
+slc(unsigned char *cp, int len)
{
- register struct spc *spcp;
- register int func,level;
+ struct spc *spcp;
+ int func,level;
slc_start_reply();
@@ -1424,10 +1297,10 @@ slc(cp, len)
setconnmode(1); /* set the new character values */
}
- void
-slc_check()
+void
+slc_check(void)
{
- register struct spc *spcp;
+ struct spc *spcp;
slc_start_reply();
for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) {
@@ -1444,12 +1317,11 @@ slc_check()
setconnmode(1);
}
-
unsigned char slc_reply[128];
unsigned char *slc_replyp;
- void
-slc_start_reply()
+void
+slc_start_reply(void)
{
slc_replyp = slc_reply;
*slc_replyp++ = IAC;
@@ -1458,11 +1330,8 @@ slc_start_reply()
*slc_replyp++ = LM_SLC;
}
- void
-slc_add_reply(func, flags, value)
- unsigned char func;
- unsigned char flags;
- cc_t value;
+void
+slc_add_reply(unsigned char func, unsigned char flags, cc_t value)
{
if ((*slc_replyp++ = func) == IAC)
*slc_replyp++ = IAC;
@@ -1472,10 +1341,10 @@ slc_add_reply(func, flags, value)
*slc_replyp++ = IAC;
}
- void
-slc_end_reply()
+void
+slc_end_reply(void)
{
- register int len;
+ int len;
*slc_replyp++ = IAC;
*slc_replyp++ = SE;
@@ -1489,10 +1358,10 @@ slc_end_reply()
/*@*/else printf("slc_end_reply: not enough room\n");
}
- int
-slc_update()
+int
+slc_update(void)
{
- register struct spc *spcp;
+ struct spc *spcp;
int need_update = 0;
for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) {
@@ -1527,13 +1396,11 @@ int old_env_value = OLD_ENV_VALUE;
# endif
#endif
- void
-env_opt(buf, len)
- register unsigned char *buf;
- register int len;
+void
+env_opt(unsigned char *buf, int len)
{
- register unsigned char *ep = 0, *epc = 0;
- register int i;
+ unsigned char *ep = 0, *epc = 0;
+ int i;
switch(buf[0]&0xff) {
case TELQUAL_SEND:
@@ -1601,8 +1468,8 @@ unsigned char *opt_reply;
unsigned char *opt_replyp;
unsigned char *opt_replyend;
- void
-env_opt_start()
+void
+env_opt_start(void)
{
if (opt_reply)
opt_reply = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE);
@@ -1621,19 +1488,18 @@ env_opt_start()
*opt_replyp++ = TELQUAL_IS;
}
- void
-env_opt_start_info()
+void
+env_opt_start_info(void)
{
env_opt_start();
if (opt_replyp)
opt_replyp[-1] = TELQUAL_INFO;
}
- void
-env_opt_add(ep)
- register unsigned char *ep;
+void
+env_opt_add(unsigned char *ep)
{
- register unsigned char *vp, c;
+ unsigned char *vp, c;
if (opt_reply == NULL) /*XXX*/
return; /*XXX*/
@@ -1654,7 +1520,7 @@ env_opt_add(ep)
if (opt_replyp + (vp ? strlen((char *)vp) : 0) +
strlen((char *)ep) + 6 > opt_replyend)
{
- register int len;
+ int len;
opt_replyend += OPT_REPLY_SIZE;
len = opt_replyend - opt_reply;
opt_reply = (unsigned char *)realloc(opt_reply, len);
@@ -1703,9 +1569,8 @@ env_opt_add(ep)
}
}
- int
-opt_welldefined(ep)
- char *ep;
+int
+opt_welldefined(const char *ep)
{
if ((strcmp(ep, "USER") == 0) ||
(strcmp(ep, "DISPLAY") == 0) ||
@@ -1716,11 +1581,11 @@ opt_welldefined(ep)
return(1);
return(0);
}
- void
-env_opt_end(emptyok)
- register int emptyok;
+
+void
+env_opt_end(int emptyok)
{
- register int len;
+ int len;
len = opt_replyp - opt_reply + 2;
if (emptyok || len > 6) {
@@ -1740,12 +1605,12 @@ env_opt_end(emptyok)
- int
-telrcv()
+int
+telrcv(void)
{
- register int c;
- register int scc;
- register unsigned char *sbp;
+ int c;
+ int scc;
+ unsigned char *sbp;
int count;
int returnValue = 0;
@@ -1790,23 +1655,6 @@ telrcv()
telrcv_state = TS_IAC;
break;
}
-# if defined(TN3270)
- if (In3270) {
- *Ifrontp++ = c;
- while (scc > 0) {
- c = *sbp++ & 0377, scc--; count++;
-#ifdef ENCRYPTION
- if (decrypt_input)
- c = (*decrypt_input)(c);
-#endif /* ENCRYPTION */
- if (c == IAC) {
- telrcv_state = TS_IAC;
- break;
- }
- *Ifrontp++ = c;
- }
- } else
-# endif /* defined(TN3270) */
/*
* The 'crmod' hack (see following) is needed
* since we can't * set CRMOD on output only.
@@ -1890,31 +1738,8 @@ process_iac:
telrcv_state = TS_SB;
continue;
-# if defined(TN3270)
- case EOR:
- if (In3270) {
- if (Ibackp == Ifrontp) {
- Ibackp = Ifrontp = Ibuf;
- ISend = 0; /* should have been! */
- } else {
- Ibackp += DataFromNetwork(Ibackp, Ifrontp-Ibackp, 1);
- ISend = 1;
- }
- }
- printoption("RCVD", IAC, EOR);
- break;
-# endif /* defined(TN3270) */
-
case IAC:
-# if !defined(TN3270)
TTYADD(IAC);
-# else /* !defined(TN3270) */
- if (In3270) {
- *Ifrontp++ = IAC;
- } else {
- TTYADD(IAC);
- }
-# endif /* !defined(TN3270) */
break;
case NOP:
@@ -1929,21 +1754,18 @@ process_iac:
case TS_WILL:
printoption("RCVD", WILL, c);
willoption(c);
- SetIn3270();
telrcv_state = TS_DATA;
continue;
case TS_WONT:
printoption("RCVD", WONT, c);
wontoption(c);
- SetIn3270();
telrcv_state = TS_DATA;
continue;
case TS_DO:
printoption("RCVD", DO, c);
dooption(c);
- SetIn3270();
if (c == TELOPT_NAWS) {
sendnaws();
} else if (c == TELOPT_LFLOW) {
@@ -1959,7 +1781,6 @@ process_iac:
dontoption(c);
flushline = 1;
setconnmode(0); /* set new tty mode (maybe) */
- SetIn3270();
telrcv_state = TS_DATA;
continue;
@@ -1993,7 +1814,6 @@ process_iac:
printoption("In SUBOPTION processing, RCVD", IAC, c);
suboption(); /* handle sub-option */
- SetIn3270();
telrcv_state = TS_IAC;
goto process_iac;
}
@@ -2005,7 +1825,6 @@ process_iac:
subpointer -= 2;
SB_TERM();
suboption(); /* handle sub-option */
- SetIn3270();
telrcv_state = TS_DATA;
}
}
@@ -2017,8 +1836,8 @@ process_iac:
static int bol = 1, local = 0;
- int
-rlogin_susp()
+int
+rlogin_susp(void)
{
if (local) {
local = 0;
@@ -2029,8 +1848,8 @@ rlogin_susp()
return(0);
}
- static int
-telsnd()
+static int
+telsnd(void)
{
int tcc;
int count;
@@ -2040,8 +1859,8 @@ telsnd()
tcc = 0;
count = 0;
while (NETROOM() > 2) {
- register int sc;
- register int c;
+ int sc;
+ int c;
if (tcc == 0) {
if (count) {
@@ -2076,7 +1895,7 @@ telsnd()
continue;
}
if (sc == escape) {
- command(0, (char *)tbp, tcc);
+ command(0, tbp, tcc);
bol = 1;
count += tcc;
tcc = 0;
@@ -2179,15 +1998,12 @@ telsnd()
*
*/
-
- int
-Scheduler(block)
- int block; /* should we block in the select ? */
+static int
+Scheduler(int block)
{
/* One wants to be a bit careful about setting returnValue
* to one, since a one implies we did some useful work,
* and therefore probably won't be called to block next
- * time (TN3270 mode only).
*/
int returnValue;
int netin, netout, netex, ttyin, ttyout;
@@ -2204,28 +2020,12 @@ Scheduler(block)
my_want_state_is_will(TELOPT_BINARY));
ttyout = ring_full_count(&ttyoring);
-#if defined(TN3270)
- ttyin = ring_empty_count(&ttyiring) && (clienteof == 0) && (shell_active == 0);
-#else /* defined(TN3270) */
ttyin = ring_empty_count(&ttyiring) && (clienteof == 0);
-#endif /* defined(TN3270) */
-#if defined(TN3270)
- netin = ring_empty_count(&netiring);
-# else /* !defined(TN3270) */
netin = !ISend && ring_empty_count(&netiring);
-# endif /* !defined(TN3270) */
netex = !SYNCHing;
- /* If we have seen a signal recently, reset things */
-# if defined(TN3270) && defined(unix)
- if (HaveInput) {
- HaveInput = 0;
- (void) signal(SIGIO, inputAvailable);
- }
-#endif /* defined(TN3270) && defined(unix) */
-
/* Call to system code to process rings */
returnValue = process_rings(netin, netout, netex, ttyin, ttyout, !block);
@@ -2233,44 +2033,30 @@ Scheduler(block)
/* Now, look at the input rings, looking for work to do. */
if (ring_full_count(&ttyiring)) {
-# if defined(TN3270)
- if (In3270) {
- int c;
-
- c = DataFromTerminal(ttyiring.consume,
- ring_full_consecutive(&ttyiring));
- if (c) {
- returnValue = 1;
- ring_consumed(&ttyiring, c);
- }
- } else {
-# endif /* defined(TN3270) */
returnValue |= telsnd();
-# if defined(TN3270)
- }
-# endif /* defined(TN3270) */
}
if (ring_full_count(&netiring)) {
-# if !defined(TN3270)
returnValue |= telrcv();
-# else /* !defined(TN3270) */
- returnValue = Push3270();
-# endif /* !defined(TN3270) */
}
return returnValue;
}
+#ifdef AUTHENTICATION
+#define __unusedhere
+#else
+#define __unusedhere __unused
+#endif
/*
* Select from tty and network...
*/
- void
-telnet(user)
- char *user;
+void
+telnet(char *user __unusedhere)
{
sys_telnet_init();
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
{
static char local_host[256] = { 0 };
@@ -2281,10 +2067,10 @@ telnet(user)
auth_encrypt_init(local_host, hostname, "TELNET", 0);
auth_encrypt_user(user);
}
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
-# if !defined(TN3270)
+#endif
+#endif
if (telnetport) {
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
if (autologin)
send_will(TELOPT_AUTHENTICATION, 1);
#endif
@@ -2300,14 +2086,12 @@ telnet(user)
send_will(TELOPT_LINEMODE, 1);
send_will(TELOPT_NEW_ENVIRON, 1);
send_do(TELOPT_STATUS, 1);
- if (env_getvalue((unsigned char *)"DISPLAY"))
+ if (env_getvalue("DISPLAY"))
send_will(TELOPT_XDISPLOC, 1);
if (eight)
tel_enter_binary(eight);
}
-# endif /* !defined(TN3270) */
-# if !defined(TN3270)
for (;;) {
int schedValue;
@@ -2323,45 +2107,6 @@ telnet(user)
return;
}
}
-# else /* !defined(TN3270) */
- for (;;) {
- int schedValue;
-
- while (!In3270 && !shell_active) {
- if (Scheduler(1) == -1) {
- setcommandmode();
- return;
- }
- }
-
- while ((schedValue = Scheduler(0)) != 0) {
- if (schedValue == -1) {
- setcommandmode();
- return;
- }
- }
- /* If there is data waiting to go out to terminal, don't
- * schedule any more data for the terminal.
- */
- if (ring_full_count(&ttyoring)) {
- schedValue = 1;
- } else {
- if (shell_active) {
- if (shell_continue() == 0) {
- ConnectScreen();
- }
- } else if (In3270) {
- schedValue = DoTerminalOutput();
- }
- }
- if (schedValue && (shell_active == 0)) {
- if (Scheduler(1) == -1) {
- setcommandmode();
- return;
- }
- }
- }
-# endif /* !defined(TN3270) */
}
#if 0 /* XXX - this not being in is a bug */
@@ -2376,9 +2121,8 @@ telnet(user)
* character.
*/
- static char *
-nextitem(current)
- char *current;
+static char *
+nextitem(char *current)
{
if ((*current&0xff) != IAC) {
return current+1;
@@ -2391,7 +2135,7 @@ nextitem(current)
return current+3;
case SB: /* loop forever looking for the SE */
{
- register char *look = current+2;
+ char *look = current+2;
for (;;) {
if ((*look++&0xff) == IAC) {
@@ -2424,51 +2168,18 @@ nextitem(current)
* us in any case.
*/
- static void
-netclear()
+static void
+netclear(void)
{
-#if 0 /* XXX */
- register char *thisitem, *next;
- char *good;
-#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
- ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
-
- thisitem = netobuf;
-
- while ((next = nextitem(thisitem)) <= netobuf.send) {
- thisitem = next;
- }
-
- /* Now, thisitem is first before/at boundary. */
-
- good = netobuf; /* where the good bytes go */
-
- while (netoring.add > thisitem) {
- if (wewant(thisitem)) {
- int length;
-
- next = thisitem;
- do {
- next = nextitem(next);
- } while (wewant(next) && (nfrontp > next));
- length = next-thisitem;
- memcpy(good, thisitem, length);
- good += length;
- thisitem = next;
- } else {
- thisitem = nextitem(thisitem);
- }
- }
-
-#endif /* 0 */
+ /* Deleted */
}
/*
* These routines add various telnet commands to the data stream.
*/
- static void
-doflush()
+static void
+doflush(void)
{
NET2ADD(IAC, DO);
NETADD(TELOPT_TM);
@@ -2479,8 +2190,8 @@ doflush()
printoption("SENT", DO, TELOPT_TM);
}
- void
-xmitAO()
+void
+xmitAO(void)
{
NET2ADD(IAC, AO);
printoption("SENT", IAC, AO);
@@ -2489,24 +2200,22 @@ xmitAO()
}
}
-
- void
-xmitEL()
+void
+xmitEL(void)
{
NET2ADD(IAC, EL);
printoption("SENT", IAC, EL);
}
- void
-xmitEC()
+void
+xmitEC(void)
{
NET2ADD(IAC, EC);
printoption("SENT", IAC, EC);
}
-
- int
-dosynch()
+int
+dosynch(char *ch __unused)
{
netclear(); /* clear the path to the network */
NETADD(IAC);
@@ -2518,11 +2227,11 @@ dosynch()
int want_status_response = 0;
- int
-get_status()
+int
+get_status(char *ch __unused)
{
unsigned char tmp[16];
- register unsigned char *cp;
+ unsigned char *cp;
if (my_want_state_is_dont(TELOPT_STATUS)) {
printf("Remote side does not support STATUS option\n");
@@ -2544,8 +2253,8 @@ get_status()
return 1;
}
- void
-intp()
+void
+intp(void)
{
NET2ADD(IAC, IP);
printoption("SENT", IAC, IP);
@@ -2554,12 +2263,12 @@ intp()
doflush();
}
if (autosynch) {
- dosynch();
+ dosynch(NULL);
}
}
- void
-sendbrk()
+void
+sendbrk(void)
{
NET2ADD(IAC, BREAK);
printoption("SENT", IAC, BREAK);
@@ -2568,12 +2277,12 @@ sendbrk()
doflush();
}
if (autosynch) {
- dosynch();
+ dosynch(NULL);
}
}
- void
-sendabort()
+void
+sendabort(void)
{
NET2ADD(IAC, ABORT);
printoption("SENT", IAC, ABORT);
@@ -2582,12 +2291,12 @@ sendabort()
doflush();
}
if (autosynch) {
- dosynch();
+ dosynch(NULL);
}
}
- void
-sendsusp()
+void
+sendsusp(void)
{
NET2ADD(IAC, SUSP);
printoption("SENT", IAC, SUSP);
@@ -2596,19 +2305,19 @@ sendsusp()
doflush();
}
if (autosynch) {
- dosynch();
+ dosynch(NULL);
}
}
- void
-sendeof()
+void
+sendeof(void)
{
NET2ADD(IAC, xEOF);
printoption("SENT", IAC, xEOF);
}
- void
-sendayt()
+void
+sendayt(void)
{
NET2ADD(IAC, AYT);
printoption("SENT", IAC, AYT);
@@ -2618,12 +2327,12 @@ sendayt()
* Send a window size update to the remote system.
*/
- void
-sendnaws()
+void
+sendnaws(void)
{
long rows, cols;
unsigned char tmp[16];
- register unsigned char *cp;
+ unsigned char *cp;
if (my_state_is_wont(TELOPT_NAWS))
return;
@@ -2650,9 +2359,8 @@ sendnaws()
}
}
- void
-tel_enter_binary(rw)
- int rw;
+void
+tel_enter_binary(int rw)
{
if (rw&1)
send_do(TELOPT_BINARY, 1);
@@ -2660,9 +2368,8 @@ tel_enter_binary(rw)
send_will(TELOPT_BINARY, 1);
}
- void
-tel_leave_binary(rw)
- int rw;
+void
+tel_leave_binary(int rw)
{
if (rw&1)
send_dont(TELOPT_BINARY, 1);
diff --git a/crypto/telnet/telnet/terminal.c b/crypto/telnet/telnet/terminal.c
index 2069396..9c77277 100644
--- a/crypto/telnet/telnet/terminal.c
+++ b/crypto/telnet/telnet/terminal.c
@@ -31,14 +31,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
#include <arpa/telnet.h>
#include <sys/types.h>
@@ -48,7 +47,7 @@ static const char rcsid[] =
#include "externs.h"
#include "types.h"
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -97,8 +96,8 @@ cc_t termAytChar;
* initialize the terminal data structures.
*/
- void
-init_terminal()
+void
+init_terminal(void)
{
if (ring_init(&ttyoring, ttyobuf, sizeof ttyobuf) != 1) {
exit(1);
@@ -109,7 +108,6 @@ init_terminal()
autoflush = TerminalAutoFlush();
}
-
/*
* Send as much data as possible to the terminal.
*
@@ -120,12 +118,10 @@ init_terminal()
* n: All data - n was written out.
*/
-
- int
-ttyflush(drop)
- int drop;
+int
+ttyflush(int drop)
{
- register int n, n0, n1;
+ int n, n0, n1;
n0 = ring_full_count(&ttyoring);
if ((n1 = n = ring_full_consecutive(&ttyoring)) > 0) {
@@ -171,8 +167,8 @@ ttyflush(drop)
*/
- int
-getconnmode()
+int
+getconnmode(void)
{
extern int linemode;
int mode = 0;
@@ -180,9 +176,6 @@ getconnmode()
extern int kludgelinemode;
#endif
- if (In3270)
- return(MODE_FLOW);
-
if (my_want_state_is_dont(TELOPT_ECHO))
mode |= MODE_ECHO;
@@ -211,14 +204,13 @@ getconnmode()
return(mode);
}
- void
-setconnmode(force)
- int force;
+void
+setconnmode(int force)
{
#ifdef ENCRYPTION
static int enc_passwd = 0;
#endif /* ENCRYPTION */
- register int newmode;
+ int newmode;
newmode = getconnmode()|(force?MODE_FORCE:0);
@@ -241,9 +233,8 @@ setconnmode(force)
}
-
- void
-setcommandmode()
+void
+setcommandmode(void)
{
TerminalNewMode(-1);
}
diff --git a/crypto/telnet/telnet/tn3270.c b/crypto/telnet/telnet/tn3270.c
deleted file mode 100644
index 92219b7..0000000
--- a/crypto/telnet/telnet/tn3270.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-#if 0
-static const char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <arpa/telnet.h>
-
-#include "general.h"
-
-#include "defines.h"
-#include "ring.h"
-#include "externs.h"
-#include "fdset.h"
-
-#if defined(TN3270)
-
-#include "../ctlr/screen.h"
-#include "../general/globals.h"
-
-#include "../sys_curses/telextrn.h"
-#include "../ctlr/externs.h"
-
-#if defined(unix)
-int
- HaveInput, /* There is input available to scan */
- cursesdata, /* Do we dump curses data? */
- sigiocount; /* Number of times we got a SIGIO */
-
-char tline[200];
-char *transcom = 0; /* transparent mode command (default: none) */
-#endif /* defined(unix) */
-
-char Ibuf[8*BUFSIZ], *Ifrontp, *Ibackp;
-
-static char sb_terminal[] = { IAC, SB,
- TELOPT_TTYPE, TELQUAL_IS,
- 'I', 'B', 'M', '-', '3', '2', '7', '8', '-', '2',
- IAC, SE };
-#define SBTERMMODEL 13
-
-static int
- Sent3270TerminalType; /* Have we said we are a 3270? */
-
-#endif /* defined(TN3270) */
-
-
- void
-init_3270()
-{
-#if defined(TN3270)
-#if defined(unix)
- HaveInput = 0;
- sigiocount = 0;
-#endif /* defined(unix) */
- Sent3270TerminalType = 0;
- Ifrontp = Ibackp = Ibuf;
- init_ctlr(); /* Initialize some things */
- init_keyboard();
- init_screen();
- init_system();
-#endif /* defined(TN3270) */
-}
-
-
-#if defined(TN3270)
-
-/*
- * DataToNetwork - queue up some data to go to network. If "done" is set,
- * then when last byte is queued, we add on an IAC EOR sequence (so,
- * don't call us with "done" until you want that done...)
- *
- * We actually do send all the data to the network buffer, since our
- * only client needs for us to do that.
- */
-
- int
-DataToNetwork(buffer, count, done)
- register char *buffer; /* where the data is */
- register int count; /* how much to send */
- int done; /* is this the last of a logical block */
-{
- register int loop, c;
- int origCount;
-
- origCount = count;
-
- while (count) {
- /* If not enough room for EORs, IACs, etc., wait */
- if (NETROOM() < 6) {
- fd_set o;
-
- FD_ZERO(&o);
- netflush();
- while (NETROOM() < 6) {
- FD_SET(net, &o);
- (void) select(net+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0);
- netflush();
- }
- }
- c = ring_empty_count(&netoring);
- if (c > count) {
- c = count;
- }
- loop = c;
- while (loop) {
- if (((unsigned char)*buffer) == IAC) {
- break;
- }
- buffer++;
- loop--;
- }
- if ((c = c-loop)) {
- ring_supply_data(&netoring, buffer-c, c);
- count -= c;
- }
- if (loop) {
- NET2ADD(IAC, IAC);
- count--;
- buffer++;
- }
- }
-
- if (done) {
- NET2ADD(IAC, EOR);
- netflush(); /* try to move along as quickly as ... */
- }
- return(origCount - count);
-}
-
-
-#if defined(unix)
- void
-inputAvailable(signo)
- int signo;
-{
- HaveInput = 1;
- sigiocount++;
-}
-#endif /* defined(unix) */
-
- void
-outputPurge()
-{
- (void) ttyflush(1);
-}
-
-
-/*
- * The following routines are places where the various tn3270
- * routines make calls into telnet.c.
- */
-
-/*
- * DataToTerminal - queue up some data to go to terminal.
- *
- * Note: there are people who call us and depend on our processing
- * *all* the data at one time (thus the select).
- */
-
- int
-DataToTerminal(buffer, count)
- register char *buffer; /* where the data is */
- register int count; /* how much to send */
-{
- register int c;
- int origCount;
-
- origCount = count;
-
- while (count) {
- if (TTYROOM() == 0) {
-#if defined(unix)
- fd_set o;
-
- FD_ZERO(&o);
-#endif /* defined(unix) */
- (void) ttyflush(0);
- while (TTYROOM() == 0) {
-#if defined(unix)
- FD_SET(tout, &o);
- (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0);
-#endif /* defined(unix) */
- (void) ttyflush(0);
- }
- }
- c = TTYROOM();
- if (c > count) {
- c = count;
- }
- ring_supply_data(&ttyoring, buffer, c);
- count -= c;
- buffer += c;
- }
- return(origCount);
-}
-
-
-/*
- * Push3270 - Try to send data along the 3270 output (to screen) direction.
- */
-
- int
-Push3270()
-{
- int save = ring_full_count(&netiring);
-
- if (save) {
- if (Ifrontp+save > Ibuf+sizeof Ibuf) {
- if (Ibackp != Ibuf) {
- memmove(Ibuf, Ibackp, Ifrontp-Ibackp);
- Ifrontp -= (Ibackp-Ibuf);
- Ibackp = Ibuf;
- }
- }
- if (Ifrontp+save < Ibuf+sizeof Ibuf) {
- (void)telrcv();
- }
- }
- return save != ring_full_count(&netiring);
-}
-
-
-/*
- * Finish3270 - get the last dregs of 3270 data out to the terminal
- * before quitting.
- */
-
- void
-Finish3270()
-{
- while (Push3270() || !DoTerminalOutput()) {
-#if defined(unix)
- HaveInput = 0;
-#endif /* defined(unix) */
- ;
- }
-}
-
-
-/* StringToTerminal - output a null terminated string to the terminal */
-
- void
-StringToTerminal(s)
- char *s;
-{
- int count;
-
- count = strlen(s);
- if (count) {
- (void) DataToTerminal(s, count); /* we know it always goes... */
- }
-}
-
-
-#if ((!defined(NOT43)) || defined(PUTCHAR))
-/* _putchar - output a single character to the terminal. This name is so that
- * curses(3x) can call us to send out data.
- */
-
- void
-_putchar(c)
- char c;
-{
-#if defined(sun) /* SunOS 4.0 bug */
- c &= 0x7f;
-#endif /* defined(sun) */
- if (cursesdata) {
- Dump('>', &c, 1);
- }
- if (!TTYROOM()) {
- (void) DataToTerminal(&c, 1);
- } else {
- TTYADD(c);
- }
-}
-#endif /* ((!defined(NOT43)) || defined(PUTCHAR)) */
-
- void
-SetIn3270()
-{
- if (Sent3270TerminalType && my_want_state_is_will(TELOPT_BINARY)
- && my_want_state_is_do(TELOPT_BINARY) && !donebinarytoggle) {
- if (!In3270) {
- In3270 = 1;
- Init3270(); /* Initialize 3270 functions */
- /* initialize terminal key mapping */
- InitTerminal(); /* Start terminal going */
- setconnmode(0);
- }
- } else {
- if (In3270) {
- StopScreen(1);
- In3270 = 0;
- Stop3270(); /* Tell 3270 we aren't here anymore */
- setconnmode(0);
- }
- }
-}
-
-/*
- * tn3270_ttype()
- *
- * Send a response to a terminal type negotiation.
- *
- * Return '0' if no more responses to send; '1' if a response sent.
- */
-
- int
-tn3270_ttype()
-{
- /*
- * Try to send a 3270 type terminal name. Decide which one based
- * on the format of our screen, and (in the future) color
- * capaiblities.
- */
- InitTerminal(); /* Sets MaxNumberColumns, MaxNumberLines */
- if ((MaxNumberLines >= 24) && (MaxNumberColumns >= 80)) {
- Sent3270TerminalType = 1;
- if ((MaxNumberLines >= 27) && (MaxNumberColumns >= 132)) {
- MaxNumberLines = 27;
- MaxNumberColumns = 132;
- sb_terminal[SBTERMMODEL] = '5';
- } else if (MaxNumberLines >= 43) {
- MaxNumberLines = 43;
- MaxNumberColumns = 80;
- sb_terminal[SBTERMMODEL] = '4';
- } else if (MaxNumberLines >= 32) {
- MaxNumberLines = 32;
- MaxNumberColumns = 80;
- sb_terminal[SBTERMMODEL] = '3';
- } else {
- MaxNumberLines = 24;
- MaxNumberColumns = 80;
- sb_terminal[SBTERMMODEL] = '2';
- }
- NumberLines = 24; /* before we start out... */
- NumberColumns = 80;
- ScreenSize = NumberLines*NumberColumns;
- if ((MaxNumberLines*MaxNumberColumns) > MAXSCREENSIZE) {
- ExitString("Programming error: MAXSCREENSIZE too small.\n",
- 1);
- /*NOTREACHED*/
- }
- printsub('>', sb_terminal+2, sizeof sb_terminal-2);
- ring_supply_data(&netoring, sb_terminal, sizeof sb_terminal);
- return 1;
- } else {
- return 0;
- }
-}
-
-#if defined(unix)
- int
-settranscom(argc, argv)
- int argc;
- char *argv[];
-{
- int i;
-
- if (argc == 1 && transcom) {
- transcom = 0;
- }
- if (argc == 1) {
- return 1;
- }
- transcom = tline;
- (void) strcpy(transcom, argv[1]);
- for (i = 2; i < argc; ++i) {
- (void) strcat(transcom, " ");
- (void) strcat(transcom, argv[i]);
- }
- return 1;
-}
-#endif /* defined(unix) */
-
-#endif /* defined(TN3270) */
diff --git a/crypto/telnet/telnet/utilities.c b/crypto/telnet/telnet/utilities.c
index 2ee709a..8342c31 100644
--- a/crypto/telnet/telnet/utilities.c
+++ b/crypto/telnet/telnet/utilities.c
@@ -31,14 +31,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
#endif
-#endif /* not lint */
#define TELOPTS
#define TELCMDS
@@ -60,10 +59,10 @@ static const char rcsid[] =
#include "externs.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -76,11 +75,10 @@ int prettydump;
* Upcase (in place) the argument.
*/
- void
-upcase(argument)
- register char *argument;
+void
+upcase(char *argument)
{
- register int c;
+ int c;
while ((c = *argument) != 0) {
if (islower(c)) {
@@ -96,21 +94,11 @@ upcase(argument)
* Compensate for differences in 4.2 and 4.3 systems.
*/
- int
-SetSockOpt(fd, level, option, yesno)
- int fd, level, option, yesno;
+int
+SetSockOpt(int fd, int level, int option, int yesno)
{
-#ifndef NOT43
return setsockopt(fd, level, option,
(char *)&yesno, sizeof yesno);
-#else /* NOT43 */
- if (yesno == 0) { /* Can't do that in 4.2! */
- fprintf(stderr, "Error: attempt to turn off an option 0x%x.\n",
- option);
- return -1;
- }
- return setsockopt(fd, level, option, 0, 0);
-#endif /* NOT43 */
}
/*
@@ -119,9 +107,8 @@ SetSockOpt(fd, level, option, yesno)
unsigned char NetTraceFile[256] = "(standard output)";
- void
-SetNetTrace(file)
- register char *file;
+void
+SetNetTrace(char *file)
{
if (NetTrace && NetTrace != stdout)
fclose(NetTrace);
@@ -137,11 +124,8 @@ SetNetTrace(file)
strcpy((char *)NetTraceFile, "(standard output)");
}
- void
-Dump(direction, buffer, length)
- char direction;
- unsigned char *buffer;
- int length;
+void
+Dump(char direction, unsigned char *buffer, int length)
{
# define BYTES_PER_LINE 32
# define min(x,y) ((x<y)? x:y)
@@ -188,10 +172,8 @@ Dump(direction, buffer, length)
}
- void
-printoption(direction, cmd, option)
- char *direction;
- int cmd, option;
+void
+printoption(const char *direction, int cmd, int option)
{
if (!showoptions)
return;
@@ -201,7 +183,7 @@ printoption(direction, cmd, option)
else
fprintf(NetTrace, "%s IAC %d", direction, option);
} else {
- register char *fmt;
+ const char *fmt;
fmt = (cmd == WILL) ? "WILL" : (cmd == WONT) ? "WONT" :
(cmd == DO) ? "DO" : (cmd == DONT) ? "DONT" : 0;
if (fmt) {
@@ -224,10 +206,10 @@ printoption(direction, cmd, option)
return;
}
- void
-optionstatus()
+void
+optionstatus(void)
{
- register int i;
+ int i;
extern char will_wont_resp[], do_dont_resp[];
for (i = 0; i < 256; i++) {
@@ -301,14 +283,13 @@ optionstatus()
}
- void
-printsub(direction, pointer, length)
- char direction; /* '<' or '>' */
- unsigned char *pointer; /* where suboption data sits */
- int length; /* length of suboption data */
+void
+printsub(char direction, unsigned char *pointer, int length)
{
- register int i;
+ int i;
+#ifdef AUTHENTICATION
char buf[512];
+#endif
extern int want_status_response;
if (showoptions || direction == 0 ||
@@ -317,7 +298,7 @@ printsub(direction, pointer, length)
fprintf(NetTrace, "%s IAC SB ",
(direction == '<')? "RCVD":"SENT");
if (length >= 3) {
- register int j;
+ int j;
i = pointer[length-2];
j = pointer[length-1];
@@ -431,7 +412,7 @@ printsub(direction, pointer, length)
fprintf(NetTrace, " ?%d?", pointer[i]);
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
fprintf(NetTrace, "AUTHENTICATION");
if (length < 2) {
@@ -668,8 +649,8 @@ printsub(direction, pointer, length)
break;
case TELOPT_STATUS: {
- register char *cp;
- register int j, k;
+ const char *cp;
+ int j, k;
fprintf(NetTrace, "STATUS");
@@ -782,7 +763,7 @@ printsub(direction, pointer, length)
fprintf(NetTrace, "INFO ");
env_common:
{
- register int noquote = 2;
+ int noquote = 2;
#if defined(ENV_HACK) && defined(OLD_ENVIRON)
extern int old_env_var, old_env_value;
#endif
@@ -877,72 +858,52 @@ printsub(direction, pointer, length)
* way to the kernel (thus the select).
*/
- void
-EmptyTerminal()
+static void
+EmptyTerminal(void)
{
-#if defined(unix)
fd_set o;
FD_ZERO(&o);
-#endif /* defined(unix) */
if (TTYBYTES() == 0) {
-#if defined(unix)
FD_SET(tout, &o);
(void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
(struct timeval *) 0); /* wait for TTLOWAT */
-#endif /* defined(unix) */
} else {
while (TTYBYTES()) {
(void) ttyflush(0);
-#if defined(unix)
FD_SET(tout, &o);
(void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
(struct timeval *) 0); /* wait for TTLOWAT */
-#endif /* defined(unix) */
}
}
}
- void
-SetForExit()
+static void
+SetForExit(void)
{
setconnmode(0);
-#if defined(TN3270)
- if (In3270) {
- Finish3270();
- }
-#else /* defined(TN3270) */
do {
(void)telrcv(); /* Process any incoming data */
EmptyTerminal();
} while (ring_full_count(&netiring)); /* While there is any */
-#endif /* defined(TN3270) */
setcommandmode();
fflush(stdout);
fflush(stderr);
-#if defined(TN3270)
- if (In3270) {
- StopScreen(1);
- }
-#endif /* defined(TN3270) */
setconnmode(0);
EmptyTerminal(); /* Flush the path to the tty */
setcommandmode();
}
- void
-Exit(returnCode)
- int returnCode;
+void
+Exit(int returnCode)
{
SetForExit();
exit(returnCode);
}
- void
-ExitString(string, returnCode)
- char *string;
- int returnCode;
+void
+ExitString(const char *string, int returnCode)
{
SetForExit();
fwrite(string, 1, strlen(string), stderr);
diff --git a/crypto/telnet/telnetd/authenc.c b/crypto/telnet/telnetd/authenc.c
index 26a85d2..fd5f585 100644
--- a/crypto/telnet/telnetd/authenc.c
+++ b/crypto/telnet/telnetd/authenc.c
@@ -31,22 +31,23 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
+/* Above "#ifdef"s actually "or"'ed together. XXX MarkM
+ */
#include "telnetd.h"
#include <libtelnet/misc.h>
- int
-net_write(str, len)
- unsigned char *str;
- int len;
+int
+net_write(unsigned char *str, int len)
{
if (nfrontp + len < netobuf + BUFSIZ) {
output_datalen(str, len);
@@ -55,8 +56,8 @@ net_write(str, len)
return(0);
}
- void
-net_encrypt()
+void
+net_encrypt(void)
{
#ifdef ENCRYPTION
char *s = (nclearto > nbackp) ? nclearto : nbackp;
@@ -67,27 +68,23 @@ net_encrypt()
#endif /* ENCRYPTION */
}
- int
-telnet_spin()
+int
+telnet_spin(void)
{
ttloop();
return(0);
}
- char *
-telnet_getenv(val)
- char *val;
+char *
+telnet_getenv(char *val)
{
return(getenv(val));
}
- char *
-telnet_gets(prompt, result, length, echo)
- char *prompt;
- char *result;
- int length;
- int echo;
+char *
+telnet_gets(const char *prompt __unused, char *result __unused, int length __unused, int echo __unused)
{
- return((char *)0);
+ return(NULL);
}
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
+#endif /* ENCRYPTION */
+#endif /* AUTHENTICATION */
diff --git a/crypto/telnet/telnetd/ext.h b/crypto/telnet/telnetd/ext.h
index 9b53c7c..d9becde 100644
--- a/crypto/telnet/telnetd/ext.h
+++ b/crypto/telnet/telnetd/ext.h
@@ -56,10 +56,7 @@ extern int diagnostic; /* telnet diagnostic capabilities */
#ifdef BFTPDAEMON
extern int bftpd; /* behave as bftp daemon */
#endif /* BFTPDAEMON */
-#if defined(SecurID)
-extern int require_SecurID;
-#endif
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
extern int auth_level;
#endif
@@ -93,12 +90,12 @@ extern int SYNCHing; /* we are in TELNET SYNCH mode */
extern void
_termstat P((void)),
- add_slc P((int, int, int)),
+ add_slc P((char, char, cc_t)),
check_slc P((void)),
- change_slc P((int, int, int)),
+ change_slc P((char, char, cc_t)),
cleanup P((int)),
clientstat P((int, int, int)),
- copy_termbuf P((char *, int)),
+ copy_termbuf P((char *, size_t)),
deferslc P((void)),
defer_terminit P((void)),
do_opt_slc P((unsigned char *, int)),
@@ -106,8 +103,8 @@ extern void
dooption P((int)),
dontoption P((int)),
edithost P((char *, char *)),
- fatal P((int, char *)),
- fatalperror P((int, char *)),
+ fatal P((int, const char *)),
+ fatalperror P((int, const char *)),
get_slc_defaults P((void)),
init_env P((void)),
init_termbuf P((void)),
@@ -117,10 +114,11 @@ extern void
netclear P((void)),
netflush P((void)),
#ifdef DIAGNOSTICS
- printoption P((char *, int)),
- printdata P((char *, char *, int)),
- printsub P((int, unsigned char *, int)),
+ printoption P((const char *, int)),
+ printdata P((const char *, char *, int)),
+ printsub P((char, unsigned char *, int)),
#endif
+ process_slc P((unsigned char, unsigned char, cc_t)),
ptyflush P((void)),
putchr P((int)),
putf P((char *, char *)),
@@ -136,7 +134,7 @@ extern void
set_termbuf P((void)),
start_login P((char *, int, char *)),
start_slc P((int)),
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
start_slave P((char *)),
#else
start_slave P((char *, int, char *)),
@@ -186,6 +184,7 @@ extern void
int output_data __P((const char *, ...)) __printflike(1, 2);
void output_datalen __P((const char *, int));
+void startslave __P((char *, int, char *));
#ifdef ENCRYPTION
extern void (*encrypt_output) P((unsigned char *, int));
diff --git a/crypto/telnet/telnetd/slc.c b/crypto/telnet/telnetd/slc.c
index 780adf1..d4eee1a 100644
--- a/crypto/telnet/telnetd/slc.c
+++ b/crypto/telnet/telnetd/slc.c
@@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)slc.c 8.2 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include "telnetd.h"
@@ -56,10 +56,10 @@ static unsigned char slcbuf[NSLC*6]; /* buffer for slc negotiation */
*
* Write out the current special characters to the client.
*/
- void
-send_slc()
+void
+send_slc(void)
{
- register int i;
+ int i;
/*
* Send out list of triplets of special characters
@@ -80,10 +80,10 @@ send_slc()
*
* Set pty special characters to all the defaults.
*/
- void
-default_slc()
+static void
+default_slc(void)
{
- register int i;
+ int i;
for (i = 1; i <= NSLC; i++) {
slctab[i].current.val = slctab[i].defset.val;
@@ -105,10 +105,10 @@ default_slc()
*
* Initialize the slc mapping table.
*/
- void
-get_slc_defaults()
+void
+get_slc_defaults(void)
{
- register int i;
+ int i;
init_termbuf();
@@ -127,10 +127,8 @@ get_slc_defaults()
*
* Add an slc triplet to the slc buffer.
*/
- void
-add_slc(func, flag, val)
- register char func, flag;
- register cc_t val;
+void
+add_slc(char func, char flag, cc_t val)
{
if ((*slcptr++ = (unsigned char)func) == 0xff)
@@ -152,9 +150,8 @@ add_slc(func, flag, val)
* The parameter getit is non-zero if it is necessary to grab a copy
* of the terminal control structures.
*/
- void
-start_slc(getit)
- register int getit;
+void
+start_slc(int getit)
{
slcchange = 0;
@@ -171,11 +168,10 @@ start_slc(getit)
*
* Finish up the slc negotiation. If something to send, then send it.
*/
- int
-end_slc(bufp)
- register unsigned char **bufp;
+int
+end_slc(unsigned char **bufp)
{
- register int len;
+ int len;
/*
* If a change has occured, store the new terminal control
@@ -217,12 +213,10 @@ end_slc(bufp)
*
* Figure out what to do about the client's slc
*/
- void
-process_slc(func, flag, val)
- register unsigned char func, flag;
- register cc_t val;
+void
+process_slc(unsigned char func, unsigned char flag, cc_t val)
{
- register int hislevel, mylevel, ack;
+ int hislevel, mylevel, ack;
/*
* Ensure that we know something about this function
@@ -283,12 +277,10 @@ process_slc(func, flag, val)
* Process a request to change one of our special characters.
* Compare client's request with what we are capable of supporting.
*/
- void
-change_slc(func, flag, val)
- register char func, flag;
- register cc_t val;
+void
+change_slc(char func, char flag, cc_t val)
{
- register int hislevel, mylevel;
+ int hislevel, mylevel;
hislevel = flag & SLC_LEVELBITS;
mylevel = slctab[(int)func].defset.flag & SLC_LEVELBITS;
@@ -393,10 +385,10 @@ cc_t oldeofc = '\004';
* likely to have changed. If a local change occurs, kick the support level
* and flags up to the defaults.
*/
- void
-check_slc()
+void
+check_slc(void)
{
- register int i;
+ int i;
for (i = 1; i <= NSLC; i++) {
#if defined(USE_TERMIO) && (VEOF == VMIN)
@@ -436,14 +428,12 @@ check_slc()
*
* ptr points to the beginning of the buffer, len is the length.
*/
- void
-do_opt_slc(ptr, len)
- register unsigned char *ptr;
- register int len;
+void
+do_opt_slc(unsigned char *ptr, int len)
{
- register unsigned char func, flag;
+ unsigned char func, flag;
cc_t val;
- register unsigned char *end = ptr + len;
+ unsigned char *end = ptr + len;
if (terminit()) { /* go ahead */
while (ptr < end) {
@@ -477,8 +467,8 @@ do_opt_slc(ptr, len)
*
* Do slc stuff that was deferred.
*/
- void
-deferslc()
+void
+deferslc(void)
{
if (def_slcbuf) {
start_slc(1);
diff --git a/crypto/telnet/telnetd/state.c b/crypto/telnet/telnetd/state.c
index 57ade2f..ff0828d 100644
--- a/crypto/telnet/telnetd/state.c
+++ b/crypto/telnet/telnetd/state.c
@@ -31,20 +31,20 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <stdarg.h>
#include "telnetd.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -89,10 +89,12 @@ unsigned char *subsave;
#define TS_DO 7 /* do " */
#define TS_DONT 8 /* dont " */
- void
-telrcv()
+static void doclientstat(void);
+
+void
+telrcv(void)
{
- register int c;
+ int c;
static int state = TS_DATA;
while (ncc > 0) {
@@ -422,9 +424,8 @@ gotiac: switch (c) {
* is complete.
*
*/
- void
-send_do(option, init)
- int option, init;
+void
+send_do(int option, int init)
{
if (init) {
if ((do_dont_resp[option] == 0 && his_state_is_will(option)) ||
@@ -446,22 +447,11 @@ send_do(option, init)
DIAG(TD_OPTIONS, printoption("td: send do", option));
}
-#ifdef AUTHENTICATION
-extern void auth_request();
-#endif
-#ifdef LINEMODE
-extern void doclientstat();
-#endif
-#ifdef ENCRYPTION
-extern void encrypt_send_support();
-#endif /* ENCRYPTION */
-
- void
-willoption(option)
- int option;
+void
+willoption(int option)
{
int changeok = 0;
- void (*func)() = 0;
+ void (*func)(void) = 0;
/*
* process input from peer.
@@ -649,9 +639,8 @@ willoption(option)
(*func)();
} /* end of willoption */
- void
-send_dont(option, init)
- int option, init;
+void
+send_dont(int option, int init)
{
if (init) {
if ((do_dont_resp[option] == 0 && his_state_is_wont(option)) ||
@@ -665,9 +654,8 @@ send_dont(option, init)
DIAG(TD_OPTIONS, printoption("td: send dont", option));
}
- void
-wontoption(option)
- int option;
+void
+wontoption(int option)
{
/*
* Process client input.
@@ -731,7 +719,7 @@ wontoption(option)
slctab[SLC_XOFF].defset.flag |= SLC_CANTCHANGE;
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
auth_finished(0, AUTH_REJECT);
break;
@@ -784,7 +772,7 @@ wontoption(option)
#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
auth_finished(0, AUTH_REJECT);
break;
@@ -798,9 +786,8 @@ wontoption(option)
} /* end of wontoption */
- void
-send_will(option, init)
- int option, init;
+void
+send_will(int option, int init)
{
if (init) {
if ((will_wont_resp[option] == 0 && my_state_is_will(option))||
@@ -825,9 +812,8 @@ send_will(option, init)
int turn_on_sga = 0;
#endif
- void
-dooption(option)
- int option;
+void
+dooption(int option)
{
int changeok = 0;
@@ -956,9 +942,8 @@ dooption(option)
} /* end of dooption */
- void
-send_wont(option, init)
- int option, init;
+void
+send_wont(int option, int init)
{
if (init) {
if ((will_wont_resp[option] == 0 && my_state_is_wont(option)) ||
@@ -972,9 +957,8 @@ send_wont(option, init)
DIAG(TD_OPTIONS, printoption("td: send wont", option));
}
- void
-dontoption(option)
- int option;
+void
+dontoption(int option)
{
/*
* Process client input.
@@ -1078,17 +1062,17 @@ int env_ovalue = -1;
* Window size
* Terminal speed
*/
- void
-suboption()
+void
+suboption(void)
{
- register int subchar;
+ int subchar;
DIAG(TD_OPTIONS, {netflush(); printsub('<', subpointer, SB_LEN()+2);});
subchar = SB_GET();
switch (subchar) {
case TELOPT_TSPEED: {
- register int xspeed, rspeed;
+ int xspeed, rspeed;
if (his_state_is_wont(TELOPT_TSPEED)) /* Ignore if option disabled */
break;
@@ -1126,7 +1110,7 @@ suboption()
while ((terminaltype < (terminalname + sizeof terminalname-1)) &&
!SB_EOF()) {
- register int c;
+ int c;
c = SB_GET();
if (isupper(c)) {
@@ -1140,7 +1124,7 @@ suboption()
} /* end of case TELOPT_TTYPE */
case TELOPT_NAWS: {
- register int xwinsize, ywinsize;
+ int xwinsize, ywinsize;
if (his_state_is_wont(TELOPT_NAWS)) /* Ignore if option disabled */
break;
@@ -1165,7 +1149,7 @@ suboption()
#ifdef LINEMODE
case TELOPT_LINEMODE: {
- register int request;
+ int request;
if (his_state_is_wont(TELOPT_LINEMODE)) /* Ignore if option disabled */
break;
@@ -1245,8 +1229,8 @@ suboption()
case TELOPT_NEW_ENVIRON:
#endif
case TELOPT_OLD_ENVIRON: {
- register int c;
- register char *cp, *varp, *valp;
+ int c;
+ char *cp, *varp, *valp;
if (SB_EOF())
return;
@@ -1277,7 +1261,7 @@ suboption()
* reversed.
*/
if (env_ovar < 0) {
- register int last = -1; /* invalid value */
+ int last = -1; /* invalid value */
int empty = 0;
int got_var = 0, got_value = 0, got_uservar = 0;
@@ -1427,7 +1411,7 @@ suboption()
unsetenv(varp);
break;
} /* end of case TELOPT_NEW_ENVIRON */
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
if (SB_EOF())
break;
@@ -1498,20 +1482,20 @@ suboption()
} /* end of suboption */
- void
-doclientstat()
+static void
+doclientstat(void)
{
clientstat(TELOPT_LINEMODE, WILL, 0);
}
#define ADD(c) *ncp++ = c
#define ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
- void
-send_status()
+void
+send_status(void)
{
unsigned char statusbuf[256];
- register unsigned char *ncp;
- register unsigned char i;
+ unsigned char *ncp;
+ unsigned char i;
ncp = statusbuf;
diff --git a/crypto/telnet/telnetd/sys_term.c b/crypto/telnet/telnetd/sys_term.c
index 2b5dfa5..9edde84 100644
--- a/crypto/telnet/telnetd/sys_term.c
+++ b/crypto/telnet/telnetd/sys_term.c
@@ -1,4 +1,4 @@
-/*
+ /*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -31,67 +31,49 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
+
+#include <sys/types.h>
+#include <sys/tty.h>
+#include <libutil.h>
+#include <stdlib.h>
+#include <utmp.h>
#include "telnetd.h"
#include "pathnames.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-extern char *altlogin;
-int cleanopen(char *line);
+int cleanopen(char *);
void scrub_env(void);
-#ifdef NEWINIT
-#include <initreq.h>
-#else /* NEWINIT*/
-# ifdef UTMPX
-# include <utmpx.h>
-struct utmpx wtmp;
-# else
-# include <utmp.h>
struct utmp wtmp;
-# endif /* UTMPX */
-# ifndef PARENT_DOES_UTMP
#ifdef _PATH_WTMP
char wtmpf[] = _PATH_WTMP;
#else
-char wtmpf[] = "/usr/adm/wtmp";
+char wtmpf[] = "/var/log/wtmp";
#endif
#ifdef _PATH_UTMP
char utmpf[] = _PATH_UTMP;
#else
-char utmpf[] = "/etc/utmp";
+char utmpf[] = "/var/run/utmp";
#endif
-# else /* PARENT_DOES_UTMP */
-char wtmpf[] = "/etc/wtmp";
-# endif /* PARENT_DOES_UTMP */
-
-#include <libutil.h>
-
-#endif /* NEWINIT */
-#ifdef STREAMSPTY
-#include <sac.h>
-#include <sys/stropts.h>
-#endif
+char *envinit[3];
+extern char **environ;
#define SCPYN(a, b) (void) strncpy(a, b, sizeof(a))
#define SCMPN(a, b) strncmp(a, b, sizeof(a))
-#ifdef STREAMS
-#include <sys/stream.h>
-#endif
-#include <sys/tty.h>
#ifdef t_erase
#undef t_erase
#undef t_kill
@@ -122,9 +104,6 @@ struct termbuf {
# define cfgetospeed(tp) (tp)->sg.sg_ospeed
# define cfgetispeed(tp) (tp)->sg.sg_ispeed
#else /* USE_TERMIO */
-# ifdef SYSV_TERMIO
-# define termios termio
-# endif
# ifndef TCSANOW
# ifdef TCSETS
# define TCSANOW TCSETS
@@ -156,9 +135,6 @@ struct termbuf {
# endif
# endif /* TCSANOW */
struct termios termbuf, termbuf2; /* pty control structure */
-# ifdef STREAMSPTY
-int ttyfd = -1;
-# endif
#endif /* USE_TERMIO */
#include <sys/types.h>
@@ -166,6 +142,7 @@ int ttyfd = -1;
int cleanopen __P((char *));
void scrub_env __P((void));
+static char **addarg __P((char **, const char *));
/*
* init_termbuf()
@@ -178,8 +155,8 @@ void scrub_env __P((void));
* set_termbuf() writes the structure into the kernel.
*/
- void
-init_termbuf()
+void
+init_termbuf(void)
{
#ifndef USE_TERMIO
(void) ioctl(pty, TIOCGETP, (char *)&termbuf.sg);
@@ -189,20 +166,14 @@ init_termbuf()
(void) ioctl(pty, TIOCGSTATE, (char *)&termbuf.state);
# endif
#else
-# ifdef STREAMSPTY
- (void) tcgetattr(ttyfd, &termbuf);
-# else
(void) tcgetattr(pty, &termbuf);
-# endif
#endif
termbuf2 = termbuf;
}
#if defined(LINEMODE) && defined(TIOCPKT_IOCTL)
- void
-copy_termbuf(cp, len)
- char *cp;
- int len;
+void
+copy_termbuf(char *cp, size_t len)
{
if (len > sizeof(termbuf))
len = sizeof(termbuf);
@@ -211,8 +182,8 @@ copy_termbuf(cp, len)
}
#endif /* defined(LINEMODE) && defined(TIOCPKT_IOCTL) */
- void
-set_termbuf()
+void
+set_termbuf(void)
{
/*
* Only make the necessary changes.
@@ -231,11 +202,7 @@ set_termbuf()
(void) ioctl(pty, TIOCLSET, (char *)&termbuf.lflags);
#else /* USE_TERMIO */
if (memcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
-# ifdef STREAMSPTY
- (void) tcsetattr(ttyfd, TCSANOW, &termbuf);
-# else
(void) tcsetattr(pty, TCSANOW, &termbuf);
-# endif
#endif /* USE_TERMIO */
}
@@ -252,11 +219,8 @@ set_termbuf()
*/
#ifndef USE_TERMIO
- int
-spcset(func, valp, valpp)
- int func;
- cc_t *valp;
- cc_t **valpp;
+int
+spcset(int func, cc_t *valp, cc_t **valpp)
{
switch(func) {
case SLC_EOF:
@@ -327,18 +291,15 @@ spcset(func, valp, valpp)
#else /* USE_TERMIO */
- int
-spcset(func, valp, valpp)
- int func;
- cc_t *valp;
- cc_t **valpp;
-{
#define setval(a, b) *valp = termbuf.c_cc[a]; \
*valpp = &termbuf.c_cc[a]; \
return(b);
#define defval(a) *valp = ((cc_t)a); *valpp = (cc_t *)0; return(SLC_DEFAULT);
+int
+spcset(int func, cc_t *valp, cc_t **valpp)
+{
switch(func) {
case SLC_EOF:
setval(VEOF, SLC_VARIABLE);
@@ -423,7 +384,6 @@ spcset(func, valp, valpp)
}
#endif /* USE_TERMIO */
-#ifndef convex
/*
* getpty()
*
@@ -432,28 +392,16 @@ spcset(func, valp, valpp)
*
* Returns the file descriptor of the opened pty.
*/
+char alpha[] = "0123456789abcdefghijklmnopqrstuv";
char line[16];
- int
-getpty(ptynum)
-int *ptynum;
+int
+getpty(int *ptynum __unused)
{
- register int p;
-#ifdef STREAMSPTY
- int t;
- char *ptsname();
-
- p = open("/dev/ptmx", 2);
- if (p > 0) {
- grantpt(p);
- unlockpt(p);
- strcpy(line, ptsname(p));
- return(p);
- }
-
-#else /* ! STREAMSPTY */
- register char *cp, *p1, *p2;
- register int i;
+ int p;
+ const char *cp;
+ char *p1, *p2;
+ int i;
(void) strcpy(line, _PATH_DEV);
(void) strcat(line, "ptyXX");
@@ -473,7 +421,7 @@ int *ptynum;
if (stat(line, &stb) < 0)
break;
for (i = 0; i < 32; i++) {
- *p2 = "0123456789abcdefghijklmnopqrstuv"[i];
+ *p2 = alpha[i];
p = open(line, 2);
if (p > 0) {
line[5] = 't';
@@ -483,10 +431,8 @@ int *ptynum;
}
}
}
-#endif /* STREAMSPTY */
return(-1);
}
-#endif /* convex */
#ifdef LINEMODE
/*
@@ -510,38 +456,24 @@ int *ptynum;
* tty_rspeed(val) Set receive speed to val.
*/
-#ifdef convex
-static int linestate;
-#endif
- int
-tty_linemode()
+int
+tty_linemode(void)
{
-#ifndef convex
#ifndef USE_TERMIO
return(termbuf.state & TS_EXTPROC);
#else
return(termbuf.c_lflag & EXTPROC);
#endif
-#else
- return(linestate);
-#endif
}
- void
-tty_setlinemode(on)
- int on;
+void
+tty_setlinemode(int on)
{
#ifdef TIOCEXT
-# ifndef convex
set_termbuf();
-# else
- linestate = on;
-# endif
(void) ioctl(pty, TIOCEXT, (char *)&on);
-# ifndef convex
init_termbuf();
-# endif
#else /* !TIOCEXT */
# ifdef EXTPROC
if (on)
@@ -553,8 +485,8 @@ tty_setlinemode(on)
}
#endif /* LINEMODE */
- int
-tty_isecho()
+int
+tty_isecho(void)
{
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & ECHO);
@@ -563,8 +495,8 @@ tty_isecho()
#endif
}
- int
-tty_flowmode()
+int
+tty_flowmode(void)
{
#ifndef USE_TERMIO
return(((termbuf.tc.t_startc) > 0 && (termbuf.tc.t_stopc) > 0) ? 1 : 0);
@@ -573,8 +505,8 @@ tty_flowmode()
#endif
}
- int
-tty_restartany()
+int
+tty_restartany(void)
{
#ifndef USE_TERMIO
# ifdef DECCTQ
@@ -587,9 +519,8 @@ tty_restartany()
#endif
}
- void
-tty_setecho(on)
- int on;
+void
+tty_setecho(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -604,8 +535,8 @@ tty_setecho(on)
#endif
}
- int
-tty_israw()
+int
+tty_israw(void)
{
#ifndef USE_TERMIO
return(termbuf.sg.sg_flags & RAW);
@@ -614,9 +545,10 @@ tty_israw()
#endif
}
-#if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
- int
-tty_setraw(on)
+#ifdef AUTHENTICATION
+#if defined(NO_LOGIN_F) && defined(LOGIN_R)
+int
+tty_setraw(int on)
{
# ifndef USE_TERMIO
if (on)
@@ -631,10 +563,10 @@ tty_setraw(on)
# endif
}
#endif
+#endif /* AUTHENTICATION */
- void
-tty_binaryin(on)
- int on;
+void
+tty_binaryin(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -650,9 +582,8 @@ tty_binaryin(on)
#endif
}
- void
-tty_binaryout(on)
- int on;
+void
+tty_binaryout(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -672,8 +603,8 @@ tty_binaryout(on)
#endif
}
- int
-tty_isbinaryin()
+int
+tty_isbinaryin(void)
{
#ifndef USE_TERMIO
return(termbuf.lflags & LPASS8);
@@ -682,8 +613,8 @@ tty_isbinaryin()
#endif
}
- int
-tty_isbinaryout()
+int
+tty_isbinaryout(void)
{
#ifndef USE_TERMIO
return(termbuf.lflags & LLITOUT);
@@ -693,8 +624,8 @@ tty_isbinaryout()
}
#ifdef LINEMODE
- int
-tty_isediting()
+int
+tty_isediting(void)
{
#ifndef USE_TERMIO
return(!(termbuf.sg.sg_flags & (CBREAK|RAW)));
@@ -703,8 +634,8 @@ tty_isediting()
#endif
}
- int
-tty_istrapsig()
+int
+tty_istrapsig(void)
{
#ifndef USE_TERMIO
return(!(termbuf.sg.sg_flags&RAW));
@@ -713,9 +644,8 @@ tty_istrapsig()
#endif
}
- void
-tty_setedit(on)
- int on;
+void
+tty_setedit(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -730,9 +660,8 @@ tty_setedit(on)
#endif
}
- void
-tty_setsig(on)
- int on;
+void
+tty_setsig(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -746,8 +675,8 @@ tty_setsig(on)
}
#endif /* LINEMODE */
- int
-tty_issofttab()
+int
+tty_issofttab(void)
{
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & XTABS);
@@ -761,9 +690,8 @@ tty_issofttab()
#endif
}
- void
-tty_setsofttab(on)
- int on;
+void
+tty_setsofttab(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -791,8 +719,8 @@ tty_setsofttab(on)
#endif
}
- int
-tty_islitecho()
+int
+tty_islitecho(void)
{
#ifndef USE_TERMIO
return (!(termbuf.lflags & LCTLECH));
@@ -809,9 +737,8 @@ tty_islitecho()
#endif
}
- void
-tty_setlitecho(on)
- int on;
+void
+tty_setlitecho(int on)
{
#ifndef USE_TERMIO
if (on)
@@ -834,8 +761,8 @@ tty_setlitecho(on)
#endif
}
- int
-tty_iscrnl()
+int
+tty_iscrnl(void)
{
#ifndef USE_TERMIO
return (termbuf.sg.sg_flags & CRMOD);
@@ -894,12 +821,11 @@ struct termspeeds {
};
#endif /* DECODE_BAUD */
- void
-tty_tspeed(val)
- int val;
+void
+tty_tspeed(int val)
{
#ifdef DECODE_BAUD
- register struct termspeeds *tp;
+ struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
@@ -911,12 +837,11 @@ tty_tspeed(val)
#endif /* DECODE_BAUD */
}
- void
-tty_rspeed(val)
- int val;
+void
+tty_rspeed(int val)
{
#ifdef DECODE_BAUD
- register struct termspeeds *tp;
+ struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
@@ -928,42 +853,16 @@ tty_rspeed(val)
#endif /* DECODE_BAUD */
}
-#ifdef PARENT_DOES_UTMP
-# ifndef NEWINIT
-extern struct utmp wtmp;
-extern char wtmpf[];
-# else /* NEWINIT */
-int gotalarm;
-
- /* ARGSUSED */
- void
-nologinproc(sig)
- int sig;
-{
- gotalarm++;
-}
-# endif /* NEWINIT */
-#endif /* PARENT_DOES_UTMP */
-
-#ifndef NEWINIT
-# ifdef PARENT_DOES_UTMP
-extern void utmp_sig_init P((void));
-extern void utmp_sig_reset P((void));
-extern void utmp_sig_wait P((void));
-extern void utmp_sig_notify P((int));
-# endif /* PARENT_DOES_UTMP */
-#endif
-
/*
* getptyslave()
*
* Open the slave side of the pty, and do any initialization
* that is necessary.
*/
- void
-getptyslave()
+static void
+getptyslave(void)
{
- register int t = -1;
+ int t = -1;
char erase;
# ifdef LINEMODE
@@ -1000,31 +899,10 @@ getptyslave()
}
# endif
-
-# ifdef PARENT_DOES_UTMP
- /*
- * Wait for our parent to get the utmp stuff to get done.
- */
- utmp_sig_wait();
-# endif
-
t = cleanopen(line);
if (t < 0)
fatalperror(net, line);
-#ifdef STREAMSPTY
-#ifdef USE_TERMIO
- ttyfd = t;
-#endif
- if (ioctl(t, I_PUSH, "ptem") < 0)
- fatal(net, "I_PUSH ptem");
- if (ioctl(t, I_PUSH, "ldterm") < 0)
- fatal(net, "I_PUSH ldterm");
- if (ioctl(t, I_PUSH, "ttcompat") < 0)
- fatal(net, "I_PUSH ttcompat");
- if (ioctl(pty, I_PUSH, "pckt") < 0)
- fatal(net, "I_PUSH pckt");
-#endif
/*
* set up the tty modes as we like them to be.
@@ -1051,15 +929,6 @@ getptyslave()
* systems, other than 4.4BSD. In 4.4BSD the
* kernel does the initial terminal setup.
*/
-# if defined(USE_TERMIO) && (BSD <= 43)
-# ifndef OXTABS
-# define OXTABS 0
-# endif
- termbuf.c_lflag |= ECHO;
- termbuf.c_oflag |= ONLCR|OXTABS;
- termbuf.c_iflag |= ICRNL;
- termbuf.c_iflag &= ~IXOFF;
-# endif /* defined(USE_TERMIO) && (BSD <= 43) */
tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600);
tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600);
if (erase)
@@ -1077,7 +946,8 @@ getptyslave()
fatalperror(net, "login_tty");
if (net > 2)
(void) close(net);
-#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
+#ifdef AUTHENTICATION
+#if defined(NO_LOGIN_F) && defined(LOGIN_R)
/*
* Leave the pty open so that we can write out the rlogin
* protocol for /bin/login, if the authentication works.
@@ -1088,6 +958,7 @@ getptyslave()
pty = -1;
}
#endif
+#endif /* AUTHENTICATION */
}
#ifndef O_NOCTTY
@@ -1097,90 +968,28 @@ getptyslave()
* Open the specified slave side of the pty,
* making sure that we have a clean tty.
*/
- int
-cleanopen(line)
- char *line;
+int
+cleanopen(char *li)
{
- register int t;
+ int t;
-#ifndef STREAMSPTY
/*
* Make sure that other people can't open the
* slave side of the connection.
*/
- (void) chown(line, 0, 0);
- (void) chmod(line, 0600);
-#endif
+ (void) chown(li, 0, 0);
+ (void) chmod(li, 0600);
- (void) revoke(line);
+ (void) revoke(li);
t = open(line, O_RDWR|O_NOCTTY);
if (t < 0)
return(-1);
- /*
- * Hangup anybody else using this ttyp, then reopen it for
- * ourselves.
- */
-# if (BSD <= 43) && !defined(STREAMSPTY)
- (void) signal(SIGHUP, SIG_IGN);
- vhangup();
- (void) signal(SIGHUP, SIG_DFL);
- t = open(line, O_RDWR|O_NOCTTY);
- if (t < 0)
- return(-1);
-# endif
return(t);
}
-#if BSD <= 43
-
- int
-login_tty(t)
- int t;
-{
- if (setsid() < 0) {
-#ifdef ultrix
- /*
- * The setsid() may have failed because we
- * already have a pgrp == pid. Zero out
- * our pgrp and try again...
- */
- if ((setpgrp(0, 0) < 0) || (setsid() < 0))
-#endif
- fatalperror(net, "setsid()");
- }
-# ifdef TIOCSCTTY
- if (ioctl(t, TIOCSCTTY, (char *)0) < 0)
- fatalperror(net, "ioctl(sctty)");
-# else
- /*
- * We get our controlling tty assigned as a side-effect
- * of opening up a tty device. But on BSD based systems,
- * this only happens if our process group is zero. The
- * setsid() call above may have set our pgrp, so clear
- * it out before opening the tty...
- */
- (void) setpgrp(0, 0);
- close(open(line, O_RDWR));
-# endif
- if (t != 0)
- (void) dup2(t, 0);
- if (t != 1)
- (void) dup2(t, 1);
- if (t != 2)
- (void) dup2(t, 2);
- if (t > 2)
- close(t);
- return(0);
-}
-#endif /* BSD <= 43 */
-
-#ifdef NEWINIT
-char *gen_id = "fe";
-#endif
-
/*
* startslave(host)
*
@@ -1189,21 +998,12 @@ char *gen_id = "fe";
*/
/* ARGSUSED */
- void
-startslave(host, autologin, autoname)
- char *host;
- int autologin;
- char *autoname;
+void
+startslave(char *host, int autologin, char *autoname)
{
- register int i;
-#ifdef NEWINIT
- extern char *ptyip;
- struct init_request request;
- void nologinproc();
- register int n;
-#endif /* NEWINIT */
-
-#if defined(AUTHENTICATION)
+ int i;
+
+#ifdef AUTHENTICATION
if (!autoname || !autoname[0])
autologin = 0;
@@ -1213,109 +1013,20 @@ startslave(host, autologin, autoname)
}
#endif
-#ifndef NEWINIT
-# ifdef PARENT_DOES_UTMP
- utmp_sig_init();
-# endif /* PARENT_DOES_UTMP */
if ((i = fork()) < 0)
fatalperror(net, "fork");
if (i) {
-# ifdef PARENT_DOES_UTMP
- /*
- * Cray parent will create utmp entry for child and send
- * signal to child to tell when done. Child waits for signal
- * before doing anything important.
- */
- register int pid = i;
- void sigjob P((int));
-
- setpgrp();
- utmp_sig_reset(); /* reset handler to default */
- /*
- * Create utmp entry for child
- */
- (void) time(&wtmp.ut_time);
- wtmp.ut_type = LOGIN_PROCESS;
- wtmp.ut_pid = pid;
- SCPYN(wtmp.ut_user, "LOGIN");
- SCPYN(wtmp.ut_host, host);
- SCPYN(wtmp.ut_line, line + sizeof(_PATH_DEV) - 1);
- SCPYN(wtmp.ut_id, wtmp.ut_line+3);
- pututline(&wtmp);
- endutent();
- if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) {
- (void) write(i, (char *)&wtmp, sizeof(struct utmp));
- (void) close(i);
- }
- utmp_sig_notify(pid);
-# endif /* PARENT_DOES_UTMP */
} else {
- getptyslave(autologin);
+ getptyslave();
start_login(host, autologin, autoname);
/*NOTREACHED*/
}
-#else /* NEWINIT */
-
- /*
- * Init will start up login process if we ask nicely. We only wait
- * for it to start up and begin normal telnet operation.
- */
- if ((i = open(INIT_FIFO, O_WRONLY)) < 0) {
- char tbuf[128];
- (void) snprintf(tbuf, sizeof(tbuf), "Can't open %s\n", INIT_FIFO);
- fatalperror(net, tbuf);
- }
- memset((char *)&request, 0, sizeof(request));
- request.magic = INIT_MAGIC;
- SCPYN(request.gen_id, gen_id);
- SCPYN(request.tty_id, &line[8]);
- SCPYN(request.host, host);
- SCPYN(request.term_type, terminaltype ? terminaltype : "network");
- request.signal = SIGCLD;
- request.pid = getpid();
-#ifdef BFTPDAEMON
- /*
- * Are we working as the bftp daemon?
- */
- if (bftpd) {
- SCPYN(request.exec_name, BFTPPATH);
- }
-#endif /* BFTPDAEMON */
- if (write(i, (char *)&request, sizeof(request)) < 0) {
- char tbuf[128];
- (void) snprintf(tbuf, sizeof(tbuf), "Can't write to %s\n", INIT_FIFO);
- fatalperror(net, tbuf);
- }
- (void) close(i);
- (void) signal(SIGALRM, nologinproc);
- for (i = 0; ; i++) {
- char tbuf[128];
- alarm(15);
- n = read(pty, ptyip, BUFSIZ);
- if (i == 3 || n >= 0 || !gotalarm)
- break;
- gotalarm = 0;
- snprintf(tbuf, sizeof(tbuf), "telnetd: waiting for /etc/init to start login process on %s\r\n", line);
- (void) write(net, tbuf, strlen(tbuf));
- }
- if (n < 0 && gotalarm)
- fatal(net, "/etc/init didn't start login process");
- pcc += n;
- alarm(0);
- (void) signal(SIGALRM, SIG_DFL);
-
- return;
-#endif /* NEWINIT */
}
-char *envinit[3];
-extern char **environ;
-
- void
-init_env()
+void
+init_env(void)
{
- extern char *getenv();
char **envp;
envp = envinit;
@@ -1325,7 +1036,6 @@ init_env()
environ = envinit;
}
-#ifndef NEWINIT
/*
* start_login(host)
@@ -1334,42 +1044,16 @@ init_env()
* function will turn us into the login process.
*/
- void
-start_login(host, autologin, name)
- char *host;
- int autologin;
- char *name;
-{
- register char **argv;
- char **addarg(), *user;
- extern char *getenv();
-#ifdef UTMPX
- register int pid = getpid();
- struct utmpx utmpx;
-#endif
-#ifdef SOLARIS
- char *term;
- char termbuf[64];
+#ifndef AUTHENTICATION
+#define undef1 __unused
+#else
+#define undef1
#endif
-#ifdef UTMPX
- /*
- * Create utmp entry for child
- */
-
- memset(&utmpx, 0, sizeof(utmpx));
- SCPYN(utmpx.ut_user, ".telnet");
- SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1);
- utmpx.ut_pid = pid;
- utmpx.ut_id[0] = 't';
- utmpx.ut_id[1] = 'n';
- utmpx.ut_id[2] = SC_WILDC;
- utmpx.ut_id[3] = SC_WILDC;
- utmpx.ut_type = LOGIN_PROCESS;
- (void) time(&utmpx.ut_tv.tv_sec);
- if (makeutx(&utmpx) == NULL)
- fatal(net, "makeutx failed");
-#endif
+void
+start_login(char *host undef1, int autologin undef1, char *name undef1)
+{
+ char **argv;
scrub_env();
@@ -1384,8 +1068,8 @@ start_login(host, autologin, name)
argv = addarg(0, "login");
#if !defined(NO_LOGIN_H)
-
-# if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
+#ifdef AUTHENTICATION
+# if defined(NO_LOGIN_F) && defined(LOGIN_R)
/*
* Don't add the "-h host" option if we are going
* to be adding the "-r host" option down below...
@@ -1395,21 +1079,8 @@ start_login(host, autologin, name)
{
argv = addarg(argv, "-h");
argv = addarg(argv, host);
-#ifdef SOLARIS
- /*
- * SVR4 version of -h takes TERM= as second arg, or -
- */
- term = getenv("TERM");
- if (term == NULL || term[0] == 0) {
- term = "-";
- } else {
- strcpy(termbuf, "TERM=");
- strncat(termbuf, term, sizeof(termbuf) - 6);
- term = termbuf;
- }
- argv = addarg(argv, term);
-#endif
}
+#endif /* AUTHENTICATION */
#endif
#if !defined(NO_LOGIN_P)
argv = addarg(argv, "-p");
@@ -1437,15 +1108,7 @@ start_login(host, autologin, name)
argv = addarg(argv, BFTPPATH);
} else
#endif
-#if defined (SecurID)
- /*
- * don't worry about the -f that might get sent.
- * A -s is supposed to override it anyhow.
- */
- if (require_SecurID)
- argv = addarg(argv, "-s");
-#endif
-#if defined (AUTHENTICATION)
+#ifdef AUTHENTICATION
if (auth_level >= 0 && autologin == AUTH_VALID) {
# if !defined(NO_LOGIN_F)
argv = addarg(argv, "-f");
@@ -1462,7 +1125,7 @@ start_login(host, autologin, name)
*/
if (pty > 2) {
- register char *cp;
+ char *cp;
char speed[128];
int isecho, israw, xpty, len;
extern int def_rspeed;
@@ -1484,11 +1147,7 @@ start_login(host, autologin, name)
argv = addarg(argv, LOGIN_HOST);
xpty = pty;
-# ifndef STREAMSPTY
pty = 0;
-# else
- ttyfd = 0;
-# endif
init_termbuf();
isecho = tty_isecho();
israw = tty_israw();
@@ -1534,7 +1193,7 @@ start_login(host, autologin, name)
argv = addarg(argv, getenv("USER"));
#if defined(LOGIN_ARGS) && defined(NO_LOGIN_P)
{
- register char **cpp;
+ char **cpp;
for (cpp = environ; *cpp; cpp++)
argv = addarg(argv, *cpp);
}
@@ -1551,20 +1210,12 @@ start_login(host, autologin, name)
*/
unsetenv("USER");
}
-#ifdef SOLARIS
- else {
- char **p;
-
- argv = addarg(argv, ""); /* no login name */
- for (p = environ; *p; p++) {
- argv = addarg(argv, *p);
- }
- }
-#endif /* SOLARIS */
-#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
+#ifdef AUTHENTICATION
+#if defined(NO_LOGIN_F) && defined(LOGIN_R)
if (pty > 2)
close(pty);
#endif
+#endif /* AUTHENTICATION */
closelog();
if (altlogin == NULL) {
@@ -1577,12 +1228,10 @@ start_login(host, autologin, name)
/*NOTREACHED*/
}
- char **
-addarg(argv, val)
- register char **argv;
- register char *val;
+static char **
+addarg(char **argv, const char *val)
{
- register char **cpp;
+ char **cpp;
if (argv == NULL) {
/*
@@ -1605,26 +1254,25 @@ addarg(argv, val)
argv++;
cpp = &argv[(int)argv[-1] - 10];
}
- *cpp++ = val;
+ *cpp++ = strdup(val);
*cpp = 0;
return(argv);
}
-#endif /* NEWINIT */
/*
* scrub_env()
*
* We only accept the environment variables listed below.
*/
- void
-scrub_env()
+void
+scrub_env(void)
{
- static const char *reject[] = {
+ static const char *rej[] = {
"TERMCAP=/",
NULL
};
- static const char *accept[] = {
+ static const char *acc[] = {
"XAUTH=", "XAUTHORITY=", "DISPLAY=",
"TERM=",
"EDITOR=",
@@ -1641,7 +1289,7 @@ scrub_env()
for (cpp2 = cpp = environ; *cpp; cpp++) {
int reject_it = 0;
- for(p = reject; *p; p++)
+ for(p = rej; *p; p++)
if(strncmp(*cpp, *p, strlen(*p)) == 0) {
reject_it = 1;
break;
@@ -1649,7 +1297,7 @@ scrub_env()
if (reject_it)
continue;
- for(p = accept; *p; p++)
+ for(p = acc; *p; p++)
if(strncmp(*cpp, *p, strlen(*p)) == 0)
break;
if(*p != NULL)
@@ -1664,13 +1312,10 @@ scrub_env()
* This is the routine to call when we are all through, to
* clean up anything that needs to be cleaned up.
*/
- /* ARGSUSED */
- void
-cleanup(sig)
- int sig;
+/* ARGSUSED */
+void
+cleanup(int sig __unused)
{
-#ifndef PARENT_DOES_UTMP
-# if (BSD > 43) || defined(convex)
char *p;
p = line + sizeof(_PATH_DEV) - 1;
@@ -1683,173 +1328,4 @@ cleanup(sig)
(void)chown(line, 0, 0);
(void) shutdown(net, 2);
exit(1);
-# else
- void rmut();
-
- rmut();
- vhangup(); /* XXX */
- (void) shutdown(net, 2);
- exit(1);
-# endif
-#else /* PARENT_DOES_UTMP */
-# ifdef NEWINIT
- (void) shutdown(net, 2);
- exit(1);
-# else /* NEWINIT */
- rmut(line);
- close(pty);
- (void) shutdown(net, 2);
- exit(1);
-# endif /* NEWINT */
-#endif /* PARENT_DOES_UTMP */
-}
-
-#if defined(PARENT_DOES_UTMP) && !defined(NEWINIT)
-/*
- * _utmp_sig_rcv
- * utmp_sig_init
- * utmp_sig_wait
- * These three functions are used to coordinate the handling of
- * the utmp file between the server and the soon-to-be-login shell.
- * The server actually creates the utmp structure, the child calls
- * utmp_sig_wait(), until the server calls utmp_sig_notify() and
- * signals the future-login shell to proceed.
- */
-static int caught=0; /* NZ when signal intercepted */
-static void (*func)(); /* address of previous handler */
-
- void
-_utmp_sig_rcv(sig)
- int sig;
-{
- caught = 1;
- (void) signal(SIGUSR1, func);
}
-
- void
-utmp_sig_init()
-{
- /*
- * register signal handler for UTMP creation
- */
- if ((int)(func = signal(SIGUSR1, _utmp_sig_rcv)) == -1)
- fatalperror(net, "telnetd/signal");
-}
-
- void
-utmp_sig_reset()
-{
- (void) signal(SIGUSR1, func); /* reset handler to default */
-}
-
- void
-utmp_sig_wait()
-{
- /*
- * Wait for parent to write our utmp entry.
- */
- sigoff();
- while (caught == 0) {
- pause(); /* wait until we get a signal (sigon) */
- sigoff(); /* turn off signals while we check caught */
- }
- sigon(); /* turn on signals again */
-}
-
- void
-utmp_sig_notify(pid)
-{
- kill(pid, SIGUSR1);
-}
-
-#endif /* defined(PARENT_DOES_UTMP) && !defined(NEWINIT) */
-
-/*
- * rmut()
- *
- * This is the function called by cleanup() to
- * remove the utmp entry for this person.
- */
-
-#ifdef UTMPX
- void
-rmut()
-{
- register f;
- int found = 0;
- struct utmp *u, *utmp;
- int nutmp;
- struct stat statbf;
-
- struct utmpx *utxp, utmpx;
-
- /*
- * This updates the utmpx and utmp entries and make a wtmp/x entry
- */
-
- SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1);
- utxp = getutxline(&utmpx);
- if (utxp) {
- utxp->ut_type = DEAD_PROCESS;
- utxp->ut_exit.e_termination = 0;
- utxp->ut_exit.e_exit = 0;
- (void) time(&utmpx.ut_tv.tv_sec);
- utmpx.ut_tv.tv_usec = 0;
- modutx(utxp);
- }
- endutxent();
-} /* end of rmut */
-#endif
-
-#if !defined(UTMPX) && BSD <= 43
- void
-rmut()
-{
- register f;
- int found = 0;
- struct utmp *u, *utmp;
- int nutmp;
- struct stat statbf;
-
- f = open(utmpf, O_RDWR);
- if (f >= 0) {
- (void) fstat(f, &statbf);
- utmp = (struct utmp *)malloc((unsigned)statbf.st_size);
- if (!utmp)
- syslog(LOG_ERR, "utmp malloc failed");
- if (statbf.st_size && utmp) {
- nutmp = read(f, (char *)utmp, (int)statbf.st_size);
- nutmp /= sizeof(struct utmp);
-
- for (u = utmp ; u < &utmp[nutmp] ; u++) {
- if (SCMPN(u->ut_line, line+5) ||
- u->ut_name[0]==0)
- continue;
- (void) lseek(f, ((long)u)-((long)utmp), L_SET);
- SCPYN(u->ut_name, "");
- SCPYN(u->ut_host, "");
- (void) time(&u->ut_time);
- (void) write(f, (char *)u, sizeof(wtmp));
- found++;
- }
- }
- (void) close(f);
- }
- if (found) {
- f = open(wtmpf, O_WRONLY|O_APPEND);
- if (f >= 0) {
- SCPYN(wtmp.ut_line, line+5);
- SCPYN(wtmp.ut_name, "");
- SCPYN(wtmp.ut_host, "");
- (void) time(&wtmp.ut_time);
- (void) write(f, (char *)&wtmp, sizeof(wtmp));
- (void) close(f);
- }
- }
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
- line[strlen(_PATH_DEV)] = 'p';
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
-} /* end of rmut */
-#endif
diff --git a/crypto/telnet/telnetd/telnetd.8 b/crypto/telnet/telnetd/telnetd.8
index 00b444c..a884357 100644
--- a/crypto/telnet/telnetd/telnetd.8
+++ b/crypto/telnet/telnetd/telnetd.8
@@ -243,26 +243,6 @@ have been idle for some period of time to determine
if the client is still there, so that idle connections
from machines that have crashed or can no longer
be reached may be cleaned up.
-.It Fl s
-This option is only enabled if
-.Nm
-is compiled with support for
-.Tn SecurID
-cards.
-It causes the
-.Fl s
-option to be passed on to
-.Xr login 1 ,
-and thus is only useful if
-.Xr login 1
-supports the
-.Fl s
-flag to indicate that only
-.Tn SecurID
-validated logins are allowed, and is
-usually useful for controlling remote logins
-from outside of a firewall.
-.It Fl S Ar tos
.It Fl u Ar len
This option is used to specify the size of the field
in the
diff --git a/crypto/telnet/telnetd/telnetd.c b/crypto/telnet/telnetd/telnetd.c
index f141dd3..7527b7e 100644
--- a/crypto/telnet/telnetd/telnetd.c
+++ b/crypto/telnet/telnetd/telnetd.c
@@ -31,67 +31,39 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include "telnetd.h"
#include "pathnames.h"
-#include <err.h>
-#include <arpa/inet.h>
-
#include <sys/mman.h>
+#include <err.h>
#include <libutil.h>
#include <paths.h>
+#include <termcap.h>
#include <utmp.h>
-#if defined(AUTHENTICATION)
+#include <arpa/inet.h>
+
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
int auth_level = 0;
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
#include <libtelnet/misc.h>
-#if defined(SecurID)
-int require_SecurID = 0;
-#endif
char remote_hostname[MAXHOSTNAMELEN];
-int utmp_len = sizeof(remote_hostname) - 1;
+size_t utmp_len = sizeof(remote_hostname) - 1;
int registerd_host_only = 0;
-#ifdef STREAMSPTY
-# include <stropts.h>
-# include <termio.h>
-/* make sure we don't get the bsd version */
-# include "/usr/include/sys/tty.h"
-# include <sys/ptyvar.h>
-
-/*
- * Because of the way ptyibuf is used with streams messages, we need
- * ptyibuf+1 to be on a full-word boundary. The following weirdness
- * is simply to make that happen.
- */
-long ptyibufbuf[BUFSIZ/sizeof(long)+1];
-char *ptyibuf = ((char *)&ptyibufbuf[1])-1;
-char *ptyip = ((char *)&ptyibufbuf[1])-1;
-char ptyibuf2[BUFSIZ];
-unsigned char ctlbuf[BUFSIZ];
-struct strbuf strbufc, strbufd;
-
-#else /* ! STREAMPTY */
/*
* I/O data buffers,
@@ -100,25 +72,21 @@ struct strbuf strbufc, strbufd;
char ptyibuf[BUFSIZ], *ptyip = ptyibuf;
char ptyibuf2[BUFSIZ];
-# include <termcap.h>
-
-int readstream(int p, char *ibuf, int bufsize);
-void doit(struct sockaddr *who);
-int terminaltypeok(char *s);
-void startslave(char *host, int autologin, char *autoname);
-
-#endif /* ! STREAMPTY */
+int readstream(int, char *, int);
+void doit(struct sockaddr *);
+int terminaltypeok(char *);
int hostinfo = 1; /* do we print login banner? */
int debug = 0;
int keepalive = 1;
-char *altlogin;
+const char *altlogin;
void doit __P((struct sockaddr *));
int terminaltypeok __P((char *));
void startslave __P((char *, int, char *));
extern void usage P((void));
+static void _gettermname __P((void));
/*
* The string to pass to getopt(). We do it this way so
@@ -143,21 +111,29 @@ char valid_opts[] = {
#ifdef LINEMODE
'l',
#endif
-#ifdef SecurID
- 's',
-#endif
'\0'
};
int family = AF_INET;
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif /* MAXHOSTNAMELEN */
+
+char *hostname;
+char host_name[MAXHOSTNAMELEN];
+
+extern void telnet P((int, int, char *));
+
+int level;
+char user_name[256];
+
int
-main(argc, argv)
- char *argv[];
+main(int argc, char *argv[])
{
struct sockaddr_storage from;
int on = 1, fromlen;
- register int ch;
+ int ch;
#if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1;
#endif
@@ -290,12 +266,6 @@ main(argc, argv)
altlogin = optarg;
break;
-#ifdef SecurID
- case 's':
- /* SecurID required */
- require_SecurID = 1;
- break;
-#endif /* SecurID */
case 'S':
#ifdef HAS_GETTOS
if ((tos = parsetos(optarg, "tcp")) < 0)
@@ -308,9 +278,7 @@ main(argc, argv)
break;
case 'u':
- utmp_len = atoi(optarg);
- if (utmp_len < 0)
- utmp_len = -utmp_len;
+ utmp_len = (size_t)atoi(optarg);
if (utmp_len >= sizeof(remote_hostname))
utmp_len = sizeof(remote_hostname) - 1;
break;
@@ -352,7 +320,7 @@ main(argc, argv)
if (debug) {
int s, ns, foo, error;
- char *service = "telnet";
+ const char *service = "telnet";
struct addrinfo hints, *res;
if (argc > 1) {
@@ -460,9 +428,6 @@ usage()
#endif
fprintf(stderr, " [-n]");
fprintf(stderr, "\n\t");
-#ifdef SecurID
- fprintf(stderr, " [-s]");
-#endif
#ifdef HAS_GETTOS
fprintf(stderr, " [-S tos]");
#endif
@@ -484,15 +449,20 @@ static unsigned char ttytype_sbbuf[] = {
IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC, SE
};
- int
-getterminaltype(name)
- char *name;
+
+#ifndef AUTHENTICATION
+#define undef2 __unused
+#else
+#define undef2
+#endif
+
+static int
+getterminaltype(char *name undef2)
{
int retval = -1;
- void _gettermname();
settimer(baseline);
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
/*
* Handle the Authentication option before we do anything else.
*/
@@ -630,8 +600,8 @@ getterminaltype(name)
return(retval);
} /* end of getterminaltype */
- void
-_gettermname()
+static void
+_gettermname(void)
{
/*
* If the client turned off the option,
@@ -648,9 +618,8 @@ _gettermname()
ttloop();
}
- int
-terminaltypeok(s)
- char *s;
+int
+terminaltypeok(char *s)
{
char buf[1024];
@@ -669,25 +638,13 @@ terminaltypeok(s)
return(1);
}
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif /* MAXHOSTNAMELEN */
-
-char *hostname;
-char host_name[MAXHOSTNAMELEN];
-
-extern void telnet P((int, int, char *));
-
-int level;
-char user_name[256];
/*
* Get a pty, scan input lines.
*/
- void
-doit(who)
- struct sockaddr *who;
+void
+doit(struct sockaddr *who)
{
- int err;
+ int err_; /* XXX */
int ptynum;
/*
@@ -721,18 +678,24 @@ doit(who)
trimdomain(remote_hostname, UT_HOSTSIZE);
if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
- err = getnameinfo(who, who->sa_len, remote_hostname,
+ err_ = getnameinfo(who, who->sa_len, remote_hostname,
sizeof(remote_hostname), NULL, 0,
NI_NUMERICHOST|NI_WITHSCOPEID);
- /* XXX: do 'err' check */
+ /* XXX: do 'err_' check */
(void) gethostname(host_name, sizeof(host_name) - 1);
host_name[sizeof(host_name) - 1] = '\0';
hostname = host_name;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#ifdef AUTHENTICATION
+#ifdef ENCRYPTION
+/* The above #ifdefs should actually be "or"'ed, not "and"'ed.
+ * This is a byproduct of needing "#ifdef" and not "#if defined()"
+ * for unifdef. XXX MarkM
+ */
auth_encrypt_init(hostname, remote_hostname, "TELNETD", 1);
#endif
+#endif
init_env();
/*
@@ -751,10 +714,8 @@ doit(who)
* Main loop. Select from pty and network, and
* hand data to telnet receiver finite state machine.
*/
- void
-telnet(f, p, host)
- int f, p;
- char *host;
+void
+telnet(int f, int p, char *host)
{
int on = 1;
#define TABBUFSIZ 512
@@ -861,12 +822,10 @@ telnet(f, p, host)
if (my_state_is_wont(TELOPT_ECHO))
send_will(TELOPT_ECHO, 1);
-#ifndef STREAMSPTY
/*
* Turn on packet mode
*/
(void) ioctl(p, TIOCPKT, (char *)&on);
-#endif
#if defined(LINEMODE) && defined(KLUDGELINEMODE)
/*
@@ -908,7 +867,7 @@ telnet(f, p, host)
#ifdef TIOCNOTTY
{
- register int t;
+ int t;
t = open(_PATH_TTY, O_RDWR);
if (t >= 0) {
(void) ioctl(t, TIOCNOTTY, (char *)0);
@@ -926,7 +885,6 @@ telnet(f, p, host)
*/
if (getent(defent, "default") == 1) {
- char *Getstr();
char *cp=defstrs;
HE = Getstr("he", &cp);
@@ -935,9 +893,9 @@ telnet(f, p, host)
if (HN && *HN)
(void) strlcpy(host_name, HN, sizeof(host_name));
if (IM == 0)
- IM = "";
+ IM = strdup("");
} else {
- IM = DEFAULT_IM;
+ IM = strdup(DEFAULT_IM);
HE = 0;
}
edithost(HE, host_name);
@@ -968,7 +926,7 @@ telnet(f, p, host)
nfd = ((f > p) ? f : p) + 1;
for (;;) {
fd_set ibits, obits, xbits;
- register int c;
+ int c;
if (ncc < 0 && pcc < 0)
break;
@@ -1089,11 +1047,7 @@ telnet(f, p, host)
* Something to read from the pty...
*/
if (FD_ISSET(p, &ibits)) {
-#ifndef STREAMSPTY
pcc = read(p, ptyibuf, BUFSIZ);
-#else
- pcc = readstream(p, ptyibuf, BUFSIZ);
-#endif
/*
* On some systems, if we try to read something
* off the master side before the slave side is
@@ -1188,114 +1142,16 @@ telnet(f, p, host)
# endif
#endif
-#ifdef STREAMSPTY
-
-int flowison = -1; /* current state of flow: -1 is unknown */
-
-int readstream(p, ibuf, bufsize)
- int p;
- char *ibuf;
- int bufsize;
-{
- int flags = 0;
- int ret = 0;
- struct termios *tsp;
- struct termio *tp;
- struct iocblk *ip;
- char vstop, vstart;
- int ixon;
- int newflow;
-
- strbufc.maxlen = BUFSIZ;
- strbufc.buf = (char *)ctlbuf;
- strbufd.maxlen = bufsize-1;
- strbufd.len = 0;
- strbufd.buf = ibuf+1;
- ibuf[0] = 0;
-
- ret = getmsg(p, &strbufc, &strbufd, &flags);
- if (ret < 0) /* error of some sort -- probably EAGAIN */
- return(-1);
-
- if (strbufc.len <= 0 || ctlbuf[0] == M_DATA) {
- /* data message */
- if (strbufd.len > 0) { /* real data */
- return(strbufd.len + 1); /* count header char */
- } else {
- /* nothing there */
- errno = EAGAIN;
- return(-1);
- }
- }
-
- /*
- * It's a control message. Return 1, to look at the flag we set
- */
-
- switch (ctlbuf[0]) {
- case M_FLUSH:
- if (ibuf[1] & FLUSHW)
- ibuf[0] = TIOCPKT_FLUSHWRITE;
- return(1);
-
- case M_IOCTL:
- ip = (struct iocblk *) (ibuf+1);
-
- switch (ip->ioc_cmd) {
- case TCSETS:
- case TCSETSW:
- case TCSETSF:
- tsp = (struct termios *)
- (ibuf+1 + sizeof(struct iocblk));
- vstop = tsp->c_cc[VSTOP];
- vstart = tsp->c_cc[VSTART];
- ixon = tsp->c_iflag & IXON;
- break;
- case TCSETA:
- case TCSETAW:
- case TCSETAF:
- tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
- vstop = tp->c_cc[VSTOP];
- vstart = tp->c_cc[VSTART];
- ixon = tp->c_iflag & IXON;
- break;
- default:
- errno = EAGAIN;
- return(-1);
- }
-
- newflow = (ixon && (vstart == 021) && (vstop == 023)) ? 1 : 0;
- if (newflow != flowison) { /* it's a change */
- flowison = newflow;
- ibuf[0] = newflow ? TIOCPKT_DOSTOP : TIOCPKT_NOSTOP;
- return(1);
- }
- }
-
- /* nothing worth doing anything about */
- errno = EAGAIN;
- return(-1);
-}
-#endif /* STREAMSPTY */
-
/*
* Send interrupt to process on other side of pty.
* If it is in raw mode, just write NULL;
* otherwise, write intr char.
*/
- void
-interrupt()
+void
+interrupt(void)
{
ptyflush(); /* half-hearted */
-#if defined(STREAMSPTY) && defined(TIOCSIGNAL)
- /* Streams PTY style ioctl to post a signal */
- {
- int sig = SIGINT;
- (void) ioctl(pty, TIOCSIGNAL, &sig);
- (void) ioctl(pty, I_FLUSH, FLUSHR);
- }
-#else
#ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGINT);
#else /* TCSIG */
@@ -1303,7 +1159,6 @@ interrupt()
*pfrontp++ = slctab[SLC_IP].sptr ?
(unsigned char)*slctab[SLC_IP].sptr : '\177';
#endif /* TCSIG */
-#endif
}
/*
@@ -1311,8 +1166,8 @@ interrupt()
* If it is in raw mode, just write NULL;
* otherwise, write quit char.
*/
- void
-sendbrk()
+void
+sendbrk(void)
{
ptyflush(); /* half-hearted */
#ifdef TCSIG
@@ -1324,8 +1179,8 @@ sendbrk()
#endif /* TCSIG */
}
- void
-sendsusp()
+void
+sendsusp(void)
{
#ifdef SIGTSTP
ptyflush(); /* half-hearted */
@@ -1342,8 +1197,8 @@ sendsusp()
* When we get an AYT, if ^T is enabled, use that. Otherwise,
* just send back "[Yes]".
*/
- void
-recv_ayt()
+void
+recv_ayt(void)
{
#if defined(SIGINFO) && defined(TCSIG)
if (slctab[SLC_AYT].sptr && *slctab[SLC_AYT].sptr != _POSIX_VDISABLE) {
@@ -1354,8 +1209,8 @@ recv_ayt()
output_data("\r\n[Yes]\r\n");
}
- void
-doeof()
+void
+doeof(void)
{
init_termbuf();
diff --git a/crypto/telnet/telnetd/telnetd.h b/crypto/telnet/telnetd/telnetd.h
index 234b973..5bfc572 100644
--- a/crypto/telnet/telnetd/telnetd.h
+++ b/crypto/telnet/telnetd/telnetd.h
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*
* @(#)telnetd.h 8.1 (Berkeley) 6/4/93
+ * $FreeBSD$
*/
@@ -45,5 +46,4 @@
/* other external variables */
extern char **environ;
-extern int errno;
-
+extern const char *altlogin;
diff --git a/crypto/telnet/telnetd/termstat.c b/crypto/telnet/telnetd/termstat.c
index ebfc745..c7dc845 100644
--- a/crypto/telnet/telnetd/termstat.c
+++ b/crypto/telnet/telnetd/termstat.c
@@ -31,17 +31,17 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include "telnetd.h"
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -133,8 +133,8 @@ static int _terminit = 0;
* then linemode is off, if server won't SGA, then linemode
* is on.
*/
- void
-localstat()
+void
+localstat(void)
{
int need_will_echo = 0;
@@ -357,8 +357,8 @@ done:
*
* Check for changes to flow control
*/
- void
-flowstat()
+void
+flowstat(void)
{
if (his_state_is_will(TELOPT_LFLOW)) {
if (tty_flowmode() != flowmode) {
@@ -387,9 +387,8 @@ flowstat()
* at a time, and if using kludge linemode, then only linemode may be
* affected.
*/
- void
-clientstat(code, parm1, parm2)
- register int code, parm1, parm2;
+void
+clientstat(int code, int parm1, int parm2)
{
/*
@@ -464,7 +463,7 @@ clientstat(code, parm1, parm2)
case LM_MODE:
{
- register int ack, changed;
+ int ack, changed;
/*
* Client has sent along a mode mask. If it agrees with
@@ -589,8 +588,8 @@ clientstat(code, parm1, parm2)
* function is called when the pty state has been processed for the first time.
* It calls other functions that do things that were deferred in each module.
*/
- void
-defer_terminit()
+void
+defer_terminit(void)
{
/*
@@ -624,8 +623,8 @@ defer_terminit()
*
* Returns true if the pty state has been processed yet.
*/
- int
-terminit()
+int
+terminit(void)
{
return(_terminit);
diff --git a/crypto/telnet/telnetd/utility.c b/crypto/telnet/telnetd/utility.c
index f9b4e46..4bbbfb8 100644
--- a/crypto/telnet/telnetd/utility.c
+++ b/crypto/telnet/telnetd/utility.c
@@ -47,10 +47,10 @@ static const char rcsid[] =
#define PRINTOPTIONS
#include "telnetd.h"
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
#endif
-#if defined(ENCRYPTION)
+#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>
#endif
@@ -95,11 +95,10 @@ ttloop()
/*
* Check a descriptor to see if out of band data exists on it.
*/
- int
-stilloob(s)
- int s; /* socket number */
+int
+stilloob(int s)
{
- static struct timeval timeout = { 0 };
+ static struct timeval timeout = { 0, 0 };
fd_set excepts;
int value;
@@ -120,8 +119,8 @@ stilloob(s)
}
}
- void
-ptyflush()
+void
+ptyflush(void)
{
int n;
@@ -151,9 +150,8 @@ ptyflush()
* if the current address is a TELNET IAC ("I Am a Command")
* character.
*/
- char *
-nextitem(current)
- char *current;
+static char *
+nextitem(char *current)
{
if ((*current&0xff) != IAC) {
return current+1;
@@ -166,7 +164,7 @@ nextitem(current)
return current+3;
case SB: /* loop forever looking for the SE */
{
- register char *look = current+2;
+ char *look = current+2;
for (;;) {
if ((*look++&0xff) == IAC) {
@@ -181,7 +179,6 @@ nextitem(current)
}
} /* end of nextitem */
-
/*
* netclear()
*
@@ -198,10 +195,10 @@ nextitem(current)
* caller should be setting the urgent data pointer AFTER calling
* us in any case.
*/
- void
-netclear()
+void
+netclear(void)
{
- register char *thisitem, *next;
+ char *thisitem, *next;
char *good;
#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
@@ -251,8 +248,8 @@ netclear()
* Send as much data as possible to the network,
* handling requests for urgent data.
*/
- void
-netflush()
+void
+netflush(void)
{
int n;
extern int not42;
@@ -326,10 +323,8 @@ netflush()
*/
- void
-fatal(f, msg)
- int f;
- char *msg;
+void
+fatal(int f, const char *msg)
{
char buf[BUFSIZ];
@@ -349,12 +344,10 @@ fatal(f, msg)
exit(1);
}
- void
-fatalperror(f, msg)
- int f;
- char *msg;
+void
+fatalperror(int f, const char *msg)
{
- char buf[BUFSIZ], *strerror();
+ char buf[BUFSIZ];
(void) snprintf(buf, sizeof(buf), "%s: %s", msg, strerror(errno));
fatal(f, buf);
@@ -362,15 +355,13 @@ fatalperror(f, msg)
char editedhost[32];
- void
-edithost(pat, host)
- register char *pat;
- register char *host;
+void
+edithost(char *pat, char *host)
{
- register char *res = editedhost;
+ char *res = editedhost;
if (!pat)
- pat = "";
+ pat = strdup("");
while (*pat) {
switch (*pat) {
@@ -404,18 +395,16 @@ edithost(pat, host)
static char *putlocation;
- void
-putstr(s)
- register char *s;
+static void
+putstr(const char *s)
{
while (*s)
putchr(*s++);
}
- void
-putchr(cc)
- int cc;
+void
+putchr(int cc)
{
*putlocation++ = cc;
}
@@ -423,18 +412,11 @@ putchr(cc)
#ifdef __FreeBSD__
static char fmtstr[] = { "%+" };
#else
-/*
- * This is split on two lines so that SCCS will not see the M
- * between two % signs and expand it...
- */
-static char fmtstr[] = { "%l:%M\
-%P on %A, %d %B %Y" };
+static char fmtstr[] = { "%l:%M%P on %A, %d %B %Y" };
#endif
- void
-putf(cp, where)
- register char *cp;
- char *where;
+void
+putf(char *cp, char *where)
{
char *slash;
time_t t;
@@ -515,10 +497,8 @@ putf(cp, where)
/*
* Print telnet options and commands in plain text, if possible.
*/
- void
-printoption(fmt, option)
- register char *fmt;
- register int option;
+void
+printoption(const char *fmt, int option)
{
if (TELOPT_OK(option))
output_data("%s %s\r\n", fmt, TELOPT(option));
@@ -529,13 +509,10 @@ printoption(fmt, option)
return;
}
- void
-printsub(direction, pointer, length)
- char direction; /* '<' or '>' */
- unsigned char *pointer; /* where suboption data sits */
- int length; /* length of suboption data */
+void
+printsub(char direction, unsigned char *pointer, int length)
{
- register int i = 0;
+ int i = 0;
if (!(diagnostic & TD_OPTIONS))
return;
@@ -544,7 +521,7 @@ printsub(direction, pointer, length)
output_data("td: %s suboption ",
direction == '<' ? "recv" : "send");
if (length >= 3) {
- register int j;
+ int j;
i = pointer[length-2];
j = pointer[length-1];
@@ -764,8 +741,8 @@ printsub(direction, pointer, length)
break;
case TELOPT_STATUS: {
- register char *cp;
- register int j, k;
+ const char *cp;
+ int j, k;
output_data("STATUS");
@@ -866,7 +843,7 @@ printsub(direction, pointer, length)
output_data("INFO ");
env_common:
{
- register int noquote = 2;
+ int noquote = 2;
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
case NEW_ENV_VAR:
@@ -911,7 +888,7 @@ printsub(direction, pointer, length)
}
break;
-#if defined(AUTHENTICATION)
+#ifdef AUTHENTICATION
case TELOPT_AUTHENTICATION:
output_data("AUTHENTICATION");
@@ -1070,13 +1047,10 @@ printsub(direction, pointer, length)
/*
* Dump a data buffer in hex and ascii to the output data stream.
*/
- void
-printdata(tag, ptr, cnt)
- register char *tag;
- register char *ptr;
- register int cnt;
+void
+printdata(const char *tag, char *ptr, int cnt)
{
- register int i;
+ int i;
char xbuf[30];
while (cnt) {
OpenPOWER on IntegriCloud