ber_len_t length;
int manageDSAit;
-#ifdef LDAP_SLAPI
- Slapi_PBlock *pb = op->o_pb;
-#endif
-
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY, "do_modrdn: begin\n", 0, 0, 0 );
#else
rs->sr_err = SLAPD_DISCONNECT;
goto cleanup;
}
- op->oq_modrdn.rs_newSup = &pnewSuperior;
- op->oq_modrdn.rs_nnewSup = &nnewSuperior;
+ op->orr_newSup = &pnewSuperior;
+ op->orr_nnewSup = &nnewSuperior;
}
#ifdef NEW_LOGGING
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,
/* FIXME: should have/use rdnPretty / rdnNormalize routines */
- rs->sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn );
+ rs->sr_err = dnPrettyNormal( NULL, &newrdn, &op->orr_newrdn, &op->orr_nnewrdn, op->o_tmpmemctx );
if( rs->sr_err != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO,
goto cleanup;
}
- if( rdnValidate( &op->oq_modrdn.rs_newrdn ) != LDAP_SUCCESS ) {
+ if( rdnValidate( &op->orr_newrdn ) != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
- "do_modrdn: invalid rdn (%s).\n", op->oq_modrdn.rs_newrdn.bv_val, 0, 0 );
+ "do_modrdn: invalid rdn (%s).\n", op->orr_newrdn.bv_val, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid rdn (%s)\n",
- op->oq_modrdn.rs_newrdn.bv_val, 0, 0 );
+ op->orr_newrdn.bv_val, 0, 0 );
#endif
send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid new RDN" );
goto cleanup;
}
- if( op->oq_modrdn.rs_newSup ) {
+ if( op->orr_newSup ) {
rs->sr_err = dnPrettyNormal( NULL, &newSuperior, &pnewSuperior,
- &nnewSuperior );
+ &nnewSuperior, op->o_tmpmemctx );
if( rs->sr_err != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO,
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;
}
/* Make sure that the entry being changed and the newSuperior are in
* the same backend, otherwise we return an error.
*/
- if( op->oq_modrdn.rs_newSup ) {
+ if( op->orr_newSup ) {
newSuperior_be = select_backend( &nnewSuperior, 0, 0 );
if ( newSuperior_be != op->o_bd ) {
}
#if defined( LDAP_SLAPI )
- slapi_x_pblock_set_operation( pb, op );
- slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn.bv_val );
- slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR,
- (void *)newSuperior.bv_val );
- slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
- slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
-
- rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
- if ( rs->sr_err != 0 ) {
- /*
- * A preoperation plugin failure will abort the
- * entire operation.
- */
+#define pb op->o_pb
+ if ( pb ) {
+ slapi_x_pblock_set_operation( pb, op );
+ slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)dn.bv_val );
+ slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn.bv_val );
+ slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR,
+ (void *)newSuperior.bv_val );
+ slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
+ slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
+
+ rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
+ if ( rs->sr_err < 0 ) {
+ /*
+ * A preoperation plugin failure will abort the
+ * entire operation.
+ */
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn preoperation plugin "
- "failed\n", 0, 0, 0 );
+ LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn preoperation plugin "
+ "failed\n", 0, 0, 0 );
#else
- Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn preoperation plugin "
- "failed.\n", 0, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn preoperation plugin "
+ "failed.\n", 0, 0, 0);
#endif
- if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0)
- rs->sr_err = LDAP_OTHER;
- goto cleanup;
+ if ( ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
+ rs->sr_err == LDAP_SUCCESS ) {
+ rs->sr_err = LDAP_OTHER;
+ }
+ goto cleanup;
+ }
}
#endif /* defined( LDAP_SLAPI ) */
/* do the update here */
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
#ifndef SLAPD_MULTIMASTER
- if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
+ if ( !op->o_bd->be_syncinfo &&
+ ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
+#else
+ if ( !op->o_bd->be_syncinfo )
#endif
{
- op->oq_modrdn.rs_deleteoldrdn = deloldrdn;
+ op->orr_deleteoldrdn = deloldrdn;
if ( (op->o_bd->be_modrdn)( op, rs ) == 0
#ifdef SLAPD_MULTIMASTER
&& ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
}
#ifndef SLAPD_MULTIMASTER
} 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;
+ BerVarray defref = NULL;
+ if ( op->o_bd->be_syncinfo ) {
+ defref = op->o_bd->be_syncinfo->si_provideruri_bv;
+ } else {
+ defref = op->o_bd->be_update_refs
+ ? op->o_bd->be_update_refs : default_referral;
+ }
+ 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 );
+ rs->sr_err = LDAP_REFERRAL;
+ send_ldap_result( op, rs );
- if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref );
+ 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_MODRDN_FN, pb ) != 0 ) {
+ if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn 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 );
- free( op->oq_modrdn.rs_newrdn.bv_val );
- free( op->oq_modrdn.rs_nnewrdn.bv_val );
+ slap_graduate_commit_csn( op );
+
+ 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 ( pnewSuperior.bv_val ) free( pnewSuperior.bv_val );
- if ( nnewSuperior.bv_val ) free( nnewSuperior.bv_val );
+ op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );
+
+ if ( pnewSuperior.bv_val ) op->o_tmpfree( pnewSuperior.bv_val, op->o_tmpmemctx );
+ if ( nnewSuperior.bv_val ) op->o_tmpfree( nnewSuperior.bv_val, op->o_tmpmemctx );
return rs->sr_err;
}
Operation *op,
SlapReply *rs,
Entry *e,
- LDAPRDN *old_rdn,
- LDAPRDN *new_rdn,
+ LDAPRDN old_rdn,
+ LDAPRDN new_rdn,
Modifications **pmod )
{
Modifications *mod = NULL;
+ Modifications **modtail = &mod;
int a_cnt, d_cnt;
+ int repl_user;
assert( new_rdn != NULL );
- assert( !op->oq_modrdn.rs_deleteoldrdn || old_rdn != NULL );
+ assert( !op->orr_deleteoldrdn || old_rdn != NULL );
+
+ repl_user = be_isupdate( op->o_bd, &op->o_ndn );
/* Add new attribute values to the entry */
- for ( a_cnt = 0; new_rdn[0][a_cnt]; a_cnt++ ) {
+ for ( a_cnt = 0; new_rdn[a_cnt]; a_cnt++ ) {
AttributeDescription *desc = NULL;
Modifications *mod_tmp;
- rs->sr_err = slap_bv2ad( &new_rdn[0][a_cnt]->la_attr, &desc, &rs->sr_text );
+ rs->sr_err = slap_bv2ad( &new_rdn[a_cnt]->la_attr, &desc, &rs->sr_text );
if ( rs->sr_err != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
"slap_modrdn2modlist: %s: %s (new)\n",
rs->sr_text,
- new_rdn[ 0 ][ a_cnt ]->la_attr.bv_val, 0 );
+ new_rdn[ a_cnt ]->la_attr.bv_val, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"slap_modrdn2modlist: %s: %s (new)\n",
rs->sr_text,
- new_rdn[ 0 ][ a_cnt ]->la_attr.bv_val, 0 );
+ new_rdn[ a_cnt ]->la_attr.bv_val, 0 );
#endif
goto done;
}
/* ACL check of newly added attrs */
if ( op->o_bd && !access_allowed( op, e, desc,
- &new_rdn[0][a_cnt]->la_value, ACL_WRITE, NULL ) ) {
+ &new_rdn[a_cnt]->la_value, ACL_WRITE, NULL ) ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
"slap_modrdn2modlist: access to attr \"%s\" "
"(new) not allowed\n",
- new_rdn[0][a_cnt]->la_attr.bv_val, 0, 0 );
+ new_rdn[a_cnt]->la_attr.bv_val, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"slap_modrdn2modlist: access to attr \"%s\" "
"(new) not allowed\n",
- new_rdn[0][ a_cnt ]->la_attr.bv_val, 0, 0 );
+ new_rdn[ a_cnt ]->la_attr.bv_val, 0, 0 );
#endif
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
goto done;
}
/* Apply modification */
-#ifdef SLAP_NVALUES
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 4 * sizeof( struct berval ) );
-#else
- mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof( struct berval ) );
-#endif
mod_tmp->sml_desc = desc;
mod_tmp->sml_values = ( BerVarray )( mod_tmp + 1 );
- mod_tmp->sml_values[0] = new_rdn[0][a_cnt]->la_value;
+ mod_tmp->sml_values[0] = new_rdn[a_cnt]->la_value;
mod_tmp->sml_values[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
if( desc->ad_type->sat_equality->smr_normalize) {
mod_tmp->sml_nvalues = &mod_tmp->sml_values[2];
(void) (*desc->ad_type->sat_equality->smr_normalize)(
- SLAP_MR_EQUALITY,
+ SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
desc->ad_type->sat_syntax,
desc->ad_type->sat_equality,
&mod_tmp->sml_values[0],
- &mod_tmp->sml_nvalues[0] );
+ &mod_tmp->sml_nvalues[0], op->o_tmpmemctx );
mod_tmp->sml_nvalues[1].bv_val = NULL;
} else {
mod_tmp->sml_nvalues = NULL;
}
-#endif
mod_tmp->sml_op = SLAP_MOD_SOFTADD;
mod_tmp->sml_next = mod;
mod = mod_tmp;
}
/* Remove old rdn value if required */
- if ( op->oq_modrdn.rs_deleteoldrdn ) {
- for ( d_cnt = 0; old_rdn[0][d_cnt]; d_cnt++ ) {
+ if ( op->orr_deleteoldrdn ) {
+ for ( d_cnt = 0; old_rdn[d_cnt]; d_cnt++ ) {
AttributeDescription *desc = NULL;
Modifications *mod_tmp;
- rs->sr_err = slap_bv2ad( &old_rdn[0][d_cnt]->la_attr, &desc, &rs->sr_text );
+ rs->sr_err = slap_bv2ad( &old_rdn[d_cnt]->la_attr, &desc, &rs->sr_text );
if ( rs->sr_err != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
"slap_modrdn2modlist: %s: %s (old)\n",
rs->sr_text,
- old_rdn[0][d_cnt]->la_attr.bv_val,
+ old_rdn[d_cnt]->la_attr.bv_val,
0 );
#else
Debug( LDAP_DEBUG_TRACE,
"slap_modrdn2modlist: %s: %s (old)\n",
rs->sr_text,
- old_rdn[0][d_cnt]->la_attr.bv_val,
+ old_rdn[d_cnt]->la_attr.bv_val,
0 );
#endif
goto done;
/* ACL check of newly added attrs */
if ( op->o_bd && !access_allowed( op, e, desc,
- &old_rdn[0][d_cnt]->la_value, ACL_WRITE,
+ &old_rdn[d_cnt]->la_value, ACL_WRITE,
NULL ) ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
"slap_modrdn2modlist: access "
"to attr \"%s\" (old) not allowed\n",
- old_rdn[ 0 ][ d_cnt ]->la_attr.bv_val,
+ old_rdn[ d_cnt ]->la_attr.bv_val,
0, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"slap_modrdn2modlist: access "
"to attr \"%s\" (old) not allowed\n",
- old_rdn[ 0 ][ d_cnt ]->la_attr.bv_val,
+ old_rdn[ d_cnt ]->la_attr.bv_val,
0, 0 );
#endif
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
}
/* Apply modification */
-#ifdef SLAP_NVALUES
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
+ 4 * sizeof ( struct berval ) );
-#else
- mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof ( struct berval ) );
-#endif
mod_tmp->sml_desc = desc;
mod_tmp->sml_values = ( BerVarray )(mod_tmp+1);
- mod_tmp->sml_values[0] = old_rdn[0][d_cnt]->la_value;
+ mod_tmp->sml_values[0] = old_rdn[d_cnt]->la_value;
mod_tmp->sml_values[1].bv_val = NULL;
-#ifdef SLAP_NVALUES
if( desc->ad_type->sat_equality->smr_normalize) {
mod_tmp->sml_nvalues = &mod_tmp->sml_values[2];
(void) (*desc->ad_type->sat_equality->smr_normalize)(
- SLAP_MR_EQUALITY,
+ SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
desc->ad_type->sat_syntax,
desc->ad_type->sat_equality,
&mod_tmp->sml_values[0],
- &mod_tmp->sml_nvalues[0] );
+ &mod_tmp->sml_nvalues[0], op->o_tmpmemctx );
mod_tmp->sml_nvalues[1].bv_val = NULL;
} else {
mod_tmp->sml_nvalues = NULL;
}
-#endif
mod_tmp->sml_op = LDAP_MOD_DELETE;
mod_tmp->sml_next = mod;
mod = mod_tmp;
}
done:
+
+ if ( !repl_user ) {
+ char textbuf[ SLAP_TEXT_BUFLEN ];
+ size_t textlen = sizeof textbuf;
+
+ for( modtail = &mod;
+ *modtail != NULL;
+ modtail = &(*modtail)->sml_next )
+ {
+ /* empty */
+ }
+
+ rs->sr_err = slap_mods_opattrs( op, mod, modtail, &rs->sr_text, textbuf, textlen );
+ }
+
/* LDAP v2 supporting correct attribute handling. */
if ( rs->sr_err != LDAP_SUCCESS && mod != NULL ) {
Modifications *tmp;