Add configure check for LBER_LOG_PRINT_FN - to intercept ldap debug.
authorMichael Adam <obnox@samba.org>
Wed, 6 Feb 2008 17:16:03 +0000 (18:16 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 7 Feb 2008 13:08:12 +0000 (14:08 +0100)
Use the resulting HAVE_LBER_LOG_PRINT_FN to determine whether we can
use it in init_ldap_debugging to intercept LDAP debug output and print
it out in the samba logs (controlled with "ldap debug level").

Michael

source/configure.in
source/lib/ldap_debug_handler.c

index 14948ad89610c2f55ed9e4af2f92f17e26677e4c..d3fb63bb5376f477d17707b000723cde4a904971 100644 (file)
@@ -3243,6 +3243,21 @@ if test x"$with_ldap_support" != x"no"; then
   # this test must be before the libldap test
   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
 
+  #######################################################
+  # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
+  # ldap logging and print it out in the samba logs
+  AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
+                samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
+                [AC_TRY_COMPILE([#include <lber.h>],
+                                [int val = LBER_OPT_LOG_PRINT_FN;],
+                                samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
+                                samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
+
+  if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
+       AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
+                 [Support for LDAP/LBER logging interception])
+  fi
+
   ########################################################
   # now see if we can find the ldap libs in standard paths
   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
index cff500625801a13437142ad9411ed52e1470c6c0..f289f743fb41b7a41611dfeab0f3882d599ec87a 100644 (file)
@@ -30,7 +30,7 @@ static void samba_ldap_log_print_fn(LDAP_CONST char *data)
 
 void init_ldap_debugging(void)
 {
-#if HAVE_LDAP
+#if defined(HAVE_LDAP) && defined(HAVE_LBER_LOG_PRINT_FN)
        int ret;
        int ldap_debug_level = lp_ldap_debug_level();
 
@@ -48,5 +48,5 @@ void init_ldap_debugging(void)
        if (ret != LBER_OPT_SUCCESS) {
                DEBUG(10, ("Error setting LBER log print function.\n"));
        }
-#endif /* HAVE_LDAP */
+#endif /* HAVE_LDAP && HAVE_LBER_LOG_PRINT_FN */
 }