krb5_keytab id;
krb5_keytab_entry *entry;
{
- return EOPNOTSUPP;
+ krb5_keytab_entry *cur_entry;
+ krb5_error_code kerror;
+ krb5_int32 delete_point;
+ krb5_boolean found = FALSE;
+
+ if (kerror = krb5_ktfileint_openw(id)) {
+ return kerror;
+ }
+
+ /*
+ * For efficiency and simplicity, we'll use a while true that
+ * is exited with a break statement.
+ */
+ while (TRUE) {
+ cur_entry = 0;
+ if (kerror = krb5_ktfileint_internal_read_entry(id, &cur_entry,
+ &delete_point))
+ break;
+
+ if ((entry->vno == cur_entry->vno) &&
+ (entry->key.keytype == cur_entry->key.keytype) &&
+ krb5_principal_compare(entry->principal, cur_entry->principal)) {
+ /* found a match */
+ found = TRUE;
+ krb5_kt_free_entry(cur_entry);
+ break;
+ }
+ krb5_kt_free_entry(cur_entry);
+ }
+
+ if (kerror && kerror != KRB5_KT_END) {
+ (void) krb5_ktfileint_close(id);
+ return kerror;
+ }
+
+ if (found) {
+ kerror = krb5_ktfileint_delete_entry(id, delete_point);
+ } else {
+ kerror = KRB5_KT_NOTFOUND;
+ }
+
+ if (kerror) {
+ (void) krb5_ktfileint_close(id);
+ } else {
+ kerror = krb5_ktfileint_close(id);
+ }
+
+ return kerror;
}