/* modrdn.c - bdb backend modrdn routine */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
text = "internal error";
goto return_results;
}
+ ldap_pvt_thread_yield();
}
if( bdb->bi_txn ) {
if ( e == NULL ) {
char* matched_dn = NULL;
- struct berval** refs;
+ BerVarray refs;
if( matched != NULL ) {
matched_dn = strdup( matched->e_dn );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ ber_bvarray_free( refs );
free( matched_dn );
goto done;
if (!manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BerVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ ber_bvarray_free( refs );
goto done;
}
- p_ndn.bv_val = dn_parent( be, e->e_ndn );
- if (p_ndn.bv_val && *p_ndn.bv_val)
- p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_ndn);
- else
+ if ( be_issuffix( be, e->e_nname.bv_val ) ) {
p_ndn.bv_len = 0;
+ p_ndn.bv_val = "";
+ } else {
+ rc = dnParent( e->e_nname.bv_val, (const char **)&p_ndn.bv_val );
+ if ( rc != LDAP_SUCCESS ) {
+ text = "internal error";
+ goto return_results;
+ }
+ p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_nname.bv_val);
+ }
np_ndn = &p_ndn;
if ( p_ndn.bv_len != 0 ) {
/* Make sure parent entry exist and we can write its
"bdb_modrdn: wr to children of entry %s OK\n",
p_ndn.bv_val, 0, 0 );
- p_dn.bv_val = dn_parent( be, e->e_dn );
- if (p_dn.bv_val && *p_dn.bv_val)
- p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_dn);
- else
+ if ( be_issuffix( be, e->e_name.bv_val ) ) {
p_dn.bv_len = 0;
+ p_dn.bv_val = "";
+ } else {
+ rc = dnParent( e->e_name.bv_val, &p_dn.bv_val );
+ if ( rc != LDAP_SUCCESS ) {
+ text = "internal error";
+ goto return_results;
+ }
+ p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_name.bv_val);
+ }
Debug( LDAP_DEBUG_TRACE,
"bdb_modrdn: parent dn=%s\n",
/* Get attribute type and attribute value of our new rdn, we will
* need to add that to our new entry
*/
- if ( ldap_str2rdn( newrdn->bv_val, &new_rdn, &text, LDAP_DN_FORMAT_LDAP ) ) {
+ if ( ldap_str2rdn( newrdn->bv_val, &new_rdn, (char **)&text,
+ LDAP_DN_FORMAT_LDAP ) )
+ {
Debug( LDAP_DEBUG_TRACE,
"bdb_modrdn: can't figure out type(s)/values(s) "
"of newrdn\n", 0, 0, 0 );
"bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
new_rdn[0][0]->la_attr.bv_val, new_rdn[0][0]->la_value.bv_val, 0 );
- if ( ldap_str2rdn( dn->bv_val, &old_rdn, &text, LDAP_DN_FORMAT_LDAP ) ) {
+ if ( ldap_str2rdn( dn->bv_val, &old_rdn, (char **)&text,
+ LDAP_DN_FORMAT_LDAP ) )
+ {
Debug( LDAP_DEBUG_TRACE,
"bdb_back_modrdn: can't figure out the old_rdn "
"type(s)/value(s)\n", 0, 0, 0 );
/* Apply modification */
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof( struct berval * ) );
+ + 2 * sizeof( struct berval ) );
mod_tmp->sml_desc = desc;
- mod_tmp->sml_bvalues = ( struct berval ** )( mod_tmp + 1 );
- mod_tmp->sml_bvalues[ 0 ] = &new_rdn[0][ a_cnt ]->la_value;
- mod_tmp->sml_bvalues[ 1 ] = NULL;
+ mod_tmp->sml_bvalues = ( BerVarray )( mod_tmp + 1 );
+ mod_tmp->sml_bvalues[ 0 ] = new_rdn[0][ a_cnt ]->la_value;
+ mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
mod_tmp->sml_op = SLAP_MOD_SOFTADD;
mod_tmp->sml_next = mod;
mod = mod_tmp;
/* Apply modification */
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof ( struct berval * ) );
+ + 2 * sizeof ( struct berval ) );
mod_tmp->sml_desc = desc;
- mod_tmp->sml_bvalues = ( struct berval ** )(mod_tmp+1);
- mod_tmp->sml_bvalues[ 0 ] = &old_rdn[0][ d_cnt ]->la_value;
- mod_tmp->sml_bvalues[ 1 ] = NULL;
+ mod_tmp->sml_bvalues = ( BerVarray )(mod_tmp+1);
+ mod_tmp->sml_bvalues[ 0 ] = old_rdn[0][ d_cnt ]->la_value;
+ mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
mod_tmp->sml_op = LDAP_MOD_DELETE;
mod_tmp->sml_next = mod;
mod = mod_tmp;