krb5_dbe_lookup_mkvno assumes an mkvno of 1 for entries with no
explicit tl_data. We've seen at least one pre-1.7 KDB with a master
kvno of 0, violating this assumption. Fix this as follows:
* krb5_dbe_lookup_mkvno outputs 0 instead of 1 if no tl_data exists.
* A new function krb5_dbe_get_mkvno translates this 0 value to the
minimum version number in the mkey_list. (krb5_dbe_lookup_mkvno
cannot do this as it doesn't take the mkey_list as a parameter.)
* Call sites to krb5_dbe_lookup_mkvno are converted to
krb5_dbe_get_mkvno, except for an LDAP case where it is acceptable
to store 0 if the mkvno is unknown.
ticket: 6650
target_version: 1.7.1
tags: pullup
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23676
dc483132-0cff-0310-8789-
dd5450dbe970
krb5_db_entry * entry,
krb5_keyblock ** mkey);
+/* Set *mkvno to mkvno in entry tl_data, or 0 if not present. */
krb5_error_code
krb5_dbe_lookup_mkvno( krb5_context context,
krb5_db_entry * entry,
krb5_kvno * mkvno);
+/* Set *mkvno to mkvno in entry tl_data, or minimum value from mkey_list. */
+krb5_error_code
+krb5_dbe_get_mkvno( krb5_context context,
+ krb5_db_entry * entry,
+ krb5_keylist_node * mkey_list,
+ krb5_kvno * mkvno);
+
krb5_error_code
krb5_dbe_lookup_mod_princ_data( krb5_context context,
krb5_db_entry * entry,
goto skip;
}
p->re_match_count++;
- retval = krb5_dbe_lookup_mkvno(util_context, ent, &old_mkvno);
+ retval = krb5_dbe_get_mkvno(util_context, ent, master_keylist, &old_mkvno);
if (retval) {
com_err(progname, retval,
"determining master key used for principal '%s'",
args = (struct purge_args *) ptr;
- retval = krb5_dbe_lookup_mkvno(args->kcontext, entry, &mkvno);
+ retval = krb5_dbe_get_mkvno(args->kcontext, entry, master_keylist, &mkvno);
if (retval)
return (retval);
}
}
+ if (master_keylist == NULL) {
+ com_err(progname, retval, "master keylist not initialized");
+ exit_status++;
+ return;
+ }
+
/* assemble & parse the master key name */
if ((retval = krb5_db_setup_mkey_name(util_context,
global_params.mkey_name,
if (kdb.key_data[i].key_data_kvno > entry->kvno)
entry->kvno = kdb.key_data[i].key_data_kvno;
- ret = krb5_dbe_lookup_mkvno(handle->context, &kdb, &entry->mkvno);
+ ret = krb5_dbe_get_mkvno(handle->context, &kdb, master_keylist,
+ &entry->mkvno);
if (ret)
goto done;
krb5_error_code retval;
krb5_keylist_node *cur_keyblock = mkey_list;
- retval = krb5_dbe_lookup_mkvno(context, entry, &mkvno);
+ retval = krb5_dbe_get_mkvno(context, entry, mkey_list, &mkvno);
if (retval)
return (retval);
return (code);
if (tl_data.tl_data_length == 0) {
- *mkvno = 1; /* default for princs that lack the KRB5_TL_MKVNO data */
+ *mkvno = 0; /* Indicates KRB5_TL_MKVNO data not present */
return (0);
} else if (tl_data.tl_data_length != 2) {
return (KRB5_KDB_TRUNCATED_RECORD);
return (0);
}
+krb5_error_code
+krb5_dbe_get_mkvno(krb5_context context,
+ krb5_db_entry * entry,
+ krb5_keylist_node * mkey_list,
+ krb5_kvno * mkvno)
+{
+ krb5_error_code code;
+ krb5_kvno kvno;
+
+ if (mkey_list == NULL)
+ return EINVAL;
+
+ /* Output the value from entry tl_data if present. */
+ code = krb5_dbe_lookup_mkvno(context, entry, &kvno);
+ if (code != 0)
+ return code;
+ if (kvno != 0) {
+ *mkvno = kvno;
+ return 0;
+ }
+
+ /* Determine the minimum kvno in mkey_list and output that. */
+ kvno = (krb5_kvno) -1;
+ while (mkey_list != NULL) {
+ if (mkey_list->kvno < kvno)
+ kvno = mkey_list->kvno;
+ mkey_list = mkey_list->next;
+ }
+ *mkvno = kvno;
+ return 0;
+}
+
krb5_error_code
krb5_dbe_update_mkvno(krb5_context context,
krb5_db_entry * entry,
krb5_dbe_free_key_data_contents
krb5_dbe_free_mkey_aux_list
krb5_dbe_free_key_list
+krb5_dbe_get_mkvno
krb5_dbe_lookup_last_pwd_change
krb5_dbe_lookup_actkvno
krb5_dbe_lookup_mkey_aux