pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/databases/php-ldap Add exop patch from Pierangelo Masa...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d13330310520
branches:  trunk
changeset: 396365:d13330310520
user:      manu <manu%pkgsrc.org@localhost>
date:      Wed Jul 22 15:59:50 2009 +0000

description:
Add exop patch from Pierangelo Masarati and myself.

This enables the folllowing extended operations:
- passwd
- whoami
- refresh
And the following controls:
- manageDSAit
- paged_results
- ppolicy
- noop
- manageDIT
- permissive_modify

diffstat:

 databases/php-ldap/Makefile                   |     4 +-
 databases/php-ldap/files/ldap-ctrl-exop.patch |  2265 +++++++++++++++++++++++++
 databases/php-ldap/options.mk                 |    10 +-
 3 files changed, 2275 insertions(+), 4 deletions(-)

diffs (truncated from 2305 to 300 lines):

diff -r 13c0b3fa54af -r d13330310520 databases/php-ldap/Makefile
--- a/databases/php-ldap/Makefile       Wed Jul 22 15:16:56 2009 +0000
+++ b/databases/php-ldap/Makefile       Wed Jul 22 15:59:50 2009 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.12 2009/05/29 21:23:58 manu Exp $
+# $NetBSD: Makefile,v 1.13 2009/07/22 15:59:50 manu Exp $
 
 MODNAME=               ldap
-PKGREVISION=          2
+PKGREVISION=          4
 CATEGORIES+=           databases
 COMMENT=               PHP extension for LDAP database access
 
