pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/databases/php-ldap/files LDAP EXOP patch fix



details:   https://anonhg.NetBSD.org/pkgsrc/rev/64f6190556c5
branches:  trunk
changeset: 363071:64f6190556c5
user:      manu <manu%pkgsrc.org@localhost>
date:      Wed May 31 14:09:30 2017 +0000

description:
LDAP EXOP patch fix

A code repetition caused add and modify operations to be done twice.

diffstat:

 databases/php-ldap/files/ldap-ctrl-exop56.patch |  322 ++++-------------------
 1 files changed, 61 insertions(+), 261 deletions(-)

diffs (truncated from 544 to 300 lines):

diff -r 8b5431ce5c8b -r 64f6190556c5 databases/php-ldap/files/ldap-ctrl-exop56.patch
--- a/databases/php-ldap/files/ldap-ctrl-exop56.patch   Wed May 31 13:24:31 2017 +0000
+++ b/databases/php-ldap/files/ldap-ctrl-exop56.patch   Wed May 31 14:09:30 2017 +0000
@@ -1,5 +1,5 @@
 --- ext/ldap/ldap.c.orig       2017-01-19 01:17:47.000000000 +0100
-+++ ext/ldap/ldap.c    2017-05-07 10:06:29.000000000 +0200
++++ ext/ldap/ldap.c    2017-05-31 16:03:19.000000000 +0200
 @@ -230,8 +230,21 @@
        REGISTER_LONG_CONSTANT("GSLC_SSL_ONEWAY_AUTH", GSLC_SSL_ONEWAY_AUTH, CONST_PERSISTENT | CONST_CS);
        REGISTER_LONG_CONSTANT("GSLC_SSL_TWOWAY_AUTH", GSLC_SSL_TWOWAY_AUTH, CONST_PERSISTENT | CONST_CS);
@@ -258,7 +258,7 @@
                ldap_mods[i] = emalloc(sizeof(LDAPMod));
                ldap_mods[i]->mod_op = oper | LDAP_MOD_BVALUES;
                ldap_mods[i]->mod_type = NULL;
-@@ -1458,19 +1640,84 @@
+@@ -1458,19 +1640,71 @@
                zend_hash_move_forward(Z_ARRVAL_P(entry));
        }
        ldap_mods[num_attribs] = NULL;
