summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Park <pjpark@mit.edu>1995-08-15 18:45:17 +0000
committerPaul Park <pjpark@mit.edu>1995-08-15 18:45:17 +0000
commit6def9dee9059b9b08043f09066e20e5a400c90e8 (patch)
tree39e48809719f2cf8f69f63ab2896e2a7a3bd25ab
parent00203d5d3f63d9ee1ba799698eb6ea026037997a (diff)
downloadkrb5-6def9dee9059b9b08043f09066e20e5a400c90e8.tar.gz
krb5-6def9dee9059b9b08043f09066e20e5a400c90e8.tar.xz
krb5-6def9dee9059b9b08043f09066e20e5a400c90e8.zip
Use krb5_dbe_find_keytype() to find appropriate key. Fix gcc -Wall complaints
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6530 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/kdc/kerberos_v4.c50
1 files changed, 18 insertions, 32 deletions
diff --git a/src/kdc/kerberos_v4.c b/src/kdc/kerberos_v4.c
index ce1e396b0..62f27cb88 100644
--- a/src/kdc/kerberos_v4.c
+++ b/src/kdc/kerberos_v4.c
@@ -286,7 +286,7 @@ hang()
char buf[256];
sprintf(buf,
"Kerberos will wait %d seconds before dying so as not to loop init",
- pause_int);
+ (int) pause_int);
klog(L_KRB_PERR, buf);
sleep(pause_int);
klog(L_KRB_PERR, "Do svedania....\n");
@@ -351,8 +351,7 @@ kerb_get_principal(name, inst, principal, maxn, more)
unsigned long *date;
char* text;
struct tm *tp;
-
- int i, max_kvno, ok_key;
+ krb5_key_data *pkey;
*more = 0;
if ( maxn > 1) {
@@ -371,12 +370,12 @@ kerb_get_principal(name, inst, principal, maxn, more)
* in v5, null instance means the null-component doesn't exist.
*/
- if (retval = krb5_425_conv_principal(kdc_context, name, inst,
- local_realm, &search))
+ if ((retval = krb5_425_conv_principal(kdc_context, name, inst,
+ local_realm, &search)))
return(0);
- if (retval = krb5_db_get_principal(kdc_context, search, &entries,
- &nprinc, &more5)) {
+ if ((retval = krb5_db_get_principal(kdc_context, search, &entries,
+ &nprinc, &more5))) {
krb5_free_principal(kdc_context, search);
return(0);
}
@@ -388,32 +387,19 @@ kerb_get_principal(name, inst, principal, maxn, more)
return(nprinc);
}
- /* First find the max kvno */
- for (max_kvno = i = 0; i < entries.n_key_data; i++) {
- if (max_kvno < entries.key_data[i].key_data_kvno) {
- max_kvno = entries.key_data[i].key_data_kvno;
- ok_key = i;
- }
- }
-
- /* Find a KEYTYPE_DES key with a KRB5_KDB_SALTTYPE_V4 salt */
- for (i = ok_key; i < entries.n_key_data; i++) {
- if (max_kvno == entries.key_data[i].key_data_kvno) {
- if ((entries.key_data[0].key_data_type[0] == KEYTYPE_DES) &&
- (entries.key_data[0].key_data_type[1] == KRB5_KDB_SALTTYPE_V4)) {
- goto found_one;
- }
- }
+ if (krb5_dbe_find_keytype(kdc_context,
+ &entries,
+ KEYTYPE_DES,
+ KRB5_KDB_SALTTYPE_V4,
+ -1,
+ &pkey)) {
+ lt = klog(L_KRB_PERR, "KDC V4: principal %s.%s isn't V4 compatible",
+ name, inst);
+ krb5_db_free_principal(kdc_context, &entries, nprinc);
+ return(0);
}
-
-
- lt = klog(L_KRB_PERR, "KDC V4: principal %s.%s isn't V4 compatible",
- name, inst);
- krb5_db_free_principal(kdc_context, &entries, nprinc);
- return(0);
-found_one:;
- if (! compat_decrypt_key( &entries.key_data[i], k)) {
+ if (! compat_decrypt_key( pkey, k)) {
memcpy( &principal->key_low, k, LONGLEN);
memcpy( &principal->key_high, (KRB4_32 *) k + 1, LONGLEN);
}
@@ -425,7 +411,7 @@ found_one:;
principal->exp_date = (unsigned long) entries.expiration;
/* principal->mod_date = (unsigned long) entries.mod_date; */
principal->kdc_key_ver = entries.mkvno;
- principal->key_version = max_kvno;
+ principal->key_version = pkey->key_data_kvno;
principal->attributes = 0;
/* set up v4 format of each date's text: */