When returning KRB5_KT_NOTFOUND from krb5_ktfile_get_entry, set an
authorGreg Hudson <ghudson@mit.edu>
Mon, 11 Oct 2010 16:43:42 +0000 (16:43 +0000)
committerGreg Hudson <ghudson@mit.edu>
Mon, 11 Oct 2010 16:43:42 +0000 (16:43 +0000)
extended error message indicating which principal was not found.

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

src/lib/krb5/keytab/kt_file.c

index 80070bcf5dfd300355ac36179f9230710a4d769f..5246009ca1ab9559018671327e3fd024ad82622c 100644 (file)
@@ -253,6 +253,7 @@ krb5_ktfile_get_entry(krb5_context context, krb5_keytab id,
     krb5_boolean similar;
     int kvno_offset = 0;
     int was_open;
+    char *princname;
 
     kerror = KTLOCK(id);
     if (kerror)
@@ -375,8 +376,14 @@ krb5_ktfile_get_entry(krb5_context context, krb5_keytab id,
             kerror = 0;
         else if (found_wrong_kvno)
             kerror = KRB5_KT_KVNONOTFOUND;
-        else
+        else {
             kerror = KRB5_KT_NOTFOUND;
+            if (krb5_unparse_name(context, principal, &princname) == 0) {
+                krb5_set_error_message(context, kerror, "No key table entry "
+                                       "found for %s", princname);
+                free(princname);
+            }
+        }
     }
     if (kerror) {
         if (was_open == 0)