/* LDAP v2 supporting correct attribute handling. */
LDAPRDN new_rdn = NULL;
LDAPRDN old_rdn = NULL;
- int isroot = -1;
int rc_id = 0;
ID id = NOID;
- const char *text = NULL;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
/* Added to support newSuperior */
/* get entry with writer lock */
/* FIXME: dn2entry() should return non-glue entry */
if (( e == NULL ) || ( !manageDSAit && e && is_entry_glue( e ))) {
- BerVarray deref = NULL;
if ( matched != NULL ) {
rs->sr_matched = strdup( matched->e_dn );
rs->sr_ref = is_entry_referral( matched )
: NULL;
cache_return_entry_r( &li->li_cache, matched );
} else {
- if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
- syncinfo_t *si;
- LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
- struct berval tmpbv;
- ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
- ber_bvarray_add( &deref, &tmpbv );
- }
- } else {
- deref = default_referral;
- }
- rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
- LDAP_SCOPE_DEFAULT );
+ rs->sr_ref = referral_rewrite( default_referral, NULL,
+ &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
send_ldap_result( op, rs );
if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
- if ( deref != default_referral ) {
- ber_bvarray_free( deref );
- }
free( (char *)rs->sr_matched );
rs->sr_ref = NULL;
rs->sr_matched = NULL;
}
/* check entry for "entry" acl */
- if ( ! access_allowed( op, e,
- entry, NULL, ACL_WRITE, NULL ) )
+ if ( ! access_allowed( op, e, entry, NULL, ACL_WRITE, NULL ) )
{
Debug( LDAP_DEBUG_TRACE,
"<=- ldbm_back_modrdn: no write access to entry\n", 0,
goto return_results;
}
+ } else {
+ p = (Entry *)&slap_entry_root;
+ }
- /* check parent for "children" acl */
- if ( ! access_allowed( op, p,
- children, NULL, ACL_WRITE, NULL ) )
- {
- Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
- 0, 0 );
+ /* check parent for "children" acl */
+ rs->sr_err = access_allowed( op, p, children, NULL,
+ op->oq_modrdn.rs_newSup != NULL ?
+ ACL_WDEL : ACL_WRITE,
+ NULL );
- send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
- NULL );
- goto return_results;
- }
+ if ( BER_BVISEMPTY( &p_ndn ))
+ p = NULL;
- Debug( LDAP_DEBUG_TRACE,
- "ldbm_back_modrdn: wr to children of entry %s OK\n",
- p_ndn.bv_val, 0, 0 );
+ if ( !rs->sr_err )
+ {
+ Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
+ 0, 0 );
- if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
- p_dn = slap_empty_bv;
- } else {
- dnParent( &e->e_name, &p_dn );
- }
+ send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
+ NULL );
+ goto return_results;
+ }
- Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: parent dn=%s\n",
- p_dn.bv_val, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE,
+ "ldbm_back_modrdn: wr to children of entry %s OK\n",
+ p_ndn.bv_val, 0, 0 );
+ if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
+ p_dn = slap_empty_bv;
} else {
- /* no parent, must be root to modify rdn */
- isroot = be_isroot( op );
- if ( ! isroot ) {
- if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
- || be_shadow_update( op ) ) {
- int can_access;
- p = (Entry *)&slap_entry_root;
-
- can_access = access_allowed( op, p,
- children, NULL, ACL_WRITE, NULL );
- p = NULL;
-
- /* check parent for "children" acl */
- if ( ! can_access ) {
- Debug( LDAP_DEBUG_TRACE,
- "<=- ldbm_back_modrdn: no "
- "access to parent\n", 0, 0, 0 );
-
- send_ldap_error( op, rs,
- LDAP_INSUFFICIENT_ACCESS,
- NULL );
- goto return_results;
- }
-
- } else {
- Debug( LDAP_DEBUG_TRACE,
- "<=- ldbm_back_modrdn: no parent & "
- "not root\n", 0, 0, 0);
-
- send_ldap_error( op, rs,
- LDAP_INSUFFICIENT_ACCESS,
- NULL );
- goto return_results;
- }
- }
-
- Debug( LDAP_DEBUG_TRACE,
- "ldbm_back_modrdn: no parent, locked root\n",
- 0, 0, 0 );
+ dnParent( &e->e_name, &p_dn );
}
+ Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: parent dn=%s\n",
+ p_dn.bv_val, 0, 0 );
+
new_parent_dn = &p_dn; /* New Parent unless newSuperior given */
if ( op->oq_modrdn.rs_newSup != NULL ) {
"ldbm_back_modrdn: newSup(ndn=%s) not here!\n",
np_ndn->bv_val, 0, 0);
- send_ldap_error( op, rs, LDAP_OTHER,
+ send_ldap_error( op, rs, LDAP_NO_SUCH_OBJECT,
"newSuperior not found" );
goto return_results;
}
/* check newSuperior for "children" acl */
if ( !access_allowed( op, np, children, NULL,
- ACL_WRITE, NULL ) )
+ ACL_WADD, NULL ) )
{
Debug( LDAP_DEBUG_TRACE,
"ldbm_back_modrdn: no wr to newSup children\n",
}
} else {
-
- /* no parent, must be root to modify newSuperior */
- if ( isroot == -1 ) {
- isroot = be_isroot( op );
- }
-
- if ( ! isroot ) {
- if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
- || be_shadow_update( op ) ) {
- int can_access;
- np = (Entry *)&slap_entry_root;
-
- can_access = access_allowed( op, np,
- children, NULL, ACL_WRITE, NULL );
- np = NULL;
-
- /* check parent for "children" acl */
- if ( ! can_access ) {
- Debug( LDAP_DEBUG_TRACE,
- "<=- ldbm_back_modrdn: no "
- "access to new superior\n", 0, 0, 0 );
+ if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv )
+ || be_shadow_update( op ) ) {
+ int can_access;
+ np = (Entry *)&slap_entry_root;
+
+ can_access = access_allowed( op, np,
+ children, NULL, ACL_WADD, NULL );
+ np = NULL;
+
+ /* check parent for "children" acl */
+ if ( ! can_access ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<=- ldbm_back_modrdn: no "
+ "access to new superior\n", 0, 0, 0 );
send_ldap_error( op, rs,
LDAP_INSUFFICIENT_ACCESS,
goto return_results;
}
- } else {
- Debug( LDAP_DEBUG_TRACE,
- "<=- ldbm_back_modrdn: \"\" "
- "not allowed as new superior\n",
- 0, 0, 0);
-
- send_ldap_error( op, rs,
- LDAP_INSUFFICIENT_ACCESS,
- NULL );
- goto return_results;
- }
+ } else {
+ Debug( LDAP_DEBUG_TRACE,
+ "<=- ldbm_back_modrdn: \"\" "
+ "not allowed as new superior\n",
+ 0, 0, 0);
+
+ send_ldap_error( op, rs,
+ LDAP_INSUFFICIENT_ACCESS,
+ NULL );
+ goto return_results;
}
}
/* check for abandon */
if ( op->o_abandon ) {
+ rs->sr_err = SLAPD_ABANDON;
goto return_results;
}
/* check for abandon */
if ( op->o_abandon ) {
+ rs->sr_err = SLAPD_ABANDON;
goto return_results;
}
tmp = mod->sml_next;
free( mod );
}
- slap_mods_free( mod );
+ slap_mods_free( mod, 1 );
}
/* LDAP v3 Support */