@@ -312,19 +312,6 @@
 +
 +      } else {
 +              if (ext) {
-+                      rc = ldap_modify_ext(ld->link, dn, ldap_mods, lsctrls, lcctrls, &msgid);
-+
-+              } else {
-+                      rc = ldap_modify_ext_s(ld->link, dn, ldap_mods, NULL, NULL);
-+              }
-+      }
-+
-+      if (rc != LDAP_SUCCESS) {
-+              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: %s", is_full_add ? "Add" : "Modify", ldap_err2string(i));
-+              RETVAL_FALSE;
-+
-+      } else {
-+              if (ext) {
 +                      rc = ldap_result(ld->link, msgid, LDAP_MSG_ALL, NULL, &ldap_res);
 +                      if ((is_full_add && rc != LDAP_RES_ADD) || (!is_full_add && rc != LDAP_RES_MODIFY)) {
 +                              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: unable to collect result", is_full_add ? "Add" : "Modify");
@@ -351,7 +338,7 @@
  
  errexit:
        for (i = 0; i < num_attribs; i++) {
-@@ -1483,8 +1730,17 @@
+@@ -1483,8 +1717,17 @@
        }
        efree(num_berval);
        efree(ldap_mods);
@@ -369,7 +356,7 @@
  }
  /* }}} */
  
-@@ -1492,9 +1748,9 @@
+@@ -1492,9 +1735,9 @@
     Add entries to LDAP directory */
  PHP_FUNCTION(ldap_add)
  {
@@ -380,7 +367,7 @@
  /* }}} */
  
  /* three functions for attribute base modifications, gerrit Thomson */
-@@ -1502,25 +1758,25 @@
+@@ -1502,25 +1745,25 @@
  /* {{{ proto bool ldap_mod_replace(resource link, string dn, array entry)
     Replace attribute values with new ones */
  PHP_FUNCTION(ldap_mod_replace)
@@ -409,7 +396,7 @@
  /* }}} */
  
  /* {{{ proto bool ldap_delete(resource link, string dn)
-@@ -1946,42 +2202,104 @@
+@@ -1946,42 +2189,104 @@
        RETURN_STRING(ldap_err2string(ld_errno), 1);
  }
  /* }}} */
@@ -514,14 +501,14 @@
 +                      case LDAP_COMPARE_TRUE:
 +                              RETURN_TRUE;
 +                              break;
- 
--      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Compare: %s", ldap_err2string(errno));
--      RETURN_LONG(-1);
++
 +                      case LDAP_COMPARE_FALSE:
 +                              RETURN_FALSE;
 +                              break;
 +              }
-+
+ 
+-      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Compare: %s", ldap_err2string(errno));
+-      RETURN_LONG(-1);
 +              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Compare: %s", ldap_err2string(rc));
 +              RETURN_LONG(-1);
 +      }
@@ -535,22 +522,13 @@
  /* }}} */
  
  /* {{{ proto bool ldap_sort(resource link, resource result, string sortfilter)
-@@ -2013,69 +2331,241 @@
+@@ -2013,17 +2318,189 @@
        RETURN_TRUE;
  }
  /* }}} */
  
 -#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)
--{
--      zval *link, *retval;
--      ldap_linkdata *ld;
--      long option;
- 
--      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &link, &option, &retval) != SUCCESS) {
--              return;
++
 +
 +/* {{{ Extended API that returns result instead of just bool
 + * to allow further manipulation by the ldap_parse_*() funcs,
@@ -608,39 +586,15 @@
 +      rc = ldap_parse_result(ld->link, ldap_res, &lerr, NULL, NULL, NULL, NULL, 0);
 +      if (rc == LDAP_SUCCESS) {
 +              rc = lerr;
-       }
- 
--      ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
- 
--      switch (option) {
--      /* options with int value */
--      case LDAP_OPT_DEREF:
--      case LDAP_OPT_SIZELIMIT:
--      case LDAP_OPT_TIMELIMIT:
--      case LDAP_OPT_PROTOCOL_VERSION:
--      case LDAP_OPT_ERROR_NUMBER:
--      case LDAP_OPT_REFERRALS:
--#ifdef LDAP_OPT_RESTART
--      case LDAP_OPT_RESTART:
--#endif
--              {
--                      int val;
++      }
++
++
 +      if (rc != LDAP_SUCCESS) {
 +              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc));
 +      }
 +}
 +/* }}} */
- 
--                      if (ldap_get_option(ld->link, option, &val)) {
--                              RETURN_FALSE;
--                      }
--                      zval_dtor(retval);
--                      ZVAL_LONG(retval, val);
--              } break;
--#ifdef LDAP_OPT_NETWORK_TIMEOUT
--      case LDAP_OPT_NETWORK_TIMEOUT:
--              {
--                      struct timeval *timeout = NULL;
++
 +/* {{{ proto result ldap_add_ext(resource link, string dn, array entry)
 +   Add entries to LDAP directory; returns result */
 +PHP_FUNCTION(ldap_add_ext)
@@ -648,24 +602,7 @@
 +      php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LD_FULL_ADD, 1);
 +}
 +/* }}} */
