]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/tools.c
normalize authcDN (ITS#3246); don't touch databases when running slapadd in dryryn...
[openldap] / servers / slapd / back-bdb / tools.c
index e73f7c70db73b1159c57cd4a5e2e6c4d0c18a675..6484e4db9e285d61ef2add639e2525312771b916 100644 (file)
@@ -204,20 +204,25 @@ static int bdb_tool_next_id(
        int hole )
 {
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
-       struct berval dn = e->e_nname;
-       struct berval pdn;
+       struct berval dn = e->e_name;
+       struct berval ndn = e->e_nname;
+       struct berval pdn, npdn;
        EntryInfo *ei = NULL;
        int rc;
 
-       rc = bdb_cache_find_ndn( op, tid, &dn, &ei );
+       if (ndn.bv_len == 0) return 0;
+
+       rc = bdb_cache_find_ndn( op, tid, &ndn, &ei );
        if ( ei ) bdb_cache_entryinfo_unlock( ei );
        if ( rc == DB_NOTFOUND ) {
-               if ( be_issuffix( op->o_bd, &dn ) ) {
-                       pdn = slap_empty_bv;
-               } else {
+               if ( !be_issuffix( op->o_bd, &ndn ) ) {
                        dnParent( &dn, &pdn );
-                       e->e_nname = pdn;
+                       dnParent( &ndn, &npdn );
+                       e->e_name = pdn;
+                       e->e_nname = npdn;
                        rc = bdb_tool_next_id( op, tid, e, text, 1 );
+                       e->e_name = dn;
+                       e->e_nname = ndn;
                        if ( rc ) {
                                return rc;
                        }
@@ -236,7 +241,6 @@ static int bdb_tool_next_id(
 #endif
                        return rc;
                }
-               e->e_nname = dn;
                rc = bdb_dn2id_add( op, tid, ei, e );
                if ( rc ) {
                        snprintf( text->bv_val, text->bv_len, 
@@ -252,21 +256,20 @@ static int bdb_tool_next_id(
                } else if ( hole ) {
                        if ( nholes == nhmax - 1 ) {
                                if ( holes == hbuf ) {
-                                       holes = ch_malloc( nhmax * sizeof(ID) * 2 );
+                                       holes = ch_malloc( nhmax * sizeof(dn_id) * 2 );
                                        AC_MEMCPY( holes, hbuf, sizeof(hbuf) );
                                } else {
-                                       holes = ch_realloc( holes, nhmax * sizeof(ID) * 2 );
+                                       holes = ch_realloc( holes, nhmax * sizeof(dn_id) * 2 );
                                }
                                nhmax *= 2;
                        }
-                       ber_dupbv( &holes[nholes].dn, &dn );
+                       ber_dupbv( &holes[nholes].dn, &ndn );
                        holes[nholes++].id = e->e_id;
                }
        } else if ( !hole ) {
                unsigned i;
 
                e->e_id = ei->bei_id;
-               rc = DB_KEYEXIST;
 
                for ( i=0; i<nholes; i++) {
                        if ( holes[i].id == e->e_id ) {
@@ -275,7 +278,6 @@ static int bdb_tool_next_id(
                                for (j=i;j<nholes;j++) holes[j] = holes[j+1];
                                holes[j].id = 0;
                                nholes--;
-                               rc = 0;
                                break;
                        } else if ( holes[i].id > e->e_id ) {
                                break;