version 1.37, 2004/12/01 20:47:13
|
version 1.37.2.3, 2005/01/24 21:28:53
|
Line 1
|
Line 1
|
/* rwm.c - rewrite/remap operations */ |
/* rwm.c - rewrite/remap operations */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/rwm.c,v 1.36 2004/11/13 16:27:15 ando Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/overlays/rwm.c,v 1.45 2005/01/20 21:44:54 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-2004 The OpenLDAP Foundation. |
* Copyright 2003-2005 The OpenLDAP Foundation. |
* Portions Copyright 2003 Pierangelo Masarati. |
* Portions Copyright 2003 Pierangelo Masarati. |
* All rights reserved. |
* All rights reserved. |
* |
* |
Line 34 rwm_op_dn_massage( Operation *op, SlapRe
|
Line 34 rwm_op_dn_massage( Operation *op, SlapRe
|
(struct ldaprwmap *)on->on_bi.bi_private; |
(struct ldaprwmap *)on->on_bi.bi_private; |
|
|
struct berval dn = BER_BVNULL, |
struct berval dn = BER_BVNULL, |
*dnp = NULL, |
|
ndn = BER_BVNULL; |
ndn = BER_BVNULL; |
int rc = 0; |
int rc = 0; |
dncookie dc; |
dncookie dc; |
Line 56 rwm_op_dn_massage( Operation *op, SlapRe
|
Line 55 rwm_op_dn_massage( Operation *op, SlapRe
|
* and the caller sets op->o_req_dn = op->o_req_ndn, |
* and the caller sets op->o_req_dn = op->o_req_ndn, |
* only rewrite the op->o_req_ndn and use it as |
* only rewrite the op->o_req_ndn and use it as |
* op->o_req_dn as well */ |
* op->o_req_dn as well */ |
|
ndn = op->o_req_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 ) { |
dnp = &dn; |
dn = op->o_req_dn; |
|
rc = rwm_dn_massage_pretty_normalize( &dc, &op->o_req_dn, &dn, &ndn ); |
|
} else { |
|
rc = rwm_dn_massage_normalize( &dc, &op->o_req_ndn, &ndn ); |
} |
} |
|
|
rc = rwm_dn_massage( &dc, &op->o_req_dn, dnp, &ndn ); |
|
if ( rc != LDAP_SUCCESS ) { |
if ( rc != LDAP_SUCCESS ) { |
return rc; |
return rc; |
} |
} |
|
|
if ( ( dnp && dn.bv_val == op->o_req_dn.bv_val ) || |
if ( ( op->o_req_dn.bv_val != op->o_req_ndn.bv_val && dn.bv_val == op->o_req_dn.bv_val ) |
( !dnp && ndn.bv_val == op->o_req_ndn.bv_val ) ) { |
|| ndn.bv_val == op->o_req_ndn.bv_val ) |
|
{ |
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
} |
} |
|
|
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); |
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); |
if ( dnp ) { |
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_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_req_ndn = ndn; |
|
|
|
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
} |
} |
|
|
static int |
static int |
rwm_add( Operation *op, SlapReply *rs ) |
rwm_op_add( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
Line 93 rwm_add( Operation *op, SlapReply *rs )
|
Line 96 rwm_add( Operation *op, SlapReply *rs )
|
i; |
i; |
Attribute **ap = NULL; |
Attribute **ap = NULL; |
char *olddn = op->o_req_dn.bv_val; |
char *olddn = op->o_req_dn.bv_val; |
|
int isupdate; |
|
|
#ifdef ENABLE_REWRITE |
#ifdef ENABLE_REWRITE |
rc = rwm_op_dn_massage( op, rs, "addDN" ); |
rc = rwm_op_dn_massage( op, rs, "addDN" ); |
Line 115 rwm_add( Operation *op, SlapReply *rs )
|
Line 119 rwm_add( Operation *op, SlapReply *rs )
|
} |
} |
|
|
/* Count number of attributes in entry */ |
/* Count number of attributes in entry */ |
|
isupdate = be_shadow_update( op ); |
for ( i = 0, ap = &op->oq_add.rs_e->e_attrs; *ap; ) { |
for ( i = 0, ap = &op->oq_add.rs_e->e_attrs; *ap; ) { |
struct berval mapped; |
|
Attribute *a; |
Attribute *a; |
|
|
if ( (*ap)->a_desc->ad_type->sat_no_user_mod ) { |
if ( (*ap)->a_desc == slap_schema.si_ad_objectClass || |
|
(*ap)->a_desc == slap_schema.si_ad_structuralObjectClass ) |
|
{ |
|
int j, last; |
|
|
|
for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[ last ] ); last++ ) |
|
/* count values */ ; |
|
last--; |
|
for ( j = 0; !BER_BVISNULL( &(*ap)->a_vals[ j ] ); j++ ) { |
|
struct ldapmapping *mapping = NULL; |
|
|
|
( void )rwm_mapping( &rwmap->rwm_oc, &(*ap)->a_vals[ j ], |
|
&mapping, RWM_MAP ); |
|
if ( mapping == NULL ) { |
|
if ( rwmap->rwm_at.drop_missing ) { |
|
/* FIXME: we allow to remove objectClasses as well; |
|
* if the resulting entry is inconsistent, that's |
|
* the relayed database's business... |
|
*/ |
|
ch_free( (*ap)->a_vals[ j ].bv_val ); |
|
if ( last > j ) { |
|
(*ap)->a_vals[ j ] = (*ap)->a_vals[ last ]; |
|
} |
|
BER_BVZERO( &(*ap)->a_vals[ last ] ); |
|
last--; |
|
j--; |
|
} |
|
|
|
} else { |
|
ch_free( (*ap)->a_vals[ j ].bv_val ); |
|
ber_dupbv( &(*ap)->a_vals[ j ], &mapping->m_dst ); |
|
} |
|
} |
|
|
|
} else if ( !isupdate && (*ap)->a_desc->ad_type->sat_no_user_mod ) { |
goto next_attr; |
goto next_attr; |
} |
|
|
|
rwm_map( &rwmap->rwm_at, &(*ap)->a_desc->ad_cname, |
} else { |
&mapped, RWM_MAP ); |
struct ldapmapping *mapping = NULL; |
if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) ) { |
|
goto cleanup_attr; |
|
} |
|
|
|
if ( (*ap)->a_desc->ad_type->sat_syntax |
( void )rwm_mapping( &rwmap->rwm_at, &(*ap)->a_desc->ad_cname, |
== slap_schema.si_syn_distinguishedName ) |
&mapping, RWM_MAP ); |
{ |
if ( mapping == NULL ) { |
/* |
if ( rwmap->rwm_at.drop_missing ) { |
* FIXME: rewrite could fail; in this case |
goto cleanup_attr; |
* the operation should give up, right? |
} |
*/ |
} |
#ifdef ENABLE_REWRITE |
|
rc = rwm_dnattr_rewrite( op, rs, "addAttrDN", |
if ( (*ap)->a_desc->ad_type->sat_syntax |
(*ap)->a_vals, |
== slap_schema.si_syn_distinguishedName ) |
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
{ |
|
/* |
|
* FIXME: rewrite could fail; in this case |
|
* the operation should give up, right? |
|
*/ |
|
#ifdef ENABLE_REWRITE |
|
rc = rwm_dnattr_rewrite( op, rs, "addAttrDN", |
|
(*ap)->a_vals, |
|
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
#else /* ! ENABLE_REWRITE */ |
#else /* ! ENABLE_REWRITE */ |
rc = 1; |
rc = 1; |
rc = rwm_dnattr_rewrite( op, rs, &rc, (*ap)->a_vals, |
rc = rwm_dnattr_rewrite( op, rs, &rc, (*ap)->a_vals, |
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
#endif /* ! ENABLE_REWRITE */ |
#endif /* ! ENABLE_REWRITE */ |
if ( rc ) { |
if ( rc ) { |
goto cleanup_attr; |
goto cleanup_attr; |
} |
} |
|
|
} else if ( (*ap)->a_desc == slap_schema.si_ad_ref ) { |
} else if ( (*ap)->a_desc == slap_schema.si_ad_ref ) { |
#ifdef ENABLE_REWRITE |
#ifdef ENABLE_REWRITE |
rc = rwm_referral_rewrite( op, rs, "referralAttrDN", |
rc = rwm_referral_rewrite( op, rs, "referralAttrDN", |
(*ap)->a_vals, |
(*ap)->a_vals, |
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
#else /* ! ENABLE_REWRITE */ |
#else /* ! ENABLE_REWRITE */ |
rc = 1; |
rc = 1; |
rc = rwm_referral_rewrite( op, rs, &rc, (*ap)->a_vals, |
rc = rwm_referral_rewrite( op, rs, &rc, (*ap)->a_vals, |
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
(*ap)->a_nvals ? &(*ap)->a_nvals : NULL ); |
#endif /* ! ENABLE_REWRITE */ |
#endif /* ! ENABLE_REWRITE */ |
if ( rc != LDAP_SUCCESS ) { |
if ( rc != LDAP_SUCCESS ) { |
goto cleanup_attr; |
goto cleanup_attr; |
|
} |
|
} |
|
|
|
if ( mapping != NULL ) { |
|
assert( mapping->m_dst_ad ); |
|
(*ap)->a_desc = mapping->m_dst_ad; |
} |
} |
} |
} |
|
|
|
|
next_attr:; |
next_attr:; |
ap = &(*ap)->a_next; |
ap = &(*ap)->a_next; |
continue; |
continue; |
Line 182 cleanup_attr:;
|
Line 229 cleanup_attr:;
|
} |
} |
|
|
static int |
static int |
rwm_bind( Operation *op, SlapReply *rs ) |
rwm_op_bind( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
Line 208 rwm_bind( Operation *op, SlapReply *rs )
|
Line 255 rwm_bind( Operation *op, SlapReply *rs )
|
} |
} |
|
|
static int |
static int |
rwm_unbind( Operation *op, SlapReply *rs ) |
rwm_op_unbind( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
Line 222 rwm_unbind( Operation *op, SlapReply *rs
|
Line 269 rwm_unbind( Operation *op, SlapReply *rs
|
} |
} |
|
|
static int |
static int |
rwm_compare( Operation *op, SlapReply *rs ) |
rwm_op_compare( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
Line 263 rwm_compare( Operation *op, SlapReply *r
|
Line 310 rwm_compare( Operation *op, SlapReply *r
|
mapped_at = op->orc_ava->aa_desc->ad_cname; |
mapped_at = op->orc_ava->aa_desc->ad_cname; |
|
|
} else { |
} else { |
rwm_map( &rwmap->rwm_at, &op->orc_ava->aa_desc->ad_cname, |
struct ldapmapping *mapping = NULL; |
&mapped_at, RWM_MAP ); |
AttributeDescription *ad = op->orc_ava->aa_desc; |
if ( BER_BVISNULL( &mapped_at ) || BER_BVISEMPTY( &mapped_at ) ) |
|
{ |
( void )rwm_mapping( &rwmap->rwm_at, &op->orc_ava->aa_desc->ad_cname, |
op->o_bd->bd_info = (BackendInfo *)on->on_info; |
&mapping, RWM_MAP ); |
send_ldap_error( op, rs, LDAP_OTHER, "compare attributeType map error" ); |
if ( mapping == NULL ) { |
return -1; |
if ( rwmap->rwm_at.drop_missing ) { |
|
op->o_bd->bd_info = (BackendInfo *)on->on_info; |
|
send_ldap_error( op, rs, LDAP_OTHER, "compare attributeType map error" ); |
|
return -1; |
|
} |
|
|
|
} else { |
|
assert( 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 ) |
{ |
{ |
struct berval *mapped_valsp[2]; |
struct berval *mapped_valsp[2]; |
Line 295 rwm_compare( Operation *op, SlapReply *r
|
Line 351 rwm_compare( Operation *op, SlapReply *r
|
|
|
op->orc_ava->aa_value = mapped_vals[0]; |
op->orc_ava->aa_value = mapped_vals[0]; |
} |
} |
|
op->orc_ava->aa_desc = ad; |
} |
} |
|
|
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
|
|
static int |
static int |
rwm_delete( Operation *op, SlapReply *rs ) |
rwm_op_delete( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
int rc; |
int rc; |
Line 322 rwm_delete( Operation *op, SlapReply *rs
|
Line 379 rwm_delete( Operation *op, SlapReply *rs
|
} |
} |
|
|
static int |
static int |
rwm_modify( Operation *op, SlapReply *rs ) |
rwm_op_modify( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
(struct ldaprwmap *)on->on_bi.bi_private; |
(struct ldaprwmap *)on->on_bi.bi_private; |
|
|
|
int isupdate; |
Modifications **mlp; |
Modifications **mlp; |
int rc; |
int rc; |
|
|
Line 343 rwm_modify( Operation *op, SlapReply *rs
|
Line 401 rwm_modify( Operation *op, SlapReply *rs
|
return -1; |
return -1; |
} |
} |
|
|
|
isupdate = be_shadow_update( op ); |
for ( mlp = &op->oq_modify.rs_modlist; *mlp; ) { |
for ( mlp = &op->oq_modify.rs_modlist; *mlp; ) { |
int is_oc = 0; |
int is_oc = 0; |
Modifications *ml; |
Modifications *ml; |
|
struct ldapmapping *mapping = NULL; |
if ( (*mlp)->sml_desc->ad_type->sat_no_user_mod ) { |
|
goto next_mod; |
|
} |
|
|
|
if ( (*mlp)->sml_desc == slap_schema.si_ad_objectClass |
if ( (*mlp)->sml_desc == slap_schema.si_ad_objectClass |
|| (*mlp)->sml_desc == slap_schema.si_ad_structuralObjectClass ) { |
|| (*mlp)->sml_desc == slap_schema.si_ad_structuralObjectClass ) |
|
{ |
is_oc = 1; |
is_oc = 1; |
|
|
|
} else if ( !isupdate && (*mlp)->sml_desc->ad_type->sat_no_user_mod ) { |
|
goto next_mod; |
|
|
} else { |
} else { |
struct ldapmapping *m; |
|
int drop_missing; |
int drop_missing; |
|
|
drop_missing = rwm_mapping( &rwmap->rwm_at, &(*mlp)->sml_desc->ad_cname, &m, RWM_MAP ); |
drop_missing = rwm_mapping( &rwmap->rwm_at, |
if ( drop_missing || ( m != NULL && BER_BVISNULL( &m->m_dst ) ) ) |
&(*mlp)->sml_desc->ad_cname, |
|
&mapping, RWM_MAP ); |
|
if ( drop_missing || ( mapping != NULL && BER_BVISNULL( &mapping->m_dst ) ) ) |
{ |
{ |
goto cleanup_mod; |
goto cleanup_mod; |
} |
} |
|
|
if ( m ) { |
|
/* use new attribute description */ |
|
assert( m->m_dst_ad ); |
|
(*mlp)->sml_desc = m->m_dst_ad; |
|
} |
|
} |
} |
|
|
if ( (*mlp)->sml_values != NULL ) { |
if ( (*mlp)->sml_values != NULL ) { |
if ( is_oc ) { |
if ( is_oc ) { |
int last, j; |
int last, j; |
|
|
for ( last = 0; !BER_BVISNULL( &(*mlp)->sml_values[last] ); last++ ) |
for ( last = 0; !BER_BVISNULL( &(*mlp)->sml_values[ last ] ); last++ ) |
/* count values */ ; |
/* count values */ ; |
last--; |
last--; |
|
|
for ( j = 0; !BER_BVISNULL( &(*mlp)->sml_values[j] ); j++ ) { |
for ( j = 0; !BER_BVISNULL( &(*mlp)->sml_values[ j ] ); j++ ) { |
struct berval mapped = BER_BVNULL; |
struct ldapmapping *mapping = NULL; |
|
|
rwm_map( &rwmap->rwm_oc, |
( void )rwm_mapping( &rwmap->rwm_oc, &(*mlp)->sml_values[ j ], |
&(*mlp)->sml_values[j], |
&mapping, RWM_MAP ); |
&mapped, RWM_MAP ); |
if ( mapping == NULL ) { |
if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) ) { |
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 |
* the relayed database's business... |
* the relayed database's business... |
*/ |
*/ |
#if 0 |
ch_free( (*mlp)->sml_values[ j ].bv_val ); |
goto cleanup_mod; |
if ( last > j ) { |
#endif |
(*mlp)->sml_values[ j ] = (*mlp)->sml_values[ last ]; |
if ( last > j ) { |
} |
(*mlp)->sml_values[j] = (*mlp)->sml_values[last]; |
BER_BVZERO( &(*mlp)->sml_values[ last ] ); |
BER_BVZERO( &(*mlp)->sml_values[last] ); |
last--; |
|
j--; |
} |
} |
last--; |
|
|
|
} else { |
} else { |
ch_free( (*mlp)->sml_values[j].bv_val ); |
ch_free( (*mlp)->sml_values[ j ].bv_val ); |
ber_dupbv( &(*mlp)->sml_values[j], &mapped ); |
ber_dupbv( &(*mlp)->sml_values[ j ], &mapping->m_dst ); |
} |
} |
} |
} |
|
|
Line 445 rwm_modify( Operation *op, SlapReply *rs
|
Line 500 rwm_modify( Operation *op, SlapReply *rs
|
} |
} |
|
|
next_mod:; |
next_mod:; |
|
if ( mapping != NULL ) { |
|
/* use new attribute description */ |
|
assert( mapping->m_dst_ad ); |
|
(*mlp)->sml_desc = mapping->m_dst_ad; |
|
} |
|
|
mlp = &(*mlp)->sml_next; |
mlp = &(*mlp)->sml_next; |
continue; |
continue; |
|
|
Line 460 cleanup_mod:;
|
Line 521 cleanup_mod:;
|
} |
} |
|
|
static int |
static int |
rwm_modrdn( Operation *op, SlapReply *rs ) |
rwm_op_modrdn( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
Line 485 rwm_modrdn( Operation *op, SlapReply *rs
|
Line 546 rwm_modrdn( Operation *op, SlapReply *rs
|
dc.tofrom = 0; |
dc.tofrom = 0; |
dc.normalized = 0; |
dc.normalized = 0; |
#endif /* ! ENABLE_REWRITE */ |
#endif /* ! ENABLE_REWRITE */ |
rc = rwm_dn_massage( &dc, op->orr_newSup, &newSup, &nnewSup ); |
newSup = *op->orr_newSup; |
|
nnewSup = *op->orr_nnewSup; |
|
rc = rwm_dn_massage_pretty_normalize( &dc, op->orr_newSup, &newSup, &nnewSup ); |
if ( rc != LDAP_SUCCESS ) { |
if ( rc != LDAP_SUCCESS ) { |
op->o_bd->bd_info = (BackendInfo *)on->on_info; |
op->o_bd->bd_info = (BackendInfo *)on->on_info; |
send_ldap_error( op, rs, rc, "newSuperiorDN massage error" ); |
send_ldap_error( op, rs, rc, "newSuperiorDN massage error" ); |
Line 515 rwm_modrdn( Operation *op, SlapReply *rs
|
Line 578 rwm_modrdn( Operation *op, SlapReply *rs
|
return -1; |
return -1; |
} |
} |
|
|
/* TODO: rewrite attribute types, values of DN-valued attributes ... */ |
/* TODO: rewrite newRDN, attribute types, |
|
* values of DN-valued attributes ... */ |
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
|
|
Line 543 static int rwm_freeself( Operation *op,
|
Line 607 static int rwm_freeself( Operation *op,
|
} |
} |
|
|
static int |
static int |
rwm_search( Operation *op, SlapReply *rs ) |
rwm_op_search( Operation *op, SlapReply *rs ) |
{ |
{ |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
struct ldaprwmap *rwmap = |
struct ldaprwmap *rwmap = |
Line 699 rwm_matched( Operation *op, SlapReply *r
|
Line 763 rwm_matched( Operation *op, SlapReply *r
|
dc.normalized = 0; |
dc.normalized = 0; |
#endif /* ! ENABLE_REWRITE */ |
#endif /* ! ENABLE_REWRITE */ |
ber_str2bv( rs->sr_matched, 0, 0, &dn ); |
ber_str2bv( rs->sr_matched, 0, 0, &dn ); |
rc = rwm_dn_massage( &dc, &dn, &mdn, NULL ); |
mdn = dn; |
|
rc = rwm_dn_massage_pretty( &dc, &dn, &mdn ); |
if ( rc != LDAP_SUCCESS ) { |
if ( rc != LDAP_SUCCESS ) { |
rs->sr_err = rc; |
rs->sr_err = rc; |
rs->sr_text = "Rewrite error"; |
rs->sr_text = "Rewrite error"; |
Line 729 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 794 rwm_attrs( Operation *op, SlapReply *rs,
|
dncookie dc; |
dncookie dc; |
int rc; |
int rc; |
Attribute **ap; |
Attribute **ap; |
|
int isupdate; |
|
|
/* |
/* |
* Rewrite the dn attrs, if needed |
* Rewrite the dn attrs, if needed |
Line 754 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 820 rwm_attrs( Operation *op, SlapReply *rs,
|
* an error (because multiple instances of attrs in |
* an error (because multiple instances of attrs in |
* response are not valid), or merge the values (what |
* response are not valid), or merge the values (what |
* about duplicate values?) */ |
* about duplicate values?) */ |
|
isupdate = be_shadow_update( op ); |
for ( ap = a_first; *ap; ) { |
for ( ap = a_first; *ap; ) { |
struct ldapmapping *m; |
struct ldapmapping *mapping; |
int drop_missing; |
int drop_missing; |
int last; |
int last; |
Attribute *a; |
Attribute *a; |
Line 764 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 831 rwm_attrs( Operation *op, SlapReply *rs,
|
{ |
{ |
/* go on */ ; |
/* go on */ ; |
|
|
} else if ( op->ors_attrs != NULL && |
} else { |
!SLAP_USERATTRS( rs->sr_attr_flags ) && |
drop_missing = rwm_mapping( &rwmap->rwm_at, |
!ad_inlist( (*ap)->a_desc, op->ors_attrs ) ) |
&(*ap)->a_desc->ad_cname, &mapping, RWM_REMAP ); |
{ |
if ( drop_missing || ( mapping != NULL && BER_BVISEMPTY( &mapping->m_dst ) ) ) |
|
{ |
|
goto cleanup_attr; |
|
} |
|
|
|
if ( mapping != NULL ) { |
|
(*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 ) { |
|
/* will be generated by frontend */ |
goto cleanup_attr; |
goto cleanup_attr; |
} |
} |
|
|
if ( (*ap)->a_desc->ad_type->sat_no_user_mod |
if ( !isupdate && (*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 ) |
{ |
{ |
goto next_attr; |
goto next_attr; |
} |
} |
|
|
drop_missing = rwm_mapping( &rwmap->rwm_at, |
|
&(*ap)->a_desc->ad_cname, &m, RWM_REMAP ); |
|
if ( drop_missing || ( m != NULL && BER_BVISEMPTY( &m->m_dst ) ) ) { |
|
goto cleanup_attr; |
|
} |
|
|
|
for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[last] ); last++ ) |
for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[last] ); last++ ) |
/* just count */ ; |
/* just count */ ; |
|
|
Line 855 rwm_attrs( Operation *op, SlapReply *rs,
|
Line 934 rwm_attrs( Operation *op, SlapReply *rs,
|
} |
} |
} |
} |
|
|
if ( m != NULL ) { |
if ( mapping != NULL ) { |
/* rewrite the attribute description */ |
/* rewrite the attribute description */ |
assert( m->m_dst_ad ); |
assert( mapping->m_dst_ad ); |
(*ap)->a_desc = m->m_dst_ad; |
(*ap)->a_desc = mapping->m_dst_ad; |
} |
} |
|
|
next_attr:; |
next_attr:; |
Line 928 rwm_send_entry( Operation *op, SlapReply
|
Line 1007 rwm_send_entry( Operation *op, SlapReply
|
* from the one known to the meta, and a DN with unknown |
* from the one known to the meta, and a DN with unknown |
* attributes is returned. |
* attributes is returned. |
*/ |
*/ |
rc = rwm_dn_massage( &dc, &e->e_name, &dn, &ndn ); |
dn = e->e_name; |
|
ndn = e->e_nname; |
|
rc = rwm_dn_massage_pretty_normalize( &dc, &e->e_name, &dn, &ndn ); |
if ( rc != LDAP_SUCCESS ) { |
if ( rc != LDAP_SUCCESS ) { |
rc = 1; |
rc = 1; |
goto fail; |
goto fail; |
Line 984 rwm_operational( Operation *op, SlapRepl
|
Line 1065 rwm_operational( Operation *op, SlapRepl
|
return SLAP_CB_CONTINUE; |
return SLAP_CB_CONTINUE; |
} |
} |
|
|
|
#if 0 |
|
/* don't use this; it cannot be reverted, and leaves op->o_req_dn |
|
* rewritten for subsequent operations; fine for plain suffixmassage, |
|
* but destroys everything else */ |
|
static int |
|
rwm_chk_referrals( Operation *op, SlapReply *rs ) |
|
{ |
|
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; |
|
int rc; |
|
|
|
#ifdef ENABLE_REWRITE |
|
rc = rwm_op_dn_massage( op, rs, "referralCheckDN" ); |
|
#else /* ! ENABLE_REWRITE */ |
|
rc = 1; |
|
rc = rwm_op_dn_massage( op, rs, &rc ); |
|
#endif /* ! ENABLE_REWRITE */ |
|
if ( rc != LDAP_SUCCESS ) { |
|
op->o_bd->bd_info = (BackendInfo *)on->on_info; |
|
send_ldap_error( op, rs, rc, "referralCheckDN massage error" ); |
|
return -1; |
|
} |
|
|
|
return SLAP_CB_CONTINUE; |
|
} |
|
#endif |
|
|
static int |
static int |
rwm_rw_config( |
rwm_rw_config( |
BackendDB *be, |
BackendDB *be, |
Line 1313 rwm_init(void)
|
Line 1420 rwm_init(void)
|
rwm.on_bi.bi_db_config = rwm_db_config; |
rwm.on_bi.bi_db_config = rwm_db_config; |
rwm.on_bi.bi_db_destroy = rwm_db_destroy; |
rwm.on_bi.bi_db_destroy = rwm_db_destroy; |
|
|
rwm.on_bi.bi_op_bind = rwm_bind; |
rwm.on_bi.bi_op_bind = rwm_op_bind; |
rwm.on_bi.bi_op_search = rwm_search; |
rwm.on_bi.bi_op_search = rwm_op_search; |
rwm.on_bi.bi_op_compare = rwm_compare; |
rwm.on_bi.bi_op_compare = rwm_op_compare; |
rwm.on_bi.bi_op_modify = rwm_modify; |
rwm.on_bi.bi_op_modify = rwm_op_modify; |
rwm.on_bi.bi_op_modrdn = rwm_modrdn; |
rwm.on_bi.bi_op_modrdn = rwm_op_modrdn; |
rwm.on_bi.bi_op_add = rwm_add; |
rwm.on_bi.bi_op_add = rwm_op_add; |
rwm.on_bi.bi_op_delete = rwm_delete; |
rwm.on_bi.bi_op_delete = rwm_op_delete; |
rwm.on_bi.bi_op_unbind = rwm_unbind; |
rwm.on_bi.bi_op_unbind = rwm_op_unbind; |
rwm.on_bi.bi_extended = rwm_extended; |
rwm.on_bi.bi_extended = rwm_extended; |
|
|
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_response = rwm_response; |
rwm.on_response = rwm_response; |
|
|