return LDAP_SUCCESS;
}
- op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
- op->o_req_ndn = ndn;
if ( op->o_req_dn.bv_val != op->o_req_ndn.bv_val ) {
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
op->o_req_dn = dn;
} else {
op->o_req_dn = ndn;
}
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+ op->o_req_ndn = ndn;
return LDAP_SUCCESS;
}
}
}
- if ( (*ap)->a_desc->ad_type->sat_syntax
- == slap_schema.si_syn_distinguishedName )
+ if ( (*ap)->a_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName
+ || ( mapping != NULL && mapping->m_dst_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) )
{
/*
* FIXME: rewrite could fail; in this case
ad = mapping->m_dst_ad;
}
- if ( op->orc_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName )
+ if ( op->orc_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName
+ || ( mapping != NULL && mapping->m_dst_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) )
{
struct berval *mapped_valsp[2];
last--;
for ( j = 0; !BER_BVISNULL( &(*mlp)->sml_values[ j ] ); j++ ) {
- struct ldapmapping *mapping = NULL;
-
+ struct ldapmapping *oc_mapping = NULL;
+
( void )rwm_mapping( &rwmap->rwm_oc, &(*mlp)->sml_values[ j ],
- &mapping, RWM_MAP );
- if ( mapping == NULL ) {
+ &oc_mapping, RWM_MAP );
+ if ( oc_mapping == NULL ) {
if ( rwmap->rwm_at.drop_missing ) {
/* FIXME: we allow to remove objectClasses as well;
* if the resulting entry is inconsistent, that's
} else {
ch_free( (*mlp)->sml_values[ j ].bv_val );
- ber_dupbv( &(*mlp)->sml_values[ j ], &mapping->m_dst );
+ ber_dupbv( &(*mlp)->sml_values[ j ], &oc_mapping->m_dst );
}
}
} else {
- if ( (*mlp)->sml_desc->ad_type->sat_syntax ==
- slap_schema.si_syn_distinguishedName )
+ if ( (*mlp)->sml_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName
+ || ( mapping != NULL && mapping->m_dst_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) )
{
#ifdef ENABLE_REWRITE
rc = rwm_dnattr_rewrite( op, rs, "modifyAttrDN",
free( ml );
}
- /* TODO: rewrite attribute types, values of DN-valued attributes ... */
return SLAP_CB_CONTINUE;
}
return SLAP_CB_CONTINUE;
}
+static slap_callback *rwm_cb;
+
+static void
+rwm_keyfree(
+ void *key,
+ void *data )
+{
+ ber_memfree_x( data, NULL );
+}
+
+static slap_callback *
+rwm_callback_get( Operation *op )
+{
+ void *data = NULL;
+
+ if ( op->o_threadctx ) {
+ ldap_pvt_thread_pool_getkey( op->o_threadctx,
+ rwm_keyfree, &data, NULL );
+ } else {
+ data = rwm_cb;
+ }
+
+ if ( data == NULL ) {
+ data = ber_memalloc( sizeof( slap_callback ) );
+ if ( op->o_threadctx ) {
+ ldap_pvt_thread_pool_setkey( op->o_threadctx,
+ rwm_keyfree, data, rwm_keyfree );
+
+ } else {
+ rwm_cb = (slap_callback *)data;
+ }
+ }
+
+ return (slap_callback *)data;
+}
+
static int
rwm_swap_attrs( Operation *op, SlapReply *rs )
{
return SLAP_CB_CONTINUE;
}
-static int rwm_freeself( Operation *op, SlapReply *rs )
-{
- if ( op->o_tag == LDAP_REQ_SEARCH && rs->sr_type == REP_RESULT ) {
- assert( op->o_callback );
-
- op->o_tmpfree( op->o_callback, op->o_tmpmemctx );
- op->o_callback = NULL;
- }
-
- return SLAP_CB_CONTINUE;
-}
-
static int
rwm_op_search( Operation *op, SlapReply *rs )
{
struct berval fstr = BER_BVNULL;
Filter *f = NULL;
- slap_callback *cb;
+ slap_callback *cb = NULL;
AttributeName *an = NULL;
char *text = NULL;
goto error_return;
}
- cb = (slap_callback *) op->o_tmpcalloc( sizeof( slap_callback ),
- 1, op->o_tmpmemctx );
- if ( cb == NULL ) {
- rc = LDAP_NO_MEMORY;
- goto error_return;
- }
+ cb = rwm_callback_get( op );
cb->sc_response = rwm_swap_attrs;
- cb->sc_cleanup = rwm_freeself;
+ cb->sc_cleanup = NULL;
cb->sc_private = (void *)op->ors_attrs;
cb->sc_next = op->o_callback;
/* just count */ ;
if ( last == 0 ) {
- /* empty? for now, we leave it in place */
+ /* empty? leave it in place because of attrsonly and vlv */
goto next_attr;
}
last--;
return SLAP_CB_CONTINUE;
fail:;
+ if ( e != NULL && e != rs->sr_entry ) {
+ if ( e->e_name.bv_val == dn.bv_val ) {
+ BER_BVZERO( &e->e_name );
+ }
+
+ if ( e->e_nname.bv_val == ndn.bv_val ) {
+ BER_BVZERO( &e->e_nname );
+ }
+
+ entry_free( e );
+ }
+
if ( !BER_BVISNULL( &dn ) ) {
ch_free( dn.bv_val );
}
ch_free( ndn.bv_val );
}
- if ( e != NULL && e != rs->sr_entry ) {
- entry_free( e );
- }
-
return rc;
}
char **argv
)
{
+ slap_overinst *on = (slap_overinst *) be->bd_info;
+ struct ldaprwmap *rwmap =
+ (struct ldaprwmap *)on->on_bi.bi_private;
+
int rc = 0;
char *argv0 = NULL;
} else if ( strcasecmp( argv[0], "suffixmassage" ) == 0 ) {
rc = rwm_suffixmassage_config( be, fname, lineno, argc, argv );
+ } else if ( strcasecmp( argv[0], "t-f-support" ) == 0 ) {
+ if ( argc != 2 ) {
+ fprintf( stderr,
+ "%s: line %d: \"t-f-support {no|yes|discover}\" needs 1 argument.\n",
+ fname, lineno );
+ return( 1 );
+ }
+
+ if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
+ rwmap->rwm_flags &= ~(RWM_F_SUPPORT_T_F|RWM_F_SUPPORT_T_F_DISCOVER);
+
+ } else if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
+ rwmap->rwm_flags |= RWM_F_SUPPORT_T_F;
+
+#if 0
+ /* TODO: not implemented yet */
+ } else if ( strcasecmp( argv[ 1 ], "discover" ) == 0 ) {
+ rwmap->rwm_flags |= RWM_F_SUPPORT_T_F_DISCOVER;
+#endif
+
+ } else {
+ fprintf( stderr,
+ "%s: line %d: unknown value \"%s\" for \"t-f-support {no|yes|discover}\".\n",
+ fname, lineno, argv[ 1 ] );
+ return 1;
+ }
+
} else {
rc = SLAP_CONF_UNKNOWN;
}