X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Fback-meta%2Fmodify.c;h=3ca7cf821f8c8a183f63b72152107e265ddaee0a;hb=843e327a39e1ba023001fbbbe89733a431956549;hp=e09b9c35666347c744093e4da5a41ad4b6ca7f9c;hpb=a050bdee682f484970ec2e6943fc1b3041c9a33a;p=openldap diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index e09b9c3566..3ca7cf821f 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1999-2005 The OpenLDAP Foundation. + * Copyright 1999-2007 The OpenLDAP Foundation. * Portions Copyright 2001-2003 Pierangelo Masarati. * Portions Copyright 1999-2003 Howard Chu. * All rights reserved. @@ -34,8 +34,9 @@ int meta_back_modify( Operation *op, SlapReply *rs ) { - struct metainfo *li = ( struct metainfo * )op->o_bd->be_private; - struct metaconn *lc; + metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; + metatarget_t *mt; + metaconn_t *mc; int rc = 0; LDAPMod **modv = NULL; LDAPMod *mods = NULL; @@ -45,29 +46,28 @@ meta_back_modify( Operation *op, SlapReply *rs ) struct berval mdn = BER_BVNULL; struct berval mapped; dncookie dc; + int msgid; + int do_retry = 1; + LDAPControl **ctrls = NULL; - lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE, - &op->o_req_ndn, &candidate, LDAP_BACK_SENDERR ); - if ( !lc || !meta_back_dobind( lc, op, LDAP_BACK_SENDERR ) ) { - return rs->sr_err; - } - - if ( !meta_back_is_valid( lc, candidate ) ) { - rs->sr_err = LDAP_OTHER; - send_ldap_result( op, rs ); + mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR ); + if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) { return rs->sr_err; } + assert( mc->mc_conns[ candidate ].msc_ld != NULL ); + /* * Rewrite the modify dn, if needed */ - dc.rwmap = &li->targets[ candidate ]->mt_rwmap; + mt = mi->mi_targets[ candidate ]; + dc.target = mt; dc.conn = op->o_conn; dc.rs = rs; dc.ctx = "modifyDN"; if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) { - rc = -1; + send_ldap_result( op, rs ); goto cleanup; } @@ -76,14 +76,14 @@ meta_back_modify( Operation *op, SlapReply *rs ) mods = ch_malloc( sizeof( LDAPMod )*i ); if ( mods == NULL ) { - rs->sr_err = LDAP_NO_MEMORY; - rc = -1; + rs->sr_err = LDAP_OTHER; + send_ldap_result( op, rs ); goto cleanup; } modv = ( LDAPMod ** )ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) ); if ( modv == NULL ) { - rs->sr_err = LDAP_NO_MEMORY; - rc = -1; + rs->sr_err = LDAP_OTHER; + send_ldap_result( op, rs ); goto cleanup; } @@ -92,7 +92,8 @@ meta_back_modify( Operation *op, SlapReply *rs ) for ( i = 0, ml = op->orm_modlist; ml; ml = ml->sml_next ) { int j, is_oc = 0; - if ( !isupdate && ml->sml_desc->ad_type->sat_no_user_mod ) { + if ( !isupdate && !get_manageDIT( op ) && ml->sml_desc->ad_type->sat_no_user_mod ) + { continue; } @@ -103,7 +104,7 @@ meta_back_modify( Operation *op, SlapReply *rs ) mapped = ml->sml_desc->ad_cname; } else { - ldap_back_map( &li->targets[ candidate ]->mt_rwmap.rwm_at, + ldap_back_map( &mt->mt_rwmap.rwm_at, &ml->sml_desc->ad_cname, &mapped, BACKLDAP_MAP ); if ( BER_BVISNULL( &mapped ) || BER_BVISEMPTY( &mapped ) ) { @@ -130,11 +131,11 @@ meta_back_modify( Operation *op, SlapReply *rs ) for ( j = 0; !BER_BVISNULL( &ml->sml_values[ j ] ); ) { struct ldapmapping *mapping; - ldap_back_mapping( &li->targets[ candidate ]->mt_rwmap.rwm_oc, + ldap_back_mapping( &mt->mt_rwmap.rwm_oc, &ml->sml_values[ j ], &mapping, BACKLDAP_MAP ); if ( mapping == NULL ) { - if ( li->targets[ candidate ]->mt_rwmap.rwm_oc.drop_missing ) { + if ( mt->mt_rwmap.rwm_oc.drop_missing ) { continue; } mods[ i ].mod_bvalues[ j ] = &ml->sml_values[ j ]; @@ -175,10 +176,31 @@ meta_back_modify( Operation *op, SlapReply *rs ) } modv[ i ] = 0; - rs->sr_err = ldap_modify_ext_s( lc->mc_conns[ candidate ].msc_ld, mdn.bv_val, - modv, op->o_ctrls, NULL ); +retry:; + ctrls = op->o_ctrls; + rc = ldap_back_proxy_authz_ctrl( &mc->mc_conns[ candidate ].msc_bound_ndn, + mt->mt_version, &mt->mt_idassert, op, rs, &ctrls ); + if ( rc != LDAP_SUCCESS ) { + send_ldap_result( op, rs ); + goto cleanup; + } + + rs->sr_err = ldap_modify_ext( mc->mc_conns[ candidate ].msc_ld, mdn.bv_val, + modv, ctrls, NULL, &msgid ); + rs->sr_err = meta_back_op_result( mc, op, rs, candidate, msgid, + mt->mt_timeout[ SLAP_OP_MODIFY ], LDAP_BACK_SENDRESULT ); + if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) { + do_retry = 0; + if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) { + /* if the identity changed, there might be need to re-authz */ + (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls ); + goto retry; + } + } cleanup:; + (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls ); + if ( mdn.bv_val != op->o_req_dn.bv_val ) { free( mdn.bv_val ); BER_BVZERO( &mdn ); @@ -191,11 +213,9 @@ cleanup:; free( mods ); free( modv ); - if ( rc != -1 ) { - return meta_back_op_result( lc, op, rs ); + if ( mc ) { + meta_back_release_conn( mi, mc ); } - - send_ldap_result( op, rs ); return rs->sr_err; }