]> git.sur5r.net Git - openldap/commitdiff
+ Fixed back-ldbm IDL delete bug (ITS#3042)
authorKurt Zeilenga <kurt@openldap.org>
Tue, 6 Apr 2004 22:29:13 +0000 (22:29 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 6 Apr 2004 22:29:13 +0000 (22:29 +0000)
+       Fixed back-ldbm modrdn indexing bug (ITS#3059)

CHANGES
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/modrdn.c

diff --git a/CHANGES b/CHANGES
index dc9fbcf66102c6cad53f4871a0de2e8b448711d0..5aec83a9c0c4a0893abefe3301506b986265b79b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,13 +6,13 @@ OpenLDAP 2.2.9 Engineering
        Fixed slapd inappropriate bind error disclosure bugs
        Fixed slapd sun_path portability bug
        Fixed slapd passwd referral memory leak
-       Fixed slapd sasl userdb checkpass bug
-       Fixed ldapmodify missing error information bug (ITS#3057)
+       Fixed slapd sasl userdb checkpass bug (ITS#3048)
        Fixed back-meta compare return code (ITS#3042)
-       Added slapd Delivery Method syntax validation
+       Fixed back-ldbm IDL delete bug (ITS#3042)
+       Fixed back-ldbm modrdn indexing bug (ITS#3059)
+       Fixed ldapmodify missing error information bug (ITS#3057)
+       Added slapd Delivery Method syntax validation (ITS#3052)
        Updated slapd overlay framework
-       Updated back-ldap backend
-       Updated back-meta backend
        Build Environment
                Fixed slapd dynamic backend build (ITS#3044)
                Removed deprecated configure options
index d592732e48651f5351df5c9f3f513034dd39a3e5..f19ece31d0c38743b405cf7c3c79334b4d21fe4d 100644 (file)
@@ -952,13 +952,16 @@ idl_delete_key (
           */
        cont_alloc( &data, &key );
 #ifndef USE_INDIRECT_NIDS
-       for ( nids = 0; !ID_BLOCK_NOID(idl, nids); nids++ )
-               ;       /* NULL */
+       for ( nids = 0; !ID_BLOCK_NOID(idl, nids); nids++ ) {
+               ;       /* Empty */
+       }
 
        for ( j = 0; j<nids; j++ ) 
 #else
        nids = ID_BLOCK_NIDS(idl);
-       for ( j = idl_find(idl, id); j >= 0; j = -1)    /* execute once */
+       j = idl_find(idl, id);
+       if ( ID_BLOCK_ID(idl, j) > id ) j--;
+       for (; j>=0; j = -1 ) /* execute once */
 #endif
        {
                ID_BLOCK *tmp;
index 11085b853547f5c4eaf9d14d38025bff88b640dd..9a404409cad16ca88972cfeee34914c4032cd7d0 100644 (file)
@@ -614,28 +614,46 @@ ldbm_back_modrdn(
                goto return_results;
        }
        
-       /* add new one */
-       if ( dn2id_add( op->o_bd, &e->e_nname, e->e_id ) != 0 ) {
-               send_ldap_error( op, rs, LDAP_OTHER,
-                       "DN index add failed" );
-               goto return_results;
-       }
+       /*
+        * NOTE: the backend MUST delete then add the entry,
+        *              otherwise indexing may get hosed
+        * FIXME: if a new ID was used, the add could be done first.
+        *              that would be safer.
+        */
+
        /* delete old one */
        if ( dn2id_delete( op->o_bd, &old_ndn, e->e_id ) != 0 ) {
-               /* undo add of new one */
-               dn2id_delete( op->o_bd, &e->e_nname, e->e_id );
                send_ldap_error( op, rs, LDAP_OTHER,
                        "DN index delete fail" );
                goto return_results;
        }
 
+       /* add new one */
+       if ( dn2id_add( op->o_bd, &e->e_nname, e->e_id ) != 0 ) {
+               /* try to repair old entry - probably hopeless */
+        if( dn2id_add( op->o_bd, &old_ndn, e->e_id) != 0 ) {
+                       send_ldap_error( op, rs, LDAP_OTHER,
+                               "DN index add and repair failed" );
+               } else {
+                       send_ldap_error( op, rs, LDAP_OTHER,
+                               "DN index add failed" );
+               }
+               goto return_results;
+       }
+
        /* id2entry index */
        if ( id2entry_add( op->o_bd, e ) != 0 ) {
                /* Try to undo */
-               dn2id_delete( op->o_bd, &e->e_nname, e->e_id );
-               dn2id_add( op->o_bd, &old_ndn, e->e_id );
-               send_ldap_error( op, rs, LDAP_OTHER,
-                       "entry update failed" );
+               int rc;
+               rc = dn2id_delete( op->o_bd, &e->e_nname, e->e_id );
+               rc |= dn2id_add( op->o_bd, &old_ndn, e->e_id );
+               if( rc ) {
+                       send_ldap_error( op, rs, LDAP_OTHER,
+                               "entry update and repair failed" );
+               } else {
+                       send_ldap_error( op, rs, LDAP_OTHER,
+                               "entry update failed" );
+               }
                goto return_results;
        }