Entry *e, *p = NULL;
Entry *matched;
int isroot = -1;
- int rootlock = 0;
#define CAN_ROLLBACK -1
#define MUST_DESTROY 1
int rc = CAN_ROLLBACK;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
/* Added to support LDAP v2 correctly (deleteoldrdn thing) */
- LDAPRDN *new_rdn;
- LDAPRDN *old_rdn;
+ LDAPRDN *new_rdn = NULL;
+ LDAPRDN *old_rdn = NULL;
int a_cnt, d_cnt;
/* Added to support newSuperior */
Entry *np = NULL; /* newSuperior Entry */
? newSuperior->bv_val : "NULL", 0 );
#endif
+ /* grab giant lock for writing */
+ ldap_pvt_thread_rdwr_wlock(&li->li_giant_rwlock);
+
/* get entry with writer lock */
if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char* matched_dn = NULL;
NULL, dn, LDAP_SCOPE_DEFAULT );
}
+ ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
+
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
goto return_results;
}
- p_ndn.bv_val = dn_parent( be, e->e_ndn );
- if ( p_ndn.bv_val )
- p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_ndn);
- else
- p_ndn.bv_len = 0;
+ if ( be_issuffix( be, &e->e_nname ) ) {
+ p_ndn = slap_empty_bv ;
+ } else {
+ dnParent( &e->e_nname, &p_ndn );
+ }
if ( p_ndn.bv_len != 0 ) {
/* Make sure parent entry exist and we can write its
/* check parent for "children" acl */
if ( ! access_allowed( be, conn, op, p,
- children, NULL, ACL_WRITE ) )
+ children, NULL, ACL_WRITE, NULL ) )
{
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
p_ndn.bv_val, 0, 0 );
#endif
- p_dn.bv_val = dn_parent( be, e->e_dn );
- if ( p_dn.bv_val )
- p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_dn);
- else
- p_dn.bv_len = 0;
+ if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
+ p_dn = slap_empty_bv;
+ } else {
+ dnParent( &e->e_name, &p_dn );
+ }
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
/* no parent, must be root to modify rdn */
isroot = be_isroot( be, &op->o_ndn );
if ( ! isroot ) {
- if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
+ if ( be_issuffix( be, (struct berval *)&slap_empty_bv ) || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
rc = access_allowed( be, conn, op, p,
- children, NULL, ACL_WRITE );
+ children, NULL, ACL_WRITE, NULL );
p = NULL;
/* check parent for "children" acl */
}
}
- ldap_pvt_thread_mutex_lock(&li->li_root_mutex);
- rootlock = 1;
-
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_modrdn: (%s) no parent, locked root.\n", e->e_dn ));
/* check newSuperior for "children" acl */
if ( !access_allowed( be, conn, op, np, children, NULL,
- ACL_WRITE ) )
+ ACL_WRITE, NULL ) )
{
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
}
if ( ! isroot ) {
- if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
+ if ( be_issuffix( be, (struct berval *)&slap_empty_bv ) || be_isupdate( be, &op->o_ndn ) ) {
np = (Entry *)&slap_entry_root;
rc = access_allowed( be, conn, op, np,
- children, NULL, ACL_WRITE );
+ children, NULL, ACL_WRITE, NULL );
np = NULL;
/* check parent for "children" acl */
#endif
/* check for abandon */
- ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
if ( op->o_abandon ) {
- ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
goto return_results;
}
- ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
if ( ( rc_id = dn2id ( be, &new_ndn, &id ) ) || id != NOID ) {
/* if (rc_id) something bad happened to ldbm cache */
send_ldap_result( conn, op,
/* Get attribute types and values of our new rdn, we will
* need to add that to our new entry
*/
- if ( ldap_str2rdn( newrdn->bv_val, &new_rdn, (char **)&text,
+ if ( ldap_bv2rdn( newrdn, &new_rdn, (char **)&text,
LDAP_DN_FORMAT_LDAP ) )
{
#ifdef NEW_LOGGING
#endif
/* Retrieve the old rdn from the entry's dn */
- if ( ldap_str2rdn( dn->bv_val, &old_rdn, (char **)&text,
+ if ( ldap_bv2rdn( dn, &old_rdn, (char **)&text,
LDAP_DN_FORMAT_LDAP ) )
{
#ifdef NEW_LOGGING
}
if ( ! access_allowed( be, conn, op, e,
- desc, &new_rdn[0][a_cnt]->la_value, ACL_WRITE ) ) {
+ desc, &new_rdn[0][a_cnt]->la_value, ACL_WRITE, NULL ) ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_modrdn: access "
}
if ( ! access_allowed( be, conn, op, e,
- desc, &old_rdn[0][d_cnt]->la_value, ACL_WRITE ) ) {
+ desc, &old_rdn[0][d_cnt]->la_value, ACL_WRITE, NULL ) ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_modrdn: access "
/* check for abandon */
- ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
if ( op->o_abandon ) {
- ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
goto return_results;
}
- ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
/* delete old one */
if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) {
cache_return_entry_w( &li->li_cache, p );
}
- if ( rootlock ) {
- /* release root writer lock */
- ldap_pvt_thread_mutex_unlock(&li->li_root_mutex);
- }
-
/* free entry and writer lock */
cache_return_entry_w( &li->li_cache, e );
if ( rc == MUST_DESTROY ) {
* the entry must be freed */
entry_free( e );
}
+ ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
return( rc );
}