r141: A number of changes to get things working on FreeBSD and reduce the breakage
authorRichard Sharpe <sharpe@samba.org>
Sat, 10 Apr 2004 06:10:26 +0000 (06:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:51:11 +0000 (12:51 -0500)
caused by someone recently ...

1. Add configure check HAVE_COMPARISON_FN_T to see if this is defined. I
have not checked this on Linux yet, but will do so soon.

2. Add the definitions of malloc_p, realloc_p etc.

3. Check for LDAP and don't build stuff that depends on LDAP if we don't\
have it.

It currently builds on FreeBSD but there is one warning printed out at the end.
(This used to be commit 7b34fbe0f2ef175e5504e34e4f3cdf9a0563970f)

source4/configure.in
source4/include/includes.h
source4/lib/ldb/common/ldb.c
source4/lib/ldb/ldb_ldap/ldb_ldap.c
source4/lib/ldb/ldb_tdb/ldb_pack.c
source4/lib/ldb/ldb_tdb/ldb_search.c
source4/lib/ldb/ldb_tdb/ldb_tdb.c

index a6639064a7236c5a1be96445643a82fc760e6271..9531da6f469b693dd36a27d1ec795444093ba592 100644 (file)
@@ -213,6 +213,113 @@ sinclude(rpc_server/config.m4)
 sinclude(lib/registry/config.m4)
 sinclude(torture/config.m4)
 
+#######################################
+# Check for comparison_fn_t
+AC_CACHE_CHECK([for comparison_fn_t],samba_cv_HAVE_COMPARISON_FN_T,[
+AC_TRY_COMPILE([
+#include <stdlib.h>
+int list_find(const void *needle, 
+             const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn)
+{
+       return 1;
+}
+],[],
+samba_cv_HAVE_COMPARISON_FN_T=yes,samba_cv_HAVE_COMPARISON_FN_T=no)
+])
+if test x"$samba_cv_HAVE_COMPARISON_FN_T" = x"yes"; then
+       AC_DEFINE(HAVE_COMPARISON_FN_T,1,[Whether or not we have comparison_fn_t])
+fi
+
+########################################################
+# Compile with LDAP support?
+
+with_ldap_support=auto
+AC_MSG_CHECKING([for LDAP support])
+
+AC_ARG_WITH(ldap,
+[  --with-ldap             LDAP support (default yes)],
+[ case "$withval" in
+    yes|no)
+       with_ldap_support=$withval
+       ;;
+  esac ])
+
+AC_MSG_RESULT($with_ldap_support)
+
+SMBLDAP=""
+AC_SUBST(SMBLDAP)
+if test x"$with_ldap_support" != x"no"; then
+
+  ##################################################################
+  # first test for ldap.h and lber.h
+  # (ldap.h is required for this test)
+  AC_CHECK_HEADERS(ldap.h lber.h)
+  
+  if test x"$ac_cv_header_ldap_h" != x"yes"; then
+       if test x"$with_ldap_support" = x"yes"; then
+        AC_MSG_ERROR(ldap.h is needed for LDAP support)
+       else
+        AC_MSG_WARN(ldap.h is needed for LDAP support)
+       fi
+       
+       with_ldap_support=no
+  fi
+fi
+
+if test x"$with_ldap_support" != x"no"; then
+  ac_save_LIBS=$LIBS
+
+  ##################################################################
+  # we might need the lber lib on some systems. To avoid link errors
+  # this test must be before the libldap test
+  AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
+
+  ########################################################
+  # now see if we can find the ldap libs in standard paths
+  AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
+
+  AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
+  
+  ########################################################
+  # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
+  # Check found in pam_ldap 145.
+  AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
+
+  LIBS="$LIBS $LDAP_LIBS"
+  AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
+    AC_TRY_COMPILE([
+       #include <lber.h>
+       #include <ldap.h>], 
+       [ldap_set_rebind_proc(0, 0, 0);], 
+       [smb_ldap_cv_ldap_set_rebind_proc=3], 
+       [smb_ldap_cv_ldap_set_rebind_proc=2]
+    ) 
+  ])
+  
+  AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
+
+  AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)        
+  
+  if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
+    AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
+    default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
+    SMBLDAP="lib/smbldap.o"
+    with_ldap_support=yes
+    AC_MSG_CHECKING(whether LDAP support is used)
+    AC_MSG_RESULT(yes)
+  else
+    if test x"$with_ldap_support" = x"yes"; then
+       AC_MSG_ERROR(libldap is needed for LDAP support)
+    else
+       AC_MSG_WARN(libldap is needed for LDAP support)
+    fi
+    
+    LDAP_LIBS=""
+    with_ldap_support=no
+  fi
+  LIBS=$ac_save_LIBS
+fi
+
 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
 
 #################################################
index be0f7baaf40c514cfcf80a11f73a2a87e66c7df2..79fca5f7b497f75a559d397ce453981cf1feb83f 100644 (file)
@@ -741,6 +741,15 @@ struct functable {
        int (*fn)(int argc, const char **argv);
 };
 
+#define malloc_p(type) (type *)malloc(sizeof(type))
+#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
+#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
+
+#ifndef HAVE_COMPARISON_FN_T
+typedef int (*comparison_fn_t)(const void *, const void *);
+#endif
+
+#include "lib/ldb/include/ldb_parse.h"
 
 #include "nsswitch/nss.h"
 
index 90b77e1e7f2e0048e029649b60f8e33934b76fbd..3ba4434e071b351b29de14085aa9c86f8aa43221 100644 (file)
@@ -52,9 +52,11 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags,
                return ltdb_connect(url, flags, options);
        }
 
+#ifdef HAVE_LDAP
        if (strncmp(url, "ldap", 4) == 0) {
                return lldb_connect(url, flags, options);
        }
+#endif /*HAVE_LDAP*/
 
        errno = EINVAL;
        return NULL;
index e6cbb52cad8724440c0ab310b18b59c1e48a45dc..25dad914da44a75755d1f1b0af3af34fa73e7693 100644 (file)
@@ -33,7 +33,8 @@
  */
 
 #include "includes.h"
-#include "ldb_ldap/ldb_ldap.h"
+#if HAVE_LDAP
+#include "ldb_ldap.h"
 
 #if 0
 /*
@@ -518,3 +519,4 @@ failed:
        if (ldb) free(ldb);
        return NULL;
 }
+#endif /*HAVE_LDAP*/
index 1b0c8a18577b4d1dd3b3627ea9275c4555553202..5964e0751d8a9c74c9c4928d4d230b26e7b20329 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-#include "ldb_tdb/ldb_tdb.h"
+#include "ldb_tdb.h"
 
 /* change this if the data format ever changes */
 #define LTDB_PACKING_FORMAT 0x26011966
index d7a7b7ffbd53da8066eae3c30d8d7c202ea54119..5905231b32218bae1501b13c1a3d2c8333e32ab9 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-#include "ldb_tdb/ldb_tdb.h"
+#include "ldb_tdb.h"
 
 /*
   free a message that has all parts separately allocated
index 95dce498f12ff47720e5a1699a9f90033ca5ab33..ec90eec03ff161b9e5a7265ac92345b160a8f0dc 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-#include "ldb_tdb/ldb_tdb.h"
+#include "ldb_tdb.h"
 
 /*
   form a TDB_DATA for a record key