#include <stdio.h>
-#include <ac/string.h>
-#include <ac/socket.h>
+#include "ac/string.h"
+#include "ac/socket.h"
#include "lutil.h"
#include "slap.h"
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;
}
static int
-cloak_search_cb( Operation *op, SlapReply *rs )
+cloak_search_response_cb( Operation *op, SlapReply *rs )
{
slap_callback *sc;
cloak_info_t *ci;
assert( op && op->o_callback && rs );
if ( rs->sr_type != REP_SEARCH || !rs->sr_entry ) {
- slap_freeself_cb( op, rs );
return ( SLAP_CB_CONTINUE );
}
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 );
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 )
{
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;
{ 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' "
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;