summaryrefslogtreecommitdiffstats
path: root/crypto/telnet/libtelnet
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-08-20 12:28:40 +0000
committermarkm <markm@FreeBSD.org>2001-08-20 12:28:40 +0000
commit62fa01a04b42f494fdbb2d37f587cf04a6d1aacb (patch)
tree2ba46740530084e43c8757dfe6c194c01635f8d3 /crypto/telnet/libtelnet
parent83e59be2f658dd3a79d19c79cb5e76b14fd75880 (diff)
downloadFreeBSD-src-62fa01a04b42f494fdbb2d37f587cf04a6d1aacb.zip
FreeBSD-src-62fa01a04b42f494fdbb2d37f587cf04a6d1aacb.tar.gz
Code merge and diff reduce with "base" telnet. This is the "later"
telnet, so it was treated as the reference code, except where later commits were made to "base" telnet.
Diffstat (limited to 'crypto/telnet/libtelnet')
-rw-r--r--crypto/telnet/libtelnet/auth.h3
-rw-r--r--crypto/telnet/libtelnet/enc_des.c3
-rw-r--r--crypto/telnet/libtelnet/genget.c25
-rw-r--r--crypto/telnet/libtelnet/getent.c11
-rw-r--r--crypto/telnet/libtelnet/kerberos5.c19
-rw-r--r--crypto/telnet/libtelnet/misc-proto.h2
-rw-r--r--crypto/telnet/libtelnet/misc.c4
-rw-r--r--crypto/telnet/libtelnet/pk.c78
-rw-r--r--crypto/telnet/libtelnet/sra.c84
9 files changed, 90 insertions, 139 deletions
diff --git a/crypto/telnet/libtelnet/auth.h b/crypto/telnet/libtelnet/auth.h
index 615e8a0..2110f9e 100644
--- a/crypto/telnet/libtelnet/auth.h
+++ b/crypto/telnet/libtelnet/auth.h
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*
* @(#)auth.h 8.1 (Berkeley) 6/4/93
+ * $FreeBSD$
*/
/*
@@ -83,5 +84,5 @@ typedef struct XauthP {
#include "auth-proto.h"
-extern auth_debug_mode;
+extern int auth_debug_mode;
#endif
diff --git a/crypto/telnet/libtelnet/enc_des.c b/crypto/telnet/libtelnet/enc_des.c
index c0f669b..c72e596 100644
--- a/crypto/telnet/libtelnet/enc_des.c
+++ b/crypto/telnet/libtelnet/enc_des.c
@@ -52,7 +52,8 @@ static const char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95";
#include "key-proto.h"
#include "misc-proto.h"
-extern encrypt_debug_mode;
+extern int encrypt_debug_mode;
+void des_set_random_generator_seed(des_cblock *); /* XXX */
#define CFB 0
#define OFB 1
diff --git a/crypto/telnet/libtelnet/genget.c b/crypto/telnet/libtelnet/genget.c
index 9f56ab0..62f272a 100644
--- a/crypto/telnet/libtelnet/genget.c
+++ b/crypto/telnet/libtelnet/genget.c
@@ -50,12 +50,11 @@ static const char rcsid[] =
* the length is returned. If *s1 is a prefix of *s2,
* the length of *s1 is returned.
*/
- int
-isprefix(s1, s2)
- register char *s1, *s2;
+int
+isprefix(char *s1, char *s2)
{
char *os1;
- register char c1, c2;
+ char c1, c2;
if (*s1 == '\0')
return(-1);
@@ -73,14 +72,11 @@ isprefix(s1, s2)
static char *ambiguous; /* special return value for command routines */
- char **
-genget(name, table, stlen)
- char *name; /* name to match */
- char **table; /* name entry in table */
- int stlen;
+char **
+genget(char *name, char **table, int stlen)
{
- register char **c, **found;
- register int n;
+ char **c, **found;
+ int n;
if (name == 0)
return 0;
@@ -101,9 +97,8 @@ genget(name, table, stlen)
/*
* Function call version of Ambiguous()
*/
- int
-Ambiguous(s)
- char **s;
+int
+Ambiguous(char *s)
{
- return(s == &ambiguous);
+ return((char **)s == &ambiguous);
}
diff --git a/crypto/telnet/libtelnet/getent.c b/crypto/telnet/libtelnet/getent.c
index 7d43a8e..03bef5f 100644
--- a/crypto/telnet/libtelnet/getent.c
+++ b/crypto/telnet/libtelnet/getent.c
@@ -40,11 +40,15 @@ static const char rcsid[] =
#endif
#endif /* not lint */
+#ifdef HAS_CGETENT
+#include <stdlib.h>
+#endif
+
static char *area;
/*ARGSUSED*/
-getent(cp, name)
-char *cp, *name;
+int
+getent(char *cp, char *name)
{
#ifdef HAS_CGETENT
char *dba[2];
@@ -60,8 +64,7 @@ char *cp, *name;
#ifndef SOLARIS
/*ARGSUSED*/
char *
-Getstr(id, cpp)
-char *id, **cpp;
+Getstr(char *id, char **cpp)
{
# ifdef HAS_CGETENT
char *answer;
diff --git a/crypto/telnet/libtelnet/kerberos5.c b/crypto/telnet/libtelnet/kerberos5.c
index bcf1a9f..78264b4 100644
--- a/crypto/telnet/libtelnet/kerberos5.c
+++ b/crypto/telnet/libtelnet/kerberos5.c
@@ -9,7 +9,7 @@ static
#ifdef __STDC__
const
#endif
-char rcsid_kerberos5_c[] = "$Id: kerberos5.c,v 1.1 1997/09/04 06:11:15 markm Exp $";
+char rcsid_kerberos5_c[] = "$FreeBSD$";
#endif /* lint */
/*-
@@ -46,7 +46,7 @@ char rcsid_kerberos5_c[] = "$Id: kerberos5.c,v 1.1 1997/09/04 06:11:15 markm Exp
*/
#ifndef lint
-static char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
+static const char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
#endif /* not lint */
/*
@@ -72,15 +72,14 @@ static char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
#ifdef KRB5
#include <arpa/telnet.h>
-#include <stdio.h>
-#include <krb5/krb5.h>
-#include <krb5/asn1.h>
-#include <krb5/crc-32.h>
-#include <krb5/los-proto.h>
-#include <krb5/ext-proto.h>
#include <com_err.h>
-#include <netdb.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 */
@@ -89,7 +88,7 @@ static char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
#include "auth.h"
#include "misc.h"
-extern auth_debug_mode;
+extern int auth_debug_mode;
#ifdef FORWARD
int forward_flags = 0; /* Flags get set in telnet/main.c on -f and -F */
diff --git a/crypto/telnet/libtelnet/misc-proto.h b/crypto/telnet/libtelnet/misc-proto.h
index e5f334a..c0d2068 100644
--- a/crypto/telnet/libtelnet/misc-proto.h
+++ b/crypto/telnet/libtelnet/misc-proto.h
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*
* @(#)misc-proto.h 8.1 (Berkeley) 6/4/93
+ * $FreeBSD$
*/
/*
@@ -76,4 +77,5 @@ 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));
#endif
diff --git a/crypto/telnet/libtelnet/misc.c b/crypto/telnet/libtelnet/misc.c
index c486418..a13beb5 100644
--- a/crypto/telnet/libtelnet/misc.c
+++ b/crypto/telnet/libtelnet/misc.c
@@ -43,8 +43,12 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include "misc.h"
+#if defined(AUTHENTICATION)
#include "auth.h"
+#endif
+#ifdef ENCRYPTION
#include "encrypt.h"
+#endif /* ENCRYPTION */
char *RemoteHostName;
char *LocalHostName;
diff --git a/crypto/telnet/libtelnet/pk.c b/crypto/telnet/libtelnet/pk.c
index 9fe5441..aa0cd43 100644
--- a/crypto/telnet/libtelnet/pk.c
+++ b/crypto/telnet/libtelnet/pk.c
@@ -10,24 +10,24 @@
char secret[HEXKEYBYTES + 1];
*/
-#include <stdio.h>
#include <sys/time.h>
-#include <string.h>
-#include <fcntl.h>
#include <openssl/des.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
#include "mp.h"
#include "pk.h"
-#if defined(SOLARIS2) || defined(LINUX)
+#if defined(SOLARIS2) || defined(LINUX) || defined(__FreeBSD__)
#include <stdlib.h>
#endif
+static void adjust(char keyout[HEXKEYBYTES+1], char *keyin);
+
/*
* Choose top 128 bits of the common key to use as our idea key.
*/
-static
-extractideakey(ck, ideakey)
- MINT *ck;
- IdeaData *ideakey;
+static void
+extractideakey(MINT *ck, IdeaData *ideakey)
{
MINT *a;
MINT *z;
@@ -55,10 +55,8 @@ extractideakey(ck, ideakey)
* Choose middle 64 bits of the common key to use as our des key, possibly
* overwriting the lower order bits by setting parity.
*/
-static
-extractdeskey(ck, deskey)
- MINT *ck;
- DesData *deskey;
+static void
+extractdeskey(MINT *ck, DesData *deskey)
{
MINT *a;
MINT *z;
@@ -85,7 +83,8 @@ extractdeskey(ck, deskey)
/*
* get common key from my secret key and his public key
*/
-void common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
+void
+common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
{
MINT *public;
MINT *secret;
@@ -109,55 +108,25 @@ void common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey
mfree(modulus);
}
-
/*
* Generate a seed
*/
-void getseed(seed, seedsize)
- char *seed;
- int seedsize;
+void
+getseed(char *seed, int seedsize)
{
-#if 0
- int i,f;
- int rseed;
- struct timeval tv;
- long devrand;
-
- (void)gettimeofday(&tv, (struct timezone *)NULL);
- rseed = tv.tv_sec + tv.tv_usec;
-/* XXX What the hell is this?! */
- for (i = 0; i < 8; i++) {
- rseed ^= (rseed << 8);
- }
-
- f=open("/dev/random",O_NONBLOCK|O_RDONLY);
- if (f>=0)
- {
- read(f,&devrand,sizeof(devrand));
- close(f);
- }
- srand48((long)rseed^devrand);
-
- for (i = 0; i < seedsize; i++) {
- seed[i] = (lrand48() & 0xff);
- }
-#else
int i;
srandomdev();
for (i = 0; i < seedsize; i++) {
seed[i] = random() & 0xff;
}
-#endif
}
-
/*
* Generate a random public/secret key pair
*/
-void genkeys(public, secret)
- char *public;
- char *secret;
+void
+genkeys(char *public, char *secret)
{
int i;
@@ -200,9 +169,8 @@ void genkeys(public, secret)
/*
* Adjust the input key so that it is 0-filled on the left
*/
-adjust(keyout, keyin)
- char keyout[HEXKEYBYTES+1];
- char *keyin;
+static void
+adjust(char keyout[HEXKEYBYTES+1], char *keyin)
{
char *p;
char *s;
@@ -220,9 +188,8 @@ adjust(keyout, keyin)
static char hextab[17] = "0123456789ABCDEF";
/* given a DES key, cbc encrypt and translate input to terminated hex */
-void pk_encode(in, out, key)
-char *in,*out;
-DesData *key;
+void
+pk_encode(char *in, char *out, DesData *key)
{
char buf[256];
DesData i;
@@ -242,9 +209,8 @@ DesData *key;
}
/* given a DES key, translate input from hex and decrypt */
-void pk_decode(in, out, key)
-char *in,*out;
-DesData *key;
+void
+pk_decode(char *in, char *out, DesData *key)
{
char buf[256];
DesData i;
diff --git a/crypto/telnet/libtelnet/sra.c b/crypto/telnet/libtelnet/sra.c
index 9c033c9..72bf480 100644
--- a/crypto/telnet/libtelnet/sra.c
+++ b/crypto/telnet/libtelnet/sra.c
@@ -15,8 +15,12 @@
#if !defined(NOPAM)
#include <security/pam_appl.h>
+#else
+#include <unistd.h>
#endif
+#include <pwd.h>
+#include <syslog.h>
#include <ttyent.h>
#include "auth.h"
@@ -32,8 +36,8 @@ IdeaData ik;
extern int auth_debug_mode;
extern char *line;
-static sra_valid = 0;
-static passwd_sent = 0;
+static int sra_valid = 0;
+static int passwd_sent = 0;
static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
AUTHTYPE_SRA, };
@@ -45,12 +49,11 @@ 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 *);
+
/* support routine to send out authentication message */
-static int Data(ap, type, d, c)
-Authenticator *ap;
-int type;
-void *d;
-int c;
+static int
+Data(Authenticator *ap, int type, void *d, int c)
{
unsigned char *p = str_data + 4;
unsigned char *cd = (unsigned char *)d;
@@ -80,9 +83,8 @@ int c;
return(net_write(str_data, p - str_data));
}
-int sra_init(ap, server)
-Authenticator *ap;
-int server;
+int
+sra_init(Authenticator *ap, int server)
{
if (server)
str_data[3] = TELQUAL_REPLY;
@@ -105,8 +107,8 @@ int server;
}
/* client received a go-ahead for sra */
-int sra_send(ap)
-Authenticator *ap;
+int
+sra_send(Authenticator *ap)
{
/* send PKA */
@@ -123,10 +125,8 @@ Authenticator *ap;
}
/* server received an IS -- could be SRA KEY, USER, or PASS */
-void sra_is(ap, data, cnt)
-Authenticator *ap;
-unsigned char *data;
-int cnt;
+void
+sra_is(Authenticator *ap, unsigned char *data, int cnt)
{
int valid;
Session_Key skey;
@@ -217,13 +217,9 @@ bad:
auth_finished(ap, AUTH_REJECT);
}
-extern char *getpass();
-
/* client received REPLY -- could be SRA KEY, CONTINUE, ACCEPT, or REJECT */
-void sra_reply(ap, data, cnt)
-Authenticator *ap;
-unsigned char *data;
-int cnt;
+void
+sra_reply(Authenticator *ap, unsigned char *data, int cnt)
{
extern char *telnet_gets();
char uprompt[256],tuser[256];
@@ -322,10 +318,8 @@ int cnt;
}
}
-int sra_status(ap, name, level)
-Authenticator *ap;
-char *name;
-int level;
+int
+sra_status(Authenticator *ap, char *name, int level)
{
if (level < AUTH_USER)
return(level);
@@ -339,9 +333,8 @@ int level;
#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-void sra_printsub(data, cnt, buf, buflen)
-unsigned char *data, *buf;
-int cnt, buflen;
+void
+sra_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
{
char lbuf[32];
register int i;
@@ -405,8 +398,7 @@ struct passwd *pw;
* Helper function for sgetpwnam().
*/
char *
-sgetsave(s)
- char *s;
+sgetsave(char *s)
{
char *new = malloc((unsigned) strlen(s) + 1);
@@ -417,16 +409,8 @@ sgetsave(s)
return (new);
}
-#include <pwd.h>
-#include <syslog.h>
-#ifdef USE_SHADOW
-#include <shadow.h>
-#endif
-
-
struct passwd *
-sgetpwnam(name)
- char *name;
+sgetpwnam(char *name)
{
static struct passwd save;
register struct passwd *p;
@@ -465,8 +449,7 @@ syslog(LOG_WARNING,"%s\n",save.pw_dir);
}
static int
-isroot(user)
-char *user;
+isroot(const char *user)
{
struct passwd *pw;
@@ -476,8 +459,7 @@ char *user;
}
static int
-rootterm(ttyn)
-char *ttyn;
+rootterm(char *ttyn)
{
struct ttyent *t;
@@ -485,11 +467,8 @@ char *ttyn;
}
#ifdef NOPAM
-char *crypt();
-
-int check_user(name, pass)
-char *name;
-char *pass;
+static int
+check_user(const char *name, const char *pass)
{
register char *cp;
char *xpasswd, *salt;
@@ -535,6 +514,7 @@ 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)
{
@@ -576,10 +556,10 @@ auth_conv(int num_msg, const struct pam_message **msg,
/*
* The PAM version as a side effect may put a new username in *name.
*/
-int check_user(const char *name, const char *pass)
+static int
+check_user(const char *name, const char *pass)
{
pam_handle_t *pamh = NULL;
- const char *tmpl_user;
const void *item;
int rval;
int e;
@@ -623,7 +603,7 @@ int check_user(const char *name, const char *pass)
*/
if ((e = pam_get_item(pamh, PAM_USER, &item)) ==
PAM_SUCCESS) {
- strcpy(name, (const char *) item);
+ strcpy((char *) name, (const char *) item);
} else
syslog(LOG_ERR, "Couldn't get PAM_USER: %s",
pam_strerror(pamh, e));
OpenPOWER on IntegriCloud