From a6cd83fe73b99958ddf4704a7bc172d84dfed41e Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Tue, 4 Jan 2011 21:45:46 +0000 Subject: [PATCH] ITS#6762 --- CHANGES | 1 + contrib/slapd-modules/cloak/cloak.c | 45 ++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 2d8586cbd6..76671cbaa9 100644 --- a/CHANGES +++ b/CHANGES @@ -94,6 +94,7 @@ OpenLDAP 2.4.24 Engineering Fixed contrib/autogroup LDAP URI with attribute filter (ITS#6536) Fixed contrib/autogroup install location (ITS#6684) Fixed contrib/autogroup crash with ppolicy (ITS#6684) + Fixed contrib/cloak callbacks (ITS#6762) Fixed contrib/nssov to only close socket on shutdown (ITS#6676) Fixed contrib/nssov multi platform support (ITS#6604) Build Environment diff --git a/contrib/slapd-modules/cloak/cloak.c b/contrib/slapd-modules/cloak/cloak.c index 03c9c09f91..8121563be9 100644 --- a/contrib/slapd-modules/cloak/cloak.c +++ b/contrib/slapd-modules/cloak/cloak.c @@ -25,8 +25,8 @@ #include -#include -#include +#include "ac/string.h" +#include "ac/socket.h" #include "lutil.h" #include "slap.h" @@ -159,7 +159,7 @@ cloak_cfgen( ConfigArgs *c ) ci_next = *cip; } - *cip = (cloak_info_t *)ch_calloc( 1, sizeof( cloak_info_t ) ); + *cip = (cloak_info_t *)SLAP_CALLOC( 1, sizeof( cloak_info_t ) ); (*cip)->ci_oc = oc; (*cip)->ci_ad = ad; (*cip)->ci_next = ci_next; @@ -177,7 +177,7 @@ cloak_cfgen( ConfigArgs *c ) } static int -cloak_search_cb( Operation *op, SlapReply *rs ) +cloak_search_response_cb( Operation *op, SlapReply *rs ) { slap_callback *sc; cloak_info_t *ci; @@ -187,7 +187,6 @@ cloak_search_cb( Operation *op, SlapReply *rs ) assert( op && op->o_callback && rs ); if ( rs->sr_type != REP_SEARCH || !rs->sr_entry ) { - slap_freeself_cb( op, rs ); return ( SLAP_CB_CONTINUE ); } @@ -237,7 +236,7 @@ cloak_search_cb( Operation *op, SlapReply *rs ) if ( a->a_desc != ci->ci_ad ) continue; - Debug( LDAP_DEBUG_TRACE, "cloak_search_cb: cloak %s\n", + Debug( LDAP_DEBUG_TRACE, "cloak_search_response_cb: cloak %s\n", a->a_desc->ad_cname.bv_val, 0, 0 ); @@ -262,6 +261,16 @@ cloak_search_cb( Operation *op, SlapReply *rs ) return ( SLAP_CB_CONTINUE ); } +static int +cloak_search_cleanup_cb( Operation *op, SlapReply *rs ) +{ + if ( rs->sr_type == REP_RESULT || rs->sr_err != LDAP_SUCCESS ) { + slap_freeself_cb( op, rs ); + } + + return SLAP_CB_CONTINUE; +} + static int cloak_search( Operation *op, SlapReply *rs ) { @@ -275,8 +284,8 @@ cloak_search( Operation *op, SlapReply *rs ) return SLAP_CB_CONTINUE; sc = op->o_tmpcalloc( 1, sizeof( *sc ), op->o_tmpmemctx ); - sc->sc_response = cloak_search_cb; - sc->sc_cleanup = slap_freeself_cb; + sc->sc_response = cloak_search_response_cb; + sc->sc_cleanup = cloak_search_cleanup_cb; sc->sc_next = op->o_callback; sc->sc_private = ci; op->o_callback = sc; @@ -298,6 +307,25 @@ static ConfigTable cloakcfg[] = { { NULL, NULL, 0, 0, 0, ARG_IGNORED } }; +static int +cloak_db_destroy( + BackendDB *be, + ConfigReply *cr ) +{ + slap_overinst *on = (slap_overinst *)be->bd_info; + cloak_info_t *ci = (cloak_info_t *)on->on_bi.bi_private; + + for ( ; ci; ) { + cloak_info_t *tmp = ci; + ci = ci->ci_next; + SLAP_FREE( tmp ); + } + + on->on_bi.bi_private = NULL; + + return 0; +} + static ConfigOCs cloakocs[] = { { "( OLcfgCtOc:4.1 " "NAME 'olcCloakConfig' " @@ -315,6 +343,7 @@ int cloak_initialize( void ) { int rc; cloak_ovl.on_bi.bi_type = "cloak"; + cloak_ovl.on_bi.bi_db_destroy = cloak_db_destroy; cloak_ovl.on_bi.bi_op_search = cloak_search; cloak_ovl.on_bi.bi_cf_ocs = cloakocs; -- 2.39.5