- 
--                      if (ldap_get_option(ld->link, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) {
--                              if (timeout) {
--                                      ldap_memfree(timeout);
--                              }
--                              RETURN_FALSE;
--                      }
--                      if (!timeout) {
--                              RETURN_FALSE;
--                      }
--                      zval_dtor(retval);
--                      ZVAL_LONG(retval, timeout->tv_sec);
--                      ldap_memfree(timeout);
--              } break;
--#elif defined(LDAP_X_OPT_CONNECT_TIMEOUT)
--      case LDAP_X_OPT_CONNECT_TIMEOUT:
--              {
--                      int timeout;
++
 +/* {{{ proto result ldap_mod_replace_ext(resource link, string dn, array entry)
 +   Replace attribute values with new ones */
 +PHP_FUNCTION(ldap_mod_replace_ext)
@@ -673,10 +610,7 @@
 +      php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE, 1);
 +}
 +/* }}} */
- 
--                      if (ldap_get_option(ld->link, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) {
--                              RETURN_FALSE;
--                      }
++
 +
 +/* {{{ proto result ldap_mod_add_ext(resource link, string dn, array entry)
 +   Add attribute values to current */
@@ -767,71 +701,32 @@
 +
 +
 +#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10
-+/* {{{ proto bool ldap_get_option(resource link, int option, mixed retval)
-+   Get the current value of various session-wide parameters */
+ /* {{{ 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)
 +PHP_FUNCTION(ldap_get_option) 
-+{
-+      zval *link, *retval;
-+      ldap_linkdata *ld;
-+      long option;
+ {
+       zval *link, *retval;
+       ldap_linkdata *ld;
+       long option;
+-
 +      
-+      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &link, &option, &retval) != SUCCESS) {
-+              return;
-+      }
-+
-+      ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
-+
-+      switch (option) {
-+      /* options with int value */
-+      case LDAP_OPT_DEREF:
-+      case LDAP_OPT_SIZELIMIT:
-+      case LDAP_OPT_TIMELIMIT:
-+      case LDAP_OPT_PROTOCOL_VERSION:
-+      case LDAP_OPT_ERROR_NUMBER:
-+      case LDAP_OPT_REFERRALS:
-+#ifdef LDAP_OPT_RESTART
-+      case LDAP_OPT_RESTART:
-+#endif
-+              {
-+                      int val;
-+
-+                      if (ldap_get_option(ld->link, option, &val)) {
-+                              RETURN_FALSE;
-+                      }
-+                      zval_dtor(retval);
-+                      ZVAL_LONG(retval, val);
-+              } break;
-+#ifdef LDAP_OPT_NETWORK_TIMEOUT
-+      case LDAP_OPT_NETWORK_TIMEOUT:
-+              {
-+                      struct timeval *timeout = NULL;
-+
-+                      if (ldap_get_option(ld->link, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) {
-+                              if (timeout) {
-+                                      ldap_memfree(timeout);
-+                              }
-+                              RETURN_FALSE;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &link, &option, &retval) != SUCCESS) {
+               return;
+       }
+ 
+@@ -2058,9 +2535,9 @@
+                               if (timeout) {
+                                       ldap_memfree(timeout);
+                               }
+                               RETURN_FALSE;
+-                      }
 +                      }                   
-+                      if (!timeout) {
-+                              RETURN_FALSE;
-+                      }
-+                      zval_dtor(retval);
-+                      ZVAL_LONG(retval, timeout->tv_sec);
-+                      ldap_memfree(timeout);
-+              } break;
-+#elif defined(LDAP_X_OPT_CONNECT_TIMEOUT)
-+      case LDAP_X_OPT_CONNECT_TIMEOUT:
-+              {
-+                      int timeout;
-+
-+                      if (ldap_get_option(ld->link, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) {
-+                              RETURN_FALSE;
-+                      }
+                       if (!timeout) {
+                               RETURN_FALSE;
+                       }
                        zval_dtor(retval);
-                       ZVAL_LONG(retval, (timeout / 1000));
-               } break;
- #endif
-@@ -2320,20 +2810,21 @@
+@@ -2320,20 +2797,21 @@
  }
  /* }}} */
  
@@ -857,7 +752,7 @@
        }
  
        ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
-@@ -2342,9 +2833,9 @@



Home | Main Index | Thread Index | Old Index