diff -r 13c0b3fa54af -r d13330310520 databases/php-ldap/files/ldap-ctrl-exop.patch
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/php-ldap/files/ldap-ctrl-exop.patch     Wed Jul 22 15:59:50 2009 +0000
@@ -0,0 +1,2265 @@
+$NetBSD: ldap-ctrl-exop.patch,v 1.1 2009/07/22 15:59:50 manu Exp $
+/*
+ * Copyright (c) 2007-2009 Pierangelo Masarati
+ * Copyright (c) 2009 Emmanuel Dreyfus
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
+ * THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+--- ext/ldap/ldap.c.orig       2009-06-15 17:18:48.000000000 +0200
++++ ext/ldap/ldap.c    2009-07-22 17:25:36.000000000 +0200
+@@ -81,8 +81,35 @@
+ 
+ ZEND_DECLARE_MODULE_GLOBALS(ldap)
+ static PHP_GINIT_FUNCTION(ldap);
+ 
++/* {{{ argXtoYofZ_force_ref - reference args helpers */
++static
++      ZEND_BEGIN_ARG_INFO(arg5of5_force_ref, 0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(1)
++      ZEND_END_ARG_INFO();
++
++static
++      ZEND_BEGIN_ARG_INFO(arg3to4of4_force_ref, 0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(1)
++              ZEND_ARG_PASS_INFO(1)
++      ZEND_END_ARG_INFO();
++
++static
++      ZEND_BEGIN_ARG_INFO(arg4to5of5_force_ref, 0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(1)
++              ZEND_ARG_PASS_INFO(1)
++      ZEND_END_ARG_INFO();
++
+ static
+       ZEND_BEGIN_ARG_INFO(arg3to6of6_force_ref, 0)
+               ZEND_ARG_PASS_INFO(0)
+               ZEND_ARG_PASS_INFO(0)
+@@ -91,8 +118,20 @@
+               ZEND_ARG_PASS_INFO(1)
+               ZEND_ARG_PASS_INFO(1)
+       ZEND_END_ARG_INFO();
+ 
++static
++      ZEND_BEGIN_ARG_INFO(arg3to7of7_force_ref, 0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(0)
++              ZEND_ARG_PASS_INFO(1)
++              ZEND_ARG_PASS_INFO(1)
++              ZEND_ARG_PASS_INFO(1)
++              ZEND_ARG_PASS_INFO(1)
++              ZEND_ARG_PASS_INFO(1)
++      ZEND_END_ARG_INFO();
++/* }}} */
++
+ static int le_link, le_result, le_result_entry;
+ 
+ /*
+       This is just a small subset of the functionality provided by the LDAP library. All the 
+@@ -133,8 +172,22 @@
+       PHP_FE(ldap_mod_replace,                                                        NULL)
+       PHP_FE(ldap_mod_del,                                                            NULL)
+ /* end gjt mod */
+ 
++/* Operations that return the result for further manipulation, Pierangelo Masarati */
++      PHP_FE(ldap_bind_ext,                                                           NULL)
++      PHP_FE(ldap_add_ext,                                                            NULL)
++      PHP_FE(ldap_delete_ext,                                                         NULL)
++      PHP_FALIAS(ldap_modify_ext,     ldap_mod_replace_ext,   NULL)
++      PHP_FE(ldap_mod_add_ext,                                                        NULL)
++      PHP_FE(ldap_mod_replace_ext,                                            NULL)
++      PHP_FE(ldap_mod_del_ext,                                                        NULL)
++      PHP_FE(ldap_compare_ext,                                                        NULL)
++#if ando_0
++      PHP_FE(ldap_rename_ext,                                                         NULL)
++#endif
++/* end of ando's mod */
++
+       PHP_FE(ldap_errno,                                                                      NULL)
+       PHP_FE(ldap_err2str,                                                            NULL)
+       PHP_FE(ldap_error,                                                                      NULL)
+       PHP_FE(ldap_compare,                                                            NULL)
+@@ -146,16 +199,32 @@
+       PHP_FE(ldap_set_option,                                                         NULL)
+       PHP_FE(ldap_first_reference,                                            NULL)
+       PHP_FE(ldap_next_reference,                                                     NULL)
+ #ifdef HAVE_LDAP_PARSE_REFERENCE
+-      PHP_FE(ldap_parse_reference,    third_arg_force_ref)
++      PHP_FE(ldap_parse_reference,            arg3to4of4_force_ref)
+ #endif
+ #ifdef HAVE_LDAP_PARSE_RESULT
+-      PHP_FE(ldap_parse_result,                       arg3to6of6_force_ref)
++      PHP_FE(ldap_parse_result,                       arg3to7of7_force_ref)
+ #endif
++/* LDAPv3 extended operations, Pierangelo Masarati */
++#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
++      PHP_FE(ldap_exop,                                       arg4to5of5_force_ref)
++      PHP_FE(ldap_exop_passwd,                        arg5of5_force_ref)
++      PHP_FE(ldap_exop_whoami,                        second_arg_force_ref)
+ #ifdef HAVE_LDAP_START_TLS_S
+       PHP_FE(ldap_start_tls,                                                          NULL)
+ #endif
++#ifdef HAVE_LDAP_REFRESH
++      PHP_FE(ldap_refresh,
++      NULL)
++#endif
++#endif
++#ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT
++      PHP_FE(ldap_parse_exop,                         arg3to4of4_force_ref)
++      PHP_FE(ldap_parse_exop_passwd,          third_arg_force_ref)
++      PHP_FE(ldap_parse_exop_whoami,          third_arg_force_ref)
++#endif
++/* end of ando mod */
+ #endif
+ 
+ #if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
+       PHP_FE(ldap_set_rebind_proc,                                            NULL)
+@@ -165,8 +234,31 @@
+       PHP_FE(ldap_t61_to_8859,                                                        NULL)
+       PHP_FE(ldap_8859_to_t61,                                                        NULL)
+ #endif
+ 
++/* routines to handle standard track controls, Pierangelo Masarati */
++#ifdef LDAP_CONTROL_MANAGEDSAIT
++      PHP_FE(ldap_ctrl_manageDSAit,                                           NULL)
++#endif
++#ifdef LDAP_CONTROL_PAGEDRESULTS
++      PHP_FE(ldap_ctrl_paged_results,         fourth_arg_force_ref)
++      PHP_FE(ldap_ctrl_paged_results_resp,    arg3to4of4_force_ref)
++#endif
++#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
++      PHP_FE(ldap_ctrl_ppolicy,                                                       NULL)
++      PHP_FE(ldap_ctrl_ppolicy_resp,          arg3to6of6_force_ref)
++#endif
++#ifdef LDAP_CONTROL_NOOP
++      PHP_FE(ldap_ctrl_noop,                                                          NULL)
++#endif
++#ifdef LDAP_CONTROL_MANAGEDIT
++      PHP_FE(ldap_ctrl_manageDIT,                                                     NULL)
++#endif
++#ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
++      PHP_FE(ldap_ctrl_permissive_modify,                                     NULL)
++#endif
++/* end of ando mod */
++
+       {NULL, NULL, NULL}
+ };
+ /* }}} */
+ 
+@@ -193,29 +285,43 @@
+ # include "zend_arg_defs.c"
+ # endif
+ #endif
+ 
++/* {{{ proto void _close_ldap_link()
++   close a connection and free LDAP resources */
+ static void _close_ldap_link(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ {
+       ldap_linkdata *ld = (ldap_linkdata *)rsrc->ptr;
+ 
+-      ldap_unbind_s(ld->link);
+-#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
++      /* ldap_unbind_s() is deprecated;
++       * the distinction between ldap_unbind() and ldap_unbind_s() is moot */
++#ifdef LDAP_API_FEATURE_X_OPENLDAP
++      ldap_unbind_ext(ld->link, NULL, NULL);
++#ifdef HAVE_3ARG_SETREBINDPROC
+       if (ld->rebindproc != NULL) {
+               zval_dtor(ld->rebindproc);
+               FREE_ZVAL(ld->rebindproc);
+       }
+ #endif
++#else /* ! LDAP_API_FEATURE_X_OPENLDAP */
++      ldap_unbind_s(ld->link);
++#endif /* ! LDAP_API_FEATURE_X_OPENLDAP */
+       efree(ld);
+       LDAPG(num_links)--;
+ }
++/* }}} */
+ 
++/* {{{ proto void _free_ldap_result()
++   free the result of an LDAP operation */
+ static void _free_ldap_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ {
+       LDAPMessage *result = (LDAPMessage *)rsrc->ptr;
+       ldap_msgfree(result);
+ }
++/* }}} */
+ 
++/* {{{ proto void _free_ldap_result_entry()
++   free an entry resulting from an LDAP search operation */
+ static void _free_ldap_result_entry(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ {
+       ldap_resultentry *entry = (ldap_resultentry *)rsrc->ptr;
+ 
+@@ -224,8 +330,162 @@
+       }
+       zend_list_delete(entry->id);
+       efree(entry);
+ } 
++/* }}} */
++
++/* {{{ proto int _php_parse_referrals_resp()
++   parse an array of LDAP referrals into a zval array */
++static int _php_parse_referrals_resp(char ***lreferralsp, zval **referrals)
++{
++      int     num_referrals = 0;
++
++      if (*lreferralsp != NULL) {
++              char    **refp = *lreferralsp;
++
++              while (*refp) {
++                      add_next_index_string(*referrals, *refp, 1);
++                      refp++;
++                      num_referrals++;
++              }
++#ifdef LDAP_API_FEATURE_X_OPENLDAP
++              ber_memvfree((void **)*lreferralsp);
++#else
++              ldap_value_free(*lreferralsp);
++#endif
++              *lreferralsp = NULL;
++      }
++
++      return num_referrals;
++}
++/* }}} */
++
++/* {{{ proto int _php_parse_controls()
++   parse an array of zvals into an array of LDAP controls */
++static int _php_parse_controls(zval **ctrls, LDAPControl ***lctrlsp)
++{
++      LDAPControl *lctrl, **lctrls, **lctrlp;
++      zval **ctrlval, **val;
++      int ncontrols;
++      char error = 0;
++
++      if ((Z_TYPE_PP(ctrls) != IS_ARRAY) || !(ncontrols = zend_hash_num_elements(Z_ARRVAL_PP(ctrls)))) {
++              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected non-empty array value");
++              return 0;
++      }
++
++      lctrls = safe_emalloc((1 + ncontrols), sizeof(*lctrls), 0);
++      *lctrls = NULL;
++      lctrlp = lctrls;
++      zend_hash_internal_pointer_reset(Z_ARRVAL_PP(ctrls));
++      while (zend_hash_get_current_data(Z_ARRVAL_PP(ctrls), (void**)&ctrlval) == SUCCESS) {
++              if (Z_TYPE_PP(ctrlval) != IS_ARRAY) {
++                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array value must contain only arrays, where each array is a control");
++                      error = 1;
++                      break;
++              }
++              if (zend_hash_find(Z_ARRVAL_PP(ctrlval), "oid", sizeof("oid"), (void **) &val) == FAILURE) {
++                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Control must have an oid key");
++                      error = 1;
++                      break;
++              }



Home | Main Index | Thread Index | Old Index