From 1d71425d115728986027714ccb492e84341d0749 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Fri, 26 Jan 2001 15:55:07 +0000 Subject: [PATCH] include shadow definition of kdb Principal, so we don't have to depend on any v4 libraries git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9506 ec53bebd-3082-4978-b11e-865c3cabbd6b --- kdc/hprop.h | 16 +++++++++++++++- kdc/v4_dump.c | 31 +++++++++++++++++++------------ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/kdc/hprop.h b/kdc/hprop.h index 141c4dbec..b493e5dbf 100644 --- a/kdc/hprop.h +++ b/kdc/hprop.h @@ -55,7 +55,21 @@ struct prop_data{ krb5_error_code v5_prop(krb5_context, HDB*, hdb_entry*, void*); int mit_prop_dump(void*, const char*); -int v4_prop(void*, Principal*); + +struct v4_principal { + char name[64]; + char instance[64]; + des_cblock key; + int kvno; + int mkvno; + time_t exp_date; + time_t mod_date; + char mod_name[64]; + char mod_instance[64]; + int max_life; +}; + +int v4_prop(void*, struct v4_principal*); int v4_prop_dump(void *arg, const char*); #endif /* __HPROP_H__ */ diff --git a/kdc/v4_dump.c b/kdc/v4_dump.c index 581544852..ab2c9cb79 100644 --- a/kdc/v4_dump.c +++ b/kdc/v4_dump.c @@ -35,7 +35,6 @@ RCSID("$Id$"); -#ifdef KRB4 static time_t time_parse(const char *cp) { @@ -82,6 +81,7 @@ time_parse(const char *cp) return(tm2time(tp, local)); } +/* convert a version 4 dump file */ int v4_prop_dump(void *arg, const char *file) { @@ -96,17 +96,17 @@ v4_prop_dump(void *arg, const char *file) while(fgets(buf, sizeof(buf), f)) { int ret; unsigned long key[2]; /* yes, long */ - int life, kkvno, kvno; char exp_date[64], mod_date[64]; - Principal pr; + struct v4_principal pr; + int attributes; memset(&pr, 0, sizeof(pr)); errno = 0; lineno++; - ret = sscanf(buf, "%s %s %d %d %d %hd %lx %lx %s %s %s %s", + ret = sscanf(buf, "%s %s %d %d %d %d %lx %lx %s %s %s %s", pr.name, pr.instance, - &life, &kkvno, &kvno, - &pr.attributes, + &pr.max_life, &pr.mkvno, &pr.kvno, + &attributes, &key[0], &key[1], exp_date, mod_date, pr.mod_name, pr.mod_instance); @@ -114,11 +114,19 @@ v4_prop_dump(void *arg, const char *file) warnx("Line %d malformed (ignored)", lineno); continue; } - pr.key_low = ntohl (key[0]); - pr.key_high = ntohl (key[1]); - pr.max_life = life; - pr.kdc_key_ver = kkvno; - pr.key_version = kvno; + if(attributes != 0) { + warnx("Line %d (%s.%s) has non-zero attributes - skipping", + lineno, pr.name, pr.instance); + continue; + } + pr.key[0] = (key[0] >> 24) & 0xff; + pr.key[1] = (key[0] >> 16) & 0xff; + pr.key[2] = (key[0] >> 8) & 0xff; + pr.key[3] = (key[0] >> 0) & 0xff; + pr.key[4] = (key[1] >> 24) & 0xff; + pr.key[5] = (key[1] >> 16) & 0xff; + pr.key[6] = (key[1] >> 8) & 0xff; + pr.key[7] = (key[1] >> 0) & 0xff; pr.exp_date = time_parse(exp_date); pr.mod_date = time_parse(mod_date); if (pr.instance[0] == '*') @@ -132,4 +140,3 @@ v4_prop_dump(void *arg, const char *file) } return 0; } -#endif