* acquire_cred.c (acquire_accept_cred): use krb5_kt_get_entry
authorBarry Jaspan <bjaspan@mit.edu>
Wed, 4 Dec 1996 18:07:12 +0000 (18:07 +0000)
committerBarry Jaspan <bjaspan@mit.edu>
Wed, 4 Dec 1996 18:07:12 +0000 (18:07 +0000)
  instead of scanning through keytab to find matching principal
  [krb5-libs/210]

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9601 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/krb5/ChangeLog
src/lib/gssapi/krb5/acquire_cred.c

index fb51f0dba68393e71167a4441ce5faa7a1418232..e1c1d98491d8eec6398cd155030cd112dbe95c46 100644 (file)
@@ -1,3 +1,9 @@
+Wed Dec  4 13:06:13 1996  Barry Jaspan  <bjaspan@mit.edu>
+
+       * acquire_cred.c (acquire_accept_cred): use krb5_kt_get_entry
+       instead of scanning through keytab to find matching principal
+       [krb5-libs/210]
+
 Sat Oct 19 00:38:22 1996  Theodore Y. Ts'o  <tytso@mit.edu>
 
        * ser_sctx.c (kg_oid_externalize, kg_oid_internalize,
index 06acb887712e8ba1302823673f0d17cdc5d34494..a99177758fe4ccd3bad6b451061dde72c5dc3703 100644 (file)
@@ -77,43 +77,15 @@ acquire_accept_cred(context, minor_status, desired_name, output_princ, cred)
       princ = (krb5_principal) desired_name;
    }
 
-   /* iterate over the keytab searching for the principal */
-
-   if (code = krb5_kt_start_seq_get(context, kt, &cur)) {
-      (void) krb5_kt_close(context, kt);
-      *minor_status = code;
-      return(GSS_S_FAILURE);
-   }
-
-   while (!(code = krb5_kt_next_entry(context, kt, &entry, &cur))) {
-      if (krb5_principal_compare(context, entry.principal, princ)) {
-        code = 0;
-        krb5_kt_free_entry(context, &entry);
-        break;
-      } 
-      krb5_kt_free_entry(context, &entry);
-   }
-
-   if (code == KRB5_KT_END) {
-      /* this means that the principal wasn't in the keytab */
-      (void)krb5_kt_end_seq_get(context, kt, &cur);
-      (void) krb5_kt_close(context, kt);
-      *minor_status = KG_KEYTAB_NOMATCH;
-      return(GSS_S_CRED_UNAVAIL);
-   } else if (code) {
-      /* this means some error occurred reading the keytab */
-      (void)krb5_kt_end_seq_get(context, kt, &cur);
-      (void) krb5_kt_close(context, kt);
-      *minor_status = code;
-      return(GSS_S_FAILURE);
-   } else {
-      /* this means that we found a matching entry */
-      if (code = krb5_kt_end_seq_get(context, kt, &cur)) {
-        (void) krb5_kt_close(context, kt);
-        *minor_status = code;
-        return(GSS_S_FAILURE);
-      }
+   if (code = krb5_kt_get_entry(context, kt, princ, 0, 0, &entry)) {
+       (void) krb5_kt_close(context, kt);
+       if (code == KRB5_KT_NOTFOUND)
+            *minor_status = KG_KEYTAB_NOMATCH;
+       else
+            *minor_status = code;
+       return(GSS_S_CRED_UNAVAIL);
    }
+   krb5_kt_free_entry(context, &entry);
 
    /* hooray.  we made it */