1 diff -Naur kcrap-0.2.3/server/kcrap_kdb.c kcrap-0.2.3-patched/server/kcrap_kdb.c
2 --- kcrap-0.2.3/server/kcrap_kdb.c 2009-08-12 19:39:34.000000000 -0400
3 +++ kcrap-0.2.3-patched/server/kcrap_kdb.c 2011-11-12 22:25:05.000000000 -0500
5 int kcrap_open_kdb(krb5_context context, profile_t profile, char* kcrap_section) {
6 krb5_error_code retval;
9 - krb5_db_entry master_entry;
10 + krb5_db_entry *master_entry;
11 krb5_principal master_princ;
15 com_err("open_kdb", retval, "while setting up master key name");
18 - if ((retval = krb5_db_get_principal(context, master_princ, &master_entry, &nentries, &more))) {
19 + /* krb5_db_get_principal(krb5_context kcontext, krb5_const_principal search_for, unsigned int flags, krb5_db_entry **entry) */
20 + if ((retval = krb5_db_get_principal(context, master_princ, 0, &master_entry))) {
21 com_err("open_kdb", retval, "while retrieving master entry");
24 - retval = KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE;
25 - com_err("open_kdb", retval, "while retrieving master entry");
27 - } else if (!nentries) {
28 - retval = KRB5_KDB_NOENTRY;
29 - com_err("open_kdb", retval, "while retrieving master entry");
33 if ((retval = profile_get_string(profile, "realms", realm, "key_stash_file", NULL, &stash_file))) {
35 com_err("open_kdb", retval, "while fetching master key %s for realm %s", KRB5_KDB_M_NAME, realm);
39 if ((retval = krb5_db_verify_master_key(context, master_princ, KVNO_ARG_OPT &master_keyblock))) {
40 com_err("kdb_open", retval, "while verifying master key");
41 krb5_free_keyblock_contents(context, &master_keyblock);
47 profile_release_string(stash_file);
49 - krb5_db_free_principal(context, &master_entry, nentries);
50 + krb5_db_free_principal(context, master_entry);
52 krb5_free_principal(context, master_princ);
53 if (retval) krb5_db_fini(context);
57 int kcrap_getkey(krb5_context context, struct kcrap_data principal, krb5_enctype keytype, int *nkeyblocks, struct keyblocks *keyblocks) {
68 if ((retval = krb5_parse_name(context, pstr, &princ)))
71 - if ((retval = krb5_db_get_principal(context, princ, &dbe, &nprincs, &more))) {
72 + if ((retval = krb5_db_get_principal(context, princ, 0, &dbe))) {
75 - retval = KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE;
77 - } else if (!nprincs) {
78 - retval = KRB5_KDB_NOENTRY;
82 if ((retval = krb5_timeofday(context, &nowtime))) {
86 - if (dbe.pw_expiration && dbe.pw_expiration < nowtime) {
87 + if (dbe->pw_expiration && dbe->pw_expiration < nowtime) {
88 retval = KRB5KDC_ERR_KEY_EXP;
91 - if (dbe.expiration && dbe.expiration < nowtime) {
92 + if (dbe->expiration && dbe->expiration < nowtime) {
93 retval = KRB5KDC_ERR_NAME_EXP;
99 - for (i = 0; i < dbe.n_key_data; i++) {
100 - if (kvno < dbe.key_data[i].key_data_kvno) {
101 + for (i = 0; i < dbe->n_key_data; i++) {
102 + if (kvno < dbe->key_data[i].key_data_kvno) {
104 - kvno = dbe.key_data[i].key_data_kvno;
105 + kvno = dbe->key_data[i].key_data_kvno;
109 @@ -195,10 +182,10 @@
113 - for (i = 0; i < dbe.n_key_data && count < *nkeyblocks; i++) {
114 - if (kvno == dbe.key_data[i].key_data_kvno) {
115 + for (i = 0; i < dbe->n_key_data && count < *nkeyblocks; i++) {
116 + if (kvno == dbe->key_data[i].key_data_kvno) {
117 /* XXX: what if we needed to specify a salt? */
118 - retval = krb5_dbekd_decrypt_key_data(context, &master_keyblock, &dbe.key_data[i], &keyblocks[count].key, NULL);
119 + retval = krb5_dbe_decrypt_key_data(context, &master_keyblock, &dbe->key_data[i], &keyblocks[count].key, NULL);
120 if (retval == 0) count++;
127 - krb5_db_free_principal(context, &dbe, nprincs);
128 + krb5_db_free_principal(context, dbe);
130 krb5_free_principal(context, princ);