]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/modrdn.c
Plug memory leak
[openldap] / servers / slapd / back-ldbm / modrdn.c
index 5a6229f1bf7e46ddf2a03cd3bf6b15e9c7fa3a80..c8ef1e5446379e24ead8ebfcf2f54773354fcc16 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -52,7 +52,6 @@ ldbm_back_modrdn(
        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 */ 
@@ -77,7 +76,6 @@ ldbm_back_modrdn(
        /* 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 )
@@ -85,18 +83,8 @@ ldbm_back_modrdn(
                                : 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);
@@ -105,9 +93,6 @@ ldbm_back_modrdn(
                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;
@@ -115,8 +100,7 @@ ldbm_back_modrdn(
        }
 
        /* 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,
@@ -177,8 +161,10 @@ ldbm_back_modrdn(
                }
 
                /* check parent for "children" acl */
-               if ( ! access_allowed( op, p,
-                       children, NULL, ACL_WRITE, NULL ) )
+               if ( ! access_allowed( op, p, children, NULL,
+                               op->oq_modrdn.rs_newSup != NULL ?
+                                       ACL_WDEL : ACL_WRITE,
+                               NULL ) )
                {
                        Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
                                0, 0 );
@@ -211,7 +197,10 @@ ldbm_back_modrdn(
                                p = (Entry *)&slap_entry_root;
                                
                                can_access = access_allowed( op, p,
-                                               children, NULL, ACL_WRITE, NULL );
+                                               children, NULL,
+                                               op->oq_modrdn.rs_newSup ?
+                                                       ACL_WDEL : ACL_WRITE,
+                                               NULL );
                                p = NULL;
                                                                
                                /* check parent for "children" acl */
@@ -284,7 +273,7 @@ ldbm_back_modrdn(
 
                        /* 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",
@@ -330,7 +319,7 @@ ldbm_back_modrdn(
                                        np = (Entry *)&slap_entry_root;
                                
                                        can_access = access_allowed( op, np,
-                                                       children, NULL, ACL_WRITE, NULL );
+                                                       children, NULL, ACL_WADD, NULL );
                                        np = NULL;
                                                                
                                        /* check parent for "children" acl */
@@ -375,6 +364,7 @@ ldbm_back_modrdn(
 
        /* check for abandon */
        if ( op->o_abandon ) {
+               rs->sr_err = SLAPD_ABANDON;
                goto return_results;
        }
 
@@ -434,6 +424,7 @@ ldbm_back_modrdn(
 
        /* check for abandon */
        if ( op->o_abandon ) {
+               rs->sr_err = SLAPD_ABANDON;
                goto return_results;
        }
 
@@ -538,7 +529,7 @@ return_results:
                        tmp = mod->sml_next;
                        free( mod );
                }
-               slap_mods_free( mod );
+               slap_mods_free( mod, 1 );
        }
 
        /* LDAP v3 Support */