]> git.sur5r.net Git - openldap/commitdiff
ITS#5355 use bi_extra instead of calling directly into back-ldap
authorHoward Chu <hyc@openldap.org>
Fri, 8 Feb 2008 02:01:17 +0000 (02:01 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 8 Feb 2008 02:01:17 +0000 (02:01 +0000)
servers/slapd/back-ldap/back-ldap.h
servers/slapd/back-ldap/init.c
servers/slapd/back-meta/add.c
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/compare.c
servers/slapd/back-meta/delete.c
servers/slapd/back-meta/init.c
servers/slapd/back-meta/modify.c
servers/slapd/back-meta/modrdn.c
servers/slapd/back-meta/search.c

index 104ae675c98b697601b1608f39b8efb0c23da397..9098d40841bd356e206692776a33fac9a173a7bf 100644 (file)
@@ -424,6 +424,12 @@ typedef enum ldap_back_send_t {
 #define LDAP_BACK_PRINT_CONNTREE 0
 #endif /* !LDAP_BACK_PRINT_CONNTREE */
 
+typedef struct ldap_extra_t {
+       int (*proxy_authz_ctrl)( Operation *op, SlapReply *rs, struct berval *bound_ndn,
+               int version, slap_idassert_t *si, LDAPControl   *ctrl );
+       int (*controls_free)( Operation *op, SlapReply *rs, LDAPControl ***pctrls );
+} ldap_extra_t;
+
 LDAP_END_DECL
 
 #include "proto-ldap.h"
index d202aab5a7acc1445a03f17f20af6bfa0aa604c2..44012c81b762541974091a6a5b73b537b3f609fc 100644 (file)
 #include "config.h"
 #include "back-ldap.h"
 
+static const ldap_extra_t ldap_extra = {
+       ldap_back_proxy_authz_ctrl,
+       ldap_back_controls_free
+};
+
 int
 ldap_back_open( BackendInfo    *bi )
 {
@@ -83,6 +88,8 @@ ldap_back_initialize( BackendInfo *bi )
        bi->bi_connection_init = 0;
        bi->bi_connection_destroy = ldap_back_conn_destroy;
 
+       bi->bi_extra = (void *)&ldap_extra;
+
        rc = chain_initialize();
        if ( rc ) {
                return rc;
index 2697899635983c87b2ab635c48443c9134fa49f6..bbe9f6a1eb7711d0e1cba99957c348447beb495b 100644 (file)
@@ -183,13 +183,13 @@ retry:;
                do_retry = 0;
                if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
                        /* if the identity changed, there might be need to re-authz */
-                       (void)ldap_back_controls_free( op, rs, &ctrls );
+                       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
                        goto retry;
                }
        }
 
 cleanup:;
-       (void)ldap_back_controls_free( op, rs, &ctrls );
+       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
 
        for ( --i; i >= 0; --i ) {
                free( attrs[ i ]->mod_bvalues );
index 190180719caa19b9af219c796583f19e86445c7d..16d952bcb682a5c903af334c51aa2ca1be4e6a6f 100644 (file)
@@ -397,6 +397,9 @@ typedef struct metainfo_t {
        time_t                  mi_idle_timeout;
        struct timeval          mi_bind_timeout;
        time_t                  mi_timeout[ SLAP_OP_LAST ];
+
+       ldap_extra_t    *mi_ldap_extra;
+
 } metainfo_t;
 
 typedef enum meta_op_type {
index 95ca3ff9e74e0ef82d45a4cdf54024a85e5eaf26..3f74836281631b6f6f7322b02fb327847483440f 100644 (file)
@@ -509,7 +509,7 @@ meta_back_single_bind(
                ldap_pvt_thread_yield();
        }
 
-       ldap_back_controls_free( op, rs, &ctrls );
+       mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
 
        meta_back_bind_op_result( op, rs, mc, candidate, msgid, LDAP_BACK_DONTSEND );
        if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -1553,7 +1553,7 @@ meta_back_proxy_authz_bind( metaconn_t *mc, int candidate, Operation *op, SlapRe
  *
  * if any needs to be added, it is prepended to existing ones,
  * in a newly allocated array.  The companion function
- * ldap_back_controls_free() must be used to restore the original
+ * mi->mi_ldap_extra->controls_free() must be used to restore the original
  * status of op->o_ctrls.
  */
 int
@@ -1595,7 +1595,7 @@ meta_back_controls_add(
        /* put controls that go __before__ existing ones here */
 
        /* proxyAuthz for identity assertion */
-       switch ( ldap_back_proxy_authz_ctrl( op, rs, &msc->msc_bound_ndn,
+       switch ( mi->mi_ldap_extra->proxy_authz_ctrl( op, rs, &msc->msc_bound_ndn,
                mt->mt_version, &mt->mt_idassert, &c[ j1 ] ) )
        {
        case SLAP_CB_CONTINUE:
index 6a5480172628434ea88299ab20bf0b1a9c07700f..5fbb9fa92875449073c0d19f92bb765d55960a7e 100644 (file)
@@ -129,13 +129,13 @@ retry:;
                do_retry = 0;
                if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
                        /* if the identity changed, there might be need to re-authz */
-                       (void)ldap_back_controls_free( op, rs, &ctrls );
+                       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
                        goto retry;
                }
        }
 
 cleanup:;
-       (void)ldap_back_controls_free( op, rs, &ctrls );
+       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
 
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                free( mdn.bv_val );
index 71391057fc98c47798c1e40765c00a6ff1bb246d..b3335a09c8aab0e05acf847fb2fa14cc4942452f 100644 (file)
@@ -81,13 +81,13 @@ retry:;
                do_retry = 0;
                if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
                        /* if the identity changed, there might be need to re-authz */
-                       (void)ldap_back_controls_free( op, rs, &ctrls );
+                       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
                        goto retry;
                }
        }
 
 cleanup:;
-       (void)ldap_back_controls_free( op, rs, &ctrls );
+       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
 
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                free( mdn.bv_val );
index e5fe76f277f5b701c7ad6f60164ccf61cc8b2d28..0c77c4c209e4ec5898a6e8f0dd84e3a49f23fb37 100644 (file)
@@ -134,6 +134,7 @@ meta_back_db_open(
        ConfigReply     *cr )
 {
        metainfo_t      *mi = (metainfo_t *)be->be_private;
+       BackendInfo *bi;
 
        int             i,
                        not_always = 0,
@@ -148,6 +149,15 @@ meta_back_db_open(
                return 1;
        }
 
+       bi = backend_info( "ldap" );
+       if ( !bi || !bi->bi_extra ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "meta_back_db_open: needs back-ldap\n",
+                       0, 0, 0 );
+               return 1;
+       }
+       mi->mi_ldap_extra = (ldap_extra_t *)bi->bi_extra;
+
        for ( i = 0; i < mi->mi_ntargets; i++ ) {
                slap_bindconf   sb = { BER_BVNULL };
                metatarget_t    *mt = mi->mi_targets[ i ];
index 84cf5d6a4790385b3e528ddd97f9e495668d06a6..e2c735b9f1b61b30bef0880e682e4d2e1dfab83c 100644 (file)
@@ -192,13 +192,13 @@ retry:;
                do_retry = 0;
                if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
                        /* if the identity changed, there might be need to re-authz */
-                       (void)ldap_back_controls_free( op, rs, &ctrls );
+                       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
                        goto retry;
                }
        }
 
 cleanup:;
-       (void)ldap_back_controls_free( op, rs, &ctrls );
+       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
 
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                free( mdn.bv_val );
index 7938d7e9b9ec6665983b16597be3a4ff8f605c02..117d7247ab90c52317aaae9caad2a8a4f070539f 100644 (file)
@@ -136,13 +136,13 @@ retry:;
                do_retry = 0;
                if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
                        /* if the identity changed, there might be need to re-authz */
-                       (void)ldap_back_controls_free( op, rs, &ctrls );
+                       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
                        goto retry;
                }
        }
 
 cleanup:;
-       (void)ldap_back_controls_free( op, rs, &ctrls );
+       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
 
        if ( mdn.bv_val != op->o_req_dn.bv_val ) {
                free( mdn.bv_val );
index 895020c6f01b377e39990241af19b53c036dad49..70437ed6a1d5d4411140be2529163188c9d7c7f7 100644 (file)
@@ -624,7 +624,7 @@ retry:;
                if ( nretries && meta_back_retry( op, rs, mcp, candidate, LDAP_BACK_DONTSEND ) ) {
                        nretries = 0;
                        /* if the identity changed, there might be need to re-authz */
-                       (void)ldap_back_controls_free( op, rs, &ctrls );
+                       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
                        goto retry;
                }
 
@@ -641,7 +641,7 @@ retry:;
        }
 
 done:;
-       (void)ldap_back_controls_free( op, rs, &ctrls );
+       (void)mi->mi_ldap_extra->controls_free( op, rs, &ctrls );
 
        if ( mapped_attrs ) {
                free( mapped_attrs );