krb5 commit: Improve error message from krb5_kt_have_content
Greg Hudson
ghudson at MIT.EDU
Sun Jun 3 20:48:41 EDT 2012
https://github.com/krb5/krb5/commit/51d406d8317aa9954cedb4f396303af8fcbef2f0
commit 51d406d8317aa9954cedb4f396303af8fcbef2f0
Author: Greg Hudson <ghudson at mit.edu>
Date: Sun Jun 3 20:35:53 2012 -0400
Improve error message from krb5_kt_have_content
src/lib/krb5/keytab/ktfns.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/lib/krb5/keytab/ktfns.c b/src/lib/krb5/keytab/ktfns.c
index e0c411e..56343ad 100644
--- a/src/lib/krb5/keytab/ktfns.c
+++ b/src/lib/krb5/keytab/ktfns.c
@@ -104,6 +104,7 @@ krb5_kt_have_content(krb5_context context, krb5_keytab keytab)
krb5_keytab_entry entry;
krb5_kt_cursor cursor;
krb5_error_code ret;
+ char name[1024];
/* If the keytab is not iterable, assume that it has content. */
if (keytab->ops->start_seq_get == NULL)
@@ -112,13 +113,20 @@ krb5_kt_have_content(krb5_context context, krb5_keytab keytab)
/* See if we can get at least one entry via iteration. */
ret = krb5_kt_start_seq_get(context, keytab, &cursor);
if (ret)
- return KRB5_KT_NOTFOUND;
+ goto no_entries;
ret = krb5_kt_next_entry(context, keytab, &entry, &cursor);
krb5_kt_end_seq_get(context, keytab, &cursor);
if (ret)
- return KRB5_KT_NOTFOUND;
+ goto no_entries;
krb5_kt_free_entry(context, &entry);
return 0;
+
+no_entries:
+ if (krb5_kt_get_name(context, keytab, name, sizeof(name)) == 0) {
+ krb5_set_error_message(context, KRB5_KT_NOTFOUND,
+ _("Keytab %s is nonexistent or empty"), name);
+ }
+ return KRB5_KT_NOTFOUND;
}
/*
More information about the cvs-krb5
mailing list