version 1.37.2.4, 2005/02/02 17:32:45
|
version 1.37.2.11, 2005/08/17 21:33:45
|
Line 1
|
Line 1
|
/* rwm.c - rewrite/remap operations */ |
/* rwm.c - rewrite/remap operations */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/rwm.c,v 1.37.2.3 2005/01/24 21:28:53 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/rwm.c,v 1.64 2005/08/17 17:40:02 ando Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 2003-2005 The OpenLDAP Foundation. |
* Copyright 2003-2005 The OpenLDAP Foundation. |
Line 73 rwm_op_dn_massage( Operation *op, SlapRe
|
Line 73 rwm_op_dn_massage( Operation *op, SlapRe
|
return LDAP_SUCCESS; |
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 ) { |
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_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); |
op->o_req_dn = dn; |
op->o_req_dn = dn; |
} else { |
} else { |
op->o_req_dn = ndn; |
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; |
return LDAP_SUCCESS; |
} |
} |
Line 111 rwm_op_add( Operation *op, SlapReply *rs
|
Line 111 rwm_op_add( Operation *op, SlapReply *rs
|
} |
} |
|
|
if ( olddn != op->o_req_dn.bv_val ) { |
if ( olddn != op->o_req_dn.bv_val ) { |
ch_free( op->ora_e->e_name.bv_val ); |
ber_bvreplace( &op->ora_e->e_name, &op->o_req_dn ); |
ch_free( op->ora_e->e_nname.bv_val ); |
ber_bvreplace( &op->ora_e->e_nname, &op->o_req_ndn ); |
|
|
ber_dupbv( &op->ora_e->e_name, &op->o_req_dn ); |
|
ber_dupbv( &op->ora_e->e_nname, &op->o_req_ndn ); |
|
} |
} |
|
|
/* Count number of attributes in entry */ |
/* Count number of attributes in entry */ |
Line 157 rwm_op_add( Operation *op, SlapReply *rs
|
Line 154 rwm_op_add( Operation *op, SlapReply *rs
|
} |
} |
} |
} |
|
|
} else if ( !isupdate && (*ap)->a_desc->ad_type->sat_no_user_mod ) { |
} else if ( !isupdate && !get_manageDIT( op ) && (*ap)->a_desc->ad_type->sat_no_user_mod ) |
|
{ |
goto next_attr; |
goto next_attr; |
|
|
} else { |
} else { |
Line 171 rwm_op_add( Operation *op, SlapReply *rs
|
Line 169 rwm_op_add( Operation *op, SlapReply *rs
|
} |
} |
} |
} |
|
|
if ( (*ap)->a_desc->ad_type->sat_syntax |
if ( (*ap)->a_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName |
== 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 |
* FIXME: rewrite could fail; in this case |
Line 207 rwm_op_add( Operation *op, SlapReply *rs
|
Line 205 rwm_op_add( Operation *op, SlapReply *rs
|
} |
} |
|
|
if ( mapping != NULL ) { |
if ( mapping != NULL ) { |
assert( mapping->m_dst_ad ); |
assert( mapping->m_dst_ad != NULL ); |
(*ap)->a_desc = mapping->m_dst_ad; |
(*ap)->a_desc = mapping->m_dst_ad; |
} |
} |
} |
} |
Line 228 cleanup_attr:;
|
Line 226 cleanup_attr:;
|
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
|
|
|
#ifdef ENABLE_REWRITE |
static int |
static int |
rwm_op_bind( Operation *op, SlapReply *rs ) |
rwm_conn_init( BackendDB *be, Connection *conn ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) be->bd_info; |
|
struct ldaprwmap *rwmap = |
|
(struct ldaprwmap *)on->on_bi.bi_private; |
|
|
|
( void )rewrite_session_init( rwmap->rwm_rw, conn ); |
|
|
|
return SLAP_CB_CONTINUE; |
|
} |
|
|
|
static int |
|
rwm_conn_destroy( BackendDB *be, Connection *conn ) |
|
{ |
|
slap_overinst *on = (slap_overinst *) be->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
(struct ldaprwmap *)on->on_bi.bi_private; |
(struct ldaprwmap *)on->on_bi.bi_private; |
|
|
|
( void )rewrite_session_delete( rwmap->rwm_rw, conn ); |
|
|
|
return SLAP_CB_CONTINUE; |
|
} |
|
#endif /* ENABLE_REWRITE */ |
|
|
|
static int |
|
rwm_op_bind( Operation *op, SlapReply *rs ) |
|
{ |
|
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
int rc; |
int rc; |
|
|
#ifdef ENABLE_REWRITE |
#ifdef ENABLE_REWRITE |
( void )rewrite_session_delete( rwmap->rwm_rw, op->o_conn ); |
|
( void )rewrite_session_init( rwmap->rwm_rw, op->o_conn ); |
|
|
|
rc = rwm_op_dn_massage( op, rs, "bindDN" ); |
rc = rwm_op_dn_massage( op, rs, "bindDN" ); |
#else /* ! ENABLE_REWRITE */ |
#else /* ! ENABLE_REWRITE */ |
rc = 1; |
rc = 1; |
Line 304 rwm_op_compare( Operation *op, SlapReply
|
Line 323 rwm_op_compare( Operation *op, SlapReply
|
return -1; |
return -1; |
|
|
} else if ( mapped_vals[0].bv_val != op->orc_ava->aa_value.bv_val ) { |
} else if ( mapped_vals[0].bv_val != op->orc_ava->aa_value.bv_val ) { |
free( op->orc_ava->aa_value.bv_val ); |
ber_bvreplace_x( &op->orc_ava->aa_value, &mapped_vals[0], op->o_tmpmemctx ); |
op->orc_ava->aa_value = mapped_vals[0]; |
|
} |
} |
mapped_at = op->orc_ava->aa_desc->ad_cname; |
mapped_at = op->orc_ava->aa_desc->ad_cname; |
|
|
Line 323 rwm_op_compare( Operation *op, SlapReply
|
Line 341 rwm_op_compare( Operation *op, SlapReply
|
} |
} |
|
|
} else { |
} else { |
assert( mapping->m_dst_ad ); |
assert( mapping->m_dst_ad != NULL ); |
ad = mapping->m_dst_ad; |
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]; |
struct berval *mapped_valsp[2]; |
|
|
Line 349 rwm_op_compare( Operation *op, SlapReply
|
Line 368 rwm_op_compare( Operation *op, SlapReply
|
return -1; |
return -1; |
} |
} |
|
|
op->orc_ava->aa_value = mapped_vals[0]; |
if ( mapped_vals[ 0 ].bv_val != op->orc_ava->aa_value.bv_val ) { |
|
/* NOTE: if we get here, rwm_dnattr_rewrite() |
|
* already freed the old value, so now |
|
* it's invalid */ |
|
ber_dupbv_x( &op->orc_ava->aa_value, &mapped_vals[0], |
|
op->o_tmpmemctx ); |
|
ber_memfree_x( mapped_vals[ 0 ].bv_val, NULL ); |
|
} |
} |
} |
op->orc_ava->aa_desc = ad; |
op->orc_ava->aa_desc = ad; |
} |
} |
Line 412 rwm_op_modify( Operation *op, SlapReply
|
Line 438 rwm_op_modify( Operation *op, SlapReply
|
{ |
{ |
is_oc = 1; |
is_oc = 1; |
|
|
} else if ( !isupdate && (*mlp)->sml_desc->ad_type->sat_no_user_mod ) { |
} else if ( !isupdate && !get_manageDIT( op ) && (*mlp)->sml_desc->ad_type->sat_no_user_mod ) |
|
{ |
goto next_mod; |
goto next_mod; |
|
|
} else { |
} else { |
Line 436 rwm_op_modify( Operation *op, SlapReply
|
Line 463 rwm_op_modify( Operation *op, SlapReply
|
last--; |
last--; |
|
|
for ( j = 0; !BER_BVISNULL( &(*mlp)->sml_values[ j ] ); j++ ) { |
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 ], |
( void )rwm_mapping( &rwmap->rwm_oc, &(*mlp)->sml_values[ j ], |
&mapping, RWM_MAP ); |
&oc_mapping, RWM_MAP ); |
if ( mapping == NULL ) { |
if ( oc_mapping == NULL ) { |
if ( rwmap->rwm_at.drop_missing ) { |
if ( rwmap->rwm_at.drop_missing ) { |
/* FIXME: we allow to remove objectClasses as well; |
/* FIXME: we allow to remove objectClasses as well; |
* if the resulting entry is inconsistent, that's |
* if the resulting entry is inconsistent, that's |
Line 457 rwm_op_modify( Operation *op, SlapReply
|
Line 484 rwm_op_modify( Operation *op, SlapReply
|
|
|
} else { |
} else { |
ch_free( (*mlp)->sml_values[ j ].bv_val ); |
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 { |
} else { |
if ( (*mlp)->sml_desc->ad_type->sat_syntax == |
if ( (*mlp)->sml_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName |
slap_schema.si_syn_distinguishedName ) |
|| ( mapping != NULL && mapping->m_dst_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) ) |
{ |
{ |
#ifdef ENABLE_REWRITE |
#ifdef ENABLE_REWRITE |
rc = rwm_dnattr_rewrite( op, rs, "modifyAttrDN", |
rc = rwm_dnattr_rewrite( op, rs, "modifyAttrDN", |
Line 502 rwm_op_modify( Operation *op, SlapReply
|
Line 529 rwm_op_modify( Operation *op, SlapReply
|
next_mod:; |
next_mod:; |
if ( mapping != NULL ) { |
if ( mapping != NULL ) { |
/* use new attribute description */ |
/* use new attribute description */ |
assert( mapping->m_dst_ad ); |
assert( mapping->m_dst_ad != NULL ); |
(*mlp)->sml_desc = mapping->m_dst_ad; |
(*mlp)->sml_desc = mapping->m_dst_ad; |
} |
} |
|
|
Line 516 cleanup_mod:;
|
Line 543 cleanup_mod:;
|
free( ml ); |
free( ml ); |
} |
} |
|
|
/* TODO: rewrite attribute types, values of DN-valued attributes ... */ |
|
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
|
|
Line 583 rwm_op_modrdn( Operation *op, SlapReply
|
Line 609 rwm_op_modrdn( Operation *op, SlapReply
|
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 == NULL ) { |
|
return &rwm_cb; |
|
} |
|
|
|
ldap_pvt_thread_pool_getkey( op->o_threadctx, |
|
rwm_keyfree, &data, NULL ); |
|
if ( data == NULL ) { |
|
data = ch_calloc( sizeof( slap_callback ), 1 ); |
|
ldap_pvt_thread_pool_setkey( op->o_threadctx, |
|
rwm_keyfree, data, rwm_keyfree ); |
|
} |
|
|
|
return (slap_callback *)data; |
|
} |
|
|
static int |
static int |
rwm_swap_attrs( Operation *op, SlapReply *rs ) |
rwm_swap_attrs( Operation *op, SlapReply *rs ) |
{ |
{ |
Line 594 rwm_swap_attrs( Operation *op, SlapReply
|
Line 650 rwm_swap_attrs( Operation *op, SlapReply
|
return SLAP_CB_CONTINUE; |
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 |
static int |
rwm_op_search( Operation *op, SlapReply *rs ) |
rwm_op_search( Operation *op, SlapReply *rs ) |
{ |
{ |
Line 619 rwm_op_search( Operation *op, SlapReply
|
Line 663 rwm_op_search( Operation *op, SlapReply
|
struct berval fstr = BER_BVNULL; |
struct berval fstr = BER_BVNULL; |
Filter *f = NULL; |
Filter *f = NULL; |
|
|
slap_callback *cb; |
slap_callback *cb = NULL; |
AttributeName *an = NULL; |
AttributeName *an = NULL; |
|
|
char *text = NULL; |
char *text = NULL; |
Line 679 rwm_op_search( Operation *op, SlapReply
|
Line 723 rwm_op_search( Operation *op, SlapReply
|
goto error_return; |
goto error_return; |
} |
} |
|
|
cb = (slap_callback *) op->o_tmpcalloc( sizeof( slap_callback ), |
cb = rwm_callback_get( op ); |
1, op->o_tmpmemctx ); |
|
if ( cb == NULL ) { |
|
rc = LDAP_NO_MEMORY; |
|
goto error_return; |
|
} |
|
|
|
cb->sc_response = rwm_swap_attrs; |
cb->sc_response = rwm_swap_attrs; |
cb->sc_cleanup = rwm_freeself; |
cb->sc_cleanup = NULL; |
cb->sc_private = (void *)op->ors_attrs; |
cb->sc_private = (void *)op->ors_attrs; |
cb->sc_next = op->o_callback; |
cb->sc_next = op->o_callback; |
|
|
Line 822 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 861 rwm_attrs( Operation *op, SlapReply *rs,
|
* about duplicate values?) */ |
* about duplicate values?) */ |
isupdate = be_shadow_update( op ); |
isupdate = be_shadow_update( op ); |
for ( ap = a_first; *ap; ) { |
for ( ap = a_first; *ap; ) { |
struct ldapmapping *mapping; |
struct ldapmapping *mapping = NULL; |
int drop_missing; |
int drop_missing; |
int last; |
int last; |
Attribute *a; |
Attribute *a; |
Line 832 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 871 rwm_attrs( Operation *op, SlapReply *rs,
|
/* go on */ ; |
/* go on */ ; |
|
|
} else { |
} else { |
|
if ( op->ors_attrs != NULL && |
|
!SLAP_USERATTRS( rs->sr_attr_flags ) && |
|
!ad_inlist( (*ap)->a_desc, op->ors_attrs ) ) |
|
{ |
|
goto cleanup_attr; |
|
} |
|
|
drop_missing = rwm_mapping( &rwmap->rwm_at, |
drop_missing = rwm_mapping( &rwmap->rwm_at, |
&(*ap)->a_desc->ad_cname, &mapping, RWM_REMAP ); |
&(*ap)->a_desc->ad_cname, &mapping, RWM_REMAP ); |
if ( drop_missing || ( mapping != NULL && BER_BVISEMPTY( &mapping->m_dst ) ) ) |
if ( drop_missing || ( mapping != NULL && BER_BVISEMPTY( &mapping->m_dst ) ) ) |
Line 842 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 888 rwm_attrs( Operation *op, SlapReply *rs,
|
if ( mapping != NULL ) { |
if ( mapping != NULL ) { |
(*ap)->a_desc = mapping->m_dst_ad; |
(*ap)->a_desc = mapping->m_dst_ad; |
} |
} |
|
|
if ( op->ors_attrs != NULL && |
|
!SLAP_USERATTRS( rs->sr_attr_flags ) && |
|
!ad_inlist( (*ap)->a_desc, op->ors_attrs ) ) |
|
{ |
|
goto cleanup_attr; |
|
} |
|
} |
} |
|
|
if ( (*ap)->a_desc == slap_schema.si_ad_entryDN ) { |
if ( (*ap)->a_desc == slap_schema.si_ad_entryDN ) { |
Line 858 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 897 rwm_attrs( Operation *op, SlapReply *rs,
|
} |
} |
|
|
} else if ( !isupdate |
} else if ( !isupdate |
|
&& !get_manageDIT( op ) |
&& (*ap)->a_desc->ad_type->sat_no_user_mod |
&& (*ap)->a_desc->ad_type->sat_no_user_mod |
&& (*ap)->a_desc->ad_type != slap_schema.si_at_undefined ) |
&& (*ap)->a_desc->ad_type != slap_schema.si_at_undefined ) |
{ |
{ |
Line 868 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 908 rwm_attrs( Operation *op, SlapReply *rs,
|
/* just count */ ; |
/* just count */ ; |
|
|
if ( last == 0 ) { |
if ( last == 0 ) { |
/* empty? for now, we leave it in place */ |
/* empty? leave it in place because of attrsonly and vlv */ |
goto next_attr; |
goto next_attr; |
} |
} |
last--; |
last--; |
Line 898 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 938 rwm_attrs( Operation *op, SlapReply *rs,
|
* the value is replaced by |
* the value is replaced by |
* ch_alloc'ed memory |
* ch_alloc'ed memory |
*/ |
*/ |
ch_free( bv[0].bv_val ); |
ber_bvreplace( &bv[0], &mapped ); |
ber_dupbv( &bv[0], &mapped ); |
|
} |
} |
} |
} |
|
|
Line 915 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 954 rwm_attrs( Operation *op, SlapReply *rs,
|
* everything pass thru the ldap backend. */ |
* everything pass thru the ldap backend. */ |
/* FIXME: handle distinguishedName-like syntaxes, like |
/* FIXME: handle distinguishedName-like syntaxes, like |
* nameAndOptionalUID */ |
* nameAndOptionalUID */ |
} else if ( (*ap)->a_desc->ad_type->sat_syntax == |
} else if ( (*ap)->a_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName |
slap_schema.si_syn_distinguishedName ) |
|| ( mapping != NULL && mapping->m_src_ad->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) ) |
{ |
{ |
#ifdef ENABLE_REWRITE |
#ifdef ENABLE_REWRITE |
dc.ctx = "searchAttrDN"; |
dc.ctx = "searchAttrDN"; |
Line 938 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 977 rwm_attrs( Operation *op, SlapReply *rs,
|
|
|
if ( mapping != NULL ) { |
if ( mapping != NULL ) { |
/* rewrite the attribute description */ |
/* rewrite the attribute description */ |
assert( mapping->m_dst_ad ); |
assert( mapping->m_dst_ad != NULL ); |
(*ap)->a_desc = mapping->m_dst_ad; |
(*ap)->a_desc = mapping->m_dst_ad; |
} |
} |
|
|
Line 964 rwm_send_entry( Operation *op, SlapReply
|
Line 1003 rwm_send_entry( Operation *op, SlapReply
|
(struct ldaprwmap *)on->on_bi.bi_private; |
(struct ldaprwmap *)on->on_bi.bi_private; |
|
|
Entry *e = NULL; |
Entry *e = NULL; |
int flags; |
slap_mask_t flags; |
struct berval dn = BER_BVNULL, |
struct berval dn = BER_BVNULL, |
ndn = BER_BVNULL; |
ndn = BER_BVNULL; |
dncookie dc; |
dncookie dc; |
int rc; |
int rc; |
|
|
assert( rs->sr_entry ); |
assert( rs->sr_entry != NULL ); |
|
|
/* |
/* |
* Rewrite the dn of the result, if needed |
* Rewrite the dn of the result, if needed |
Line 1045 rwm_send_entry( Operation *op, SlapReply
|
Line 1084 rwm_send_entry( Operation *op, SlapReply
|
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
|
|
fail:; |
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 ) ) { |
if ( !BER_BVISNULL( &dn ) ) { |
ch_free( dn.bv_val ); |
ch_free( dn.bv_val ); |
} |
} |
Line 1053 fail:;
|
Line 1104 fail:;
|
ch_free( ndn.bv_val ); |
ch_free( ndn.bv_val ); |
} |
} |
|
|
if ( e != NULL && e != rs->sr_entry ) { |
|
entry_free( e ); |
|
} |
|
|
|
return rc; |
return rc; |
} |
} |
|
|
Line 1253 rwm_response( Operation *op, SlapReply *
|
Line 1300 rwm_response( Operation *op, SlapReply *
|
switch( op->o_tag ) { |
switch( op->o_tag ) { |
case LDAP_REQ_SEARCH: |
case LDAP_REQ_SEARCH: |
/* Note: the operation attrs are remapped */ |
/* Note: the operation attrs are remapped */ |
if ( op->ors_attrs != NULL && op->ors_attrs != rs->sr_attrs ) |
if ( rs->sr_type == REP_RESULT |
|
&& op->ors_attrs != NULL |
|
&& op->ors_attrs != rs->sr_attrs ) |
{ |
{ |
ch_free( op->ors_attrs ); |
ch_free( op->ors_attrs ); |
op->ors_attrs = rs->sr_attrs; |
op->ors_attrs = rs->sr_attrs; |
Line 1308 rwm_db_config(
|
Line 1357 rwm_db_config(
|
char **argv |
char **argv |
) |
) |
{ |
{ |
|
slap_overinst *on = (slap_overinst *) be->bd_info; |
|
struct ldaprwmap *rwmap = |
|
(struct ldaprwmap *)on->on_bi.bi_private; |
|
|
int rc = 0; |
int rc = 0; |
char *argv0 = NULL; |
char *argv0 = NULL; |
|
|
Line 1325 rwm_db_config(
|
Line 1378 rwm_db_config(
|
} else if ( strcasecmp( argv[0], "suffixmassage" ) == 0 ) { |
} else if ( strcasecmp( argv[0], "suffixmassage" ) == 0 ) { |
rc = rwm_suffixmassage_config( be, fname, lineno, argc, argv ); |
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 { |
} else { |
rc = SLAP_CONF_UNKNOWN; |
rc = SLAP_CONF_UNKNOWN; |
} |
} |
Line 1344 rwm_db_init(
|
Line 1424 rwm_db_init(
|
slap_overinst *on = (slap_overinst *) be->bd_info; |
slap_overinst *on = (slap_overinst *) be->bd_info; |
struct ldapmapping *mapping = NULL; |
struct ldapmapping *mapping = NULL; |
struct ldaprwmap *rwmap; |
struct ldaprwmap *rwmap; |
|
#ifdef ENABLE_REWRITE |
|
char *rargv[ 3 ]; |
|
#endif /* ENABLE_REWRITE */ |
|
|
rwmap = (struct ldaprwmap *)ch_malloc(sizeof(struct ldaprwmap)); |
rwmap = (struct ldaprwmap *)ch_calloc( 1, sizeof( struct ldaprwmap ) ); |
memset(rwmap, 0, sizeof(struct ldaprwmap)); |
|
|
|
#ifdef ENABLE_REWRITE |
#ifdef ENABLE_REWRITE |
rwmap->rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT ); |
rwmap->rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT ); |
Line 1355 rwm_db_init(
|
Line 1437 rwm_db_init(
|
return -1; |
return -1; |
} |
} |
|
|
{ |
/* this rewriteContext by default must be null; |
char *rargv[3]; |
* rules can be added if required */ |
|
rargv[ 0 ] = "rewriteContext"; |
/* this rewriteContext by default must be null; |
rargv[ 1 ] = "searchFilter"; |
* rules can be added if required */ |
rargv[ 2 ] = NULL; |
rargv[ 0 ] = "rewriteContext"; |
rewrite_parse( rwmap->rwm_rw, "<suffix massage>", 1, 2, rargv ); |
rargv[ 1 ] = "searchFilter"; |
|
rargv[ 2 ] = NULL; |
rargv[ 0 ] = "rewriteContext"; |
rewrite_parse( rwmap->rwm_rw, "<suffix massage>", 1, 2, rargv ); |
rargv[ 1 ] = "default"; |
|
rargv[ 2 ] = NULL; |
rargv[ 0 ] = "rewriteContext"; |
rewrite_parse( rwmap->rwm_rw, "<suffix massage>", 2, 2, rargv ); |
rargv[ 1 ] = "default"; |
|
rargv[ 2 ] = NULL; |
|
rewrite_parse( rwmap->rwm_rw, "<suffix massage>", 2, 2, rargv ); |
|
} |
|
|
|
#endif /* ENABLE_REWRITE */ |
#endif /* ENABLE_REWRITE */ |
|
|
if ( rwm_map_init( &rwmap->rwm_oc, &mapping ) != LDAP_SUCCESS || |
if ( rwm_map_init( &rwmap->rwm_oc, &mapping ) != LDAP_SUCCESS || |
Line 1410 rwm_db_destroy(
|
Line 1487 rwm_db_destroy(
|
avl_free( rwmap->rwm_oc.map, rwm_mapping_free ); |
avl_free( rwmap->rwm_oc.map, rwm_mapping_free ); |
avl_free( rwmap->rwm_at.remap, NULL ); |
avl_free( rwmap->rwm_at.remap, NULL ); |
avl_free( rwmap->rwm_at.map, rwm_mapping_free ); |
avl_free( rwmap->rwm_at.map, rwm_mapping_free ); |
|
|
|
ch_free( rwmap ); |
} |
} |
|
|
return rc; |
return rc; |
Line 1441 rwm_init(void)
|
Line 1520 rwm_init(void)
|
rwm.on_bi.bi_operational = rwm_operational; |
rwm.on_bi.bi_operational = rwm_operational; |
rwm.on_bi.bi_chk_referrals = 0 /* rwm_chk_referrals */ ; |
rwm.on_bi.bi_chk_referrals = 0 /* rwm_chk_referrals */ ; |
|
|
|
#ifdef ENABLE_REWRITE |
|
rwm.on_bi.bi_connection_init = rwm_conn_init; |
|
rwm.on_bi.bi_connection_destroy = rwm_conn_destroy; |
|
#endif /* ENABLE_REWRITE */ |
|
|
rwm.on_response = rwm_response; |
rwm.on_response = rwm_response; |
|
|
return overlay_register( &rwm ); |
return overlay_register( &rwm ); |