ber_int_t mop;
Modifications tmp, *mod;
-#ifdef SLAP_NVALUES
tmp.sml_nvalues = NULL;
-#endif
if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
&tmp.sml_type, &tmp.sml_values )
mod->sml_op = mop;
mod->sml_type = tmp.sml_type;
mod->sml_values = tmp.sml_values;
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
mod->sml_desc = NULL;
mod->sml_next = NULL;
*modtail = mod;
goto cleanup;
}
- rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn );
+ rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
if( rs->sr_err != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n",
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = default_referral;
- rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
+ if (rs->sr_ref != NULL ) {
+ rs->sr_err = LDAP_REFERRAL;
+ send_ldap_result( op, rs );
- if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
+ if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
+ } else {
+ send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
+ "referral missing" );
+ }
goto cleanup;
}
slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
- if ( rs->sr_err != 0 ) {
+ if ( rs->sr_err < 0 ) {
/*
* A preoperation plugin failure will abort the
* entire operation.
if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0) {
rs->sr_err = LDAP_OTHER;
}
- ldap_mods_free( modv, 1 );
+ slapi_x_free_ldapmods( modv );
modv = NULL;
goto cleanup;
}
*/
slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
modlist = slapi_x_ldapmods2modifications( modv );
+
+ /*
+ * NB: it is valid for the plugin to return no modifications
+ * (for example, a plugin might store some attributes elsewhere
+ * and remove them from the modification list; if only those
+ * attribute types were included in the modification request,
+ * then slapi_x_ldapmods2modifications() above will return
+ * NULL).
+ */
+ if ( modlist == NULL ) {
+ rs->sr_err = LDAP_SUCCESS;
+ send_ldap_result( op, rs );
+ goto cleanup;
+ }
#endif /* defined( LDAP_SLAPI ) */
/*
size_t textlen = sizeof textbuf;
rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
- textbuf, textlen );
+ textbuf, textlen, NULL );
if( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
}
}
- op->oq_modify.rs_modlist = modlist;
+ op->orm_modlist = modlist;
if ( (op->o_bd->be_modify)( op, rs ) == 0
#ifdef SLAPD_MULTIMASTER
&& !repl_user
} else {
BerVarray defref = op->o_bd->be_update_refs
? op->o_bd->be_update_refs : default_referral;
- rs->sr_ref = referral_rewrite( defref,
- NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
-
- if (!rs->sr_ref) rs->sr_ref = defref;
- rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
- if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref );
+ if ( defref != NULL ) {
+ rs->sr_ref = referral_rewrite( defref,
+ NULL, &op->o_req_dn,
+ LDAP_SCOPE_DEFAULT );
+ if (!rs->sr_ref) rs->sr_ref = defref;
+ rs->sr_err = LDAP_REFERRAL;
+ send_ldap_result( op, rs );
+ if (rs->sr_ref != defref) {
+ ber_bvarray_free( rs->sr_ref );
+ }
+ } else {
+ send_ldap_error( op, rs,
+ LDAP_UNWILLING_TO_PERFORM,
+ "referral missing" );
+ }
#endif
}
} else {
}
#if defined( LDAP_SLAPI )
- if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) != 0 ) {
+ if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
"failed\n", 0, 0, 0 );
#endif /* defined( LDAP_SLAPI ) */
cleanup:
- free( op->o_req_dn.bv_val );
- free( op->o_req_ndn.bv_val );
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
if ( modlist != NULL ) slap_mods_free( modlist );
#if defined( LDAP_SLAPI )
if ( modv != NULL ) slapi_x_free_ldapmods( modv );
int update,
const char **text,
char *textbuf,
- size_t textlen )
+ size_t textlen,
+ void *ctx )
{
int rc;
struct berval pval;
if( pretty ) {
rc = pretty( ad->ad_type->sat_syntax,
- &ml->sml_values[nvals], &pval );
+ &ml->sml_values[nvals], &pval, ctx );
} else {
rc = validate( ad->ad_type->sat_syntax,
&ml->sml_values[nvals] );
}
if( pretty ) {
- ber_memfree( ml->sml_values[nvals].bv_val );
+ ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
ml->sml_values[nvals] = pval;
}
}
return LDAP_CONSTRAINT_VIOLATION;
}
-#ifdef SLAP_NVALUES
if( nvals && ad->ad_type->sat_equality &&
ad->ad_type->sat_equality->smr_normalize )
{
- ml->sml_nvalues = ch_malloc( (nvals+1)*sizeof(struct berval) );
+ ml->sml_nvalues = ber_memalloc_x( (nvals+1)*sizeof(struct berval), ctx );
for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
rc = ad->ad_type->sat_equality->smr_normalize(
0,
ad->ad_type->sat_syntax,
ad->ad_type->sat_equality,
- &ml->sml_values[nvals], &ml->sml_nvalues[nvals] );
+ &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
if( rc ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
ml->sml_nvalues[nvals].bv_val = NULL;
ml->sml_nvalues[nvals].bv_len = 0;
}
-#endif
}
}
char *textbuf, size_t textlen )
{
struct berval name, timestamp, csn;
-#ifdef SLAP_NVALUES
struct berval nname;
-#endif
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
Modifications *mod;
if( op->o_dn.bv_len == 0 ) {
name.bv_val = SLAPD_ANONYMOUS;
name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
-#ifdef SLAP_NVALUES
nname = name;
-#endif
} else {
name = op->o_dn;
-#ifdef SLAP_NVALUES
nname = op->o_ndn;
-#endif
}
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &tmpval );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &nname );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues =
(BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
ber_dupbv( &mod->sml_nvalues[0], &nname );
mod->sml_nvalues[1].bv_len = 0;
mod->sml_nvalues[1].bv_val = NULL;
assert( mod->sml_nvalues[0].bv_val );
-#endif
*modtail = mod;
modtail = &mod->sml_next;
mod->sml_values[1].bv_len = 0;
mod->sml_values[1].bv_val = NULL;
assert( mod->sml_values[0].bv_val );
-#ifdef SLAP_NVALUES
mod->sml_nvalues = NULL;
-#endif
*modtail = mod;
modtail = &mod->sml_next;
}