From c5e4d4e9a3f6896f0f3c631ea26bb49a79b5cd8e Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 12 Oct 2012 18:19:06 +0200 Subject: Only call krb5_set_trace_callback on platforms that support it --- src/external/krb5.m4 | 1 + src/providers/krb5/krb5_child.c | 2 +- src/providers/ldap/ldap_child.c | 2 +- src/util/sss_krb5.c | 17 ++++++++++++++++- src/util/sss_krb5.h | 5 ++--- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/external/krb5.m4 b/src/external/krb5.m4 index 474cb37c..cb420aae 100644 --- a/src/external/krb5.m4 +++ b/src/external/krb5.m4 @@ -59,6 +59,7 @@ AC_CHECK_FUNCS([krb5_get_init_creds_opt_alloc krb5_get_error_message \ krb5_principal_get_realm \ krb5_cc_cache_match \ krb5_timestamp_to_sfstring \ + krb5_set_trace_callback \ krb5_cc_get_full_name]) CFLAGS=$SAVE_CFLAGS LIBS=$SAVE_LIBS diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c index cd826add..a92ba57b 100644 --- a/src/providers/krb5/krb5_child.c +++ b/src/providers/krb5/krb5_child.c @@ -1625,7 +1625,7 @@ set_child_debugging(krb5_context ctx) krb5_error_ctx = ctx; if (debug_level & SSSDBG_TRACE_ALL) { - kerr = krb5_set_trace_callback(ctx, sss_child_krb5_trace_cb, NULL); + kerr = sss_child_set_krb5_tracing(ctx); if (kerr) { KRB5_CHILD_DEBUG(SSSDBG_MINOR_FAILURE, kerr); return EIO; diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c index de25fc07..e0529dbc 100644 --- a/src/providers/ldap/ldap_child.c +++ b/src/providers/ldap/ldap_child.c @@ -150,7 +150,7 @@ set_child_debugging(krb5_context ctx) krb5_error_ctx = ctx; if (debug_level & SSSDBG_TRACE_ALL) { - kerr = krb5_set_trace_callback(ctx, sss_child_krb5_trace_cb, NULL); + kerr = sss_child_set_krb5_tracing(ctx); if (kerr) { LDAP_CHILD_DEBUG(SSSDBG_MINOR_FAILURE, kerr); return EIO; diff --git a/src/util/sss_krb5.c b/src/util/sss_krb5.c index 0a80f23a..c36a1374 100644 --- a/src/util/sss_krb5.c +++ b/src/util/sss_krb5.c @@ -964,7 +964,8 @@ sss_krb5_residual_check_type(const char *full_location, return sss_krb5_residual_by_type(full_location, type); } -void +#ifdef HAVE_KRB5_SET_TRACE_CALLBACK +static void sss_child_krb5_trace_cb(krb5_context context, const struct krb5_trace_info *info, void *data) { @@ -975,3 +976,17 @@ sss_child_krb5_trace_cb(krb5_context context, DEBUG(SSSDBG_TRACE_ALL, ("%s\n", info->message)); } + +errno_t +sss_child_set_krb5_tracing(krb5_context ctx) +{ + return krb5_set_trace_callback(ctx, sss_child_krb5_trace_cb, NULL); +} +#else /* HAVE_KRB5_SET_TRACE_CALLBACK */ +errno_t +sss_child_set_krb5_tracing(krb5_context ctx) +{ + DEBUG(SSSDBG_CONF_SETTINGS, ("krb5 tracing is not available\n")); + return 0; +} +#endif /* HAVE_KRB5_SET_TRACE_CALLBACK */ diff --git a/src/util/sss_krb5.h b/src/util/sss_krb5.h index 708914c6..c16dab59 100644 --- a/src/util/sss_krb5.h +++ b/src/util/sss_krb5.h @@ -167,8 +167,7 @@ typedef krb5_ticket_times sss_krb5_ticket_times; typedef krb5_times sss_krb5_ticket_times; #endif -void -sss_child_krb5_trace_cb(krb5_context context, - const struct krb5_trace_info *info, void *data); +/* Redirect libkrb5 tracing towards our DEBUG statements */ +errno_t sss_child_set_krb5_tracing(krb5_context ctx); #endif /* __SSS_KRB5_H__ */ -- cgit