summaryrefslogtreecommitdiffstats
path: root/eBones/libkadm
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/libkadm
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/libkadm')
-rw-r--r--eBones/libkadm/Makefile3
-rw-r--r--eBones/libkadm/kadm.h16
-rw-r--r--eBones/libkadm/kadm_cli_wrap.c74
-rw-r--r--eBones/libkadm/kadm_stream.c80
-rw-r--r--eBones/libkadm/kadm_supp.c26
5 files changed, 151 insertions, 48 deletions
diff --git a/eBones/libkadm/Makefile b/eBones/libkadm/Makefile
index 4642530..293e842 100644
--- a/eBones/libkadm/Makefile
+++ b/eBones/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/libkadm/kadm.h b/eBones/libkadm/kadm.h
index eea05df..21a23bb 100644
--- a/eBones/libkadm/kadm.h
+++ b/eBones/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/libkadm/kadm_cli_wrap.c b/eBones/libkadm/kadm_cli_wrap.c
index 3522e74..e25439d 100644
--- a/eBones/libkadm/kadm_cli_wrap.c
+++ b/eBones/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/libkadm/kadm_stream.c b/eBones/libkadm/kadm_stream.c
index 02b8263..58a625a 100644
--- a/eBones/libkadm/kadm_stream.c
+++ b/eBones/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/libkadm/kadm_supp.c b/eBones/libkadm/kadm_supp.c
index deaf63b..353fed0 100644
--- a/eBones/libkadm/kadm_supp.c
+++ b/eBones/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));
OpenPOWER on IntegriCloud