]> granicus.if.org Git - php/commitdiff
Fixed the SASL config check.
authorfoobar <sniper@php.net>
Fri, 13 Jun 2003 13:30:46 +0000 (13:30 +0000)
committerfoobar <sniper@php.net>
Fri, 13 Jun 2003 13:30:46 +0000 (13:30 +0000)
ext/ldap/config.m4
ext/ldap/ldap.c
ext/ldap/php_ldap.h

index 685b4f437a90c71d799f87ad694ee74844df38fa..39fac5a2d7cd4ee46efd8d26a0cefa9820772563 100644 (file)
@@ -18,9 +18,56 @@ AC_DEFUN(PHP_LDAP_CHECKS, [
   fi
 ])
 
+AC_DEFUN(PHP_LDAP_SASL_CHECKS, [
+  if test "$1" = "yes"; then
+    SEARCH_DIRS="/usr/local /usr"
+  else
+    SEARCH_DIRS=$1
+  fi
+
+  for i in $SEARCH_DIRS; do
+    if test -f $i/include/sasl/sasl.h; then
+      LDAP_SASL_DIR=$i
+      AC_DEFINE(HAVE_LDAP_SASL_SASL_H,1,[ ])
+      break
+    elif test -f $i/include/sasl.h; then
+      LDAP_SASL_DIR=$i
+      AC_DEFINE(HAVE_LDAP_SASL_H,1,[ ])
+      break
+    fi
+  done
+  
+  if test "$LDAP_SASL_DIR"; then
+    LDAP_SASL_INCDIR=$LDAP_SASL_DIR/include
+    LDAP_SASL_LIBDIR=$LDAP_SASL_DIR/lib
+  else
+    AC_MSG_ERROR([sasl.h not found!])
+  fi
+
+  if test "$PHP_LDAP_SASL" = "yes"; then
+    SASL_LIB="-lsasl2"
+  else
+    SASL_LIB="-L$LDAP_SASL_LIBDIR -lsasl2"
+  fi
+  
+  PHP_CHECK_LIBRARY(ldap, sasl_version,
+  [
+    PHP_ADD_INCLUDE($LDAP_SASL_INCDIR)
+    PHP_ADD_LIBRARY_WITH_PATH(sasl2, $LDAP_SASL_LIBDIR, LDAP_SHARED_LIBADD)
+    AC_DEFINE(HAVE_LDAP_SASL, 1, [LDAP SASL support])
+  ], [
+    AC_MSG_ERROR([LDAP SASL check failed. Please check config.log for more information.])
+  ], [
+    $LDAP_SHARED_LIBADD $SASL_LIB
+  ])
+])
+
 PHP_ARG_WITH(ldap,for LDAP support,
 [  --with-ldap[=DIR]       Include LDAP support.])
 
+PHP_ARG_WITH(ldap-sasl,for LDAP Cyrus SASL support,
+[  --with-ldap-sasl[=DIR]    LDAP: Include Cyrus SASL support.], no, no)
+
 if test "$PHP_LDAP" != "no"; then
 
   PHP_NEW_EXTENSION(ldap, ldap.c, $ext_shared)
@@ -121,5 +168,19 @@ if test "$PHP_LDAP" != "no"; then
 
   dnl Solaris 2.8 claims to be 2004 API, but doesn't have
   dnl ldap_parse_reference() nor ldap_start_tls_s()
-  AC_CHECK_FUNCS([ldap_parse_reference ldap_start_tls_s ldap_sasl_interactive_bind_s])
+  AC_CHECK_FUNCS([ldap_parse_reference ldap_start_tls_s])
+
+  dnl
+  dnl SASL check
+  dnl
+  if test "$PHP_LDAP_SASL" != "no"; then
+    PHP_LDAP_SASL_CHECKS([$PHP_LDAP_SASL])
+  fi
+
+  dnl
+  dnl Sanity check
+  dnl 
+  AC_CHECK_FUNC(ldap_bind_s, [], [
+    AC_MSG_ERROR([LDAP build check failed. Please check config.log for more information.]) 
+  ])
 fi 
index 12b44ed43004d8cb6283a097c8eaed9a6c4dc526..a148e5767e7230f17732481a8ed4b69f0846ced7 100644 (file)
 #include "ext/standard/php_string.h"
 #include "ext/standard/info.h"
 
+#ifdef HAVE_LDAP_SASL_H
+#include <sasl.h>
+#elif defined(HAVE_LDAP_SASL_SASL_H)
+#include <sasl/sasl.h>
+#endif
+
 typedef struct {
        LDAP *link;
 #if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
@@ -88,7 +94,7 @@ function_entry ldap_functions[] = {
        PHP_FE(ldap_connect,                                                            NULL)
        PHP_FALIAS(ldap_close,          ldap_unbind,                    NULL)
        PHP_FE(ldap_bind,                                                                       NULL)
-#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
+#ifdef HAVE_LDAP_SASL
        PHP_FE(ldap_sasl_bind,                                                          NULL)
 #endif
        PHP_FE(ldap_unbind,                                                                     NULL)
@@ -335,6 +341,10 @@ PHP_MINFO_FUNCTION(ldap)
        php_info_print_table_row(2, "Level of Encryption", tmp);
 #endif
 
+#ifdef HAVE_LDAP_SASL
+       php_info_print_table_row(2, "SASL Support", "Enabled");
+#endif
+
        php_info_print_table_end();
 }
 /* }}} */
@@ -466,7 +476,7 @@ PHP_FUNCTION(ldap_bind)
 }
 /* }}} */
 
-#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
+#ifdef HAVE_LDAP_SASL
 /* {{{ _php_sasl_interact
    Interact function for SASL */
 static int _php_sasl_interact(LDAP *ld, unsigned flags, void *defaults, void *in)
@@ -505,7 +515,7 @@ PHP_FUNCTION(ldap_sasl_bind)
        }
 }
 /* }}} */
-#endif /* HAVE_LDAP_SASL_INTERACTIVE_BIND_S */
+#endif /* HAVE_LDAP_SASL */
 
 /* {{{ proto bool ldap_unbind(resource link)
    Unbind from LDAP directory */
index 4c622ed40373f1d3d8279d90cd58b042858067ac..211a63f70cc3f5165b181dbc2d795117877f3cc6 100644 (file)
@@ -38,7 +38,7 @@ PHP_MINFO_FUNCTION(ldap);
 
 PHP_FUNCTION(ldap_connect);
 PHP_FUNCTION(ldap_bind);
-#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
+#ifdef HAVE_LDAP_SASL
 PHP_FUNCTION(ldap_sasl_bind);
 #endif
 PHP_FUNCTION(ldap_unbind);