summaryrefslogtreecommitdiffstats
path: root/eBones/kdb
diff options
context:
space:
mode:
Diffstat (limited to 'eBones/kdb')
-rw-r--r--eBones/kdb/Makefile4
-rw-r--r--eBones/kdb/krb_cache.c43
-rw-r--r--eBones/kdb/krb_dbm.c135
-rw-r--r--eBones/kdb/krb_kdb_utils.c62
-rw-r--r--eBones/kdb/krb_lib.c38
-rw-r--r--eBones/kdb/print_princ.c20
6 files changed, 117 insertions, 185 deletions
diff --git a/eBones/kdb/Makefile b/eBones/kdb/Makefile
index b69c0d9..42f4235 100644
--- a/eBones/kdb/Makefile
+++ b/eBones/kdb/Makefile
@@ -1,11 +1,11 @@
# From: @(#)Makefile 5.1 (Berkeley) 6/25/90
-# $Id: Makefile,v 1.3 1994/09/09 21:43:41 g89r4222 Exp $
+# $Id: Makefile,v 1.4 1995/07/18 16:37:10 mark Exp $
SHLIB_MAJOR= 2
SHLIB_MINOR= 0
LIB= kdb
-CFLAGS+=-DKERBEROS -DDEBUG -I${.CURDIR}/../include
+CFLAGS+=-DKERBEROS -DDEBUG -I${.CURDIR}/../include -Wall
SRCS= krb_cache.c krb_dbm.c krb_kdb_utils.c krb_lib.c print_princ.c
.include <bsd.lib.mk>
diff --git a/eBones/kdb/krb_cache.c b/eBones/kdb/krb_cache.c
index 8da1d7d..0dafb140 100644
--- a/eBones/kdb/krb_cache.c
+++ b/eBones/kdb/krb_cache.c
@@ -6,13 +6,15 @@
* This is where a cache would be implemented, if it were necessary.
*
* from: krb_cache.c,v 4.5 89/01/24 18:12:34 jon Exp $
- * $Id: krb_cache.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $
+ * $Id: krb_cache.c,v 1.3 1995/07/18 16:37:12 mark Exp $
*/
+#if 0
#ifndef lint
static char rcsid[] =
-"$Id: krb_cache.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $";
+"$Id: krb_cache.c,v 1.3 1995/07/18 16:37:12 mark Exp $";
#endif lint
+#endif
#include <stdio.h>
#include <sys/types.h>
@@ -25,8 +27,6 @@ static char rcsid[] =
#include <krb.h>
#include <krb_db.h>
-extern char *strncpy();
-
#ifdef DEBUG
extern int debug;
extern long kerb_debug;
@@ -49,15 +49,10 @@ kerb_cache_init()
*/
int
-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 */
-
+kerb_cache_get_principal(char *serv, char *inst, Principal *principal,
+ unsigned int max)
{
int found = 0;
- u_long i;
if (!init)
kerb_cache_init();
@@ -70,7 +65,7 @@ kerb_cache_get_principal(serv, inst, principal, max)
#ifdef DEBUG
if (kerb_debug & 2) {
if (found) {
- fprintf(stderr, "cache get %s %s found %s %s sid = %d\n",
+ fprintf(stderr, "cache get %s %s found %s %s\n",
serv, inst, principal->name, principal->instance);
} else {
fprintf(stderr, "cache %s %s not found\n", serv,
@@ -87,13 +82,8 @@ kerb_cache_get_principal(serv, inst, principal, max)
*/
int
-kerb_cache_put_principal(principal, max)
- Principal *principal;
- unsigned int max; /* max number of principal structs to
- * insert */
-
+kerb_cache_put_principal(Principal *principal, unsigned int max)
{
- int found = 0;
u_long i;
int count = 0;
@@ -125,15 +115,9 @@ kerb_cache_put_principal(principal, max)
*/
int
-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 */
-
+kerb_cache_get_dba(char *serv, char *inst, Dba *dba, unsigned int max)
{
int found = 0;
- u_long i;
if (!init)
kerb_cache_init();
@@ -147,7 +131,7 @@ kerb_cache_get_dba(serv, inst, dba, max)
#ifdef DEBUG
if (kerb_debug & 2) {
if (found) {
- fprintf(stderr, "cache get %s %s found %s %s sid = %d\n",
+ fprintf(stderr, "cache get %s %s found %s %s\n",
serv, inst, dba->name, dba->instance);
} else {
fprintf(stderr, "cache %s %s not found\n", serv, inst);
@@ -162,12 +146,8 @@ kerb_cache_get_dba(serv, inst, dba, max)
*/
int
-kerb_cache_put_dba(dba, max)
- Dba *dba;
- unsigned int max; /* max number of dba structs to insert */
-
+kerb_cache_put_dba(Dba *dba, unsigned int max)
{
- int found = 0;
u_long i;
int count = 0;
@@ -190,4 +170,3 @@ kerb_cache_put_dba(dba, max)
}
return count;
}
-
diff --git a/eBones/kdb/krb_dbm.c b/eBones/kdb/krb_dbm.c
index c42df20..68f428b 100644
--- a/eBones/kdb/krb_dbm.c
+++ b/eBones/kdb/krb_dbm.c
@@ -4,19 +4,27 @@
* <Copyright.MIT>.
*
* from: krb_dbm.c,v 4.9 89/04/18 16:15:13 wesommer Exp $
- * $Id: krb_dbm.c,v 1.3 1995/05/30 06:40:38 rgrimes Exp $
- */
+ * $Id: krb_dbm.c,v 1.4 1995/08/03 17:15:42 mark Exp $
+*/
+#if 0
#ifndef lint
static char rcsid[] =
-"$Id: krb_dbm.c,v 1.3 1995/05/30 06:40:38 rgrimes Exp $";
+"$Id: krb_dbm.c,v 1.4 1995/08/03 17:15:42 mark Exp $";
#endif lint
+#endif
#if defined(__FreeBSD__) || defined(__NetBSD__)
-#define NDBM
+#define NDBM_
+#endif
+
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+#define DBM_
#endif
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/uio.h>
@@ -27,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 DB
+#define DBM_
#endif
#define KERB_DB_MAX_RETRY 5
@@ -47,10 +55,8 @@ extern int debug;
extern long kerb_debug;
extern char *progname;
#endif
-extern char *malloc();
-extern int errno;
-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();
@@ -122,7 +128,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))
@@ -139,9 +145,7 @@ typedef char DBM;
* Utility routine: generate name of database file.
*/
-static char *gen_dbsuffix(db_name, sfx)
- char *db_name;
- char *sfx;
+static char *gen_dbsuffix(char *db_name, char *sfx)
{
char *dbsuffix;
@@ -158,7 +162,7 @@ static char *gen_dbsuffix(db_name, sfx)
* initialization for data base routines.
*/
-kerb_db_init()
+int kerb_db_init()
{
init = 1;
return (0);
@@ -169,7 +173,7 @@ kerb_db_init()
* a kerb_db_init
*/
-kerb_db_fini()
+void kerb_db_fini()
{
}
@@ -180,8 +184,7 @@ kerb_db_fini()
* If the alternate database doesn't exist, nothing is changed.
*/
-kerb_db_set_name(name)
- char *name;
+int kerb_db_set_name(char *name)
{
DBM *db;
@@ -225,8 +228,7 @@ long kerb_get_db_age()
* the server (for example, during slave updates).
*/
-static long kerb_start_update(db_name)
- char *db_name;
+static long kerb_start_update(char *db_name)
{
char *okname = gen_dbsuffix(db_name, ".ok");
long age = kerb_get_db_age();
@@ -239,9 +241,7 @@ static long kerb_start_update(db_name)
return age;
}
-static long kerb_end_update(db_name, age)
- char *db_name;
- long age;
+static long kerb_end_update(char *db_name, long age)
{
int fd;
int retval = 0;
@@ -281,8 +281,7 @@ static long kerb_start_read()
return kerb_get_db_age();
}
-static long kerb_end_read(age)
- u_long age;
+static long kerb_end_read(u_long age)
{
if (kerb_get_db_age() != age || age == -1) {
return -1;
@@ -294,13 +293,12 @@ static long kerb_end_read(age)
* Create the database, assuming it's not there.
*/
-kerb_db_create(db_name)
- char *db_name;
+int kerb_db_create(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);
@@ -343,11 +341,10 @@ kerb_db_create(db_name)
* necessarily know to complete the transaction the rename, but...
*/
-kerb_db_rename(from, to)
- char *from;
- char *to;
+int kerb_db_rename(char *from, char *to)
{
-#ifdef DB
+ int ok = 0;
+#ifdef DBM_
char *fromdb = gen_dbsuffix (from, ".db");
char *todb = gen_dbsuffix (to, ".db");
#else
@@ -358,9 +355,8 @@ kerb_db_rename(from, to)
#endif
char *fromok = gen_dbsuffix(from, ".ok");
long trans = kerb_start_update(to);
- int ok;
-#ifdef DB
+#ifdef DBM_
if (rename (fromdb, todb) == 0) {
#else
if ((rename (fromdir, todir) == 0)
@@ -371,7 +367,7 @@ kerb_db_rename(from, to)
}
free (fromok);
-#ifdef DB
+#ifdef DBM_
free (fromdb);
free (todb);
#else
@@ -389,15 +385,15 @@ kerb_db_rename(from, 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?
*/
-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 kerb_db_get_principal(char *name, char *inst, Principal *principal,
+ unsigned int max, int *more)
{
int found = 0, code;
extern int errorproc();
@@ -495,11 +491,7 @@ kerb_db_get_principal(name, inst, principal, max, more)
* successfully updated.
*/
-kerb_db_put_principal(principal, max)
- Principal *principal;
- unsigned int max; /* number of principal structs to
- * update */
-
+int kerb_db_put_principal(Principal *principal, unsigned int max)
{
int found = 0, code;
u_long i;
@@ -544,9 +536,7 @@ kerb_db_put_principal(principal, max)
}
static void
-encode_princ_key(key, name, instance)
- datum *key;
- char *name, *instance;
+encode_princ_key(datum *key, char *name, char *instance)
{
static char keystring[ANAME_SZ + INST_SZ];
@@ -558,9 +548,7 @@ encode_princ_key(key, name, instance)
}
static void
-decode_princ_key(key, name, instance)
- datum *key;
- char *name, *instance;
+decode_princ_key(datum *key, char *name, char *instance)
{
strncpy(name, key->dptr, ANAME_SZ);
strncpy(instance, key->dptr + ANAME_SZ, INST_SZ);
@@ -569,24 +557,19 @@ decode_princ_key(key, name, instance)
}
static void
-encode_princ_contents(contents, principal)
- datum *contents;
- Principal *principal;
+encode_princ_contents(datum *contents, Principal *principal)
{
contents->dsize = sizeof(*principal);
contents->dptr = (char *) principal;
}
static void
-decode_princ_contents(contents, principal)
- datum *contents;
- Principal *principal;
+decode_princ_contents(datum *contents, Principal *principal)
{
bcopy(contents->dptr, (char *) principal, sizeof(*principal));
}
-kerb_db_get_stat(s)
- DB_stat *s;
+void kerb_db_get_stat(DB_stat *s)
{
gettimeofday(&timestamp, NULL);
@@ -604,13 +587,11 @@ kerb_db_get_stat(s)
/* update local copy too */
}
-kerb_db_put_stat(s)
- DB_stat *s;
+void kerb_db_put_stat(DB_stat *s)
{
}
-delta_stat(a, b, c)
- DB_stat *a, *b, *c;
+void delta_stat(DB_stat *a, DB_stat *b, DB_stat *c)
{
/* c = a - b then b = a for the next time */
@@ -626,7 +607,6 @@ delta_stat(a, b, c)
c->n_put_stat = a->n_put_stat - b->n_put_stat;
bcopy(a, b, sizeof(DB_stat));
- return;
}
/*
@@ -634,21 +614,14 @@ delta_stat(a, b, c)
* whether there were more than requested.
*/
-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? */
-
+int kerb_db_get_dba(char *dba_name, char *dba_inst, Dba *dba, unsigned int max,
+ int *more)
{
*more = 0;
return (0);
}
-kerb_db_iterate (func, arg)
- int (*func)();
- char *arg; /* void *, really */
+int kerb_db_iterate (int (*func)(), char *arg)
{
datum key, contents;
Principal *principal;
@@ -677,7 +650,7 @@ static int dblfd = -1;
static int mylock = 0;
static int inited = 0;
-static kerb_dbl_init()
+static int kerb_dbl_init()
{
if (!inited) {
char *filename = gen_dbsuffix (current_db_name, ".ok");
@@ -701,8 +674,7 @@ static void kerb_dbl_fini()
mylock = 0;
}
-static int kerb_dbl_lock(mode)
- int mode;
+static int kerb_dbl_lock(int mode)
{
int flock_mode;
@@ -750,8 +722,7 @@ static void kerb_dbl_unlock()
mylock = 0;
}
-int kerb_db_set_lockmode(mode)
- int mode;
+int kerb_db_set_lockmode(int mode)
{
int old = non_blocking;
non_blocking = mode;
diff --git a/eBones/kdb/krb_kdb_utils.c b/eBones/kdb/krb_kdb_utils.c
index c283e0f..275cc39 100644
--- a/eBones/kdb/krb_kdb_utils.c
+++ b/eBones/kdb/krb_kdb_utils.c
@@ -10,25 +10,27 @@
* Jon Rochlis, MIT Telecom, March 1988
*
* from: krb_kdb_utils.c,v 4.1 89/07/26 11:01:12 jtkohl Exp $
- * $Id: krb_kdb_utils.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $
+ * $Id: krb_kdb_utils.c,v 1.3 1995/07/18 16:37:15 mark Exp $
*/
+#if 0
#ifndef lint
static char rcsid[] =
-"$Id: krb_kdb_utils.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $";
+"$Id: krb_kdb_utils.c,v 1.3 1995/07/18 16:37:15 mark Exp $";
#endif lint
+#endif
-#include <des.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>
-#include <stdio.h>
-#include <sys/file.h>
-long kdb_get_master_key(prompt, master_key, master_key_sched)
- int prompt;
- C_Block master_key;
- Key_schedule master_key_sched;
+long kdb_get_master_key(int prompt, C_Block master_key,
+ Key_schedule master_key_sched)
{
int kfile;
@@ -37,7 +39,7 @@ long kdb_get_master_key(prompt, master_key, master_key_sched)
placebo_read_password(master_key,
"\nEnter Kerberos master key: ", 0);
#else
- des_read_password(master_key,
+ des_read_password((C_Block *)master_key,
"\nEnter Kerberos master key: ", 0);
#endif
printf ("\n");
@@ -55,20 +57,33 @@ long kdb_get_master_key(prompt, master_key, master_key_sched)
}
#ifndef NOENCRYPTION
- key_sched(master_key,master_key_sched);
+ key_sched((C_Block *)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 (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 */
+long kdb_verify_master_key (C_Block master_key, Key_schedule master_key_sched,
+ FILE *out)
{
C_Block key_from_db;
Principal principal_data[1];
@@ -122,20 +137,3 @@ long kdb_verify_master_key (master_key, master_key_sched, out)
return (master_key_version);
}
-
-/* The old algorithm used the key schedule as the initial vector which
- was byte order depedent ... */
-
-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(in,out,(long)sizeof(C_Block),master_key_sched,master_key,
- e_d_flag);
-#endif
-}
diff --git a/eBones/kdb/krb_lib.c b/eBones/kdb/krb_lib.c
index b90d1a5..5610dbb 100644
--- a/eBones/kdb/krb_lib.c
+++ b/eBones/kdb/krb_lib.c
@@ -1,6 +1,6 @@
/*
- * $Source: /home/ncvs/src/eBones/kdb/krb_lib.c,v $
- * $Author: csgr $
+ * $Source: /usr/cvs/src/eBones/kdb/krb_lib.c,v $
+ * $Author: mark $
*
* Copyright 1988 by the Massachusetts Institute of Technology.
*
@@ -8,12 +8,15 @@
* <mit-copyright.h>.
*/
+#if 0
#ifndef lint
static char rcsid[] =
-"$Id: krb_lib.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $";
+"$Id: krb_lib.c,v 1.3 1995/07/18 16:37:17 mark Exp $";
#endif lint
+#endif
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/uio.h>
@@ -30,10 +33,6 @@ extern char *progname;
long kerb_debug;
#endif
-extern char *strncpy();
-extern char *ctime();
-extern char *getenv();
-
static init = 0;
/*
@@ -47,7 +46,7 @@ kerb_init()
if (!init) {
char *dbg = getenv("KERB_DBG");
if (dbg)
- sscanf(dbg, "%d", &kerb_debug);
+ sscanf(dbg, "%ld", &kerb_debug);
init = 1;
}
#endif
@@ -67,7 +66,7 @@ kerb_init()
* caches, if they're ever really implemented.
*/
-int
+void
kerb_fini()
{
kerb_db_fini();
@@ -79,13 +78,8 @@ kerb_fini()
*/
int
-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 */
-
+kerb_get_principal(char *name, char *inst, Principal *principal,
+ unsigned int max, int *more)
{
int found = 0;
#ifdef CACHE
@@ -137,9 +131,7 @@ kerb_get_principal(name, inst, principal, max, more)
}
/* principals */
-kerb_put_principal(principal, n)
- Principal *principal;
- unsigned int n; /* number of principal structs to write */
+int kerb_put_principal(Principal *principal, unsigned int n)
{
long time();
struct tm *tp, *localtime();
@@ -184,13 +176,7 @@ kerb_put_principal(principal, n)
}
int
-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 */
-
+kerb_get_dba(char *name, char *inst, Dba *dba, unsigned int max, int *more)
{
int found = 0;
#ifdef CACHE
diff --git a/eBones/kdb/print_princ.c b/eBones/kdb/print_princ.c
index d04ca39..b1d1ca9 100644
--- a/eBones/kdb/print_princ.c
+++ b/eBones/kdb/print_princ.c
@@ -3,14 +3,16 @@
* For copying and distribution information, please see the file
* <Copyright.MIT>.
*
- * from: $Header: /home/ncvs/src/eBones/kdb/print_princ.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $
- * $Id: print_princ.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $
+ * from: $Header: /usr/cvs/src/eBones/kdb/print_princ.c,v 1.3 1995/07/18 16:37:19 mark Exp $
+ * $Id: print_princ.c,v 1.3 1995/07/18 16:37:19 mark Exp $
*/
+#if 0
#ifndef lint
static char rcsid[] =
-"$Id: print_princ.c,v 1.1.1.1 1994/09/30 14:49:55 csgr Exp $";
+"$Id: print_princ.c,v 1.3 1995/07/18 16:37:19 mark Exp $";
#endif lint
+#endif
#include <stdio.h>
#include <sys/types.h>
@@ -20,15 +22,11 @@ static char rcsid[] =
#include <krb_db.h>
extern int debug;
-extern char *strncpy();
-extern char *ctime();
-extern struct tm *localtime();
-struct tm *time_p;
long kerb_debug;
+static struct tm *time_p;
-krb_print_principal(a_n)
- Principal *a_n;
+void krb_print_principal(Principal *a_n)
{
/* run-time database does not contain string versions */
time_p = localtime(&(a_n->exp_date));
@@ -42,9 +40,9 @@ krb_print_principal(a_n)
a_n->max_life, 5 * a_n->max_life, a_n->attributes);
fprintf(stderr,
- "\n\tkey_ver %d k_low 0x%08x k_high 0x%08x akv %d exists %d\n",
+ "\n\tkey_ver %d k_low 0x%08lx k_high 0x%08lx akv %d exists %d\n",
a_n->key_version, a_n->key_low, a_n->key_high,
- a_n->kdc_key_ver, a_n->old);
+ a_n->kdc_key_ver, (int)a_n->old);
fflush(stderr);
}
OpenPOWER on IntegriCloud