From: Theodore Tso Date: Tue, 29 Sep 1992 13:53:20 +0000 (+0000) Subject: Added support for the ktf_remove function X-Git-Tag: krb5-1.0-beta2~40 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=60e789515b0035eb310af4b505b059041c1cc5be;p=krb5.git Added support for the ktf_remove function git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2422 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/keytab/file/ktf_remove.c b/src/lib/krb5/keytab/file/ktf_remove.c index 8f068ee89..d79e380d6 100644 --- a/src/lib/krb5/keytab/file/ktf_remove.c +++ b/src/lib/krb5/keytab/file/ktf_remove.c @@ -40,5 +40,52 @@ krb5_ktfile_remove(id, entry) 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; }