]> git.sur5r.net Git - openldap/commitdiff
Fix slapd directoryString exact index normalization bug
authorKurt Zeilenga <kurt@openldap.org>
Wed, 26 Feb 2003 16:17:49 +0000 (16:17 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 26 Feb 2003 16:17:49 +0000 (16:17 +0000)
    Fix back-bdb bdb_cache_find_entry* retry bug
    Fix back-bdb log message bug
    Fix back-bdb group/atttribute txn code
    Updated slapadd to complain about holes in the DIT

20 files changed:
CHANGES
servers/slapd/ad.c
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/attribute.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/group.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/operational.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-bdb/search.c
servers/slapd/back-bdb/tools.c
servers/slapd/entry.c
servers/slapd/schema_init.c
servers/slapd/schema_prep.c
servers/slapd/slapd.conf
servers/slapd/tools/slapadd.c

diff --git a/CHANGES b/CHANGES
index 99baba13bbe801e9040c465a2125f1941d26fe8b..275cacdac43cb017698830372d1783d17609d9f7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,14 @@
 OpenLDAP 2.1 Change Log
 
+OpenLDAP 2.1.14 Engineering
+       Fix slapd directoryString exact index normalization bug
+       Fix back-bdb bdb_cache_find_entry* retry bug
+       Fix back-bdb log message bug
+       Fix back-bdb group/atttribute txn code
+       Updated slapadd to complain about holes in the DIT
+       Documentation
+               Misc man page updates
+
 OpenLDAP 2.1.13 Release
        Fixed back-bdb group ACL deadlock bug (ITS#2195)
        Fixed back-bdb passwd hang bug (ITS#2122)
@@ -29,8 +38,9 @@ OpenLDAP 2.1.13 Release
        Build Environment
                Check back-bdb requirement for BDB 4.1
                Removed configure flags for deprecated features
-               Misc man page updates
                Updated test suite
+       Documentation
+               Misc man page updates
 
 OpenLDAP 2.1.12 Release
        Build Environment
index ece6019282ac7133ec0137000b55dca02328519c..4ed522cd2cb76fb813d0dc31f006985703ef50b4 100644 (file)
@@ -325,6 +325,7 @@ done:;
                }
 
                d2 = ch_malloc(sizeof(AttributeDescription) + dlen);
+               d2->ad_next = NULL;
                d2->ad_type = desc.ad_type;
                d2->ad_flags = desc.ad_flags;
                d2->ad_cname.bv_len = desc.ad_type->sat_cname.bv_len;
index 3e85b1a7ad04343114f135f79f7bdbb99f916e54..b7c47dadb42f9f3fdd4b7d455f564b87df69e163 100644 (file)
@@ -99,6 +99,7 @@ retry:        /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -134,6 +135,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
        
        /*
@@ -216,13 +218,13 @@ retry:    /* transaction retry */
                rc = access_allowed( be, conn, op, p,
                        children, NULL, ACL_WRITE, NULL );
 
-               switch( opinfo.boi_err ) {
-               case DB_LOCK_DEADLOCK:
-               case DB_LOCK_NOTGRANTED:
-                       goto retry;
-               }
-
                if ( ! rc ) {
+                       switch( opinfo.boi_err ) {
+                       case DB_LOCK_DEADLOCK:
+                       case DB_LOCK_NOTGRANTED:
+                               goto retry;
+                       }
+
 #ifdef NEW_LOGGING
                        LDAP_LOG ( OPERATION, DETAIL1, 
                                "bdb_add: no write access to parent\n", 0, 0, 0 );
@@ -316,13 +318,13 @@ retry:    /* transaction retry */
 
                                p = NULL;
 
-                               switch( opinfo.boi_err ) {
-                               case DB_LOCK_DEADLOCK:
-                               case DB_LOCK_NOTGRANTED:
-                                       goto retry;
-                               }
-
                                if ( ! rc ) {
+                                       switch( opinfo.boi_err ) {
+                                       case DB_LOCK_DEADLOCK:
+                                       case DB_LOCK_NOTGRANTED:
+                                               goto retry;
+                                       }
+
 #ifdef NEW_LOGGING
                                        LDAP_LOG ( OPERATION, DETAIL1, 
                                                "bdb_add: no write access to parent\n", 0, 0, 0 );
@@ -379,13 +381,13 @@ retry:    /* transaction retry */
        rc = access_allowed( be, conn, op, e,
                entry, NULL, ACL_WRITE, NULL );
 
-       switch( opinfo.boi_err ) {
-       case DB_LOCK_DEADLOCK:
-       case DB_LOCK_NOTGRANTED:
-               goto retry;
-       }
-
        if ( ! rc ) {
+               switch( opinfo.boi_err ) {
+               case DB_LOCK_DEADLOCK:
+               case DB_LOCK_NOTGRANTED:
+                       goto retry;
+               }
+
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, DETAIL1, 
                        "bdb_add: no write access to entry\n", 0, 0, 0 );
index 10ef737faecd7d5edd2b73b915d41bb07e395e47..f5cbdf7577a693ecd4900d8ec6fd8c3332e6c71b 100644 (file)
@@ -97,13 +97,19 @@ bdb_attribute(
        } else {
 dn2entry_retry:
                /* can we find entry */
-               rc = bdb_dn2entry_r( be, NULL, entry_ndn, &e, NULL, 0, locker, &lock );
+               rc = bdb_dn2entry_r( be, txn, entry_ndn, &e, NULL, 0, locker, &lock );
                switch( rc ) {
                case DB_NOTFOUND:
                case 0:
                        break;
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
+                       /* the txn must abort and retry */
+                       if ( txn ) {
+                               boi->boi_err = rc;
+                               return LDAP_BUSY;
+                       }
+                       ldap_pvt_thread_yield();
                        goto dn2entry_retry;
                default:
                        boi->boi_err = rc;
index 5a28d25581beda00a009eaa534f845a1a21a0ffd..449d0f6d7339be00c4ffe52f27d155ff9349147c 100644 (file)
@@ -157,6 +157,7 @@ struct bdb_op_info {
        DB_TXN*         boi_txn;
        u_int32_t       boi_err;
        u_int32_t       boi_locker;
+       int             boi_acl_cache;
 };
 
 #define        DB_OPEN(db, file, name, type, flags, mode) \
index ad98106a69783ffd9ccbc5fc6f31b6d745e908b0..ef753b29e1c93a187937ac76edeeb96457f7b911 100644 (file)
@@ -794,7 +794,7 @@ try_again:
                /*
                 * entry is deleted or not fully created yet
                 */
-               if ( state != CACHE_ENTRY_READY ) {
+               if ( state != CACHE_ENTRY_READY && state != CACHE_ENTRY_COMMITTED ) {
                        assert(state != CACHE_ENTRY_UNDEFINED);
 
                        /* free cache read lock */
@@ -889,7 +889,7 @@ try_again:
                /*
                 * entry is deleted or not fully created yet
                 */
-               if ( state != CACHE_ENTRY_READY ) {
+               if ( state != CACHE_ENTRY_READY && state != CACHE_ENTRY_COMMITTED ) {
 
                        assert(state != CACHE_ENTRY_UNDEFINED);
 
index 79cb4608439ce6c7225257a4978302f433f978dd..079b44081ca4e2b3155167a3924e99be92b35422 100644 (file)
@@ -70,6 +70,7 @@ retry:        /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -106,6 +107,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        if ( !be_issuffix( be, ndn ) ) {
@@ -162,13 +164,13 @@ retry:    /* transaction retry */
                bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p);
                p = NULL;
 
-               switch( opinfo.boi_err ) {
-               case DB_LOCK_DEADLOCK:
-               case DB_LOCK_NOTGRANTED:
-                       goto retry;
-               }
-
                if ( !rc  ) {
+                       switch( opinfo.boi_err ) {
+                       case DB_LOCK_DEADLOCK:
+                       case DB_LOCK_NOTGRANTED:
+                               goto retry;
+                       }
+
 #ifdef NEW_LOGGING
                        LDAP_LOG ( OPERATION, DETAIL1, 
                                "<=- bdb_delete: no write access to parent\n", 0, 0, 0 );
@@ -195,13 +197,13 @@ retry:    /* transaction retry */
 
                                p = NULL;
 
-                               switch( opinfo.boi_err ) {
-                               case DB_LOCK_DEADLOCK:
-                               case DB_LOCK_NOTGRANTED:
-                                       goto retry;
-                               }
-
                                if ( !rc  ) {
+                                       switch( opinfo.boi_err ) {
+                                       case DB_LOCK_DEADLOCK:
+                                       case DB_LOCK_NOTGRANTED:
+                                               goto retry;
+                                       }
+
 #ifdef NEW_LOGGING
                                        LDAP_LOG ( OPERATION, DETAIL1, 
                                                "<=- bdb_delete: no access to parent\n", 0, 0, 0 );
@@ -298,13 +300,13 @@ retry:    /* transaction retry */
        rc = access_allowed( be, conn, op, e,
                entry, NULL, ACL_WRITE, NULL );
 
-       switch( opinfo.boi_err ) {
-       case DB_LOCK_DEADLOCK:
-       case DB_LOCK_NOTGRANTED:
-               goto retry;
-       }
-
        if ( !rc  ) {
+               switch( opinfo.boi_err ) {
+               case DB_LOCK_DEADLOCK:
+               case DB_LOCK_NOTGRANTED:
+                       goto retry;
+               }
+
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, DETAIL1, 
                        "<=- bdb_delete: no write access to entry\n", 0, 0, 0 );
index d449056794b7b56cd6f8896e923afbeb48265f28..ddb23f705586fb755f80eac441a5cf4fa7fa022e 100644 (file)
@@ -107,11 +107,21 @@ bdb_group(
        } else {
 dn2entry_retry:
                /* can we find group entry */
-               rc = bdb_dn2entry_r( be, NULL, gr_ndn, &e, NULL, 0, locker, &lock ); 
+               rc = bdb_dn2entry_r( be, txn, gr_ndn, &e, NULL, 0, locker, &lock ); 
                if( rc ) {
-                       if ( rc == DB_LOCK_DEADLOCK || rc == DB_LOCK_NOTGRANTED )
-                               goto dn2entry_retry;
                        boi->boi_err = rc;
+                       if ( rc == DB_LOCK_DEADLOCK || rc == DB_LOCK_NOTGRANTED ) {
+                               if ( txn ) {
+                               /* must let owning txn abort, but our result
+                                * is still inconclusive, so don't let it
+                                * get cached.
+                                */
+                                       op->o_do_not_cache = 1;
+                                       return( 1 );
+                               }
+                               ldap_pvt_thread_yield();
+                               goto dn2entry_retry;
+                       }
                        if ( free_lock_id ) {
                                LOCK_ID_FREE ( bdb->bi_dbenv, locker );
                        }
@@ -206,8 +216,10 @@ dn2entry_retry:
                group_oc_name, group_at_name, 0 ); 
 #endif
 
-       if( value_find_ex( group_at, SLAP_MR_VALUE_NORMALIZED_MATCH,
-               attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
+       if( value_find_ex( group_at,
+               SLAP_MR_VALUE_NORMALIZED_MATCH,
+               attr->a_vals, op_ndn ) != LDAP_SUCCESS )
+       {
 #ifdef NEW_LOGGING
                LDAP_LOG( BACK_BDB, DETAIL1, 
                        "bdb_group: \"%s\" not in \"%s\": %s\n",
index 5e4ef60df488d9d6ac345c49336b95af563828fa..87260b65d818f984c3e343a103f7bc27d2060091 100644 (file)
@@ -204,6 +204,18 @@ int bdb_entry_return(
        if( (void *) e->e_attrs != (void *) (e+1)) {
                attrs_free( e->e_attrs );
        }
+#ifdef SLAP_NVALUES
+       else {
+               /* nvals are not contiguous with the rest. oh well. */
+               Attribute *a;
+               for (a = e->e_attrs; a; a=a->a_next) {
+                       if (a->a_nvals) {
+                               ber_bvarray_free( a->a_nvals );
+                               a->a_nvals = NULL;
+                       }
+               }
+       }
+#endif
 
 #ifndef BDB_HIER
        /* See if the DNs were changed by modrdn */
index b2ffc7a178f25c28907fba17d1d939e3349d4eb2..167938a9605af9f4c25798b9987c15019d418759 100644 (file)
@@ -210,7 +210,7 @@ int bdb_modify_internal(
        for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
                if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
                        rc = bdb_index_values( be, tid, ap->a_desc, ap->a_vals,
-                                              e->e_id, SLAP_INDEX_DELETE_OP );
+                               e->e_id, SLAP_INDEX_DELETE_OP );
                        if ( rc != LDAP_SUCCESS ) {
                                attrs_free( e->e_attrs );
                                e->e_attrs = save_attrs;
@@ -233,7 +233,7 @@ int bdb_modify_internal(
        for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) {
                if (ap->a_flags & SLAP_ATTR_IXADD) {
                        rc = bdb_index_values( be, tid, ap->a_desc, ap->a_vals,
-                                              e->e_id, SLAP_INDEX_ADD_OP );
+                               e->e_id, SLAP_INDEX_ADD_OP );
                        if ( rc != LDAP_SUCCESS ) {
                                attrs_free( e->e_attrs );
                                e->e_attrs = save_attrs;
@@ -319,6 +319,7 @@ retry:      /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -351,6 +352,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        /* get entry */
@@ -449,6 +451,9 @@ retry:      /* transaction retry */
                        "bdb_modify: modify failed (%d)\n",
                        rc, 0, 0 );
 #endif
+               if ( (rc == LDAP_INSUFFICIENT_ACCESS) && opinfo.boi_err ) {
+                       rc = opinfo.boi_err;
+               }
                switch( rc ) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
index 8fcba26ffd4b93f4c424d95b7229961761aa65d5..783bd70fc59e7740069cf977241549cd67486534 100644 (file)
@@ -108,6 +108,7 @@ retry:      /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        text = "internal error";
@@ -141,6 +142,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        /* get entry */
@@ -191,13 +193,13 @@ retry:    /* transaction retry */
        /* check write on old entry */
        rc = access_allowed( be, conn, op, e, entry, NULL, ACL_WRITE, NULL );
 
-       switch( opinfo.boi_err ) {
-       case DB_LOCK_DEADLOCK:
-       case DB_LOCK_NOTGRANTED:
-               goto retry;
-       }
-
        if ( ! rc ) {
+               switch( opinfo.boi_err ) {
+               case DB_LOCK_DEADLOCK:
+               case DB_LOCK_NOTGRANTED:
+                       goto retry;
+               }
+
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, ERR, 
                        "==>bdb_modrdn: no access to entry\n", 0, 0, 0 );
@@ -277,6 +279,12 @@ retry:     /* transaction retry */
                        children, NULL, ACL_WRITE, NULL );
 
                if ( ! rc ) {
+                       switch( opinfo.boi_err ) {
+                       case DB_LOCK_DEADLOCK:
+                       case DB_LOCK_NOTGRANTED:
+                               goto retry;
+                       }
+
                        rc = LDAP_INSUFFICIENT_ACCESS;
 #ifdef NEW_LOGGING
                        LDAP_LOG ( OPERATION, ERR, 
@@ -329,6 +337,12 @@ retry:     /* transaction retry */
                                p = NULL;
 
                                if ( ! rc ) {
+                                       switch( opinfo.boi_err ) {
+                                       case DB_LOCK_DEADLOCK:
+                                       case DB_LOCK_NOTGRANTED:
+                                               goto retry;
+                                       }
+
                                        rc = LDAP_INSUFFICIENT_ACCESS;
 #ifdef NEW_LOGGING
                                        LDAP_LOG ( OPERATION, ERR, 
@@ -468,6 +482,12 @@ retry:     /* transaction retry */
                                NULL, ACL_WRITE, NULL );
 
                        if( ! rc ) {
+                               switch( opinfo.boi_err ) {
+                               case DB_LOCK_DEADLOCK:
+                               case DB_LOCK_NOTGRANTED:
+                                       goto retry;
+                               }
+
 #ifdef NEW_LOGGING
                                LDAP_LOG ( OPERATION, DETAIL1, 
                                        "==>bdb_modrdn: no wr to newSup children\n", 0, 0, 0 );
@@ -531,6 +551,12 @@ retry:     /* transaction retry */
                                        np = NULL;
 
                                        if ( ! rc ) {
+                                               switch( opinfo.boi_err ) {
+                                               case DB_LOCK_DEADLOCK:
+                                               case DB_LOCK_NOTGRANTED:
+                                                       goto retry;
+                                               }
+
                                                rc = LDAP_INSUFFICIENT_ACCESS;
 #ifdef NEW_LOGGING
                                                LDAP_LOG ( OPERATION, ERR, 
@@ -621,15 +647,6 @@ retry:     /* transaction retry */
                goto return_results;
        }
 
-#ifdef NEW_LOGGING
-       LDAP_LOG ( OPERATION, ERR, 
-               "bdb_modrdn: new ndn=%s does not exist\n", new_ndn.bv_val, 0, 0 );
-#else
-       Debug( LDAP_DEBUG_TRACE,
-               "bdb_modrdn: new ndn=%s does not exist\n",
-               new_ndn.bv_val, 0, 0 );
-#endif
-
        /* Get attribute type and attribute value of our new rdn, we will
         * need to add that to our new entry
         */
@@ -745,6 +762,9 @@ retry:      /* transaction retry */
                &text, textbuf, textlen );
 
        if( rc != LDAP_SUCCESS ) {
+               if ( ( rc == LDAP_INSUFFICIENT_ACCESS ) && opinfo.boi_err ) {
+                       rc = opinfo.boi_err;
+               }
                switch( rc ) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
index ca87a6c7277d8df465513073ab2c3b0d67aa1a41..8ffb72c2fb01db2f7741117a3cccd5283c6faaa9 100644 (file)
@@ -29,63 +29,17 @@ bdb_hasSubordinates(
 {
        struct bdb_info *bdb = (struct bdb_info *) be->be_private;
        int             rc;
-       DB_TXN          *ltid = NULL;
-       struct bdb_op_info opinfo;
        
        assert( e );
        assert( hasSubordinates );
 
-       if( 0 ) {
-retry: /* transaction retry */
-#if 0
-               if( e != NULL ) {
-                       bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
-               }
-#endif
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, DETAIL1, 
-                       "=> bdb_hasSubordinates: retrying...\n", 0, 0, 0 );
-#else
-               Debug( LDAP_DEBUG_TRACE, "==> bdb_hasSubordinates: retrying...\n", 
-                               0, 0, 0 );
-#endif
-               rc = TXN_ABORT( ltid );
-               ltid = NULL;
-               op->o_private = NULL;
-               if( rc != 0 ) {
-                       rc = LDAP_OTHER;
-                       goto return_results;
-               }
-               ldap_pvt_thread_yield();
-       }
-
-       /* begin transaction */
-       rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &ltid, bdb->bi_db_opflags );
-       if ( rc != 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, ERR, 
-                       "=> bdb_hasSubordinates: txn_begin failed: %s (%d)\n",
-                       db_strerror(rc), rc, 0 );
-#else
-               Debug( LDAP_DEBUG_TRACE,
-                       "bdb_hasSubordinates: txn_begin failed: %s (%d)\n",
-                       db_strerror( rc ), rc, 0 );
-#endif
-               rc = LDAP_OTHER;
-               return rc;
-       }
-
-       opinfo.boi_bdb = be;
-       opinfo.boi_txn = ltid;
-       opinfo.boi_locker = TXN_ID ( ltid );
-       opinfo.boi_err = 0;
-       op->o_private = &opinfo;
-
-       rc = bdb_dn2id_children( be, ltid, &e->e_nname, 0 );
+retry:
+       rc = bdb_dn2id_children( be, NULL, &e->e_nname, 0 );
        
        switch( rc ) {
        case DB_LOCK_DEADLOCK:
        case DB_LOCK_NOTGRANTED:
+               ldap_pvt_thread_yield();
                goto retry;
 
        case 0:
@@ -110,18 +64,6 @@ retry:      /* transaction retry */
                rc = LDAP_OTHER;
        }
 
-return_results:
-       if ( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
-               ldap_pvt_thread_yield();
-               TXN_CHECKPOINT( bdb->bi_dbenv,
-                       bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
-       }
-
-       if ( ltid != NULL ) {
-               TXN_ABORT( ltid );
-               op->o_private = NULL;
-       }
-
        return rc;
 }
 
index d801fb926082891fffb37868102fd109796be6c6..33803ff633ce0684c92523c6e236fbc42953caf1 100644 (file)
@@ -122,6 +122,7 @@ retry:      /* transaction retry */
                rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
+               op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rc != 0 ) {
                        rc = LDAP_OTHER;
                        *text = "internal error";
@@ -155,6 +156,7 @@ retry:      /* transaction retry */
        opinfo.boi_txn = ltid;
        opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
+       opinfo.boi_acl_cache = op->o_do_not_cache;
        op->o_private = &opinfo;
 
        /* get entry */
@@ -221,6 +223,9 @@ retry:      /* transaction retry */
                rc = bdb_modify_internal( be, conn, op, ltid,
                        &ml, e, text, textbuf, textlen );
 
+               if ( (rc == LDAP_INSUFFICIENT_ACCESS) && opinfo.boi_err ) {
+                       rc = opinfo.boi_err;
+               }
                switch(rc) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
index 34a60cf355d96a86df05d65b93bc982621a11d8d..feea82ee22d3745101c07f1e415dcd4949e79cf6 100644 (file)
@@ -84,7 +84,6 @@ bdb_search(
 
        u_int32_t       locker = 0;
        DB_LOCK         lock;
-       struct bdb_op_info opinfo;
 
 #ifdef NEW_LOGGING
        LDAP_LOG ( OPERATION, ENTRY, "bdb_back_search\n", 0, 0, 0 );
@@ -136,12 +135,6 @@ bdb_search(
                return rc;
        }
 
-       opinfo.boi_bdb = be;
-       opinfo.boi_txn = NULL;
-       opinfo.boi_locker = locker;
-       opinfo.boi_err = 0;
-       op->o_private = &opinfo;
-
        if ( nbase->bv_len == 0 ) {
                /* DIT root special case */
                e = (Entry *) &slap_entry_root;
@@ -809,10 +802,10 @@ id2entry_retry:
                } else {
 #ifdef NEW_LOGGING
                        LDAP_LOG ( OPERATION, RESULTS,
-                               "bdb_search: %ld does match filter\n", (long) id, 0, 0);
+                               "bdb_search: %ld does not match filter\n", (long) id, 0, 0);
 #else
                        Debug( LDAP_DEBUG_TRACE,
-                               "bdb_search: %ld does match filter\n",
+                               "bdb_search: %ld does not match filter\n",
                                (long) id, 0, 0 );
 #endif
                }
index 04307c5c7cd71453fa94169c3138fcafa68702bd..679ca32c000fc8e13090bc046a747c7ac96fb9a1 100644 (file)
 static DBC *cursor = NULL;
 static DBT key, data;
 
+typedef struct dn_id {
+       ID id;
+       struct berval dn;
+} dn_id;
+
+#define        HOLE_SIZE       4096
+dn_id hbuf[HOLE_SIZE], *holes = hbuf;
+unsigned nhmax = HOLE_SIZE;
+unsigned nholes;
+
 int bdb_tool_entry_open(
        BackendDB *be, int mode )
 {
@@ -46,6 +56,16 @@ int bdb_tool_entry_close(
                cursor = NULL;
        }
 
+       if( nholes ) {
+               unsigned i;
+               fprintf( stderr, "Error, entries missing!\n");
+               for (i=0; i<nholes; i++) {
+                       fprintf(stderr, "  entry %d: %s\n",
+                               holes[i].id, holes[i].dn.bv_val, 0);
+               }
+               return -1;
+       }
+                       
        return 0;
 }
 
@@ -112,7 +132,8 @@ int bdb_tool_next_id(
        BackendDB *be,
        DB_TXN *tid,
        Entry *e,
-       struct berval *text )
+       struct berval *text,
+       int hole )
 {
        struct bdb_info *bdb = (struct bdb_info *) be->be_private;
        struct berval dn = e->e_nname;
@@ -126,7 +147,7 @@ int bdb_tool_next_id(
                } else {
                        dnParent( &dn, &pdn );
                        e->e_nname = pdn;
-                       rc = bdb_tool_next_id( be, tid, e, text );
+                       rc = bdb_tool_next_id( be, tid, e, text, 1 );
                        if ( rc ) {
                                return rc;
                        }
@@ -158,6 +179,33 @@ int bdb_tool_next_id(
                Debug( LDAP_DEBUG_ANY,
                        "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
 #endif
+               } else if ( hole ) {
+                       if ( nholes == nhmax - 1 ) {
+                               if ( holes == hbuf ) {
+                                       holes = malloc( nhmax * sizeof(ID) * 2 );
+                                       AC_MEMCPY( holes, hbuf, sizeof(hbuf) );
+                               } else {
+                                       holes = realloc( holes, nhmax * sizeof(ID) * 2 );
+                               }
+                               nhmax *= 2;
+                       }
+                       ber_dupbv( &holes[nholes].dn, &dn );
+                       holes[nholes++].id = e->e_id;
+               }
+       } else if ( !hole ) {
+               unsigned i;
+
+               for ( i=0; i<nholes; i++) {
+                       if ( holes[i].id == e->e_id ) {
+                               int j;
+                               free(holes[i].dn.bv_val);
+                               for (j=i;j<nholes;j++) holes[j] = holes[j+1];
+                               holes[j].id = 0;
+                               nholes--;
+                               break;
+                       } else if ( holes[i].id > e->e_id ) {
+                               break;
+                       }
                }
        }
        return rc;
@@ -205,7 +253,7 @@ ID bdb_tool_entry_put(
        }
 
        /* add dn2id indices */
-       rc = bdb_tool_next_id( be, tid, e, text );
+       rc = bdb_tool_next_id( be, tid, e, text, 0 );
        if( rc != 0 ) {
                goto done;
        }
index 40f29db621a74b144613f72a5dac7507c59d9ddc..8f3fa9ad0284d2c27de4e48b939460b96d4dbb8b 100644 (file)
@@ -87,6 +87,7 @@ str2entry( char *s )
        e->e_id = NOID;
 
        /* dn + attributes */
+       vals[0].bv_len = 0;
        vals[1].bv_val = NULL;
 
        next = s;
index 12d0d5d324f1d5a8c824ec233a7015ad4c4cee33..53cdb6a6f2bc9a20c8221cefdfcc662aa12d3b9c 100644 (file)
@@ -1246,8 +1246,8 @@ static int caseExactIgnoreIndexer(
        BerVarray values,
        BerVarray *keysp )
 {
-       int i;
-       unsigned casefold;
+       int i,j;
+       unsigned casefold,wasspace;
        size_t slen, mlen;
        BerVarray keys;
        HASH_CONTEXT   HASHcontext;
@@ -1272,9 +1272,33 @@ static int caseExactIgnoreIndexer(
                ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
 
        for( i=0; values[i].bv_val != NULL; i++ ) {
-               struct berval value;
+               struct berval value, nvalue;
                UTF8bvnormalize( &values[i], &value, casefold );
 
+               /* collapse spaces (in place) */
+               nvalue.bv_len = 0;
+               nvalue.bv_val = value.bv_val;
+
+               wasspace=1;
+               for( j=0; j<value.bv_len; j++) {
+                       if ( ASCII_SPACE( value.bv_val[j] )) {
+                               if( wasspace++ == 0 ) {
+                                       nvalue.bv_val[nvalue.bv_len++] = value.bv_val[j];
+                               }
+                       } else {
+                               wasspace = 0;
+                               nvalue.bv_val[nvalue.bv_len++] = value.bv_val[j];
+                       }
+               }
+
+               if( nvalue.bv_len == 0 ) {
+                       nvalue.bv_val = " ";
+                       nvalue.bv_len = sizeof(" ")-1;
+               } else {
+                       if( wasspace ) --nvalue.bv_len;
+                       nvalue.bv_val[nvalue.bv_len] = '\0';
+               }
+
                HASH_Init( &HASHcontext );
                if( prefix != NULL && prefix->bv_len > 0 ) {
                        HASH_Update( &HASHcontext,
@@ -1285,11 +1309,10 @@ static int caseExactIgnoreIndexer(
                HASH_Update( &HASHcontext,
                        mr->smr_oid, mlen );
                HASH_Update( &HASHcontext,
-                       value.bv_val, value.bv_len );
+                       nvalue.bv_val, nvalue.bv_len );
                HASH_Final( HASHdigest, &HASHcontext );
 
                free( value.bv_val );
-
                ber_dupbv( &keys[i], &digest );
        }
 
@@ -1367,11 +1390,11 @@ static int caseExactIgnoreSubstringsIndexer(
        BerVarray values,
        BerVarray *keysp )
 {
-       unsigned casefold;
-       ber_len_t i, nkeys;
+       unsigned casefold, wasspace;
+       ber_len_t i, j, nkeys;
        size_t slen, mlen;
        BerVarray keys;
-       BerVarray nvalues;
+       BerVarray tvalues, nvalues;
 
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
@@ -1391,10 +1414,39 @@ static int caseExactIgnoreSubstringsIndexer(
        casefold = ( mr != caseExactSubstringsMatchingRule )
                ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
 
+       tvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
        nvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
+
        for( i=0; values[i].bv_val != NULL; i++ ) {
-               UTF8bvnormalize( &values[i], &nvalues[i], casefold );
+               UTF8bvnormalize( &values[i], &tvalues[i], casefold );
+
+               /* collapse spaces (in place) */
+               nvalues[i].bv_len = 0;
+               nvalues[i].bv_val = tvalues[i].bv_val;
+
+               wasspace=1;
+               for( j=0; j<tvalues[i].bv_len; j++) {
+                       if ( ASCII_SPACE( tvalues[i].bv_val[j] )) {
+                               if( wasspace++ == 0 ) {
+                                       nvalues[i].bv_val[nvalues[i].bv_len++] =
+                                               tvalues[i].bv_val[j];
+                               }
+                       } else {
+                               wasspace = 0;
+                               nvalues[i].bv_val[nvalues[i].bv_len++] = tvalues[i].bv_val[j];
+                       }
+               }
+
+               if( nvalues[i].bv_len == 0 ) {
+                       nvalues[i].bv_val = " ";
+                       nvalues[i].bv_len = sizeof(" ")-1;
+               } else {
+                       if( wasspace ) --nvalues[i].bv_len;
+                       nvalues[i].bv_val[nvalues[i].bv_len] = '\0';
+               }
        }
+
+       tvalues[i].bv_val = NULL;
        nvalues[i].bv_val = NULL;
        values = nvalues;
 
@@ -1432,7 +1484,8 @@ static int caseExactIgnoreSubstringsIndexer(
        if( nkeys == 0 ) {
                /* no keys to generate */
                *keysp = NULL;
-               ber_bvarray_free( nvalues );
+               ber_bvarray_free( tvalues );
+               ch_free( nvalues );
                return LDAP_SUCCESS;
        }
 
@@ -1533,7 +1586,8 @@ static int caseExactIgnoreSubstringsIndexer(
                *keysp = NULL;
        }
 
-       ber_bvarray_free( nvalues );
+       ber_bvarray_free( tvalues );
+       ch_free( nvalues );
 
        return LDAP_SUCCESS;
 }
index 85c4f80a09d77799331ae993e95941c9f79c62d3..1fc700ba122c3a14a14d8d48b88bd745dd2afd12 100644 (file)
@@ -524,8 +524,7 @@ static struct slap_schema_ad_map {
        { "monitorContext", "( 1.3.6.1.4.1.4203.666.1.10 "
                        "NAME 'monitorContext' "
                        "DESC 'monitor context' "
-                       "EQUALITY objectIdentifierMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "SINGLE-VALUE NO-USER-MODIFICATION "
                        "USAGE dSAOperation )",
                rootDseAttribute, SLAP_AT_HIDE,
index cfdf733971fd6ee03626c6aebc2dc3ebca3caa6b..679cbbf9366317e96f83bdd09e7396427af2c91d 100644 (file)
@@ -34,12 +34,14 @@ argsfile    %LOCALSTATEDIR%/slapd.args
 
 # Sample access control policy:
 #      Root DSE: allow anyone to read it
+#      Subschema (sub)entry DSE: allow anyone to read it
 #      Other DSEs:
 #              Allow self write access
 #              Allow authenticated users read access
 #              Allow anonymous users to authenticate
 #      Directives needed to implement policy:
 # access to dn.base="" by * read
+# access to dn.base="cn=Subschema" by * read
 # access to *
 #      by self write
 #      by users read
index 1f31d57735385f4f5b0195d30c424622e6c173b9..6ae5bdfbfdec758d96fc686e1d388e7a30a540c4 100644 (file)
@@ -261,7 +261,7 @@ main( int argc, char **argv )
 
        ch_free( buf );
 
-       be->be_entry_close( be );
+       if( be->be_entry_close( be )) rc = EXIT_FAILURE;
 
        if( be->be_sync ) {
                be->be_sync( be );