Commit:    5bc377457e155ceaddd27a536467a4d353fdcd4f
Author:    Christopher Jones <s...@php.net>         Fri, 4 Oct 2013 15:50:16 
-0700
Parents:   fb6f5d2e2d44e205cdde7320a7674e43fdd7980b
Branches:  PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=5bc377457e155ceaddd27a536467a4d353fdcd4f

Log:
Allow the ldap extension to be compiled with Oracle's LDAP
implementation, if desired.  Note the implementations differ so you
will see different ldap behavior.

The patch allows configuration similar to:
--with-ldap=$HOME/instantclient --with-oci8=instantclient,$HOME/instantclient

The patch doesn't support configuration similar to:
--with-ldap --with-oci8=instantclient,$HOME/instantclient
since this would try and mix the default LDAP and Oracle LDAP
implementations.

This patch closes out bug #61450 and the associated github PR.

Regardless of this patch, my recommended way to install both OCI8 and
ldap extensions is to statically configure PHP with ldap, and then add
OCI8 as a shared extension from PECL.

Bugs:
https://bugs.php.net/61450

Changed paths:
  M  ext/ldap/config.m4
  M  ext/ldap/ldap.c

diff --git a/ext/ldap/config.m4 b/ext/ldap/config.m4
index 3c8e23e..2804cd5 100644
--- a/ext/ldap/config.m4
+++ b/ext/ldap/config.m4
@@ -15,6 +15,28 @@ AC_DEFUN([PHP_LDAP_CHECKS], [
     LDAP_DIR=$1
     LDAP_INCDIR=$1/ldap/public
     LDAP_LIBDIR=$1/$PHP_LIBDIR
+  else
+
+    dnl Find Oracle Instant Client RPM header location corresponding to the 
given lib path e.g. for --with-ldap=/usr/lib/oracle/12.1/client64/lib
+    AC_CHECK_SIZEOF(long int, 4)
+    if test "$ac_cv_sizeof_long_int" = "4"; then
+      PHP_OCI8_IC_LIBDIR_SUFFIX=""
+    else
+      PHP_OCI8_IC_LIBDIR_SUFFIX=64
+    fi
+    OCISDKRPMINC=`echo "$1" | $SED -e 
's!^/usr/lib/oracle/\(.*\)/client\('${PHP_OCI8_IC_LIBDIR_SUFFIX}'\)*/lib[/]*$!/usr/include/oracle/\1/client\2!'`
+
+    dnl Check for Oracle Instant Client RPM install
+    if test -f $OCISDKRPMINC/ldap.h; then
+      LDAP_DIR=$1
+      LDAP_INCDIR=$OCISDKRPMINC
+      LDAP_LIBDIR=$1
+    dnl Check for Oracle Instant Client ZIP install
+    elif test -f $1/sdk/include/ldap.h; then
+      LDAP_DIR=$1
+      LDAP_INCDIR=$1/sdk/include
+      LDAP_LIBDIR=$1
+    fi
   fi
 ])
 
@@ -143,12 +165,21 @@ if test "$PHP_LDAP" != "no"; then
     PHP_ADD_LIBRARY_WITH_PATH(umich_lber, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
     PHP_ADD_LIBRARY_WITH_PATH(umich_ldap, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
 
-  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME; then
+  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.12.1; then
     PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
     AC_DEFINE(HAVE_ORALDAP,1,[ ])
-    if test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
-      AC_DEFINE(HAVE_ORALDAP_10,1,[ ])
-    fi
+    AC_DEFINE(HAVE_ORALDAP_12,1,[ ])
+
+  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.11.1; then
+    PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
+    AC_DEFINE(HAVE_ORALDAP,1,[ ])
+    AC_DEFINE(HAVE_ORALDAP_11,1,[ ])
+
+  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME; then
+     PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
+     AC_DEFINE(HAVE_ORALDAP,1,[ ])
+     AC_DEFINE(HAVE_ORALDAP_10,1,[ ])
+
   else
     AC_MSG_ERROR(Cannot find ldap libraries in $LDAP_LIBDIR.)
   fi
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 71d57d6..e95f898 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -152,7 +152,7 @@ PHP_MINIT_FUNCTION(ldap)
        REGISTER_LONG_CONSTANT("LDAP_DEREF_FINDING", LDAP_DEREF_FINDING, 
CONST_PERSISTENT | CONST_CS);
        REGISTER_LONG_CONSTANT("LDAP_DEREF_ALWAYS", LDAP_DEREF_ALWAYS, 
CONST_PERSISTENT | CONST_CS);
 
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP
        /* LDAP options */
        REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, 
CONST_PERSISTENT | CONST_CS);
        REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, 
CONST_PERSISTENT | CONST_CS);
@@ -361,7 +361,7 @@ PHP_FUNCTION(ldap_connect)
 static int _get_lderrno(LDAP *ldap)
 {
 #if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP_10
+#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP
        int lderr;
 
        /* New versions of OpenLDAP do it this way */
@@ -550,7 +550,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int 
timelimit, int deref, in
 {
        /* sizelimit */
        if (sizelimit > -1) {
-#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP
                ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_sizelimit);
                ldap_set_option(ldap, LDAP_OPT_SIZELIMIT, &sizelimit);
 #else
@@ -561,7 +561,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int 
timelimit, int deref, in
 
        /* timelimit */
        if (timelimit > -1) {
-#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP
                ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_timelimit);
                ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit);
 #else
@@ -572,7 +572,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int 
timelimit, int deref, in
 
        /* deref */
        if (deref > -1) {
-#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP || HAVE_ORALDAP
                ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_deref);
                ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
 #else
@@ -975,12 +975,12 @@ PHP_FUNCTION(ldap_get_entries)
                        add_index_string(tmp1, num_attrib, attribute, 1);
 
                        num_attrib++;
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                        ldap_memfree(attribute);
 #endif
                        attribute = ldap_next_attribute(ldap, 
ldap_result_entry, ber);
                }
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                if (ber != NULL) {
                        ber_free(ber, 0);
                }
