diff options
author | Sumit Bose <sbose@redhat.com> | 2014-12-05 13:23:12 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-12-07 21:54:35 +0100 |
commit | 5dcf3ffa3aa228701a79556dc0b889dba0aac535 (patch) | |
tree | babb420581eacd7b27ef0e812879696bc1db99a3 /src/util | |
parent | 6cab8e9a9f92726885c158d299020a8daa1306ea (diff) | |
download | sssd-5dcf3ffa3aa228701a79556dc0b889dba0aac535.tar.gz sssd-5dcf3ffa3aa228701a79556dc0b889dba0aac535.tar.xz sssd-5dcf3ffa3aa228701a79556dc0b889dba0aac535.zip |
krb5: add wrapper for krb5_kt_have_content()
krb5_kt_have_content() was introduced in MIT Kerberos 1.11. For older
platforms this patch adds sss_krb5_kt_have_content() as a wrapper.
Resolves https://fedorahosted.org/sssd/ticket/2518
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/sss_krb5.c | 40 | ||||
-rw-r--r-- | src/util/sss_krb5.h | 2 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/util/sss_krb5.c b/src/util/sss_krb5.c index b5cc55376..447b5a5bc 100644 --- a/src/util/sss_krb5.c +++ b/src/util/sss_krb5.c @@ -1029,3 +1029,43 @@ done: return NULL; #endif /* HAVE_KRB5_CC_COLLECTION */ } + +krb5_error_code sss_krb5_kt_have_content(krb5_context context, + krb5_keytab keytab) +{ +#ifdef HAVE_KRB5_KT_HAVE_CONTENT + return krb5_kt_have_content(context, keytab); +#else + krb5_keytab_entry entry; + krb5_kt_cursor cursor; + krb5_error_code kerr; + krb5_error_code kerr_end; + + kerr = krb5_kt_start_seq_get(context, keytab, &cursor); + if (kerr != 0) { + DEBUG(SSSDBG_OP_FAILURE, + "krb5_kt_start_seq_get failed, assuming no entries.\n"); + return KRB5_KT_NOTFOUND; + } + + kerr = krb5_kt_next_entry(context, keytab, &entry, &cursor); + kerr_end = krb5_kt_end_seq_get(context, keytab, &cursor); + if (kerr != 0) { + DEBUG(SSSDBG_OP_FAILURE, + "krb5_kt_next_entry failed, assuming no entries.\n"); + return KRB5_KT_NOTFOUND; + } + kerr = krb5_free_keytab_entry_contents(context, &entry); + + if (kerr_end != 0) { + DEBUG(SSSDBG_TRACE_FUNC, + "krb5_kt_end_seq_get failed, ignored.\n"); + } + if (kerr != 0) { + DEBUG(SSSDBG_TRACE_FUNC, + "krb5_free_keytab_entry_contents failed, ignored.\n"); + } + + return 0; +#endif +} diff --git a/src/util/sss_krb5.h b/src/util/sss_krb5.h index afa0d1943..462dbbe0b 100644 --- a/src/util/sss_krb5.h +++ b/src/util/sss_krb5.h @@ -187,4 +187,6 @@ sss_krb5_get_primary(TALLOC_CTX *mem_ctx, const char *pattern, const char *hostname); +krb5_error_code sss_krb5_kt_have_content(krb5_context context, + krb5_keytab keytab); #endif /* __SSS_KRB5_H__ */ |