summaryrefslogtreecommitdiffstats
path: root/eBones/lib
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>1995-09-07 21:39:00 +0000
committermarkm <markm@FreeBSD.org>1995-09-07 21:39:00 +0000
commit2539acf77b018acd7416a9857a14c466e55cd7e8 (patch)
tree96ff3578d62372822240f11a1567e45b880f3910 /eBones/lib
parenteed9438eb23b62f78af7685dc226228e2bf5c524 (diff)
downloadFreeBSD-src-2539acf77b018acd7416a9857a14c466e55cd7e8.zip
FreeBSD-src-2539acf77b018acd7416a9857a14c466e55cd7e8.tar.gz
Major cleanup of eBones code:
- Get all functions prototyped or at least defined before use. - Make code compile (Mostly) clean with -Wall set - Start to reduce the degree to which DES aka libdes is built in. - get all functions to the same uniform standard of definition: int foo(a, b) int a; int *b; { : } - fix numerous bugs exposed by above processes. Note - this replaces the previous work which used an unpopular function definition style.
Diffstat (limited to 'eBones/lib')
-rw-r--r--eBones/lib/libacl/Makefile4
-rw-r--r--eBones/lib/libacl/acl_files.c83
-rw-r--r--eBones/lib/libkadm/Makefile3
-rw-r--r--eBones/lib/libkadm/kadm.h16
-rw-r--r--eBones/lib/libkadm/kadm_cli_wrap.c74
-rw-r--r--eBones/lib/libkadm/kadm_stream.c80
-rw-r--r--eBones/lib/libkadm/kadm_supp.c26
-rw-r--r--eBones/lib/libkdb/krb_cache.c39
-rw-r--r--eBones/lib/libkdb/krb_dbm.c169
-rw-r--r--eBones/lib/libkdb/krb_kdb_utils.c59
-rw-r--r--eBones/lib/libkdb/krb_lib.c22
-rw-r--r--eBones/lib/libkdb/print_princ.c5
-rw-r--r--eBones/lib/libkrb/Makefile22
-rw-r--r--eBones/lib/libkrb/add_ticket.c1
-rw-r--r--eBones/lib/libkrb/create_auth_reply.c1
-rw-r--r--eBones/lib/libkrb/create_ciph.c22
-rw-r--r--eBones/lib/libkrb/create_ticket.c23
-rw-r--r--eBones/lib/libkrb/decomp_ticket.c26
-rw-r--r--eBones/lib/libkrb/des_rw.c29
-rw-r--r--eBones/lib/libkrb/dest_tkt.c6
-rw-r--r--eBones/lib/libkrb/extract_ticket.c11
-rw-r--r--eBones/lib/libkrb/fgetst.c8
-rw-r--r--eBones/lib/libkrb/get_ad_tkt.c15
-rw-r--r--eBones/lib/libkrb/get_admhst.c6
-rw-r--r--eBones/lib/libkrb/get_cred.c7
-rw-r--r--eBones/lib/libkrb/get_in_tkt.c65
-rw-r--r--eBones/lib/libkrb/get_krbhst.c6
-rw-r--r--eBones/lib/libkrb/get_krbrlm.c7
-rw-r--r--eBones/lib/libkrb/get_phost.c7
-rw-r--r--eBones/lib/libkrb/get_pw_tkt.c7
-rw-r--r--eBones/lib/libkrb/get_request.c7
-rw-r--r--eBones/lib/libkrb/get_svc_in_tkt.c6
-rw-r--r--eBones/lib/libkrb/get_tf_fullname.c8
-rw-r--r--eBones/lib/libkrb/get_tf_realm.c5
-rw-r--r--eBones/lib/libkrb/getrealm.c4
-rw-r--r--eBones/lib/libkrb/getst.c6
-rw-r--r--eBones/lib/libkrb/in_tkt.c9
-rw-r--r--eBones/lib/libkrb/k_gethostname.c5
-rw-r--r--eBones/lib/libkrb/klog.c12
-rw-r--r--eBones/lib/libkrb/kname_parse.c16
-rw-r--r--eBones/lib/libkrb/kntoln.c5
-rw-r--r--eBones/lib/libkrb/kparse.c75
-rw-r--r--eBones/lib/libkrb/krb_get_in_tkt.c31
-rw-r--r--eBones/lib/libkrb/krbglue.c12
-rw-r--r--eBones/lib/libkrb/kuserok.c5
-rw-r--r--eBones/lib/libkrb/log.c23
-rw-r--r--eBones/lib/libkrb/mk_priv.c22
-rw-r--r--eBones/lib/libkrb/mk_req.c20
-rw-r--r--eBones/lib/libkrb/mk_safe.c15
-rw-r--r--eBones/lib/libkrb/month_sname.c3
-rw-r--r--eBones/lib/libkrb/netread.c8
-rw-r--r--eBones/lib/libkrb/netwrite.c8
-rw-r--r--eBones/lib/libkrb/pkt_clen.c8
-rw-r--r--eBones/lib/libkrb/rd_err.c9
-rw-r--r--eBones/lib/libkrb/rd_priv.c20
-rw-r--r--eBones/lib/libkrb/rd_req.c29
-rw-r--r--eBones/lib/libkrb/rd_safe.c16
-rw-r--r--eBones/lib/libkrb/read_service_key.c12
-rw-r--r--eBones/lib/libkrb/recvauth.c24
-rw-r--r--eBones/lib/libkrb/save_credentials.c13
-rw-r--r--eBones/lib/libkrb/send_to_kdc.c323
-rw-r--r--eBones/lib/libkrb/sendauth.c30
-rw-r--r--eBones/lib/libkrb/stime.c3
-rw-r--r--eBones/lib/libkrb/tf_shm.c13
-rw-r--r--eBones/lib/libkrb/tf_util.c115
-rw-r--r--eBones/lib/libkrb/tkt_string.c6
-rw-r--r--eBones/lib/libkrb/util.c6
67 files changed, 1183 insertions, 598 deletions
diff --git a/eBones/lib/libacl/Makefile b/eBones/lib/libacl/Makefile
index 0ac5183..c015eaa 100644
--- a/eBones/lib/libacl/Makefile
+++ b/eBones/lib/libacl/Makefile
@@ -6,5 +6,9 @@ SHLIB_MAJOR= 2
SHLIB_MINOR= 0
CFLAGS+=-DDEBUG -DKERBEROS -I${.CURDIR}/../include -Wall
SRCS= acl_files.c
+MAN3= acl_check.3
+MLINKS= acl_check.3 acl_canonicalize_principal.3 \
+ acl_check.3 acl_exact_match.3 acl_check.3 acl_add.3 \
+ acl_check.3 acl_delete.3 acl_check.3 acl_initialize.3
.include <bsd.lib.mk>
diff --git a/eBones/lib/libacl/acl_files.c b/eBones/lib/libacl/acl_files.c
index 1f488f3..a3e1f68 100644
--- a/eBones/lib/libacl/acl_files.c
+++ b/eBones/lib/libacl/acl_files.c
@@ -19,16 +19,16 @@ static char rcsid[] =
/*** Routines for manipulating access control list files ***/
-#include <stdio.h>
+#include <unistd.h>
#include <stdlib.h>
+#include <stdio.h>
#include <strings.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include <ctype.h>
-#include <unistd.h>
-#include <krb.h>
+#include "krb.h"
__BEGIN_DECLS
static int acl_abort __P((char *, FILE *));
@@ -57,16 +57,15 @@ __END_DECLS
#define COR(a,b) ((a!=NULL)?(a):(b))
-extern int errno;
-
-/* extern time_t time(); */
-
/* Canonicalize a principal name */
/* If instance is missing, it becomes "" */
/* If realm is missing, it becomes the local realm */
/* Canonicalized form is put in canon, which must be big enough to hold
MAX_PRINCIPAL_SIZE characters */
-void acl_canonicalize_principal(char *principal, char *canon)
+void
+acl_canonicalize_principal(principal, canon)
+char *principal;
+char *canon;
{
char *dot, *atsign, *end;
int len;
@@ -127,7 +126,9 @@ void acl_canonicalize_principal(char *principal, char *canon)
/* Return new FILE pointer */
/* or NULL if file cannot be modified */
/* REQUIRES WRITE PERMISSION TO CONTAINING DIRECTORY */
-static FILE *acl_lock_file(char *acl_file)
+static FILE *
+acl_lock_file(acl_file)
+char *acl_file;
{
struct stat s;
char new[LINESIZE];
@@ -174,7 +175,10 @@ static FILE *acl_lock_file(char *acl_file)
/* Returns > 0 if lock was broken */
/* Returns < 0 if some other error occurs */
/* Closes f */
-static int acl_commit(char *acl_file, FILE *f)
+static int
+acl_commit(acl_file, f)
+char *acl_file;
+FILE *f;
{
char new[LINESIZE];
int ret;
@@ -198,7 +202,10 @@ static int acl_commit(char *acl_file, FILE *f)
* Returns 0 if successful, < 0 otherwise
* Closes f
*/
-static int acl_abort(char *acl_file, FILE *f)
+static int
+acl_abort(acl_file, f)
+char *acl_file;
+FILE *f;
{
char new[LINESIZE];
int ret;
@@ -220,7 +227,10 @@ static int acl_abort(char *acl_file, FILE *f)
/* Creates the file with permissions perm if it does not exist */
/* Erases it if it does */
/* Returns return value of acl_commit */
-int acl_initialize(char *acl_file, int perm)
+int
+acl_initialize(acl_file, perm)
+char *acl_file;
+int perm;
{
FILE *new;
int fd;
@@ -241,7 +251,9 @@ int acl_initialize(char *acl_file, int perm)
/* Eliminate all whitespace character in buf */
/* Modifies its argument */
-static void nuke_whitespace(char *buf)
+static void
+nuke_whitespace(buf)
+char *buf;
{
register char *pin, *pout;
@@ -259,7 +271,8 @@ struct hashtbl {
};
/* Make an empty hash table of size s */
-static struct hashtbl *make_hash(size)
+static struct hashtbl *
+make_hash(size)
int size;
{
struct hashtbl *h;
@@ -273,7 +286,9 @@ int size;
}
/* Destroy a hash table */
-static void destroy_hash(struct hashtbl *h)
+static void
+destroy_hash(h)
+struct hashtbl *h;
{
int i;
@@ -285,7 +300,9 @@ static void destroy_hash(struct hashtbl *h)
}
/* Compute hash value for a string */
-static unsigned hashval(char *s)
+static unsigned
+hashval(s)
+register char *s;
{
register unsigned hv;
@@ -296,7 +313,10 @@ static unsigned hashval(char *s)
}
/* Add an element to a hash table */
-static void add_hash(struct hashtbl *h, char *el)
+static void
+add_hash(h, el)
+struct hashtbl *h;
+char *el;
{
unsigned hv;
char *s;
@@ -327,7 +347,10 @@ static void add_hash(struct hashtbl *h, char *el)
}
/* Returns nonzero if el is in h */
-static int check_hash(struct hashtbl *h, char *el)
+static int
+check_hash(h, el)
+struct hashtbl *h;
+char *el;
{
unsigned hv;
@@ -354,7 +377,9 @@ static int acl_cache_next = 0;
/* Returns < 0 if unsuccessful in loading acl */
/* Returns index into acl_cache otherwise */
/* Note that if acl is already loaded, this is just a lookup */
-static int acl_load(char *name)
+static int
+acl_load(name)
+char *name;
{
int i;
FILE *f;
@@ -421,7 +446,10 @@ static int acl_load(char *name)
/* Returns nonzero if it can be determined that acl contains principal */
/* Principal is not canonicalized, and no wildcarding is done */
-int acl_exact_match(char *acl, char *principal)
+int
+acl_exact_match(acl, principal)
+char *acl;
+char *principal;
{
int idx;
@@ -432,7 +460,10 @@ int acl_exact_match(char *acl, char *principal)
/* Returns nonzero if it can be determined that acl contains principal */
/* Recognizes wildcards in acl of the form
name.*@realm, *.*@realm, and *.*@* */
-int acl_check(char *acl, char *principal)
+int
+acl_check(acl, principal)
+char *acl;
+char *principal;
{
char buf[MAX_PRINCIPAL_SIZE];
char canon[MAX_PRINCIPAL_SIZE];
@@ -458,7 +489,10 @@ int acl_check(char *acl, char *principal)
/* Adds principal to acl */
/* Wildcards are interpreted literally */
-int acl_add(char *acl, char *principal)
+int
+acl_add(acl, principal)
+char *acl;
+char *principal;
{
int idx;
int i;
@@ -490,7 +524,10 @@ int acl_add(char *acl, char *principal)
/* Removes principal from acl */
/* Wildcards are interpreted literally */
-int acl_delete(char *acl, char *principal)
+int
+acl_delete(acl, principal)
+char *acl;
+char *principal;
{
int idx;
int i;
diff --git a/eBones/lib/libkadm/Makefile b/eBones/lib/libkadm/Makefile
index 4642530..293e842 100644
--- a/eBones/lib/libkadm/Makefile
+++ b/eBones/lib/libkadm/Makefile
@@ -3,7 +3,8 @@
LIB= kadm
SRCS= kadm_err.c kadm_stream.c kadm_supp.c kadm_cli_wrap.c
-CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/../include -I${KRBOBJDIR} -DPOSIX -Wall
+CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/../include -I${KRBOBJDIR} \
+ -DPOSIX -Wall
CLEANFILES+= kadm_err.c kadm_err.h
kadm_err.c kadm_err.h: kadm_err.et
diff --git a/eBones/lib/libkadm/kadm.h b/eBones/lib/libkadm/kadm.h
index eea05df..21a23bb 100644
--- a/eBones/lib/libkadm/kadm.h
+++ b/eBones/lib/libkadm/kadm.h
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <netinet/in.h>
#include <krb.h>
+#include <krb_db.h>
#include <des.h>
/* The global structures for the client and server */
@@ -145,4 +146,19 @@ int vts_short(u_short dat, u_char **st, int loc);
int vts_long(u_long dat, u_char **st, int loc);
int vts_char(u_char dat, u_char **st, int loc);
+int kadm_cli_conn(void);
+void kadm_cli_disconn(void);
+int kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz);
+int kadm_cli_out(u_char *dat, int dat_len, u_char **ret_dat, int *ret_siz);
+int kadm_cli_keyd(des_cblock s_k, des_key_schedule s_s);
+
+int kadm_get(Kadm_vals *vals, u_char fl[4]);
+int kadm_mod(Kadm_vals *vals1, Kadm_vals *vals2);
+int kadm_add(Kadm_vals *vals);
+int kadm_change_pw(des_cblock newkey);
+int kadm_init_link(char n[], char i[], char r[]);
+void prin_vals(Kadm_vals *vals);
+void kadm_vals_to_prin(u_char fields[FLDSZ], Principal *new, Kadm_vals *old);
+void kadm_prin_to_vals(u_char fields[FLDSZ], Kadm_vals *new, Principal *old);
+
#endif KADM_DEFS
diff --git a/eBones/lib/libkadm/kadm_cli_wrap.c b/eBones/lib/libkadm/kadm_cli_wrap.c
index 3522e74..e25439d 100644
--- a/eBones/lib/libkadm/kadm_cli_wrap.c
+++ b/eBones/lib/libkadm/kadm_cli_wrap.c
@@ -20,9 +20,9 @@ static const char rcsid[] =
* kadm_cli_wrap.c the client side wrapping of the calls to the admin server
*/
-#include <sys/types.h>
#include <unistd.h>
#include <string.h>
+#include <sys/types.h>
#include <errno.h>
#include <signal.h>
#include <netdb.h>
@@ -31,12 +31,6 @@ static const char rcsid[] =
#include <kadm_err.h>
#include <krb_err.h>
-int kadm_cli_out(u_char *dat, int dat_len, u_char **ret_dat, int *ret_siz);
-int kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz);
-int kadm_cli_keyd(des_cblock *s_k, des_key_schedule s_s);
-int kadm_cli_conn(void);
-void kadm_cli_disconn(void);
-
#ifndef NULL
#define NULL 0
#endif
@@ -50,11 +44,11 @@ static Kadm_Client client_parm;
static des_cblock sess_key; /* to be filled in by kadm_cli_keyd */
static Key_schedule sess_sched;
-static void clear_secrets()
+static void
+clear_secrets()
{
bzero((char *)sess_key, sizeof(sess_key));
bzero((char *)sess_sched, sizeof(sess_sched));
- return;
}
/*
@@ -65,7 +59,11 @@ static void clear_secrets()
* data about the connection between the server and client, the services
* used, the locations and other fun things
*/
-int kadm_init_link(char n[], char i[], char r[])
+int
+kadm_init_link(n, i, r)
+char n[];
+char i[];
+char r[];
{
struct servent *sep; /* service we will talk to */
struct hostent *hop; /* host we will talk to */
@@ -104,7 +102,9 @@ int kadm_init_link(char n[], char i[], char r[])
* key. Returns no actual data from the master server, since this is called
* by a user
*/
-int kadm_change_pw(des_cblock newkey)
+int
+kadm_change_pw(newkey)
+des_cblock newkey; /* The DES form of the users key */
{
int stsize, retc; /* stream size and return code */
u_char *send_st; /* send stream */
@@ -148,7 +148,9 @@ int kadm_change_pw(des_cblock newkey)
* entry, so if you leave certain fields blank you will be able to determine
* the default values they are set to
*/
-int kadm_add(Kadm_vals *vals)
+int
+kadm_add(vals)
+Kadm_vals *vals;
{
u_char *st, *st2; /* st will hold the stream of values */
int st_len; /* st2 the final stream with opcode */
@@ -184,7 +186,10 @@ int kadm_add(Kadm_vals *vals)
* Modifies all entries corresponding to the first values so they match the
* second values. returns the values for the changed entries in vals2
*/
-int kadm_mod(Kadm_vals *vals1, Kadm_vals *vals2)
+int
+kadm_mod(vals1, vals2)
+Kadm_vals *vals1;
+Kadm_vals *vals2;
{
u_char *st, *st2; /* st will hold the stream of values */
int st_len, nlen; /* st2 the final stream with opcode */
@@ -228,7 +233,11 @@ int kadm_mod(Kadm_vals *vals1, Kadm_vals *vals2)
* this data for each matching recipient, after a count of how many such
* matches there were
*/
-int kadm_get(Kadm_vals *vals, u_char fl[4])
+int
+kadm_get(vals, fl)
+Kadm_vals *vals;
+u_char fl[4];
+
{
int loop; /* for copying the fields data */
u_char *st, *st2; /* st will hold the stream of values */
@@ -276,7 +285,12 @@ int kadm_get(Kadm_vals *vals, u_char fl[4])
* connection to the admin server. If the connection is succesfully open
* then it sends the data and waits for a reply.
*/
-int kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz)
+int
+kadm_cli_send(st_dat, st_siz, ret_dat, ret_siz)
+u_char *st_dat; /* the actual data */
+int st_siz; /* length of said data */
+u_char **ret_dat; /* to give return info */
+int *ret_siz; /* length of returned info */
{
int act_len, retdat; /* current offset into packet, return
* data */
@@ -292,7 +306,7 @@ int kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz)
(void) strncpy((char *)act_st, KADM_VERSTR, KADM_VERSIZE);
act_len = KADM_VERSIZE;
- if ((retdat = kadm_cli_keyd(&sess_key, sess_sched)) != KADM_SUCCESS) {
+ if ((retdat = kadm_cli_keyd(sess_key, sess_sched)) != KADM_SUCCESS) {
free((char *)act_st);
return retdat; /* couldnt get key working */
}
@@ -312,7 +326,7 @@ int kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz)
cksum = 0;
#else
cksum = quad_cksum((des_cblock *)priv_pak, (des_cblock *)0,
- (long)priv_len, 0, &sess_key);
+ (long)priv_len, 0, (des_cblock *)sess_key);
#endif
if ((retdat = krb_mk_req(&authent, client_parm.sname, client_parm.sinst,
client_parm.krbrlm, (long)cksum))) {
@@ -379,7 +393,10 @@ int kadm_cli_send(u_char *st_dat, int st_siz, u_char **ret_dat, int *ret_siz)
}
/* takes in the sess_key and key_schedule and sets them appropriately */
-int kadm_cli_keyd(des_cblock *s_k, des_key_schedule s_s)
+int
+kadm_cli_keyd(s_k, s_s)
+des_cblock s_k; /* session key */
+des_key_schedule s_s; /* session key schedule */
{
CREDENTIALS cred; /* to get key data */
int stat;
@@ -393,7 +410,7 @@ int kadm_cli_keyd(des_cblock *s_k, des_key_schedule s_s)
#ifdef NOENCRYPTION
bzero(s_s, sizeof(des_key_schedule));
#else
- if ((stat = key_sched(s_k,s_s)))
+ if ((stat = key_sched((des_cblock *)s_k,s_s)))
return(stat+krb_err_base);
#endif
return KADM_SUCCESS;
@@ -401,7 +418,8 @@ int kadm_cli_keyd(des_cblock *s_k, des_key_schedule s_s)
static sigtype (*opipe)();
-int kadm_cli_conn()
+int
+kadm_cli_conn()
{ /* this connects and sets my_addr */
int on = 1;
@@ -435,15 +453,21 @@ int kadm_cli_conn()
return KADM_SUCCESS;
}
-void kadm_cli_disconn()
+void
+kadm_cli_disconn()
{
(void) close(client_parm.admin_fd);
(void) signal(SIGPIPE, opipe);
- return;
}
-int kadm_cli_out(u_char *dat, int dat_len, u_char **ret_dat, int *ret_siz)
+int
+kadm_cli_out(dat, dat_len, ret_dat, ret_siz)
+u_char *dat;
+int dat_len;
+u_char **ret_dat;
+int *ret_siz;
{
+ extern int errno;
u_short dlen;
int retval;
@@ -461,7 +485,7 @@ int kadm_cli_out(u_char *dat, int dat_len, u_char **ret_dat, int *ret_siz)
return (errno); /* XXX */
if ((retval = krb_net_read(client_parm.admin_fd, (char *) &dlen,
- sizeof(u_short))) != sizeof(u_short)) {
+ sizeof(u_short)) != sizeof(u_short))) {
if (retval < 0)
return(errno); /* XXX */
else
@@ -474,7 +498,7 @@ int kadm_cli_out(u_char *dat, int dat_len, u_char **ret_dat, int *ret_siz)
return(KADM_NOMEM);
if ((retval = krb_net_read(client_parm.admin_fd, (char *) *ret_dat,
- (int) dlen)) != dlen) {
+ (int) dlen) != dlen)) {
if (retval < 0)
return(errno); /* XXX */
else
diff --git a/eBones/lib/libkadm/kadm_stream.c b/eBones/lib/libkadm/kadm_stream.c
index 02b8263..58a625a 100644
--- a/eBones/lib/libkadm/kadm_stream.c
+++ b/eBones/lib/libkadm/kadm_stream.c
@@ -29,7 +29,7 @@ static const char rcsid[] =
*/
#include <string.h>
-#include "kadm.h"
+#include <kadm.h>
#define min(a,b) (((a) < (b)) ? (a) : (b))
@@ -40,7 +40,11 @@ vals_to_stream
this function creates a byte-stream representation of the kadm_vals structure
*/
-int vals_to_stream(Kadm_vals *dt_in, u_char **dt_out)
+
+int
+vals_to_stream(dt_in, dt_out)
+Kadm_vals *dt_in;
+u_char **dt_out;
{
int vsloop, stsize; /* loop counter, stream size */
@@ -74,21 +78,32 @@ int vals_to_stream(Kadm_vals *dt_in, u_char **dt_out)
return(stsize);
}
-int build_field_header(u_char *cont, u_char **st)
+int
+build_field_header(cont, st)
+u_char *cont; /* container for fields data */
+u_char **st; /* stream */
{
*st = (u_char *) malloc (4);
bcopy((char *) cont, (char *) *st, 4);
return 4; /* return pointer to current stream location */
}
-int vts_string(char *dat, u_char **st, int loc)
+int
+vts_string(dat, st, loc)
+char *dat; /* a string to put on the stream */
+u_char **st; /* base pointer to the stream */
+int loc; /* offset into the stream for current data */
{
*st = (u_char *) realloc ((char *)*st, (unsigned) (loc + strlen(dat) + 1));
bcopy(dat, (char *)(*st + loc), strlen(dat)+1);
return strlen(dat)+1;
}
-int vts_short(u_short dat, u_char **st, int loc)
+int
+vts_short(dat, st, loc)
+u_short dat; /* the attributes field */
+u_char **st; /* a base pointer to the stream */
+int loc; /* offset into the stream for current data */
{
u_short temp; /* to hold the net order short */
@@ -98,7 +113,11 @@ int vts_short(u_short dat, u_char **st, int loc)
return sizeof(u_short);
}
-int vts_long(u_long dat, u_char **st, int loc)
+int
+vts_long(dat, st, loc)
+u_long dat; /* the attributes field */
+u_char **st; /* a base pointer to the stream */
+int loc; /* offset into the stream for current data */
{
u_long temp; /* to hold the net order short */
@@ -108,8 +127,11 @@ int vts_long(u_long dat, u_char **st, int loc)
return sizeof(u_long);
}
-
-int vts_char(u_char dat, u_char **st, int loc)
+int
+vts_char(dat, st, loc)
+u_char dat; /* the attributes field */
+u_char **st; /* a base pointer to the stream */
+int loc; /* offset into the stream for current data */
{
*st = (u_char *) realloc ((char *)*st, (unsigned)(loc + sizeof(u_char)));
(*st)[loc] = (u_char) dat;
@@ -123,7 +145,11 @@ stream_to_vals
this decodes a byte stream represntation of a vals struct into kadm_vals
*/
-int stream_to_vals(u_char *dt_in, Kadm_vals *dt_out, int maxlen)
+int
+stream_to_vals(dt_in, dt_out, maxlen)
+u_char *dt_in;
+Kadm_vals *dt_out;
+int maxlen; /* max length to use */
{
register int vsloop, stsize; /* loop counter, stream size */
register int status;
@@ -182,7 +208,11 @@ int stream_to_vals(u_char *dt_in, Kadm_vals *dt_out, int maxlen)
return stsize;
}
-int check_field_header(u_char *st, u_char *cont, int maxlen)
+int
+check_field_header(st, cont, maxlen)
+u_char *st; /* stream */
+u_char *cont; /* container for fields data */
+int maxlen;
{
if (4 > maxlen)
return(-1);
@@ -190,7 +220,13 @@ int check_field_header(u_char *st, u_char *cont, int maxlen)
return 4; /* return pointer to current stream location */
}
-int stv_string(u_char *st, char *dat, int loc, int stlen, int maxlen)
+int
+stv_string(st, dat, loc, stlen, maxlen)
+register u_char *st; /* base pointer to the stream */
+char *dat; /* a string to read from the stream */
+register int loc; /* offset into the stream for current data */
+int stlen; /* max length of string to copy in */
+int maxlen; /* max length of input stream */
{
int maxcount; /* max count of chars to copy */
@@ -203,7 +239,12 @@ int stv_string(u_char *st, char *dat, int loc, int stlen, int maxlen)
return strlen(dat)+1;
}
-int stv_short(u_char *st, u_short *dat, int loc, int maxlen)
+int
+stv_short(st, dat, loc, maxlen)
+u_char *st; /* a base pointer to the stream */
+u_short *dat; /* the attributes field */
+int loc; /* offset into the stream for current data */
+int maxlen;
{
u_short temp; /* to hold the net order short */
@@ -214,7 +255,12 @@ int stv_short(u_char *st, u_short *dat, int loc, int maxlen)
return sizeof(u_short);
}
-int stv_long(u_char *st, u_long *dat, int loc, int maxlen)
+int
+stv_long(st, dat, loc, maxlen)
+u_char *st; /* a base pointer to the stream */
+u_long *dat; /* the attributes field */
+int loc; /* offset into the stream for current data */
+int maxlen; /* maximum length of st */
{
u_long temp; /* to hold the net order short */
@@ -225,10 +271,16 @@ int stv_long(u_char *st, u_long *dat, int loc, int maxlen)
return sizeof(u_long);
}
-int stv_char(u_char *st, u_char *dat, int loc, int maxlen)
+int
+stv_char(st, dat, loc, maxlen)
+u_char *st; /* a base pointer to the stream */
+u_char *dat; /* the attributes field */
+int loc; /* offset into the stream for current data */
+int maxlen;
{
if (loc + 1 > maxlen)
return(-1);
*dat = *(st + loc);
return 1;
}
+
diff --git a/eBones/lib/libkadm/kadm_supp.c b/eBones/lib/libkadm/kadm_supp.c
index deaf63b..353fed0 100644
--- a/eBones/lib/libkadm/kadm_supp.c
+++ b/eBones/lib/libkadm/kadm_supp.c
@@ -26,16 +26,18 @@ static const char rcsid[] =
structure
*/
-#include <time.h>
#include <string.h>
-#include "kadm.h"
-#include "krb_db.h"
+#include <time.h>
+#include <kadm.h>
+#include <krb_db.h>
/*
prin_vals:
recieves : a vals structure
*/
-void prin_vals(Kadm_vals *vals)
+void
+prin_vals(vals)
+Kadm_vals *vals;
{
printf("Info in Database for %s.%s:\n", vals->name, vals->instance);
printf(" Max Life: %d Exp Date: %s\n",vals->max_life,
@@ -45,9 +47,9 @@ void prin_vals(Kadm_vals *vals)
}
#ifdef notdef
-int nierror(int s)
+nierror(s)
+int s;
{
- extern char *error_message();
printf("Kerberos admin server loses..... %s\n",error_message(s));
return(s);
}
@@ -57,7 +59,11 @@ int nierror(int s)
it copies the fields in Principal specified by fields into Kadm_vals,
i.e from old to new */
-void kadm_prin_to_vals(u_char fields[], Kadm_vals *new, Principal *old)
+void
+kadm_prin_to_vals(fields, new, old)
+u_char fields[FLDSZ];
+Kadm_vals *new;
+Principal *old;
{
bzero((char *)new, sizeof(*new));
if (IS_FIELD(KADM_NAME,fields)) {
@@ -87,7 +93,11 @@ void kadm_prin_to_vals(u_char fields[], Kadm_vals *new, Principal *old)
}
}
-void kadm_vals_to_prin(u_char fields[], Principal *new, Kadm_vals *old)
+void
+kadm_vals_to_prin(fields, new, old)
+u_char fields[FLDSZ];
+Principal *new;
+Kadm_vals *old;
{
bzero((char *)new, sizeof(*new));
diff --git a/eBones/lib/libkdb/krb_cache.c b/eBones/lib/libkdb/krb_cache.c
index 0dafb140..1c7c9ce 100644
--- a/eBones/lib/libkdb/krb_cache.c
+++ b/eBones/lib/libkdb/krb_cache.c
@@ -49,21 +49,21 @@ kerb_cache_init()
*/
int
-kerb_cache_get_principal(char *serv, char *inst, Principal *principal,
- unsigned int max)
+kerb_cache_get_principal(serv, inst, principal, max)
+ char *serv; /* could have wild card */
+ char *inst; /* could have wild card */
+ Principal *principal;
+ unsigned int max; /* max number of name structs to return */
+
{
int found = 0;
if (!init)
kerb_cache_init();
#ifdef DEBUG
- if (kerb_debug & 2)
+ if (kerb_debug & 2) {
fprintf(stderr, "cache_get_principal for %s %s max = %d\n",
serv, inst, max);
-#endif DEBUG
-
-#ifdef DEBUG
- if (kerb_debug & 2) {
if (found) {
fprintf(stderr, "cache get %s %s found %s %s\n",
serv, inst, principal->name, principal->instance);
@@ -82,7 +82,11 @@ kerb_cache_get_principal(char *serv, char *inst, Principal *principal,
*/
int
-kerb_cache_put_principal(Principal *principal, unsigned int max)
+kerb_cache_put_principal(principal, max)
+ Principal *principal;
+ unsigned int max; /* max number of principal structs to
+ * insert */
+
{
u_long i;
int count = 0;
@@ -115,7 +119,12 @@ kerb_cache_put_principal(Principal *principal, unsigned int max)
*/
int
-kerb_cache_get_dba(char *serv, char *inst, Dba *dba, unsigned int max)
+kerb_cache_get_dba(serv, inst, dba, max)
+ char *serv; /* could have wild card */
+ char *inst; /* could have wild card */
+ Dba *dba;
+ unsigned int max; /* max number of name structs to return */
+
{
int found = 0;
@@ -123,13 +132,9 @@ kerb_cache_get_dba(char *serv, char *inst, Dba *dba, unsigned int max)
kerb_cache_init();
#ifdef DEBUG
- if (kerb_debug & 2)
+ if (kerb_debug & 2) {
fprintf(stderr, "cache_get_dba for %s %s max = %d\n",
serv, inst, max);
-#endif
-
-#ifdef DEBUG
- if (kerb_debug & 2) {
if (found) {
fprintf(stderr, "cache get %s %s found %s %s\n",
serv, inst, dba->name, dba->instance);
@@ -146,7 +151,10 @@ kerb_cache_get_dba(char *serv, char *inst, Dba *dba, unsigned int max)
*/
int
-kerb_cache_put_dba(Dba *dba, unsigned int max)
+kerb_cache_put_dba(dba, max)
+ Dba *dba;
+ unsigned int max; /* max number of dba structs to insert */
+
{
u_long i;
int count = 0;
@@ -170,3 +178,4 @@ kerb_cache_put_dba(Dba *dba, unsigned int max)
}
return count;
}
+
diff --git a/eBones/lib/libkdb/krb_dbm.c b/eBones/lib/libkdb/krb_dbm.c
index 68f428b..760bd6f 100644
--- a/eBones/lib/libkdb/krb_dbm.c
+++ b/eBones/lib/libkdb/krb_dbm.c
@@ -6,7 +6,7 @@
* from: krb_dbm.c,v 4.9 89/04/18 16:15:13 wesommer Exp $
* $Id: krb_dbm.c,v 1.4 1995/08/03 17:15:42 mark Exp $
*/
-
+
#if 0
#ifndef lint
static char rcsid[] =
@@ -15,16 +15,16 @@ static char rcsid[] =
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__)
-#define NDBM_
+#define _NDBM_
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__)
-#define DBM_
+#define _DBM_
#endif
+#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/uio.h>
@@ -35,17 +35,17 @@ static char rcsid[] =
#include <strings.h>
#include <des.h>
#include <sys/file.h>
-#ifdef NDBM_
+#ifdef _NDBM_
#include <ndbm.h>
-#else /*NDBM_*/
+#else /*_NDBM_*/
#include <dbm.h>
-#endif /*NDBM_*/
+#endif /*_NDBM_*/
/* before krb_db.h */
#include <krb.h>
#include <krb_db.h>
#ifdef dbm_pagfno
-#define DBM_
+#define DB
#endif
#define KERB_DB_MAX_RETRY 5
@@ -56,14 +56,18 @@ extern long kerb_debug;
extern char *progname;
#endif
-static init = 0;
+static init = 0;
static char default_db_name[] = DBM_FILE;
static char *current_db_name = default_db_name;
-static void encode_princ_key(), decode_princ_key();
-static void encode_princ_contents(), decode_princ_contents();
-static void kerb_dbl_fini();
-static int kerb_dbl_lock();
-static void kerb_dbl_unlock();
+static void encode_princ_key(datum *key, char *name, char *instance);
+static void decode_princ_key(datum *key, char *name, char *instance);
+static void encode_princ_contents(datum *contents, Principal *principal);
+static void decode_princ_contents(datum *contents, Principal *principal);
+static void kerb_dbl_fini(void);
+static int kerb_dbl_lock(int mode);
+static void kerb_dbl_unlock(void);
+static long kerb_start_update(char *db_name);
+static long kerb_end_update(char *db_name, long age);
static struct timeval timestamp;/* current time of request */
static int non_blocking = 0;
@@ -128,7 +132,7 @@ static int non_blocking = 0;
* Instead, all routines call "dbm_next" instead.
*/
-#ifndef NDBM_
+#ifndef _NDBM_
typedef char DBM;
#define dbm_open(file, flags, mode) ((dbminit(file) == 0)?"":((char *)0))
@@ -145,7 +149,9 @@ typedef char DBM;
* Utility routine: generate name of database file.
*/
-static char *gen_dbsuffix(char *db_name, char *sfx)
+static char *gen_dbsuffix(db_name, sfx)
+ char *db_name;
+ char *sfx;
{
char *dbsuffix;
@@ -162,7 +168,8 @@ static char *gen_dbsuffix(char *db_name, char *sfx)
* initialization for data base routines.
*/
-int kerb_db_init()
+int
+kerb_db_init()
{
init = 1;
return (0);
@@ -173,7 +180,8 @@ int kerb_db_init()
* a kerb_db_init
*/
-void kerb_db_fini()
+void
+kerb_db_fini()
{
}
@@ -184,7 +192,9 @@ void kerb_db_fini()
* If the alternate database doesn't exist, nothing is changed.
*/
-int kerb_db_set_name(char *name)
+int
+kerb_db_set_name(name)
+ char *name;
{
DBM *db;
@@ -203,7 +213,8 @@ int kerb_db_set_name(char *name)
* Return the last modification time of the database.
*/
-long kerb_get_db_age()
+long
+kerb_get_db_age()
{
struct stat st;
char *okname;
@@ -228,7 +239,9 @@ long kerb_get_db_age()
* the server (for example, during slave updates).
*/
-static long kerb_start_update(char *db_name)
+static long
+kerb_start_update(db_name)
+ char *db_name;
{
char *okname = gen_dbsuffix(db_name, ".ok");
long age = kerb_get_db_age();
@@ -241,7 +254,10 @@ static long kerb_start_update(char *db_name)
return age;
}
-static long kerb_end_update(char *db_name, long age)
+static long
+kerb_end_update(db_name, age)
+ char *db_name;
+ long age;
{
int fd;
int retval = 0;
@@ -276,12 +292,15 @@ static long kerb_end_update(char *db_name, long age)
return retval;
}
-static long kerb_start_read()
+static long
+kerb_start_read()
{
return kerb_get_db_age();
}
-static long kerb_end_read(u_long age)
+static long
+kerb_end_read(age)
+ u_long age;
{
if (kerb_get_db_age() != age || age == -1) {
return -1;
@@ -293,12 +312,14 @@ static long kerb_end_read(u_long age)
* Create the database, assuming it's not there.
*/
-int kerb_db_create(char *db_name)
+int
+kerb_db_create(db_name)
+ char *db_name;
{
char *okname = gen_dbsuffix(db_name, ".ok");
int fd;
register int ret = 0;
-#ifdef NDBM_
+#ifdef _NDBM_
DBM *db;
db = dbm_open(db_name, O_RDWR|O_CREAT|O_EXCL, 0600);
@@ -341,10 +362,12 @@ int kerb_db_create(char *db_name)
* necessarily know to complete the transaction the rename, but...
*/
-int kerb_db_rename(char *from, char *to)
+int
+kerb_db_rename(from, to)
+ char *from;
+ char *to;
{
- int ok = 0;
-#ifdef DBM_
+#ifdef _DBM_
char *fromdb = gen_dbsuffix (from, ".db");
char *todb = gen_dbsuffix (to, ".db");
#else
@@ -355,8 +378,9 @@ int kerb_db_rename(char *from, char *to)
#endif
char *fromok = gen_dbsuffix(from, ".ok");
long trans = kerb_start_update(to);
+ int ok = 0;
-#ifdef DBM_
+#ifdef _DBM_
if (rename (fromdb, todb) == 0) {
#else
if ((rename (fromdir, todir) == 0)
@@ -367,7 +391,7 @@ int kerb_db_rename(char *from, char *to)
}
free (fromok);
-#ifdef DBM_
+#ifdef _DBM_
free (fromdb);
free (todb);
#else
@@ -385,15 +409,16 @@ int kerb_db_rename(char *from, char *to)
/*
* look up a principal in the data base returns number of principals
* found , and whether there were more than requested.
- char *name could have wild card
- char *inst could have wild card
- Principal *principal
- unsigned int max max number of name structs to return
- int *more where there more than 'max' tuples?
*/
-int kerb_db_get_principal(char *name, char *inst, Principal *principal,
- unsigned int max, int *more)
+int
+kerb_db_get_principal(name, inst, principal, max, more)
+ char *name; /* could have wild card */
+ char *inst; /* could have wild card */
+ Principal *principal;
+ unsigned int max; /* max number of name structs to return */
+ int *more; /* where there more than 'max' tuples? */
+
{
int found = 0, code;
extern int errorproc();
@@ -491,7 +516,12 @@ int kerb_db_get_principal(char *name, char *inst, Principal *principal,
* successfully updated.
*/
-int kerb_db_put_principal(Principal *principal, unsigned int max)
+int
+kerb_db_put_principal(principal, max)
+ Principal *principal;
+ unsigned int max; /* number of principal structs to
+ * update */
+
{
int found = 0, code;
u_long i;
@@ -536,7 +566,9 @@ int kerb_db_put_principal(Principal *principal, unsigned int max)
}
static void
-encode_princ_key(datum *key, char *name, char *instance)
+encode_princ_key(key, name, instance)
+ datum *key;
+ char *name, *instance;
{
static char keystring[ANAME_SZ + INST_SZ];
@@ -548,7 +580,9 @@ encode_princ_key(datum *key, char *name, char *instance)
}
static void
-decode_princ_key(datum *key, char *name, char *instance)
+decode_princ_key(key, name, instance)
+ datum *key;
+ char *name, *instance;
{
strncpy(name, key->dptr, ANAME_SZ);
strncpy(instance, key->dptr + ANAME_SZ, INST_SZ);
@@ -557,19 +591,25 @@ decode_princ_key(datum *key, char *name, char *instance)
}
static void
-encode_princ_contents(datum *contents, Principal *principal)
+encode_princ_contents(contents, principal)
+ datum *contents;
+ Principal *principal;
{
contents->dsize = sizeof(*principal);
contents->dptr = (char *) principal;
}
static void
-decode_princ_contents(datum *contents, Principal *principal)
+decode_princ_contents(contents, principal)
+ datum *contents;
+ Principal *principal;
{
bcopy(contents->dptr, (char *) principal, sizeof(*principal));
}
-void kerb_db_get_stat(DB_stat *s)
+void
+kerb_db_get_stat(s)
+ DB_stat *s;
{
gettimeofday(&timestamp, NULL);
@@ -587,11 +627,15 @@ void kerb_db_get_stat(DB_stat *s)
/* update local copy too */
}
-void kerb_db_put_stat(DB_stat *s)
+void
+kerb_db_put_stat(s)
+ DB_stat *s;
{
}
-void delta_stat(DB_stat *a, DB_stat *b, DB_stat *c)
+void
+delta_stat(a, b, c)
+ DB_stat *a, *b, *c;
{
/* c = a - b then b = a for the next time */
@@ -614,14 +658,23 @@ void delta_stat(DB_stat *a, DB_stat *b, DB_stat *c)
* whether there were more than requested.
*/
-int kerb_db_get_dba(char *dba_name, char *dba_inst, Dba *dba, unsigned int max,
- int *more)
+int
+kerb_db_get_dba(dba_name, dba_inst, dba, max, more)
+ char *dba_name; /* could have wild card */
+ char *dba_inst; /* could have wild card */
+ Dba *dba;
+ unsigned int max; /* max number of name structs to return */
+ int *more; /* where there more than 'max' tuples? */
+
{
*more = 0;
return (0);
}
-int kerb_db_iterate (int (*func)(), char *arg)
+int
+kerb_db_iterate (func, arg)
+ int (*func)();
+ char *arg; /* void *, really */
{
datum key, contents;
Principal *principal;
@@ -650,7 +703,8 @@ static int dblfd = -1;
static int mylock = 0;
static int inited = 0;
-static int kerb_dbl_init()
+static void
+kerb_dbl_init()
{
if (!inited) {
char *filename = gen_dbsuffix (current_db_name, ".ok");
@@ -663,10 +717,10 @@ static int kerb_dbl_init()
free(filename);
inited++;
}
- return (0);
}
-static void kerb_dbl_fini()
+static void
+kerb_dbl_fini()
{
close(dblfd);
dblfd = -1;
@@ -674,7 +728,9 @@ static void kerb_dbl_fini()
mylock = 0;
}
-static int kerb_dbl_lock(int mode)
+static int
+kerb_dbl_lock(mode)
+ int mode;
{
int flock_mode;
@@ -706,7 +762,8 @@ static int kerb_dbl_lock(int mode)
return 0;
}
-static void kerb_dbl_unlock()
+static void
+kerb_dbl_unlock()
{
if (!mylock) { /* lock already unlocked */
fprintf(stderr, "Kerberos database lock not locked when unlocking.\n");
@@ -722,7 +779,9 @@ static void kerb_dbl_unlock()
mylock = 0;
}
-int kerb_db_set_lockmode(int mode)
+int
+kerb_db_set_lockmode(mode)
+ int mode;
{
int old = non_blocking;
non_blocking = mode;
diff --git a/eBones/lib/libkdb/krb_kdb_utils.c b/eBones/lib/libkdb/krb_kdb_utils.c
index 275cc39..0256348 100644
--- a/eBones/lib/libkdb/krb_kdb_utils.c
+++ b/eBones/lib/libkdb/krb_kdb_utils.c
@@ -20,17 +20,20 @@ static char rcsid[] =
#endif lint
#endif
+#include <des.h>
+#include <krb.h>
+#include <krb_db.h>
+#include <kdc.h>
#include <stdio.h>
-#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/file.h>
-#include <krb.h>
-#include <krb_db.h>
-#include <kdc.h>
-long kdb_get_master_key(int prompt, C_Block master_key,
- Key_schedule master_key_sched)
+long
+kdb_get_master_key(prompt, master_key, master_key_sched)
+ int prompt;
+ C_Block master_key;
+ Key_schedule master_key_sched;
{
int kfile;
@@ -39,7 +42,7 @@ long kdb_get_master_key(int prompt, C_Block master_key,
placebo_read_password(master_key,
"\nEnter Kerberos master key: ", 0);
#else
- des_read_password((C_Block *)master_key,
+ des_read_password((des_cblock *)master_key,
"\nEnter Kerberos master key: ", 0);
#endif
printf ("\n");
@@ -57,33 +60,21 @@ long kdb_get_master_key(int prompt, C_Block master_key,
}
#ifndef NOENCRYPTION
- key_sched((C_Block *)master_key,master_key_sched);
+ key_sched((des_cblock *)master_key,master_key_sched);
#endif
return (0);
}
-/* The old algorithm used the key schedule as the initial vector which
- was byte order depedent ... */
-
-void kdb_encrypt_key (C_Block in, C_Block out, C_Block master_key,
- Key_schedule master_key_sched, int e_d_flag)
-{
-
-#ifdef NOENCRYPTION
- bcopy(in, out, sizeof(C_Block));
-#else
- pcbc_encrypt((C_Block *)in,(C_Block *)out,(long)sizeof(C_Block),
- master_key_sched,(C_Block *)master_key, e_d_flag);
-#endif
-}
-
/* The caller is reasponsible for cleaning up the master key and sched,
even if we can't verify the master key */
/* Returns master key version if successful, otherwise -1 */
-long kdb_verify_master_key (C_Block master_key, Key_schedule master_key_sched,
- FILE *out)
+long
+kdb_verify_master_key (master_key, master_key_sched, out)
+ C_Block master_key;
+ Key_schedule master_key_sched;
+ FILE *out; /* setting this to non-null be do output */
{
C_Block key_from_db;
Principal principal_data[1];
@@ -137,3 +128,21 @@ long kdb_verify_master_key (C_Block master_key, Key_schedule master_key_sched,
return (master_key_version);
}
+
+/* The old algorithm used the key schedule as the initial vector which
+ was byte order depedent ... */
+
+void
+kdb_encrypt_key (in, out, master_key, master_key_sched, e_d_flag)
+ C_Block in, out, master_key;
+ Key_schedule master_key_sched;
+ int e_d_flag;
+{
+
+#ifdef NOENCRYPTION
+ bcopy(in, out, sizeof(C_Block));
+#else
+ pcbc_encrypt((des_cblock*)in,(des_cblock*)out,(long)sizeof(C_Block),
+ master_key_sched,(des_cblock*)master_key,e_d_flag);
+#endif
+}
diff --git a/eBones/lib/libkdb/krb_lib.c b/eBones/lib/libkdb/krb_lib.c
index 5610dbb..2cf4fb8 100644
--- a/eBones/lib/libkdb/krb_lib.c
+++ b/eBones/lib/libkdb/krb_lib.c
@@ -78,8 +78,13 @@ kerb_fini()
*/
int
-kerb_get_principal(char *name, char *inst, Principal *principal,
- unsigned int max, int *more)
+kerb_get_principal(name, inst, principal, max, more)
+ char *name; /* could have wild card */
+ char *inst; /* could have wild card */
+ Principal *principal;
+ unsigned int max; /* max number of name structs to return */
+ int *more; /* more tuples than room for */
+
{
int found = 0;
#ifdef CACHE
@@ -131,7 +136,10 @@ kerb_get_principal(char *name, char *inst, Principal *principal,
}
/* principals */
-int kerb_put_principal(Principal *principal, unsigned int n)
+int
+kerb_put_principal(principal, n)
+ Principal *principal;
+ unsigned int n; /* number of principal structs to write */
{
long time();
struct tm *tp, *localtime();
@@ -176,7 +184,13 @@ int kerb_put_principal(Principal *principal, unsigned int n)
}
int
-kerb_get_dba(char *name, char *inst, Dba *dba, unsigned int max, int *more)
+kerb_get_dba(name, inst, dba, max, more)
+ char *name; /* could have wild card */
+ char *inst; /* could have wild card */
+ Dba *dba;
+ unsigned int max; /* max number of name structs to return */
+ int *more; /* more tuples than room for */
+
{
int found = 0;
#ifdef CACHE
diff --git a/eBones/lib/libkdb/print_princ.c b/eBones/lib/libkdb/print_princ.c
index b1d1ca9..64e9106 100644
--- a/eBones/lib/libkdb/print_princ.c
+++ b/eBones/lib/libkdb/print_princ.c
@@ -15,6 +15,7 @@ static char rcsid[] =
#endif
#include <stdio.h>
+#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include <strings.h>
@@ -26,7 +27,9 @@ extern int debug;
long kerb_debug;
static struct tm *time_p;
-void krb_print_principal(Principal *a_n)
+void
+krb_print_principal(a_n)
+ Principal *a_n;
{
/* run-time database does not contain string versions */
time_p = localtime(&(a_n->exp_date));
diff --git a/eBones/lib/libkrb/Makefile b/eBones/lib/libkrb/Makefile
index 10ef4ba..b09b96b 100644
--- a/eBones/lib/libkrb/Makefile
+++ b/eBones/lib/libkrb/Makefile
@@ -31,4 +31,26 @@ beforeinstall:
install -c -o ${BINOWN} -g ${BINGRP} -m 444 krb_err.h \
${DESTDIR}/usr/include/kerberosIV
+MAN3= krb.3 krb_realmofhost.3 krb_sendauth.3 krb_set_tkt_string.3 \
+ kuserok.3 tf_util.3
+
+MLINKS= krb.3 krb_mk_req.3 krb.3 krb_rd_req.3 krb.3 krb_kntoln.3 \
+ krb.3 krb_set_key.3 krb.3 krb_get_cred.3 krb.3 krb_mk_priv.3 \
+ krb.3 krb_rd_priv.3 krb.3 krb_mk_safe.3 krb.3 krb_rd_safe.3 \
+ krb.3 krb_mk_err.3 krb.3 krb_rd_err.3 krb.3 krb_ck_repl.3
+
+MLINKS+=krb_realmofhost.3 krb_get_phost.3 krb_realmofhost.3 krb_get_krbhst.3 \
+ krb_realmofhost.3 krb_get_admhst.3 krb_realmofhost.3 krb_get_lrealm.3
+
+MLINKS+=krb_realmofhost.3 realm.3
+
+MLINKS+=krb_sendauth.3 krb_recvauth.3 krb_sendauth.3 krb_net_write.3 \
+ krb_sendauth.3 krb_net_read.3
+
+MLINKS+=krb_sendauth.3 ksend.3
+
+MLINKS+=tf_util.3 tf_init.3 tf_util.3 tf_get_pname.3 \
+ tf_util.3 tf_get_pinst.3 tf_util.3 tf_get_cred.3 \
+ tf_util.3 tf_close.3
+
.include <bsd.lib.mk>
diff --git a/eBones/lib/libkrb/add_ticket.c b/eBones/lib/libkrb/add_ticket.c
index bec7cd8..14ef47c 100644
--- a/eBones/lib/libkrb/add_ticket.c
+++ b/eBones/lib/libkrb/add_ticket.c
@@ -46,6 +46,7 @@ static char rcsid[] =
/* XXX they aren't all used; to avoid incompatible changes we will
* fool lint for the moment */
/*ARGSUSED */
+int
add_ticket(cipher,n,session,lifetime,sname,instance,realm,kvno,ticket)
KTEXT cipher; /* Ciphertext info for ticket */
char *sname; /* Service name */
diff --git a/eBones/lib/libkrb/create_auth_reply.c b/eBones/lib/libkrb/create_auth_reply.c
index ea3afd6..e304b17 100644
--- a/eBones/lib/libkrb/create_auth_reply.c
+++ b/eBones/lib/libkrb/create_auth_reply.c
@@ -15,7 +15,6 @@ static char *rcsid =
#endif /* lint */
#endif
-#include <stdio.h>
#include <krb.h>
#include <prot.h>
#include <strings.h>
diff --git a/eBones/lib/libkrb/create_ciph.c b/eBones/lib/libkrb/create_ciph.c
index a383604..7fb93e3 100644
--- a/eBones/lib/libkrb/create_ciph.c
+++ b/eBones/lib/libkrb/create_ciph.c
@@ -56,9 +56,19 @@ static char *rcsid =
*
*/
-int create_ciph(KTEXT c, des_cblock session, char *service, char *instance,
- char *realm, unsigned long life, int kvno, KTEXT tkt,
- unsigned long kdc_time, des_cblock key)
+int
+create_ciph(c, session, service, instance, realm, life, kvno, tkt,
+ kdc_time, key)
+ KTEXT c; /* Text block to hold ciphertext */
+ C_Block session; /* Session key to send to user */
+ char *service; /* Service name on ticket */
+ char *instance; /* Instance name on ticket */
+ char *realm; /* Realm of this KDC */
+ unsigned long life; /* Lifetime of the ticket */
+ int kvno; /* Key version number for service */
+ KTEXT tkt; /* The ticket for the service */
+ unsigned long kdc_time; /* KDC time */
+ C_Block key; /* Key to encrypt ciphertext with */
{
char *ptr;
Key_schedule key_s;
@@ -93,9 +103,9 @@ int create_ciph(KTEXT c, des_cblock session, char *service, char *instance,
c->length = (((ptr - (char *) c->dat) + 7) / 8) * 8;
#ifndef NOENCRYPTION
- key_sched((des_cblock *)key,key_s);
- pcbc_encrypt((des_cblock *)c->dat,(des_cblock *)c->dat,(long) c->length,
- key_s,(des_cblock *)key,ENCRYPT);
+ key_sched((C_Block *)key,key_s);
+ pcbc_encrypt((C_Block *)c->dat,(C_Block *)c->dat,(long) c->length,key_s,
+ (C_Block *)key,ENCRYPT);
#endif /* NOENCRYPTION */
return(KSUCCESS);
diff --git a/eBones/lib/libkrb/create_ticket.c b/eBones/lib/libkrb/create_ticket.c
index 264d1ac..e1d6974 100644
--- a/eBones/lib/libkrb/create_ticket.c
+++ b/eBones/lib/libkrb/create_ticket.c
@@ -70,9 +70,20 @@ static char rcsid[] =
*
*/
-int krb_create_ticket(KTEXT tkt, unsigned char flags, char *pname,
- char *pinstance, char *prealm, long paddress, char *session, short life,
- long time_sec, char *sname, char *sinstance, des_cblock key)
+int krb_create_ticket(tkt, flags, pname, pinstance, prealm, paddress,
+ session, life, time_sec, sname, sinstance, key)
+ KTEXT tkt; /* Gets filled in by the ticket */
+ unsigned char flags; /* Various Kerberos flags */
+ char *pname; /* Principal's name */
+ char *pinstance; /* Principal's instance */
+ char *prealm; /* Principal's authentication domain */
+ long paddress; /* Net address of requesting entity */
+ char *session; /* Session key inserted in ticket */
+ short life; /* Lifetime of the ticket */
+ long time_sec; /* Issue time and date */
+ char *sname; /* Service Name */
+ char *sinstance; /* Instance Name */
+ C_Block key; /* Service's secret key */
{
Key_schedule key_s;
register char *data; /* running index into ticket */
@@ -113,9 +124,9 @@ int krb_create_ticket(KTEXT tkt, unsigned char flags, char *pname,
}
#ifndef NOENCRYPTION
- key_sched((des_cblock *)key,key_s);
- pcbc_encrypt((des_cblock *)tkt->dat,(des_cblock *)tkt->dat,
- (long)tkt->length,key_s,(des_cblock *)key,ENCRYPT);
+ key_sched((C_Block *)key,key_s);
+ pcbc_encrypt((C_Block *)tkt->dat,(C_Block *)tkt->dat,(long)tkt->length,
+ key_s,(C_Block *)key,ENCRYPT);
#endif
return 0;
}
diff --git a/eBones/lib/libkrb/decomp_ticket.c b/eBones/lib/libkrb/decomp_ticket.c
index ab46450..04316ad 100644
--- a/eBones/lib/libkrb/decomp_ticket.c
+++ b/eBones/lib/libkrb/decomp_ticket.c
@@ -46,18 +46,32 @@ static char *rcsid =
* See create_ticket.c for the format of the ticket packet.
*/
-int decomp_ticket(KTEXT tkt, unsigned char *flags, char *pname,
- char *pinstance, char *prealm, unsigned long *paddress, des_cblock session,
- int *life, unsigned long *time_sec, char *sname, char *sinstance,
- des_cblock key, des_key_schedule key_s)
+int
+decomp_ticket(tkt, flags, pname, pinstance, prealm, paddress, session,
+ life, time_sec, sname, sinstance, key, key_s)
+ KTEXT tkt; /* The ticket to be decoded */
+ unsigned char *flags; /* Kerberos ticket flags */
+ char *pname; /* Authentication name */
+ char *pinstance; /* Principal's instance */
+ char *prealm; /* Principal's authentication domain */
+ unsigned long *paddress; /* Net address of entity
+ * requesting ticket */
+ C_Block session; /* Session key inserted in ticket */
+ int *life; /* Lifetime of the ticket */
+ unsigned long *time_sec; /* Issue time and date */
+ char *sname; /* Service name */
+ char *sinstance; /* Service instance */
+ C_Block key; /* Service's secret key
+ * (to decrypt the ticket) */
+ Key_schedule key_s; /* The precomputed key schedule */
{
static int tkt_swap_bytes;
unsigned char *uptr;
char *ptr = (char *)tkt->dat;
#ifndef NOENCRYPTION
- pcbc_encrypt((des_cblock *)tkt->dat,(des_cblock *)tkt->dat,
- (long)tkt->length,key_s,(des_cblock *)key,DECRYPT);
+ pcbc_encrypt((C_Block *)tkt->dat,(C_Block *)tkt->dat,(long)tkt->length,
+ key_s,(C_Block *)key,DECRYPT);
#endif /* ! NOENCRYPTION */
*flags = *ptr; /* get flags byte */
diff --git a/eBones/lib/libkrb/des_rw.c b/eBones/lib/libkrb/des_rw.c
index 774e62b..5b339ee 100644
--- a/eBones/lib/libkrb/des_rw.c
+++ b/eBones/lib/libkrb/des_rw.c
@@ -1,4 +1,4 @@
-/* -
+/*
* Copyright (c) 1994 Geoffrey M. Rehmet, Rhodes University
* All rights reserved.
*
@@ -100,10 +100,10 @@
#include <sys/param.h>
#include <sys/types.h>
-#include <krb.h>
#include <des.h>
+#include <krb.h>
-static bit_64 des_key;
+static des_cblock des_key;
static des_key_schedule key_schedule;
/*
@@ -120,10 +120,15 @@ static u_char *buff_ptr = buffer;
* inkey is the initial vector for the DES encryption, while insched is
* the DES key, in unwrapped form.
*/
-void des_set_key(bit_64 *inkey, u_char *insched)
+
+int
+des_set_key(inkey, insched)
+ des_cblock *inkey;
+ des_key_schedule insched;
{
- bcopy(inkey, &des_key, sizeof(bit_64));
+ bcopy(inkey, des_key, sizeof(des_cblock));
bcopy(insched, &key_schedule, sizeof(des_key_schedule));
+ return 0;
}
/*
@@ -136,7 +141,11 @@ void des_clear_key()
bzero(&key_schedule, sizeof(des_key_schedule));
}
-int des_read(int fd, char *buf, int len)
+int
+des_read(fd, buf, len)
+ int fd;
+ register char * buf;
+ int len;
{
int msg_length; /* length of actual message data */
int pad_length; /* length of padded message */
@@ -161,7 +170,7 @@ int des_read(int fd, char *buf, int len)
}
}
- nread = krb_net_read(fd,(char *)&msg_length, sizeof(msg_length));
+ nread = krb_net_read(fd, (char *)&msg_length, sizeof(msg_length));
if(nread != (int)(sizeof(msg_length)))
return(0);
@@ -200,7 +209,11 @@ int des_read(int fd, char *buf, int len)
* Write a message onto a file descriptor (generally a socket), using
* DES to encrypt the message.
*/
-int des_write(int fd, char *buf, int len)
+int
+des_write(fd, buf, len)
+ int fd;
+ char * buf;
+ int len;
{
static int seeded = 0;
char garbage[8];
diff --git a/eBones/lib/libkrb/dest_tkt.c b/eBones/lib/libkrb/dest_tkt.c
index 6e6082e..df04be0 100644
--- a/eBones/lib/libkrb/dest_tkt.c
+++ b/eBones/lib/libkrb/dest_tkt.c
@@ -15,10 +15,9 @@ static char *rcsid =
#endif /* lint */
#endif
+#include <unistd.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <krb.h>
#include <sys/file.h>
#include <sys/types.h>
@@ -37,7 +36,8 @@ static char *rcsid =
* The ticket file (TKT_FILE) is defined in "krb.h".
*/
-int dest_tkt()
+int
+dest_tkt()
{
char *file = TKT_FILE;
int i,fd;
diff --git a/eBones/lib/libkrb/extract_ticket.c b/eBones/lib/libkrb/extract_ticket.c
index 97e8432..8ad3097 100644
--- a/eBones/lib/libkrb/extract_ticket.c
+++ b/eBones/lib/libkrb/extract_ticket.c
@@ -27,8 +27,15 @@ static char *rcsid =
* session, liftime and kvno.
*/
-void extract_ticket(KTEXT cipher, int n, char *session, int *lifetime,
- int *kvno, char *realm, KTEXT ticket)
+void
+extract_ticket(cipher,n,session,lifetime,kvno,realm,ticket)
+ KTEXT cipher; /* The ciphertext */
+ int n; /* Which ticket */
+ char *session; /* The session key for this tkt */
+ int *lifetime; /* The life of this ticket */
+ int *kvno; /* The kvno for the service */
+ char *realm; /* Realm in which tkt issued */
+ KTEXT ticket; /* The ticket itself */
{
char *ptr;
int i;
diff --git a/eBones/lib/libkrb/fgetst.c b/eBones/lib/libkrb/fgetst.c
index 4c6a364..796caca 100644
--- a/eBones/lib/libkrb/fgetst.c
+++ b/eBones/lib/libkrb/fgetst.c
@@ -25,9 +25,13 @@ static char rcsid[] =
* returns the number of characters read, including the null terminator.
*/
-int fgetst(FILE *f, char *s, int n)
+int
+fgetst(f, s, n)
+ FILE *f;
+ register char *s;
+ int n;
{
- register count = n;
+ register int count = n;
int ch; /* NOT char; otherwise you don't see EOF */
while ((ch = getc(f)) != EOF && ch && --count) {
diff --git a/eBones/lib/libkrb/get_ad_tkt.c b/eBones/lib/libkrb/get_ad_tkt.c
index ad76a4f..f96644a 100644
--- a/eBones/lib/libkrb/get_ad_tkt.c
+++ b/eBones/lib/libkrb/get_ad_tkt.c
@@ -27,6 +27,8 @@ static char rcsid[] =
#include <sys/time.h>
#include <sys/types.h>
+extern int krb_debug;
+
struct timeval tt_local = { 0, 0 };
int swap_bytes;
@@ -65,7 +67,12 @@ unsigned long rep_err_code;
* extraction macros like pkt_version(), pkt_msg_type(), etc.
*/
-int get_ad_tkt(char *service, char *sinstance, char *realm, int lifetime)
+int
+get_ad_tkt(service,sinstance,realm,lifetime)
+ char *service;
+ char *sinstance;
+ char *realm;
+ int lifetime;
{
static KTEXT_ST pkt_st;
KTEXT pkt = & pkt_st; /* Packet to KDC */
@@ -177,9 +184,9 @@ int get_ad_tkt(char *service, char *sinstance, char *realm, int lifetime)
bcopy((char *) pkt_cipher(rpkt),(char *) (cip->dat),cip->length);
#ifndef NOENCRYPTION
- key_sched((des_cblock *)cr.session,key_s);
- pcbc_encrypt((des_cblock *)cip->dat,(des_cblock *)cip->dat,
- (long)cip->length,key_s,(des_cblock *)cr.session,DECRYPT);
+ key_sched((C_Block *)cr.session,key_s);
+ pcbc_encrypt((C_Block *)cip->dat,(C_Block *)cip->dat,(long)cip->length,
+ key_s,(C_Block *)cr.session,DECRYPT);
#endif
/* Get rid of all traces of key */
bzero((char *) cr.session, sizeof(key));
diff --git a/eBones/lib/libkrb/get_admhst.c b/eBones/lib/libkrb/get_admhst.c
index b33b828..a01a40f 100644
--- a/eBones/lib/libkrb/get_admhst.c
+++ b/eBones/lib/libkrb/get_admhst.c
@@ -39,7 +39,11 @@ static char *rcsid =
* provided by a nameserver.
*/
-int krb_get_admhst(char *h, char *r, int n)
+int
+krb_get_admhst(h, r, n)
+ char *h;
+ char *r;
+ int n;
{
FILE *cnffile;
char tr[REALM_SZ];
diff --git a/eBones/lib/libkrb/get_cred.c b/eBones/lib/libkrb/get_cred.c
index 14e1cc1..6023386 100644
--- a/eBones/lib/libkrb/get_cred.c
+++ b/eBones/lib/libkrb/get_cred.c
@@ -27,7 +27,12 @@ static char *rcsid =
* On failure it returns a Kerberos error code.
*/
-int krb_get_cred(char *service, char *instance, char *realm, CREDENTIALS *c)
+int
+krb_get_cred(service,instance,realm,c)
+ char *service; /* Service name */
+ char *instance; /* Instance */
+ char *realm; /* Auth domain */
+ CREDENTIALS *c; /* Credentials struct */
{
int tf_status; /* return value of tf function calls */
diff --git a/eBones/lib/libkrb/get_in_tkt.c b/eBones/lib/libkrb/get_in_tkt.c
index 79758f6..b95f073 100644
--- a/eBones/lib/libkrb/get_in_tkt.c
+++ b/eBones/lib/libkrb/get_in_tkt.c
@@ -16,10 +16,10 @@ static char rcsid[] =
#include <krb.h>
#include <prot.h>
-#include <des.h>
-#include "conf.h"
-#include <stdio.h>
+#ifndef NULL
+#define NULL 0
+#endif
/*
* This file contains two routines: passwd_to_key() converts
@@ -44,17 +44,18 @@ static char rcsid[] =
*/
/*ARGSUSED */
-static int passwd_to_key(char *user, char *instance, char *realm,
- char *passwd, des_cblock key)
+static int passwd_to_key(user,instance,realm,passwd,key)
+ char *user, *instance, *realm, *passwd;
+ C_Block *key;
{
#ifdef NOENCRYPTION
if (!passwd)
placebo_read_password(key, "Password: ", 0);
#else
if (passwd)
- string_to_key(passwd,(des_cblock *)key);
+ string_to_key(passwd,key);
else
- des_read_password((des_cblock *)key,"Password: ",0);
+ des_read_password(key,"Password: ",0);
#endif
return (0);
}
@@ -76,8 +77,11 @@ static int passwd_to_key(char *user, char *instance, char *realm,
* The result of the call to krb_get_in_tkt() is returned.
*/
-int krb_get_pw_in_tkt(char *user, char *instance, char *realm, char *service,
- char *sinstance, int life, char *password)
+int
+krb_get_pw_in_tkt(user,instance,realm,service,sinstance,life,password)
+ char *user, *instance, *realm, *service, *sinstance;
+ int life;
+ char *password;
{
return(krb_get_in_tkt(user,instance,realm,service,sinstance,life,
passwd_to_key, NULL, password));
@@ -99,16 +103,36 @@ int krb_get_pw_in_tkt(char *user, char *instance, char *realm, char *service,
* echoing.
*/
-#if 0
-#ifndef lint
-static char rcsid_read_password_c[] =
-"Bones$Header: /usr/cvs/src/eBones/krb/get_in_tkt.c,v 1.3 1995/07/18 16:38:30 mark Exp $";
-#endif lint
+#include <des.h>
+#include "conf.h"
+
+#include <stdio.h>
+#ifdef BSDUNIX
+#include <strings.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <setjmp.h>
+#else
+/* char *strcpy();
+int strcmp(); */
#endif
+#ifdef BSDUNIX
+static jmp_buf env;
+#endif
+
+#ifdef BSDUNIX
+static void sig_restore();
+static push_signals(), pop_signals();
+int placebo_read_pw_string();
+#endif
/*** Routines ****************************************************** */
-int placebo_read_password(des_cblock *k, char *prompt, int verify)
+int
+placebo_read_password(k,prompt,verify)
+ des_cblock *k;
+ char *prompt;
+ int verify;
{
int ok;
char key_string[BUFSIZ];
@@ -135,7 +159,8 @@ lose:
* Returns 0 on success, non-zero on failure.
*/
-int placebo_read_pw_string(char *s, int max, char *prompt, int verify)
+int
+placebo_read_pw_string(s,max,prompt,verify)
char *s;
int max;
char *prompt;
@@ -237,21 +262,23 @@ static void (*old_sigfunc[NSIG])();
static int (*old_sigfunc[NSIG])();
#endif POSIX
-static void push_signals()
+static push_signals()
{
register i;
for (i = 0; i < NSIG; i++)
old_sigfunc[i] = signal(i,sig_restore);
}
-static void pop_signals()
+static pop_signals()
{
register i;
for (i = 0; i < NSIG; i++)
signal(i,old_sigfunc[i]);
}
-static void sig_restore(int sig, int code, struct sigcontext *scp)
+static void sig_restore(sig,code,scp)
+ int sig,code;
+ struct sigcontext *scp;
{
longjmp(env,1);
}
diff --git a/eBones/lib/libkrb/get_krbhst.c b/eBones/lib/libkrb/get_krbhst.c
index ab3abbd..cfc6e1c 100644
--- a/eBones/lib/libkrb/get_krbhst.c
+++ b/eBones/lib/libkrb/get_krbhst.c
@@ -50,7 +50,11 @@ static char *rcsid =
* nameserver.
*/
-int krb_get_krbhst(char *h, char *r, int n)
+int
+krb_get_krbhst(h,r,n)
+ char *h;
+ char *r;
+ int n;
{
FILE *cnffile;
char tr[REALM_SZ];
diff --git a/eBones/lib/libkrb/get_krbrlm.c b/eBones/lib/libkrb/get_krbrlm.c
index 150a916..a4803e5 100644
--- a/eBones/lib/libkrb/get_krbrlm.c
+++ b/eBones/lib/libkrb/get_krbrlm.c
@@ -34,9 +34,12 @@ static char *rcsid =
* krb_get_krbhst().
*/
-int krb_get_lrealm(char *r, int n)
+int
+krb_get_lrealm(r,n)
+ char *r;
+ int n;
{
- FILE *cnffile;
+ FILE *cnffile, *fopen();
if (n > 1)
return(KFAILURE); /* Temporary restriction */
diff --git a/eBones/lib/libkrb/get_phost.c b/eBones/lib/libkrb/get_phost.c
index 4b0f495..cd83b2d 100644
--- a/eBones/lib/libkrb/get_phost.c
+++ b/eBones/lib/libkrb/get_phost.c
@@ -15,10 +15,10 @@ static char rcsid[] =
#endif
#include <stdio.h>
-#include <string.h>
#include <ctype.h>
#include <netdb.h>
-#include <krb.h>
+
+char *index();
/*
* This routine takes an alias for a host name and returns the first
@@ -37,7 +37,8 @@ static char rcsid[] =
* to the original "alias" argument is returned.
*/
-char *krb_get_phost(char *alias)
+char * krb_get_phost(alias)
+ char *alias;
{
struct hostent *h;
char *phost = alias;
diff --git a/eBones/lib/libkrb/get_pw_tkt.c b/eBones/lib/libkrb/get_pw_tkt.c
index 1b016a8..48b6126 100644
--- a/eBones/lib/libkrb/get_pw_tkt.c
+++ b/eBones/lib/libkrb/get_pw_tkt.c
@@ -48,7 +48,12 @@ static char *rcsid =
* the password-changing server will be in the user's ticket file.
*/
-int get_pw_tkt(char *user, char *instance, char *realm, char *cpw)
+int
+get_pw_tkt(user,instance,realm,cpw)
+ char *user;
+ char *instance;
+ char *realm;
+ char *cpw;
{
int kerror;
diff --git a/eBones/lib/libkrb/get_request.c b/eBones/lib/libkrb/get_request.c
index dec742b..c4982bf3 100644
--- a/eBones/lib/libkrb/get_request.c
+++ b/eBones/lib/libkrb/get_request.c
@@ -28,7 +28,12 @@ static char *rcsid =
* if there are less than n requests in the packet.
*/
-int get_request(KTEXT pkt, int n, char **s_name, char **instance)
+int
+get_request(pkt, n, s_name, instance)
+ KTEXT pkt; /* The packet itself */
+ int n; /* Which request do we want */
+ char **s_name; /* Service name to be filled in */
+ char **instance; /* Instance name to be filled in */
{
/* Go to the beginning of the request list */
char *ptr = (char *) pkt_a_realm(pkt) + 6 +
diff --git a/eBones/lib/libkrb/get_svc_in_tkt.c b/eBones/lib/libkrb/get_svc_in_tkt.c
index cd90f9e..f5680db 100644
--- a/eBones/lib/libkrb/get_svc_in_tkt.c
+++ b/eBones/lib/libkrb/get_svc_in_tkt.c
@@ -44,7 +44,8 @@ static char rcsid[] =
* The service key is placed in "key".
*/
-static int srvtab_to_key(user, instance, realm, srvtab, key)
+static int
+srvtab_to_key(user, instance, realm, srvtab, key)
char *user, *instance, *realm, *srvtab;
C_Block key;
{
@@ -65,7 +66,8 @@ static int srvtab_to_key(user, instance, realm, srvtab, key)
* It returns the return value of the krb_get_in_tkt() call.
*/
-int krb_get_svc_in_tkt(user, instance, realm, service, sinstance, life, srvtab)
+int
+krb_get_svc_in_tkt(user, instance, realm, service, sinstance, life, srvtab)
char *user, *instance, *realm, *service, *sinstance;
int life;
char *srvtab;
diff --git a/eBones/lib/libkrb/get_tf_fullname.c b/eBones/lib/libkrb/get_tf_fullname.c
index 45226db..8d76399 100644
--- a/eBones/lib/libkrb/get_tf_fullname.c
+++ b/eBones/lib/libkrb/get_tf_fullname.c
@@ -32,8 +32,12 @@ static char rcsid[] =
* krb_get_in_tkt().
*/
-int krb_get_tf_fullname(char *ticket_file, char *name, char *instance,
- char *realm)
+int
+krb_get_tf_fullname(ticket_file, name, instance, realm)
+ char *ticket_file;
+ char *name;
+ char *instance;
+ char *realm;
{
int tf_status;
CREDENTIALS c;
diff --git a/eBones/lib/libkrb/get_tf_realm.c b/eBones/lib/libkrb/get_tf_realm.c
index 704c687..8d75a9d 100644
--- a/eBones/lib/libkrb/get_tf_realm.c
+++ b/eBones/lib/libkrb/get_tf_realm.c
@@ -28,7 +28,10 @@ static char rcsid[] =
*
*/
-int krb_get_tf_realm(char *ticket_file, char *realm)
+int
+krb_get_tf_realm(ticket_file, realm)
+ char *ticket_file;
+ char *realm;
{
return(krb_get_tf_fullname(ticket_file, 0, 0, realm));
}
diff --git a/eBones/lib/libkrb/getrealm.c b/eBones/lib/libkrb/getrealm.c
index 37686c4..dcd4d28 100644
--- a/eBones/lib/libkrb/getrealm.c
+++ b/eBones/lib/libkrb/getrealm.c
@@ -47,7 +47,9 @@ static char rcsid[] =
static char ret_realm[REALM_SZ+1];
-char *krb_realmofhost(char *host)
+char *
+krb_realmofhost(host)
+char *host;
{
char *domain;
FILE *trans_file;
diff --git a/eBones/lib/libkrb/getst.c b/eBones/lib/libkrb/getst.c
index 549ec50..e50e4bb 100644
--- a/eBones/lib/libkrb/getst.c
+++ b/eBones/lib/libkrb/getst.c
@@ -26,7 +26,11 @@ static char rcsid[] =
* the null terminator.
*/
-int getst(int fd, char *s, int n)
+int
+getst(fd, s, n)
+ int fd;
+ register char *s;
+ int n;
{
register count = n;
while (read(fd, s, 1) > 0 && --count)
diff --git a/eBones/lib/libkrb/in_tkt.c b/eBones/lib/libkrb/in_tkt.c
index 12fbb39..1f6ee8a 100644
--- a/eBones/lib/libkrb/in_tkt.c
+++ b/eBones/lib/libkrb/in_tkt.c
@@ -16,8 +16,8 @@ static char rcsid[] =
#endif
#include <unistd.h>
-#include <stdio.h>
#include <string.h>
+#include <stdio.h>
#include <krb.h>
#include <sys/file.h>
#include <sys/fcntl.h>
@@ -27,6 +27,8 @@ static char rcsid[] =
#include <sys/param.h>
#endif
+extern int krb_debug;
+
/*
* in_tkt() is used to initialize the ticket store. It creates the
* file to contain the tickets and writes the given user's name "pname"
@@ -34,7 +36,10 @@ static char rcsid[] =
* success, or KFAILURE if something goes wrong.
*/
-int in_tkt(char *pname, char *pinst)
+int
+in_tkt(pname,pinst)
+ char *pname;
+ char *pinst;
{
int tktfile;
uid_t me, metoo;
diff --git a/eBones/lib/libkrb/k_gethostname.c b/eBones/lib/libkrb/k_gethostname.c
index 093ee5d..cfb4f92 100644
--- a/eBones/lib/libkrb/k_gethostname.c
+++ b/eBones/lib/libkrb/k_gethostname.c
@@ -41,7 +41,10 @@ extern get_custom();
* not work.
*/
-int k_gethostname(char *name, int namelen)
+int
+k_gethostname(name, namelen)
+ char *name;
+ int namelen;
{
#ifdef BSD42
return gethostname(name, namelen);
diff --git a/eBones/lib/libkrb/klog.c b/eBones/lib/libkrb/klog.c
index 97d52c7..7fdc774 100644
--- a/eBones/lib/libkrb/klog.c
+++ b/eBones/lib/libkrb/klog.c
@@ -50,11 +50,13 @@ static char logtxt[1000];
* text string "logtxt".
*/
-char *klog(int type, char *format, int a1, int a2, int a3, int a4, int a5,
- int a6, int a7, int a8, int a9, int a0)
+char * klog(type,format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0)
+ int type;
+ char *format;
+ int a1,a2,a3,a4,a5,a6,a7,a8,a9,a0;
{
FILE *logfile;
- long time(),now;
+ long now;
struct tm *tm;
static int logtype_array[NLOGTYPE] = {0,0};
static int array_initialized;
@@ -99,7 +101,9 @@ char *klog(int type, char *format, int a1, int a2, int a3, int a4, int a5,
* the logfile defaults to KRBLOG, defined in "krb.h".
*/
-void kset_logfile(char *filename)
+void
+kset_logfile(filename)
+ char *filename;
{
log_name = filename;
is_open = 0;
diff --git a/eBones/lib/libkrb/kname_parse.c b/eBones/lib/libkrb/kname_parse.c
index c69b5cc..da7ec93 100644
--- a/eBones/lib/libkrb/kname_parse.c
+++ b/eBones/lib/libkrb/kname_parse.c
@@ -54,7 +54,9 @@ extern char *krb_err_txt[];
* KNAME_FMT is returned.
*/
-int kname_parse(char *np, char *ip, char *rp, char *fullname)
+int
+kname_parse(np, ip, rp, fullname)
+ char *np, *ip, *rp, *fullname;
{
static char buf[FULL_SZ];
char *rnext, *wnext; /* next char to read, write */
@@ -137,7 +139,9 @@ int kname_parse(char *np, char *ip, char *rp, char *fullname)
* Kerberos name; returns 0 if it's not.
*/
-int k_isname(char *s)
+int
+k_isname(s)
+ char *s;
{
register char c;
int backslash = 0;
@@ -172,7 +176,9 @@ int k_isname(char *s)
* Kerberos instance; returns 0 if it's not.
*/
-int k_isinst(char *s)
+int
+k_isinst(s)
+ char *s;
{
register char c;
int backslash = 0;
@@ -204,7 +210,9 @@ int k_isinst(char *s)
* Kerberos realm; returns 0 if it's not.
*/
-int k_isrealm(char *s)
+int
+k_isrealm(s)
+ char *s;
{
register char c;
int backslash = 0;
diff --git a/eBones/lib/libkrb/kntoln.c b/eBones/lib/libkrb/kntoln.c
index ddb1ba2..388704c 100644
--- a/eBones/lib/libkrb/kntoln.c
+++ b/eBones/lib/libkrb/kntoln.c
@@ -44,7 +44,10 @@ static char *rcsid =
* KSUCCESS if all goes well, otherwise KFAILURE.
*/
-int krb_kntoln(AUTH_DAT *ad, char *lname)
+int
+krb_kntoln(ad,lname)
+ AUTH_DAT *ad;
+ char *lname;
{
static char lrealm[REALM_SZ] = "";
diff --git a/eBones/lib/libkrb/kparse.c b/eBones/lib/libkrb/kparse.c
index edb471c..5b25ac7 100644
--- a/eBones/lib/libkrb/kparse.c
+++ b/eBones/lib/libkrb/kparse.c
@@ -40,8 +40,8 @@ static char rcsid[] =
#endif lint
#endif
-#include <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include <ctype.h>
#include <kparse.h>
@@ -53,18 +53,20 @@ static char rcsid[] =
#define MAXKEY 80
#define MAXVALUE 80
-int fGetKeywordValue(FILE *fp, char *keyword, int klen, char *value, int vlen);
-int fGetToken(FILE *fp, char *dest, int maxlen);
+int fUngetChar(int ch, FILE *fp);
int fGetChar(FILE *fp);
-int fUngetChar(int ch, FILE*fp);
-int fGetLiteral(FILE *fp);;
+int fGetLiteral(FILE *fp);
int LineNbr=1; /* current line nbr in parameter file */
char ErrorMsg[80]; /* meaningful only when KV_SYNTAX, PS_SYNTAX,
* or PS_BAD_KEYWORD is returned by
* fGetKeywordValue or fGetParameterSet */
-int fGetParameterSet(FILE *fp, parmtable parm[], int parmcount )
+int
+fGetParameterSet( fp,parm,parmcount )
+ FILE *fp;
+ parmtable parm[];
+ int parmcount;
{
int rc,i;
char keyword[MAXKEY];
@@ -127,7 +129,12 @@ int fGetParameterSet(FILE *fp, parmtable parm[], int parmcount )
* different. Like strcmp, ParmCompare returns 0 for a match found, -1
* otherwise
*/
-int ParmCompare(parmtable parm[], int parmcount, char *keyword, char *value )
+int
+ParmCompare( parm, parmcount, keyword, value )
+ parmtable parm[];
+ int parmcount;
+ char *keyword;
+ char *value;
{
int i;
@@ -143,7 +150,10 @@ int ParmCompare(parmtable parm[], int parmcount, char *keyword, char *value )
return(-1);
}
-void FreeParameterSet(parmtable parm[], int parmcount)
+void
+FreeParameterSet(parm,parmcount)
+ parmtable parm[];
+ int parmcount;
{
int i;
@@ -155,7 +165,13 @@ void FreeParameterSet(parmtable parm[], int parmcount)
}
}
-int fGetKeywordValue(FILE *fp, char *keyword, int klen, char *value, int vlen)
+int
+fGetKeywordValue( fp, keyword, klen, value, vlen )
+ FILE *fp;
+ char *keyword;
+ int klen;
+ char *value;
+ int vlen;
{
int rc;
int gotit;
@@ -311,7 +327,7 @@ int fGetKeywordValue(FILE *fp, char *keyword, int klen, char *value, int vlen)
} while ( !gotit );
/*NOTREACHED*/
- return 0; /* I know, I know. - markm */
+ return(0); /*just to shut up -Wall MRVM*/
}
/*
@@ -343,7 +359,11 @@ int fGetKeywordValue(FILE *fp, char *keyword, int klen, char *value, int vlen)
* classification for end of file is
* always zero.
*/
-int fGetToken(FILE *fp, char *dest, int maxlen)
+int
+fGetToken(fp, dest, maxlen)
+ FILE *fp;
+ char *dest;
+ int maxlen;
{
int ch='\0';
int len=0;
@@ -436,7 +456,9 @@ int fGetToken(FILE *fp, char *dest, int maxlen)
* special case certain values (\n, \f, \r, \b) or return a literal
* otherwise (useful for \", for example).
*/
-int fGetLiteral(FILE *fp)
+int
+fGetLiteral(fp)
+ FILE *fp;
{
int ch;
int n=0;
@@ -511,7 +533,10 @@ int fGetLiteral(FILE *fp)
* exactly the same as ungetc(3) except that the line number of the
* input file is maintained.
*/
-int fUngetChar(int ch, FILE*fp)
+int
+fUngetChar(ch,fp)
+ int ch;
+ FILE *fp;
{
if (ch=='\n') LineNbr--;
return(ungetc(ch,fp));
@@ -522,7 +547,9 @@ int fUngetChar(int ch, FILE*fp)
* exactly the same as fgetc(3) except that the line number of the
* input file is maintained.
*/
-int fGetChar(FILE *fp)
+int
+fGetChar(fp)
+ FILE *fp;
{
int ch = fgetc(fp);
if (ch=='\n') LineNbr++;
@@ -548,7 +575,9 @@ int fGetChar(FILE *fp)
* Return Value: pointer to copied string
*
*/
-char *strsave(char *p)
+char *
+strsave(p)
+ char *p;
{
return(strcpy(malloc(strlen(p)+1),p));
}
@@ -559,7 +588,9 @@ char *strsave(char *p)
* the pointer to the beginning of the string is returned.
*/
-char *strutol(char *start)
+char *
+strutol( start )
+ char *start;
{
char *q;
for (q=start; *q; q++)
@@ -574,7 +605,9 @@ char *strutol(char *start)
char *pgm = "gettoken";
-main(int argc, char **argv)
+main(argc,argv)
+ int argc;
+ char **argv;
{
char *p;
int type;
@@ -627,7 +660,9 @@ main(int argc, char **argv)
#ifdef KVTEST
-main(int argc, char **argv)
+main(argc,argv)
+ int argc;
+ char **argv;
{
int rc,ch;
FILE *fp;
@@ -684,7 +719,9 @@ parmtable kparm[] = {
{ "instance", "", (char *)NULL }
};
-main(int argc, char **argv)
+main(argc,argv)
+ int argc;
+ char **argv;
{
int rc,i,ch;
FILE *fp;
diff --git a/eBones/lib/libkrb/krb_get_in_tkt.c b/eBones/lib/libkrb/krb_get_in_tkt.c
index e17b60e..b6ff308 100644
--- a/eBones/lib/libkrb/krb_get_in_tkt.c
+++ b/eBones/lib/libkrb/krb_get_in_tkt.c
@@ -35,8 +35,14 @@ int swap_bytes;
* using the key returned by key_proc.
*/
-static int decrypt_tkt(char *user, char *instance, char *realm, char *arg,
- int (*key_proc)(), KTEXT *cipp)
+static int
+decrypt_tkt(user, instance, realm, arg, key_proc, cipp)
+ char *user;
+ char *instance;
+ char *realm;
+ char *arg;
+ int (*key_proc)();
+ KTEXT *cipp;
{
KTEXT cip = *cipp;
C_Block key; /* Key for decrypting cipher */
@@ -56,9 +62,9 @@ static int decrypt_tkt(char *user, char *instance, char *realm, char *arg,
}
#ifndef NOENCRYPTION
- key_sched((des_cblock *)key,key_s);
- pcbc_encrypt((des_cblock *)cip->dat,(des_cblock *)cip->dat,
- (long) cip->length,key_s,(des_cblock *)key,DES_DECRYPT);
+ key_sched(&key,key_s);
+ pcbc_encrypt((C_Block *)cip->dat,(C_Block *)cip->dat,
+ (long) cip->length,key_s,(C_Block *)key,DES_DECRYPT);
#endif /* !NOENCRYPTION */
/* Get rid of all traces of key */
bzero((char *)key,sizeof(key));
@@ -108,9 +114,18 @@ static int decrypt_tkt(char *user, char *instance, char *realm, char *arg,
* string sinstance service's instance
*/
-int krb_get_in_tkt(char *user, char *instance, char *realm, char *service,
- char *sinstance, int life, int (*key_proc)(), int (*decrypt_proc)(),
- char *arg)
+int
+krb_get_in_tkt(user, instance, realm, service, sinstance, life,
+ key_proc, decrypt_proc, arg)
+ char *user;
+ char *instance;
+ char *realm;
+ char *service;
+ char *sinstance;
+ int life;
+ int (*key_proc)();
+ int (*decrypt_proc)();
+ char *arg;
{
KTEXT_ST pkt_st;
KTEXT pkt = &pkt_st; /* Packet to KDC */
diff --git a/eBones/lib/libkrb/krbglue.c b/eBones/lib/libkrb/krbglue.c
index de5b7e2..f82cf70 100644
--- a/eBones/lib/libkrb/krbglue.c
+++ b/eBones/lib/libkrb/krbglue.c
@@ -22,10 +22,11 @@ $Id: krbglue.c,v 1.3 1995/07/18 16:39:05 mark Exp $";
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
-#include "des.h"
+#include <des.h>
#include "krb.h"
/* These definitions should be in krb.h, no? */
+/*
#if defined(__HIGHC__)
#undef __STDC__
#endif
@@ -59,7 +60,7 @@ extern char *krb_get_phost (char *);
extern int krb_get_krbhst (char *, char *, int);
#ifdef DEBUG
extern KTEXT krb_create_death_packet (char *);
-#endif /* DEBUG */
+#endif
#else
extern int krb_mk_req ();
extern int krb_rd_req ();
@@ -81,8 +82,11 @@ extern char *krb_get_phost ();
extern int krb_get_krbhst ();
#ifdef DEBUG
extern KTEXT krb_create_death_packet ();
-#endif /* DEBUG */
-#endif /* STDC */
+#endif
+#endif
+*/
+
+
int mk_ap_req(authent, service, instance, realm, checksum)
KTEXT authent;
char *service, *instance, *realm;
diff --git a/eBones/lib/libkrb/kuserok.c b/eBones/lib/libkrb/kuserok.c
index 15a25e8..8e5d18a 100644
--- a/eBones/lib/libkrb/kuserok.c
+++ b/eBones/lib/libkrb/kuserok.c
@@ -86,7 +86,10 @@ parmtable kparm[] = {
#define KPARMS kparm,PARMCOUNT(kparm)
#endif ATHENA_COMPAT
-int kuserok(AUTH_DAT *kdata, char *luser)
+int
+kuserok(kdata, luser)
+ AUTH_DAT *kdata;
+ char *luser;
{
struct stat sbuf;
struct passwd *pwd;
diff --git a/eBones/lib/libkrb/log.c b/eBones/lib/libkrb/log.c
index aea6ab9..e33477f 100644
--- a/eBones/lib/libkrb/log.c
+++ b/eBones/lib/libkrb/log.c
@@ -44,12 +44,18 @@ static is_open;
* The return value is undefined.
*/
+__BEGIN_DECLS
+char *month_sname __P((int));
+__END_DECLS
+
+
/*VARARGS1 */
-void log(char *format,int a1,int a2,int a3,int a4,int a5,int a6,int a7,
- int a8,int a9,int a0)
+void log(format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a0)
+ char *format;
+ int a1,a2,a3,a4,a5,a6,a7,a8,a9,a0;
{
- FILE *logfile;
- long now;
+ FILE *logfile, *fopen();
+ long time(),now;
struct tm *tm;
if ((logfile = fopen(log_name,"a")) == NULL)
@@ -73,7 +79,9 @@ void log(char *format,int a1,int a2,int a3,int a4,int a5,int a6,int a7,
* the logfile defaults to KRBLOG, defined in "krb.h".
*/
-void set_logfile(char *filename)
+void
+set_logfile(filename)
+ char *filename;
{
log_name = filename;
is_open = 0;
@@ -86,7 +94,10 @@ void set_logfile(char *filename)
* on success.
*/
-int new_log(long t, char *string)
+int
+new_log(t,string)
+ long t;
+ char *string;
{
static FILE *logfile;
diff --git a/eBones/lib/libkrb/mk_priv.c b/eBones/lib/libkrb/mk_priv.c
index bc377de..d45d734 100644
--- a/eBones/lib/libkrb/mk_priv.c
+++ b/eBones/lib/libkrb/mk_priv.c
@@ -40,8 +40,13 @@ static char rcsid[] =
#include <prot.h>
#include "lsb_addr_comp.h"
+extern char *errmsg();
+extern int errno;
+extern int krb_debug;
+
/* static storage */
+
static u_long c_length;
static struct timeval msg_time;
static u_char msg_time_5ms;
@@ -90,9 +95,16 @@ static long msg_time_sec;
* 0<=n<=7 bytes pad to 8 byte multiple zeroes
*/
-long krb_mk_priv(u_char *in, u_char *out, u_long length,
- des_key_schedule schedule, des_cblock key, struct sockaddr_in *sender,
- struct sockaddr_in *receiver)
+long krb_mk_priv(in,out,length,schedule,key,sender,receiver)
+ u_char *in; /* application data */
+ u_char *out; /* put msg here, leave room for
+ * header! breaks if in and out
+ * (header stuff) overlap */
+ u_long length; /* of in data */
+ Key_schedule schedule; /* precomputed key schedule */
+ C_Block key; /* encryption key for seed and ivec */
+ struct sockaddr_in *sender; /* sender address */
+ struct sockaddr_in *receiver; /* receiver address */
{
register u_char *p,*q;
static u_char *c_length_ptr;
@@ -187,8 +199,8 @@ long krb_mk_priv(u_char *in, u_char *out, u_long length,
bcopy((char *) &c_length,(char *)c_length_ptr,sizeof(c_length));
#ifndef NOENCRYPTION
- pcbc_encrypt((des_cblock *)q,(des_cblock *)q,(long)(p-q),schedule,
- (des_cblock *)key,ENCRYPT);
+ pcbc_encrypt((C_Block *)q,(C_Block *)q,(long)(p-q),schedule,(C_Block *)key,
+ ENCRYPT);
#endif /* NOENCRYPTION */
return (q - out + c_length); /* resulting size */
diff --git a/eBones/lib/libkrb/mk_req.c b/eBones/lib/libkrb/mk_req.c
index 971e6a2..a27c1c0 100644
--- a/eBones/lib/libkrb/mk_req.c
+++ b/eBones/lib/libkrb/mk_req.c
@@ -21,6 +21,7 @@ static char *rcsid =
#include <sys/time.h>
#include <strings.h>
+extern int krb_ap_req_debug;
static struct timeval tv_local = { 0, 0 };
static int lifetime = DEFAULT_TKT_LIFE;
@@ -68,8 +69,13 @@ static int lifetime = DEFAULT_TKT_LIFE;
* all rounded up to multiple of 8.
*/
-int krb_mk_req(KTEXT authent, char *service, char *instance, char *realm,
- long checksum)
+int
+krb_mk_req(authent,service,instance,realm,checksum)
+ register KTEXT authent; /* Place to build the authenticator */
+ char *service; /* Name of the service */
+ char *instance; /* Service instance */
+ char *realm; /* Authentication domain of service */
+ long checksum; /* Checksum of data (optional) */
{
static KTEXT_ST req_st; /* Temp storage for req id */
register KTEXT req_id = &req_st;
@@ -151,9 +157,9 @@ int krb_mk_req(KTEXT authent, char *service, char *instance, char *realm,
req_id->length = ((req_id->length+7)/8)*8;
#ifndef NOENCRYPTION
- key_sched((des_cblock *)cr.session,key_s);
- pcbc_encrypt((des_cblock *)req_id->dat,(des_cblock *)req_id->dat,
- (long)req_id->length,key_s,(des_cblock *)cr.session,ENCRYPT);
+ key_sched((C_Block *)cr.session,key_s);
+ pcbc_encrypt((C_Block *)req_id->dat,(C_Block *)req_id->dat,
+ (long)req_id->length,key_s,(C_Block *)cr.session,ENCRYPT);
bzero((char *) key_s, sizeof(key_s));
#endif /* NOENCRYPTION */
@@ -181,7 +187,9 @@ int krb_mk_req(KTEXT authent, char *service, char *instance, char *realm,
* It returns the previous value of the default lifetime.
*/
-int krb_set_lifetime(int newval)
+int
+krb_set_lifetime(newval)
+int newval;
{
int olife = lifetime;
diff --git a/eBones/lib/libkrb/mk_safe.c b/eBones/lib/libkrb/mk_safe.c
index f4aab32..e5490bc 100644
--- a/eBones/lib/libkrb/mk_safe.c
+++ b/eBones/lib/libkrb/mk_safe.c
@@ -83,8 +83,17 @@ static long msg_time_sec;
* above using "key"
*/
-long krb_mk_safe(u_char *in, u_char *out, u_long length, des_cblock key,
- struct sockaddr_in *sender, struct sockaddr_in *receiver)
+long krb_mk_safe(in,out,length,key,sender,receiver)
+ u_char *in; /* application data */
+ u_char *out; /*
+ * put msg here, leave room for header!
+ * breaks if in and out (header stuff)
+ * overlap
+ */
+ u_long length; /* of in data */
+ C_Block *key; /* encryption key for seed and ivec */
+ struct sockaddr_in *sender; /* sender address */
+ struct sockaddr_in *receiver; /* receiver address */
{
register u_char *p,*q;
@@ -148,7 +157,7 @@ long krb_mk_safe(u_char *in, u_char *out, u_long length, des_cblock key,
cksum = 0;
bzero(big_cksum, sizeof(big_cksum));
#else
- cksum=quad_cksum((des_cblock *)q,big_cksum,p-q,2,(des_cblock *)key);
+ cksum=quad_cksum((C_Block *)q,big_cksum,p-q,2,key);
#endif
if (krb_debug)
printf("\ncksum = %lu",cksum);
diff --git a/eBones/lib/libkrb/month_sname.c b/eBones/lib/libkrb/month_sname.c
index 3443e41..f4ef339 100644
--- a/eBones/lib/libkrb/month_sname.c
+++ b/eBones/lib/libkrb/month_sname.c
@@ -22,7 +22,8 @@ static char *rcsid =
* month. Returns 0 if the argument is out of range.
*/
-char *month_sname(int n)
+char *month_sname(n)
+ int n;
{
static char *name[] = {
"Jan","Feb","Mar","Apr","May","Jun",
diff --git a/eBones/lib/libkrb/netread.c b/eBones/lib/libkrb/netread.c
index c773bc8..628004e 100644
--- a/eBones/lib/libkrb/netread.c
+++ b/eBones/lib/libkrb/netread.c
@@ -14,9 +14,7 @@ static char rcsid[] =
#endif lint
#endif
-#include <stdio.h>
#include <unistd.h>
-#include <krb.h>
/*
* krb_net_read() reads from the file descriptor "fd" to the buffer
@@ -28,7 +26,11 @@ static char rcsid[] =
* XXX must not use non-blocking I/O
*/
-int krb_net_read(int fd, char *buf, int len)
+int
+krb_net_read(fd, buf, len)
+int fd;
+register char *buf;
+register int len;
{
int cc, len2 = 0;
diff --git a/eBones/lib/libkrb/netwrite.c b/eBones/lib/libkrb/netwrite.c
index 7af91ff..f85f7ba 100644
--- a/eBones/lib/libkrb/netwrite.c
+++ b/eBones/lib/libkrb/netwrite.c
@@ -14,9 +14,7 @@ static char rcsid[] =
#endif lint
#endif
-#include <stdio.h>
#include <unistd.h>
-#include <krb.h>
/*
* krb_net_write() writes "len" bytes from "buf" to the file
@@ -27,7 +25,11 @@ static char rcsid[] =
* XXX must not use non-blocking I/O
*/
-int krb_net_write(int fd, char *buf, int len)
+int
+krb_net_write(fd, buf, len)
+int fd;
+register char *buf;
+int len;
{
int cc;
register int wrlen = len;
diff --git a/eBones/lib/libkrb/pkt_clen.c b/eBones/lib/libkrb/pkt_clen.c
index 17d46c2..f8dacae 100644
--- a/eBones/lib/libkrb/pkt_clen.c
+++ b/eBones/lib/libkrb/pkt_clen.c
@@ -15,10 +15,12 @@ static char *rcsid =
#endif /* lint */
#endif
+#include <string.h>
+
#include <krb.h>
#include <prot.h>
-#include <string.h>
+extern int krb_debug;
extern int swap_bytes;
/*
@@ -29,7 +31,9 @@ extern int swap_bytes;
* ciphertext length out of the packet.
*/
-int pkt_clen(KTEXT pkt)
+int
+pkt_clen(pkt)
+ KTEXT pkt;
{
static unsigned short temp,temp2;
int clen = 0;
diff --git a/eBones/lib/libkrb/rd_err.c b/eBones/lib/libkrb/rd_err.c
index 8c5b8a2..e46dc66 100644
--- a/eBones/lib/libkrb/rd_err.c
+++ b/eBones/lib/libkrb/rd_err.c
@@ -24,8 +24,8 @@ static char rcsid[] =
#endif
/* system include files */
-#include <stdio.h>
#include <string.h>
+#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -50,7 +50,12 @@ static char rcsid[] =
* The AUTH_MSG_APPL_ERR message format can be found in mk_err.c
*/
-int krb_rd_err(u_char *in, u_long in_length, long *code, MSG_DAT *m_data)
+int
+krb_rd_err(in,in_length,code,m_data)
+ u_char *in; /* pointer to the msg received */
+ u_long in_length; /* of in msg */
+ long *code; /* received error code */
+ MSG_DAT *m_data;
{
register u_char *p;
int swap_bytes = 0;
diff --git a/eBones/lib/libkrb/rd_priv.c b/eBones/lib/libkrb/rd_priv.c
index 457352e..0c21a1d 100644
--- a/eBones/lib/libkrb/rd_priv.c
+++ b/eBones/lib/libkrb/rd_priv.c
@@ -26,8 +26,8 @@ static char rcsid[]=
#endif
/* system include files */
-#include <stdio.h>
#include <string.h>
+#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -39,6 +39,8 @@ static char rcsid[]=
#include <prot.h>
#include "lsb_addr_comp.h"
+extern int krb_debug;
+
/* static storage */
static u_long c_length;
@@ -68,9 +70,15 @@ int private_msg_ver = KRB_PROT_VERSION;
* information, MSG_DAT, is defined in "krb.h".
*/
-long krb_rd_priv(u_char *in, u_long in_length, des_key_schedule schedule,
- des_cblock key, struct sockaddr_in *sender, struct sockaddr_in *receiver,
- MSG_DAT *m_data)
+long
+krb_rd_priv(in,in_length,schedule,key,sender,receiver,m_data)
+ u_char *in; /* pointer to the msg received */
+ u_long in_length; /* length of "in" msg */
+ Key_schedule schedule; /* precomputed key schedule */
+ C_Block key; /* encryption key for seed and ivec */
+ struct sockaddr_in *sender;
+ struct sockaddr_in *receiver;
+ MSG_DAT *m_data; /*various input/output data from msg */
{
register u_char *p,*q;
static u_long src_addr; /* Can't send structs since no
@@ -103,8 +111,8 @@ long krb_rd_priv(u_char *in, u_long in_length, des_key_schedule schedule,
q = p; /* mark start of encrypted stuff */
#ifndef NOENCRYPTION
- pcbc_encrypt((des_cblock *)q,(des_cblock *)q,(long)c_length,schedule,
- (des_cblock *)key,DECRYPT);
+ pcbc_encrypt((C_Block *)q,(C_Block *)q,(long)c_length,schedule,
+ (C_Block *)key,DECRYPT);
#endif
/* safely get application data length */
diff --git a/eBones/lib/libkrb/rd_req.c b/eBones/lib/libkrb/rd_req.c
index b77ec48..60ee948 100644
--- a/eBones/lib/libkrb/rd_req.c
+++ b/eBones/lib/libkrb/rd_req.c
@@ -15,13 +15,14 @@ static char *rcsid =
#endif /* lint */
#endif
-#include <stdio.h>
#include <des.h>
#include <krb.h>
#include <prot.h>
#include <sys/time.h>
#include <strings.h>
+extern int krb_ap_req_debug;
+
static struct timeval t_local = { 0, 0 };
/*
@@ -65,17 +66,20 @@ static char st_inst[INST_SZ]; /* server's instance */
* krb_rd_req().
*/
-int krb_set_key(char *key, int cvt)
+int
+krb_set_key(key,cvt)
+ char *key;
+ int cvt;
{
#ifdef NOENCRYPTION
bzero(ky, sizeof(ky));
return KSUCCESS;
#else
if (cvt)
- string_to_key(key,(des_cblock *)ky);
+ string_to_key(key,(C_Block *)ky);
else
bcopy(key,(char *)ky,8);
- return(des_key_sched((des_cblock *)ky,serv_key));
+ return(des_key_sched((C_Block *)ky,serv_key));
#endif
}
@@ -121,8 +125,14 @@ int krb_set_key(char *key, int cvt)
* Mutual authentication is not implemented.
*/
-int krb_rd_req (KTEXT authent, char *service, char *instance, long from_addr,
- AUTH_DAT *ad, char *fn)
+int
+krb_rd_req(authent,service,instance,from_addr,ad,fn)
+ register KTEXT authent; /* The received message */
+ char *service; /* Service name */
+ char *instance; /* Service instance */
+ long from_addr; /* Net address of originating host */
+ AUTH_DAT *ad; /* Structure to be filled in */
+ char *fn; /* Filename to get keys from */
{
static KTEXT_ST ticket; /* Temp storage for ticket */
static KTEXT tkt = &ticket;
@@ -241,10 +251,9 @@ int krb_rd_req (KTEXT authent, char *service, char *instance, long from_addr,
bcopy(ptr + tkt->length, (char *)(req_id->dat),req_id->length);
#ifndef NOENCRYPTION
- key_sched((des_cblock *)ad->session,seskey_sched);
- pcbc_encrypt((des_cblock *)req_id->dat,(des_cblock *)req_id->dat,
- (long)req_id->length,seskey_sched,(des_cblock *)ad->session,
- DES_DECRYPT);
+ key_sched((C_Block *)ad->session,seskey_sched);
+ pcbc_encrypt((C_Block *)req_id->dat,(C_Block *)req_id->dat,
+ (long)req_id->length,seskey_sched,(C_Block *)ad->session,DES_DECRYPT);
#endif /* NOENCRYPTION */
#define check_ptr() if ((ptr - (char *) req_id->dat) > req_id->length) return(RD_AP_MODIFIED);
diff --git a/eBones/lib/libkrb/rd_safe.c b/eBones/lib/libkrb/rd_safe.c
index 48d43c5..4d3e8d6 100644
--- a/eBones/lib/libkrb/rd_safe.c
+++ b/eBones/lib/libkrb/rd_safe.c
@@ -37,6 +37,10 @@ static char rcsid[] =
#include <prot.h>
#include "lsb_addr_comp.h"
+extern char *errmsg();
+extern int errno;
+extern int krb_debug;
+
/* static storage */
static C_Block calc_cksum[2];
@@ -62,9 +66,13 @@ static u_long delta_t;
* information, MSG_DAT, is defined in "krb.h".
*/
-long krb_rd_safe(u_char *in, u_long in_length, des_cblock key,
- struct sockaddr_in *sender, struct sockaddr_in *receiver,
- MSG_DAT *m_data)
+long krb_rd_safe(in,in_length,key,sender,receiver,m_data)
+ u_char *in; /* pointer to the msg received */
+ u_long in_length; /* length of "in" msg */
+ C_Block *key; /* encryption key for seed and ivec */
+ struct sockaddr_in *sender; /* sender's address */
+ struct sockaddr_in *receiver; /* receiver's address -- me */
+ MSG_DAT *m_data; /* where to put message information */
{
register u_char *p,*q;
static u_long src_addr; /* Can't send structs since no
@@ -162,7 +170,7 @@ krb_rd_safe protocol err sizeof(u_long) != sizeof(struct in_addr)");
#ifdef NOENCRYPTION
bzero(calc_cksum, sizeof(calc_cksum));
#else
- quad_cksum((des_cblock *)q,calc_cksum,p-q,2,(des_cblock *)key);
+ quad_cksum((C_Block *)q,calc_cksum,p-q,2,key);
#endif
if (krb_debug)
diff --git a/eBones/lib/libkrb/read_service_key.c b/eBones/lib/libkrb/read_service_key.c
index aa577fd..6064292 100644
--- a/eBones/lib/libkrb/read_service_key.c
+++ b/eBones/lib/libkrb/read_service_key.c
@@ -17,8 +17,8 @@ static char *rcsid =
#include <krb.h>
#include <stdio.h>
-#include <strings.h>
#include <unistd.h>
+#include <strings.h>
/*
* The private keys for servers on a given host are stored in a
@@ -54,8 +54,14 @@ static char *rcsid =
/*ARGSUSED */
-int read_service_key(char *service, char *instance, char *realm, int kvno,
- char *file, char *key)
+int
+read_service_key(service,instance,realm,kvno,file,key)
+ char *service; /* Service Name */
+ char *instance; /* Instance name or "*" */
+ char *realm; /* Realm */
+ int kvno; /* Key version number */
+ char *file; /* Filename */
+ char *key; /* Pointer to key to be filled in */
{
char serv[SNAME_SZ];
char inst[INST_SZ];
diff --git a/eBones/lib/libkrb/recvauth.c b/eBones/lib/libkrb/recvauth.c
index 8e9a6bb..45d68ee 100644
--- a/eBones/lib/libkrb/recvauth.c
+++ b/eBones/lib/libkrb/recvauth.c
@@ -14,6 +14,7 @@ static char rcsid[] =
#endif lint
#endif
+#include <krb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <syslog.h>
@@ -22,7 +23,6 @@ static char rcsid[] =
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
-#include <krb.h>
#define KRB_SENDAUTH_VERS "AUTHV0.1" /* MUST be KRB_SENDAUTH_VLEN
@@ -34,6 +34,8 @@ static char rcsid[] =
* be sure to support old versions of krb_sendauth!
*/
+extern int errno;
+
/*
* krb_recvauth() reads (and optionally responds to) a message sent
* using krb_sendauth(). The "options" argument is a bit-field of
@@ -120,14 +122,24 @@ static char rcsid[] =
#endif /* max */
int
-krb_recvauth(long options, int fd, KTEXT ticket, char *service, char *instance,
- struct sockaddr_in *faddr, struct sockaddr_in *laddr, AUTH_DAT *kdata,
- char *filename, des_key_schedule schedule, char *version)
+krb_recvauth(options, fd, ticket, service, instance, faddr, laddr, kdata,
+ filename, schedule, version)
+long options; /* bit-pattern of options */
+int fd; /* file descr. to read from */
+KTEXT ticket; /* storage for client's ticket */
+char *service; /* service expected */
+char *instance; /* inst expected (may be filled in) */
+struct sockaddr_in *faddr; /* address of foreign host on fd */
+struct sockaddr_in *laddr; /* local address */
+AUTH_DAT *kdata; /* kerberos data (returned) */
+char *filename; /* name of file with service keys */
+Key_schedule schedule; /* key schedule (return) */
+char *version; /* version string (filled in) */
{
int i, cc, old_vers = 0;
char krb_vers[KRB_SENDAUTH_VLEN + 1]; /* + 1 for the null terminator */
- char *cp = NULL;
+ char *cp;
int rem;
long tkt_len, priv_len;
u_long cksum;
@@ -242,7 +254,7 @@ krb_recvauth(long options, int fd, KTEXT ticket, char *service, char *instance,
cksum = kdata->checksum + 1;
cksum = htonl(cksum);
#ifndef NOENCRYPTION
- key_sched((des_cblock *)kdata->session,schedule);
+ key_sched((C_Block *)kdata->session,schedule);
#endif
priv_len = krb_mk_priv((unsigned char *)&cksum,
tmp_buf,
diff --git a/eBones/lib/libkrb/save_credentials.c b/eBones/lib/libkrb/save_credentials.c
index bec225f..268bb77 100644
--- a/eBones/lib/libkrb/save_credentials.c
+++ b/eBones/lib/libkrb/save_credentials.c
@@ -30,8 +30,17 @@ static char *rcsid =
* by the tf_init() or tf_save_cred() routines.
*/
-int save_credentials(char *service, char *instance, char *realm,
- des_cblock session, int lifetime, int kvno, KTEXT ticket, long issue_date)
+int
+save_credentials(service, instance, realm, session, lifetime, kvno,
+ ticket, issue_date)
+ char *service; /* Service name */
+ char *instance; /* Instance */
+ char *realm; /* Auth domain */
+ C_Block session; /* Session key */
+ int lifetime; /* Lifetime */
+ int kvno; /* Key version number */
+ KTEXT ticket; /* The ticket itself */
+ long issue_date; /* The issue time */
{
int tf_status; /* return values of the tf_util calls */
diff --git a/eBones/lib/libkrb/send_to_kdc.c b/eBones/lib/libkrb/send_to_kdc.c
index 96b3cb5..a2a329a 100644
--- a/eBones/lib/libkrb/send_to_kdc.c
+++ b/eBones/lib/libkrb/send_to_kdc.c
@@ -4,7 +4,7 @@
* <Copyright.MIT>.
*
* from: send_to_kdc.c,v 4.20 90/01/02 13:40:37 jtkohl Exp $
- * $Id: send_to_kdc.c,v 1.5 1995/08/25 22:52:05 markm Exp $
+ * $Id: send_to_kdc.c,v 1.3 1995/07/18 16:39:42 mark Exp $
*/
#if 0
@@ -17,9 +17,9 @@ static char rcsid_send_to_kdc_c[] =
#include <krb.h>
#include <prot.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -34,6 +34,11 @@ static char rcsid_send_to_kdc_c[] =
#define S_AD_SZ sizeof(struct sockaddr_in)
+extern int errno;
+extern int krb_debug;
+
+extern char *malloc(), *calloc(), *realloc();
+
int krb_udp_port = 0;
/* CLIENT_KRB_TIMEOUT indicates the time to wait before
@@ -41,6 +46,7 @@ int krb_udp_port = 0;
*/
static struct timeval timeout = { CLIENT_KRB_TIMEOUT, 0};
static char *prog = "send_to_kdc";
+static send_recv();
/*
* This file contains two routines, send_to_kdc() and send_recv().
@@ -48,106 +54,6 @@ static char *prog = "send_to_kdc";
*/
/*
- * try to send out and receive message.
- * return 1 on success, 0 on failure
- */
-
-static int send_recv(KTEXT pkt, KTEXT rpkt, int f, struct sockaddr_in *_to,
- struct hostent *addrs)
-{
- fd_set readfds;
- register struct hostent *hp;
- struct sockaddr_in from;
- int sin_size;
- int numsent;
- int addr_count;
-
- if (krb_debug) {
- if (_to->sin_family == AF_INET)
- printf("Sending message to %s...",
- inet_ntoa(_to->sin_addr));
- else
- printf("Sending message...");
- (void) fflush(stdout);
- }
- if ((numsent = sendto(f,(char *)(pkt->dat), pkt->length, 0,
- (struct sockaddr *)_to,
- S_AD_SZ)) != pkt->length) {
- if (krb_debug)
- printf("sent only %d/%d\n",numsent, pkt->length);
- return 0;
- }
- if (krb_debug) {
- printf("Sent\nWaiting for reply...");
- (void) fflush(stdout);
- }
- FD_ZERO(&readfds);
- FD_SET(f, &readfds);
- errno = 0;
- /* select - either recv is ready, or timeout */
- /* see if timeout or error or wrong descriptor */
- if (select(f + 1, &readfds, (fd_set *)0, (fd_set *)0, &timeout) < 1
- || !FD_ISSET(f, &readfds)) {
- if (krb_debug) {
- fprintf(stderr, "select failed: readfds=%lx",
- (unsigned long)&readfds);
- perror("");
- }
- return 0;
- }
- sin_size = sizeof(from);
- if (recvfrom(f, (char *)(rpkt->dat), sizeof(rpkt->dat), 0,
- (struct sockaddr *)&from, &sin_size)
- < 0) {
- if (krb_debug)
- perror("recvfrom");
- return 0;
- }
- if (krb_debug) {
- printf("received packet from %s\n", inet_ntoa(from.sin_addr));
- fflush(stdout);
- }
-/* At least Sun OS version 3.2 (or worse) and Ultrix version 2.2
- (or worse) only return one address ... */
-#if (defined(ULTRIX022) || (defined(SunOS) && SunOS < 40))
- for (hp = addrs; hp->h_name != (char *)NULL; hp++) {
- if (!bcmp(hp->h_addr, (char *)&from.sin_addr.s_addr,
- hp->h_length)) {
- if (krb_debug) {
- printf("Received it\n");
- (void) fflush(stdout);
- }
- return 1;
- }
- if (krb_debug)
- fprintf(stderr, "packet not from %s\n",
- inet_ntoa(*(struct in_addr *)hp->h_addr));
- }
- }
-#else /* !(ULTRIX022 || (SunOS < 40)) */
- for (hp = addrs; hp->h_name != (char *)NULL; hp++) {
- for (addr_count = 0; hp->h_addr_list[addr_count]; addr_count++) {
- if (!bcmp(hp->h_addr_list[addr_count],
- (char *)&from.sin_addr.s_addr, hp->h_length)) {
- if (krb_debug) {
- printf("Received it\n");
- (void) fflush(stdout);
- }
- return 1;
- }
- if (krb_debug)
- fprintf(stderr, "packet not from %s\n",
- inet_ntoa(*(struct in_addr *)hp->h_addr_list[addr_count]));
- }
- }
-#endif /* !(ULTRIX022 || (SunOS < 40)) */
- if (krb_debug)
- fprintf(stderr, "%s: received packet from wrong host! (%s)\n",
- "send_to_kdc(send_rcv)", inet_ntoa(from.sin_addr));
- return 0;
-}
-
-/*
* send_to_kdc() sends a message to the Kerberos authentication
* server(s) in the given realm and returns the reply message.
* The "pkt" argument points to the message to be sent to Kerberos;
@@ -174,16 +80,20 @@ static int send_recv(KTEXT pkt, KTEXT rpkt, int f, struct sockaddr_in *_to,
* after several retries
*/
-int send_to_kdc(KTEXT pkt, KTEXT rpkt, char *realm)
+int
+send_to_kdc(pkt,rpkt,realm)
+ KTEXT pkt;
+ KTEXT rpkt;
+ char *realm;
{
int i, f;
int no_host; /* was a kerberos host found? */
int retry;
int n_hosts;
int retval;
- int addr_count;
struct sockaddr_in to;
struct hostent *host, *hostlist;
+ char *cp;
char krbhst[MAX_HSTNM];
char lrealm[REALM_SZ];
@@ -242,70 +152,35 @@ int send_to_kdc(KTEXT pkt, KTEXT rpkt, char *realm)
continue;
no_host = 0; /* found at least one */
n_hosts++;
- /*
- * Preserve host network addresses to check against later
- */
+ /* preserve host network address to check later
+ * (would be better to preserve *all* addresses,
+ * take care of that later)
+ */
hostlist = (struct hostent *)
realloc((char *)hostlist,
(unsigned)
sizeof(struct hostent)*(n_hosts+1));
- if (!hostlist) {
- fprintf(stderr, "Could not grow hostlist\n");
- return /*errno */SKDC_CANT;
- }
- bcopy((char *)host, (char *)&hostlist[n_hosts-1],
- sizeof(struct hostent));
- host = &hostlist[n_hosts-1];
+ if (!hostlist)
+ return /*errno */SKDC_CANT;
+ bcopy((char *)host, (char *)&hostlist[n_hosts-1],
+ sizeof(struct hostent));
+ host = &hostlist[n_hosts-1];
+ cp = malloc((unsigned)host->h_length);
+ if (!cp) {
+ retval = /*errno */SKDC_CANT;
+ goto rtn;
+ }
+ bcopy((char *)host->h_addr, cp, host->h_length);
/* At least Sun OS version 3.2 (or worse) and Ultrix version 2.2
- (or worse) only return one address ... */
-#if (defined(ULTRIX022) || (defined(SunOS) && SunOS < 40))
- {
- char *cp = malloc((unsigned)host->h_length);
- if (!cp) {
- retval = /*errno */SKDC_CANT;
- goto rtn;
- }
- bcopy((char *)host->h_addr, cp, host->h_length);
- host->h_addr = cp;
- }
-#else /* !(ULTRIX022 || (SunOS < 40)) */
- /*
- * Make a copy of the entire h_addr_list.
- */
- {
- char *addr;
- char **old_addr_list;
- addr_count = 0;
- old_addr_list = host->h_addr_list;
- while(old_addr_list[addr_count++])
- ;
- host->h_addr_list = (char **)malloc(addr_count+1 * sizeof(char *));
- if (host->h_addr_list == NULL) {
- fprintf(stderr, "Could not allocate host->h_addr_list\n");
- retval = SKDC_CANT;
- goto rtn;
- }
- if (krb_debug) {
- printf("h_length = %d\n", host->h_length);
- printf("Number of addresses = %d\n", addr_count);
- }
- for (addr_count = 0; old_addr_list[addr_count]; addr_count++) {
- if (krb_debug)
- printf ("addr[%d] = %s\n", addr_count,
- inet_ntoa(*(struct in_addr *)old_addr_list[addr_count]));
- addr = (char *)malloc(host->h_length);
- if (addr == NULL) {
- fprintf(stderr, "Could not allocate address\n");
- retval = SKDC_CANT;
- goto rtn;
- }
- bcopy(old_addr_list[addr_count], addr, host->h_length);
- host->h_addr_list[addr_count] = addr;
- }
- host->h_addr_list[addr_count] = NULL;
- }
-#endif /* !(ULTRIX022 || (SunOS < 40)) */
-
+ (or worse) only return one name ... */
+#if !(defined(ULTRIX022) || (defined(SunOS) && SunOS < 40))
+ host->h_addr_list = (char **)malloc(sizeof(char *));
+ if (!host->h_addr_list) {
+ retval = /*errno */SKDC_CANT;
+ goto rtn;
+ }
+#endif /* ULTRIX022 || SunOS */
+ host->h_addr = cp;
bzero((char *)&hostlist[n_hosts],
sizeof(struct hostent));
to.sin_family = host->h_addrtype;
@@ -323,36 +198,22 @@ int send_to_kdc(KTEXT pkt, KTEXT rpkt, char *realm)
}
if (no_host) {
if (krb_debug)
- fprintf(stderr, "%s: can't find any Kerberos host.\n", prog);
+ fprintf(stderr, "%s: can't find any Kerberos host.\n",
+ prog);
retval = SKDC_CANT;
goto rtn;
}
- /*
- * retry each host in sequence. Some addresses may be unreachable
- * from where we are, so loop through them as well.
- */
+ /* retry each host in sequence */
for (retry = 0; retry < CLIENT_KRB_RETRY; ++retry) {
for (host = hostlist; host->h_name != (char *)NULL; host++) {
-#if (defined(ULTRIX022) || (defined(SunOS) && SunOS < 40))
- to.sin_family = host->h_addrtype;
- bcopy(host->h_addr_list[addr_count], (char *)&to.sin_addr,
- host->h_length);
- if (send_recv(pkt, rpkt, f, &to, hostlist)) {
- retval = KSUCCESS;
- goto rtn;
- }
-#else /* !(ULTRIX022 || (SunOS < 40)) */
- for (addr_count = 0; host->h_addr_list[addr_count]; addr_count++) {
- to.sin_family = host->h_addrtype;
- bcopy(host->h_addr_list[addr_count], (char *)&to.sin_addr,
- host->h_length);
- if (send_recv(pkt, rpkt, f, &to, hostlist)) {
- retval = KSUCCESS;
- goto rtn;
- }
- }
-#endif /* !(ULTRIX022 || (SunOS < 40)) */
- }
+ to.sin_family = host->h_addrtype;
+ bcopy(host->h_addr, (char *)&to.sin_addr,
+ host->h_length);
+ if (send_recv(pkt, rpkt, f, &to, hostlist)) {
+ retval = KSUCCESS;
+ goto rtn;
+ }
+ }
}
retval = SKDC_RETRY;
rtn:
@@ -375,3 +236,87 @@ rtn:
}
return(retval);
}
+
+/*
+ * try to send out and receive message.
+ * return 1 on success, 0 on failure
+ */
+
+static int
+send_recv(pkt,rpkt,f,_to,addrs)
+ KTEXT pkt;
+ KTEXT rpkt;
+ int f;
+ struct sockaddr_in *_to;
+ struct hostent *addrs;
+{
+ fd_set readfds;
+ register struct hostent *hp;
+ struct sockaddr_in from;
+ int sin_size;
+ int numsent;
+
+ if (krb_debug) {
+ if (_to->sin_family == AF_INET)
+ printf("Sending message to %s...",
+ inet_ntoa(_to->sin_addr));
+ else
+ printf("Sending message...");
+ (void) fflush(stdout);
+ }
+ if ((numsent = sendto(f,(char *)(pkt->dat), pkt->length, 0,
+ (struct sockaddr *)_to,
+ S_AD_SZ)) != pkt->length) {
+ if (krb_debug)
+ printf("sent only %d/%d\n",numsent, pkt->length);
+ return 0;
+ }
+ if (krb_debug) {
+ printf("Sent\nWaiting for reply...");
+ (void) fflush(stdout);
+ }
+ FD_ZERO(&readfds);
+ FD_SET(f, &readfds);
+ errno = 0;
+ /* select - either recv is ready, or timeout */
+ /* see if timeout or error or wrong descriptor */
+ if (select(f + 1, &readfds, (fd_set *)0, (fd_set *)0, &timeout) < 1
+ || !FD_ISSET(f, &readfds)) {
+ if (krb_debug) {
+ fprintf(stderr, "select failed: readfds=%x",
+ readfds);
+ perror("");
+ }
+ return 0;
+ }
+ sin_size = sizeof(from);
+ if (recvfrom(f, (char *)(rpkt->dat), sizeof(rpkt->dat), 0,
+ (struct sockaddr *)&from, &sin_size)
+ < 0) {
+ if (krb_debug)
+ perror("recvfrom");
+ return 0;
+ }
+ if (krb_debug) {
+ printf("received packet from %s\n", inet_ntoa(from.sin_addr));
+ fflush(stdout);
+ }
+ for (hp = addrs; hp->h_name != (char *)NULL; hp++) {
+ if (!bcmp(hp->h_addr, (char *)&from.sin_addr.s_addr,
+ hp->h_length)) {
+ if (krb_debug) {
+ printf("Received it\n");
+ (void) fflush(stdout);
+ }
+ return 1;
+ }
+ if (krb_debug)
+ fprintf(stderr,
+ "packet not from %lx\n",
+ (unsigned long)hp->h_addr);
+ }
+ if (krb_debug)
+ fprintf(stderr, "%s: received packet from wrong host! (%lx)\n",
+ "send_to_kdc(send_rcv)", from.sin_addr.s_addr);
+ return 0;
+}
diff --git a/eBones/lib/libkrb/sendauth.c b/eBones/lib/libkrb/sendauth.c
index add71d9..a1d79e7 100644
--- a/eBones/lib/libkrb/sendauth.c
+++ b/eBones/lib/libkrb/sendauth.c
@@ -28,6 +28,10 @@ static char rcsid[] =
* and make appropriate changes in krb_recvauth.c
*/
+extern int errno;
+
+extern char *krb_get_phost();
+
/*
* This file contains two routines: krb_sendauth() and krb_sendsrv().
*
@@ -107,10 +111,21 @@ static char rcsid[] =
* will disappear when krb_sendauth() returns.
*/
-int krb_sendauth(long options, int fd, KTEXT ticket, char *service, char *inst,
- char *realm, u_long checksum, MSG_DAT *msg_data, CREDENTIALS *cred,
- des_key_schedule schedule, struct sockaddr_in *laddr,
- struct sockaddr_in *faddr, char *version)
+int
+krb_sendauth(options, fd, ticket, service, inst, realm, checksum,
+ msg_data, cred, schedule, laddr, faddr, version)
+long options; /* bit-pattern of options */
+int fd; /* file descriptor to write onto */
+KTEXT ticket; /* where to put ticket (return); or
+ * supplied in case of KOPT_DONT_MK_REQ */
+char *service, *inst, *realm; /* service name, instance, realm */
+u_long checksum; /* checksum to include in request */
+MSG_DAT *msg_data; /* mutual auth MSG_DAT (return) */
+CREDENTIALS *cred; /* credentials (return) */
+Key_schedule schedule; /* key schedule (return) */
+struct sockaddr_in *laddr; /* local address */
+struct sockaddr_in *faddr; /* address of foreign host on fd */
+char *version; /* version string */
{
int rem, i, cc;
char srv_inst[INST_SZ];
@@ -198,7 +213,7 @@ int krb_sendauth(long options, int fd, KTEXT ticket, char *service, char *inst,
/* ...and decrypt it */
#ifndef NOENCRYPTION
- key_sched((des_cblock *)cred->session,schedule);
+ key_sched((C_Block *)cred->session,schedule);
#endif
if ((cc = krb_rd_priv(priv_buf,(unsigned long) tkt_len, schedule,
cred->session, faddr, laddr, msg_data)))
@@ -221,7 +236,10 @@ int krb_sendauth(long options, int fd, KTEXT ticket, char *service, char *inst,
* krb_sendsvc
*/
-int krb_sendsvc(int fd, char *service)
+int
+krb_sendsvc(fd, service)
+int fd;
+char *service;
{
/* write the service name length and then the service name to
the fd */
diff --git a/eBones/lib/libkrb/stime.c b/eBones/lib/libkrb/stime.c
index f70c33d..2da2463 100644
--- a/eBones/lib/libkrb/stime.c
+++ b/eBones/lib/libkrb/stime.c
@@ -26,7 +26,8 @@ static char *rcsid =
* "25-Jan-88 10:17:56"
*/
-char *stime(t)
+char *
+stime(t)
long *t;
{
static char st_data[40];
diff --git a/eBones/lib/libkrb/tf_shm.c b/eBones/lib/libkrb/tf_shm.c
index ad6690a..31894cb 100644
--- a/eBones/lib/libkrb/tf_shm.c
+++ b/eBones/lib/libkrb/tf_shm.c
@@ -28,6 +28,9 @@ static char rcsid[] =
#define MAX_BUFF sizeof(des_cblock)*1000 /* room for 1k keys */
+extern int errno;
+extern int krb_debug;
+
/*
* krb_create_shmtkt:
*
@@ -35,7 +38,9 @@ static char rcsid[] =
* in the specified filename.
*/
-int krb_shm_create(char *file_name)
+int
+krb_shm_create(file_name)
+char *file_name;
{
int retval;
int shmid;
@@ -133,7 +138,8 @@ int krb_is_diskless()
* file pointing to it.
*/
-int krb_shm_dest(char *file)
+int krb_shm_dest(file)
+char *file;
{
int shmid;
FILE *sfile;
@@ -165,3 +171,6 @@ int krb_shm_dest(char *file)
} else
return(RET_TKFIL); /* XXX */
}
+
+
+
diff --git a/eBones/lib/libkrb/tf_util.c b/eBones/lib/libkrb/tf_util.c
index ef91658..e939c38 100644
--- a/eBones/lib/libkrb/tf_util.c
+++ b/eBones/lib/libkrb/tf_util.c
@@ -14,9 +14,9 @@ static char rcsid[] =
#endif /* lint */
#endif
-#include <stdio.h>
-#include <string.h>
#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -33,12 +33,13 @@ static char rcsid[] =
#define TF_LCK_RETRY ((unsigned)2) /* seconds to sleep before
* retry if ticket file is
* locked */
+extern int krb_debug;
+
#ifdef TKT_SHMEM
char *krb_shm_addr = 0;
static char *tmp_shm_addr = 0;
static char krb_dummy_skey[8] = {0,0,0,0,0,0,0,0};
-char *shmat();
#endif /* TKT_SHMEM */
/*
@@ -54,12 +55,13 @@ char *shmat();
* c. In tf_close, be sure it gets reinitialized to a negative
* number.
*/
-static int fd = -1;
-static int curpos; /* Position in tfbfr */
-static int lastpos; /* End of tfbfr */
+static fd = -1;
+static curpos; /* Position in tfbfr */
+static lastpos; /* End of tfbfr */
static char tfbfr[BUFSIZ]; /* Buffer for ticket data */
-static tf_gets(), tf_read();
+static int tf_read(char *s, int n);
+static int tf_gets(char *s, int n);
/*
* This file contains routines for manipulating the ticket cache file.
@@ -123,7 +125,10 @@ static tf_gets(), tf_read();
* TKT_FIL_LCK - couldn't lock the file, even after a retry
*/
-int tf_init(char *tf_name, int rw)
+int
+tf_init(tf_name, rw)
+ char *tf_name;
+ int rw;
{
int wflag;
uid_t me, getuid();
@@ -259,7 +264,9 @@ int tf_init(char *tf_name, int rw)
* was longer than ANAME_SZ, TKT_FIL_FMT is returned.
*/
-int tf_get_pname(char *p)
+int
+tf_get_pname(p)
+ char *p;
{
if (fd < 0) {
if (krb_debug)
@@ -281,7 +288,9 @@ int tf_get_pname(char *p)
* instance may be null.
*/
-int tf_get_pinst(char *inst)
+int
+tf_get_pinst(inst)
+ char *inst;
{
if (fd < 0) {
if (krb_debug)
@@ -294,33 +303,6 @@ int tf_get_pinst(char *inst)
}
/*
- * tf_close() closes the ticket file and sets "fd" to -1. If "fd" is
- * not a valid file descriptor, it just returns. It also clears the
- * buffer used to read tickets.
- *
- * The return value is not defined.
- */
-
-void tf_close()
-{
- if (!(fd < 0)) {
-#ifdef TKT_SHMEM
- if (shmdt(krb_shm_addr)) {
- /* what kind of error? */
- if (krb_debug)
- fprintf(stderr, "shmdt 0x%x: errno %d",krb_shm_addr, errno);
- } else {
- krb_shm_addr = 0;
- }
-#endif TKT_SHMEM
- (void) flock(fd, LOCK_UN);
- (void) close(fd);
- fd = -1; /* see declaration of fd above */
- }
- bzero(tfbfr, sizeof(tfbfr));
-}
-
-/*
* tf_get_cred() reads a CREDENTIALS record from a ticket file and fills
* in the given structure "c". It should only be called after tf_init(),
* tf_get_pname(), and tf_get_pinst() have been called. If all goes well,
@@ -331,7 +313,9 @@ void tf_close()
* EOF - end of file encountered
*/
-int tf_get_cred(CREDENTIALS *c)
+int
+tf_get_cred(c)
+ CREDENTIALS *c;
{
KTEXT ticket = &c->ticket_st; /* pointer to ticket */
int k_errno;
@@ -388,6 +372,34 @@ int tf_get_cred(CREDENTIALS *c)
}
/*
+ * tf_close() closes the ticket file and sets "fd" to -1. If "fd" is
+ * not a valid file descriptor, it just returns. It also clears the
+ * buffer used to read tickets.
+ *
+ * The return value is not defined.
+ */
+
+void
+tf_close()
+{
+ if (!(fd < 0)) {
+#ifdef TKT_SHMEM
+ if (shmdt(krb_shm_addr)) {
+ /* what kind of error? */
+ if (krb_debug)
+ fprintf(stderr, "shmdt 0x%x: errno %d",krb_shm_addr, errno);
+ } else {
+ krb_shm_addr = 0;
+ }
+#endif TKT_SHMEM
+ (void) flock(fd, LOCK_UN);
+ (void) close(fd);
+ fd = -1; /* see declaration of fd above */
+ }
+ bzero(tfbfr, sizeof(tfbfr));
+}
+
+/*
* tf_gets() is an internal routine. It takes a string "s" and a count
* "n", and reads from the file until either it has read "n" characters,
* or until it reads a null byte. When finished, what has been read exists
@@ -405,7 +417,10 @@ int tf_get_cred(CREDENTIALS *c)
* file is seriously ill.
*/
-static int tf_gets(char *s, int n)
+static int
+tf_gets(s, n)
+ register char *s;
+ int n;
{
register count;
@@ -444,9 +459,12 @@ static int tf_gets(char *s, int n)
* 0 on end of file or read error
*/
-static int tf_read(char *s, int n)
+static int
+tf_read(s, n)
+ register char *s;
+ register int n;
{
- int count;
+ register count;
for (count = n; count > 0; --count) {
if (curpos >= sizeof(tfbfr)) {
@@ -462,8 +480,6 @@ static int tf_read(char *s, int n)
return n;
}
-char *tkt_string();
-
/*
* tf_save_cred() appends an incoming ticket to the end of the ticket
* file. You must call tf_init() before calling tf_save_cred().
@@ -478,8 +494,17 @@ char *tkt_string();
* called previously, and KFAILURE for anything else that went wrong.
*/
-int tf_save_cred(char *service, char *instance, char *realm,
- des_cblock session, int lifetime, int kvno, KTEXT ticket, long issue_date)
+int
+tf_save_cred(service, instance, realm, session, lifetime, kvno,
+ ticket, issue_date)
+ char *service; /* Service name */
+ char *instance; /* Instance */
+ char *realm; /* Auth domain */
+ C_Block session; /* Session key */
+ int lifetime; /* Lifetime */
+ int kvno; /* Key version number */
+ KTEXT ticket; /* The ticket itself */
+ long issue_date; /* The issue time */
{
off_t lseek();
diff --git a/eBones/lib/libkrb/tkt_string.c b/eBones/lib/libkrb/tkt_string.c
index bbbdbc5..d944833 100644
--- a/eBones/lib/libkrb/tkt_string.c
+++ b/eBones/lib/libkrb/tkt_string.c
@@ -15,8 +15,8 @@ static char *rcsid =
#endif /* lint */
#endif
-#include <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include <sys/types.h>
#include <krb.h>
#include <string.h>
@@ -68,7 +68,9 @@ char *tkt_string()
* and return an undesired ticket file name until this routine is called.
*/
-void krb_set_tkt_string(char *val)
+void
+krb_set_tkt_string(val)
+char *val;
{
(void) strncpy(krb_ticket_string, val, sizeof(krb_ticket_string)-1);
diff --git a/eBones/lib/libkrb/util.c b/eBones/lib/libkrb/util.c
index 8dca743..68c0dbc 100644
--- a/eBones/lib/libkrb/util.c
+++ b/eBones/lib/libkrb/util.c
@@ -30,7 +30,9 @@ static char rcsid[] =
* pname, pinst, prealm, netaddr, flags, cksum, timestamp, session
*/
-void ad_print(AUTH_DAT *x)
+void
+ad_print(x)
+AUTH_DAT *x;
{
struct in_addr in;
@@ -44,7 +46,7 @@ void ad_print(AUTH_DAT *x)
#ifdef NOENCRYPTION
placebo_cblock_print(x->session);
#else
- des_cblock_print_file((des_cblock *)x->session,stdout);
+ des_cblock_print_file((C_Block *)x->session,stdout);
#endif
/* skip reply for now */
}
OpenPOWER on IntegriCloud