@@ -989,7 +989,7 @@ PHP_FUNCTION(ldap_get_entries)
                add_assoc_long(tmp1, "count", num_attrib);
                dn = ldap_get_dn(ldap, ldap_result_entry);
                add_assoc_string(tmp1, "dn", dn, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                ldap_memfree(dn);
 #else
                free(dn);
@@ -1027,7 +1027,7 @@ PHP_FUNCTION(ldap_first_attribute)
                RETURN_FALSE;
        } else {
                RETVAL_STRING(attribute, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                ldap_memfree(attribute);
 #endif
        }
@@ -1057,7 +1057,7 @@ PHP_FUNCTION(ldap_next_attribute)
        }
 
        if ((attribute = ldap_next_attribute(ld->link, resultentry->data, 
resultentry->ber)) == NULL) {
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                if (resultentry->ber != NULL) {
                        ber_free(resultentry->ber, 0);
                        resultentry->ber = NULL;
@@ -1066,7 +1066,7 @@ PHP_FUNCTION(ldap_next_attribute)
                RETURN_FALSE;
        } else {
                RETVAL_STRING(attribute, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                ldap_memfree(attribute);
 #endif
        }
@@ -1113,12 +1113,12 @@ PHP_FUNCTION(ldap_get_attributes)
                add_index_string(return_value, num_attrib, attribute, 1);
 
                num_attrib++;
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                ldap_memfree(attribute);
 #endif
                attribute = ldap_next_attribute(ld->link, resultentry->data, 
ber);
        }
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
        if (ber != NULL) {
                ber_free(ber, 0);
        }
@@ -1183,7 +1183,7 @@ PHP_FUNCTION(ldap_get_dn)
        text = ldap_get_dn(ld->link, resultentry->data);
        if (text != NULL) {
                RETVAL_STRING(text, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                ldap_memfree(text);
 #else
                free(text);
@@ -1241,7 +1241,7 @@ PHP_FUNCTION(ldap_dn2ufn)
        
        if (ufn != NULL) {
                RETVAL_STRING(ufn, 1);
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
                ldap_memfree(ufn);
 #endif
        } else {
@@ -1546,7 +1546,7 @@ PHP_FUNCTION(ldap_sort)
 }
 /* }}} */
 
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP
 /* {{{ proto bool ldap_get_option(resource link, int option, mixed retval)
    Get the current value of various session-wide parameters */
 PHP_FUNCTION(ldap_get_option) 
@@ -2003,7 +2003,7 @@ PHP_FUNCTION(ldap_rename)
                newparent = NULL;
        }
 
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP
        rc = ldap_rename_s(ld->link, dn, newrdn, newparent, deleteoldrdn, NULL, 
NULL);
 #else
        if (newparent_len != 0) {
@@ -2047,7 +2047,7 @@ PHP_FUNCTION(ldap_start_tls)
 }
 /* }}} */
 #endif
-#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 */
+#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP */
 
 #if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
 /* {{{ _ldap_rebind_proc()
@@ -2567,7 +2567,7 @@ 
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_control_paged_result_response, 0, 0, 2)
 ZEND_END_ARG_INFO();
 #endif
 
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP
 ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_rename, 0, 0, 5)
        ZEND_ARG_INFO(0, link_identifier)
        ZEND_ARG_INFO(0, dn)
@@ -2683,7 +2683,7 @@ const zend_function_entry ldap_functions[] = {
        PHP_FE(ldap_compare,                                                    
        arginfo_ldap_compare)
        PHP_FE(ldap_sort,                                                       
                arginfo_ldap_sort)
 
-#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP
        PHP_FE(ldap_rename,                                                     
                arginfo_ldap_rename)
        PHP_FE(ldap_get_option,                                                 
        arginfo_ldap_get_option)
        PHP_FE(ldap_set_option,                                                 
        arginfo_ldap_set_option)
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to