if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
-
goto cleanup;
}
op->o_bd = frontendDB;
rs->sr_err = frontendDB->be_modify( op, rs );
+#ifdef LDAP_X_TXN
+ if( rs->sr_err == LDAP_X_TXN_SPECIFY_OKAY ) {
+ /* skip cleanup */
+ return rs->sr_err;
+ }
+#endif
+
cleanup:
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
Modifications *tmp;
#endif
int manageDSAit;
- BackendDB *op_be;
+ BackendDB *op_be, *bd = op->o_bd;
char textbuf[ SLAP_TEXT_BUFLEN ];
size_t textlen = sizeof( textbuf );
Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
op->o_log_prefix, abuf, 0, 0, 0 );
- len = 0;
+ len = 0;
ptr = abuf;
if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
*/
op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
if ( op->o_bd == NULL ) {
+ op->o_bd = bd;
rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if ( !rs->sr_ref ) {
if ( rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL;
- op->o_bd = frontendDB;
send_ldap_result( op, rs );
- op->o_bd = NULL;
if ( rs->sr_ref != default_referral ) {
ber_bvarray_free( rs->sr_ref );
}
} else {
- op->o_bd = frontendDB;
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"no global superior knowledge" );
- op->o_bd = NULL;
}
goto cleanup;
}
/* do the update here */
int repl_user = be_isupdate( op );
- /* Multimaster slapd does not have to check for replicator dn
+ /*
+ * Multimaster slapd does not have to check for replicator dn
* because it accepts each modify request
*/
-#ifndef SLAPD_MULTIMASTER
- if ( !SLAP_SHADOW(op->o_bd) || repl_user )
-#endif /* ! SLAPD_MULTIMASTER */
- {
- int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
- slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
+ if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) {
+ int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
+ slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
op->o_bd = op_be;
}
}
-#ifdef SLAPD_MULTIMASTER
- if ( !repl_user )
-#endif /* SLAPD_MULTIMASTER */
- {
+ if ( !repl_user ) {
/* but multimaster slapd logs only the ones
* not from a replicator user */
cb.sc_next = op->o_callback;
}
op->o_bd->be_modify( op, rs );
-#ifndef SLAPD_MULTIMASTER
- /* send a referral */
- } else {
+ } else { /* send a referral */
BerVarray defref = op->o_bd->be_update_refs
? op->o_bd->be_update_refs : default_referral;
if ( defref != NULL ) {
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"shadow context; no update referral" );
}
-#endif /* ! SLAPD_MULTIMASTER */
}
+
} else {
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"operation not supported within namingContext" );
}
cleanup:;
+ op->o_bd = bd;
return rs->sr_err;
}
char *textbuf,
size_t textlen )
{
- if( get_manageDIT( op ) ) return LDAP_SUCCESS;
+ if( get_relax( op ) ) return LDAP_SUCCESS;
for ( ; ml != NULL; ml = ml->sml_next ) {
if ( is_at_obsolete( ml->sml_desc->ad_type ) &&
continue;
}
- if ( get_manageDIT( op ) ) {
+ if ( get_relax( op ) ) {
if ( ml->sml_desc->ad_type->sat_flags & SLAP_AT_MANAGEABLE ) {
ml->sml_flags |= SLAP_MOD_MANAGING;
continue;
struct berval pval;
if ( pretty ) {
-#ifdef SLAP_ORDERED_PRETTYNORM
rc = ordered_value_pretty( ad,
&ml->sml_values[nvals], &pval, ctx );
-#else /* ! SLAP_ORDERED_PRETTYNORM */
- rc = pretty( ad->ad_type->sat_syntax,
- &ml->sml_values[nvals], &pval, ctx );
-#endif /* ! SLAP_ORDERED_PRETTYNORM */
} else {
-#ifdef SLAP_ORDERED_PRETTYNORM
rc = ordered_value_validate( ad,
&ml->sml_values[nvals], ml->sml_op );
-#else /* ! SLAP_ORDERED_PRETTYNORM */
- rc = validate( ad->ad_type->sat_syntax,
- &ml->sml_values[nvals] );
-#endif /* ! SLAP_ORDERED_PRETTYNORM */
}
if( rc != 0 ) {
(nvals+1)*sizeof(struct berval), ctx );
for ( nvals = 0; !BER_BVISNULL( &ml->sml_values[nvals] ); nvals++ ) {
-#ifdef SLAP_ORDERED_PRETTYNORM
rc = ordered_value_normalize(
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
ad,
ad->ad_type->sat_equality,
&ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
-#else /* ! SLAP_ORDERED_PRETTYNORM */
- rc = ad->ad_type->sat_equality->smr_normalize(
- SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
- ad->ad_type->sat_syntax,
- ad->ad_type->sat_equality,
- &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
-#endif /* ! SLAP_ORDERED_PRETTYNORM */
if ( rc ) {
Debug( LDAP_DEBUG_ANY,
"<= str2entry NULL (ssyn_normalize %d)\n",
#endif
}
-/* modify only calls this for non-replicas. modrdn always calls.
+/* Called for all modify and modrdn ops. If the current op was replicated
+ * from elsewhere, all of the attrs should already be present.
*/
void slap_mods_opattrs(
Operation *op,
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
Modifications *mod, **modtail, *modlast;
+ int gotcsn = 0, gotmname = 0, gotmtime = 0;
if ( SLAP_LASTMOD( op->o_bd ) ) {
char *ptr;
timestamp.bv_val = timebuf;
+ for ( modtail = modsp; *modtail; modtail = &(*modtail)->sml_next ) {
+ if ( (*modtail)->sml_op != LDAP_MOD_ADD &&
+ (*modtail)->sml_op != LDAP_MOD_REPLACE ) continue;
+ if ( (*modtail)->sml_desc == slap_schema.si_ad_entryCSN ) {
+ csn = (*modtail)->sml_values[0];
+ gotcsn = 1;
+ } else
+ if ( (*modtail)->sml_desc == slap_schema.si_ad_modifiersName ) {
+ gotmname = 1;
+ } else
+ if ( (*modtail)->sml_desc == slap_schema.si_ad_modifyTimestamp ) {
+ gotmtime = 1;
+ }
+ }
if ( BER_BVISEMPTY( &op->o_csn )) {
- csn.bv_val = csnbuf;
- csn.bv_len = sizeof( csnbuf );
- slap_get_csn( op, &csn, manage_ctxcsn );
+ if ( !gotcsn ) {
+ csn.bv_val = csnbuf;
+ csn.bv_len = sizeof( csnbuf );
+ slap_get_csn( op, &csn, manage_ctxcsn );
+ } else {
+ if ( manage_ctxcsn )
+ slap_queue_csn( op, &csn );
+ }
} else {
csn = op->o_csn;
}
nname = op->o_ndn;
}
- for ( modtail = modsp; *modtail; modtail = &(*modtail)->sml_next )
- ;
-
- mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = LDAP_MOD_REPLACE;
- mod->sml_flags = SLAP_MOD_INTERNAL;
- mod->sml_next = NULL;
- BER_BVZERO( &mod->sml_type );
- mod->sml_desc = slap_schema.si_ad_entryCSN;
- mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- ber_dupbv( &mod->sml_values[0], &csn );
- BER_BVZERO( &mod->sml_values[1] );
- assert( !BER_BVISNULL( &mod->sml_values[0] ) );
- mod->sml_nvalues = NULL;
- *modtail = mod;
- modlast = mod;
- modtail = &mod->sml_next;
-
- if ( get_manageDIT( op ) ) {
- for ( mod = *modsp; mod != modlast; mod = mod->sml_next ) {
- if ( mod->sml_desc == slap_schema.si_ad_modifiersName ) {
- break;
- }
- }
+ if ( !gotcsn ) {
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
+ mod->sml_op = LDAP_MOD_REPLACE;
+ mod->sml_flags = SLAP_MOD_INTERNAL;
+ mod->sml_next = NULL;
+ BER_BVZERO( &mod->sml_type );
+ mod->sml_desc = slap_schema.si_ad_entryCSN;
+ mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_values[0], &csn );
+ BER_BVZERO( &mod->sml_values[1] );
+ assert( !BER_BVISNULL( &mod->sml_values[0] ) );
+ mod->sml_nvalues = NULL;
+ *modtail = mod;
+ modlast = mod;
+ modtail = &mod->sml_next;
}
- if ( mod->sml_desc != slap_schema.si_ad_modifiersName ) {
+ if ( !gotmname ) {
mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_flags = SLAP_MOD_INTERNAL;
modtail = &mod->sml_next;
}
- if ( get_manageDIT( op ) ) {
- for ( mod = *modsp; mod != modlast; mod = mod->sml_next ) {
- if ( mod->sml_desc == slap_schema.si_ad_modifyTimestamp ) {
- break;
- }
- }
- }
-
- if ( mod->sml_desc != slap_schema.si_ad_modifyTimestamp ) {
+ if ( !gotmtime ) {
mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_flags = SLAP_MOD_INTERNAL;