]> git.sur5r.net Git - openldap/commitdiff
Merge in latest changes from HEAD
authorKurt Zeilenga <kurt@openldap.org>
Mon, 6 Oct 2003 16:57:28 +0000 (16:57 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 6 Oct 2003 16:57:28 +0000 (16:57 +0000)
77 files changed:
build/top.mk
clients/tools/ldapsearch.c
doc/man/man5/slapd-bdb.5
include/lber.h
include/ldbm.h
include/slapi-plugin.h
libraries/liblber/Makefile.in
libraries/libldap/cyrus.c
libraries/libldap/sasl.c
libraries/libldap_r/rq.c
servers/slapd/Makefile.in
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/ctxcsn.c
servers/slapd/back-bdb/dbcache.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/index.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-bdb/proto-bdb.h
servers/slapd/back-bdb/search.c
servers/slapd/back-bdb/trans.c
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/bind.c
servers/slapd/back-ldbm/compare.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/back-ldbm/referral.c
servers/slapd/back-ldbm/search.c
servers/slapd/back-meta/search.c
servers/slapd/back-perl/add.c
servers/slapd/back-perl/bind.c
servers/slapd/back-perl/close.c
servers/slapd/back-perl/compare.c
servers/slapd/back-perl/config.c
servers/slapd/back-perl/delete.c
servers/slapd/back-perl/init.c
servers/slapd/back-perl/modify.c
servers/slapd/back-perl/modrdn.c
servers/slapd/back-perl/search.c
servers/slapd/back-sql/modify.c
servers/slapd/backend.c
servers/slapd/backover.c
servers/slapd/bind.c
servers/slapd/connection.c
servers/slapd/ctxcsn.c
servers/slapd/dn.c
servers/slapd/filter.c
servers/slapd/globals.c
servers/slapd/overlays/README [new file with mode: 0644]
servers/slapd/overlays/dyngroup.c [new file with mode: 0644]
servers/slapd/proto-slap.h
servers/slapd/result.c
servers/slapd/slap.h
servers/slapd/slapi/Makefile.in
servers/slapd/slapi/plugin.c
servers/slapd/slapi/proto-slapi.h
servers/slapd/slapi/slapi_pblock.c
servers/slapd/slapi/slapi_utils.c
servers/slapd/syncrepl.c
servers/slapd/tools/Makefile.in
servers/slapd/tools/slapadd.c
servers/slurpd/config.c
tests/Makefile.in
tests/data/do_search.0
tests/progs/slapd-tester.c
tests/scripts/all
tests/scripts/args.sh
tests/scripts/test008-concurrency
tests/scripts/test017-syncreplication-refresh
tests/scripts/test018-syncreplication-persist
tests/scripts/test020-syncreplication-cascading

index bcfb0d6088490359c6db74c51c36fa35b63132fb..5495b79b00c7466aabfda018111265d5ca0c8275 100644 (file)
@@ -148,8 +148,11 @@ LDAP_LIBLBER_LA = $(LDAP_LIBDIR)/liblber/liblber.la
 LDAP_LIBLDAP_LA = $(LDAP_LIBDIR)/libldap/libldap.la
 LDAP_LIBLDAP_R_LA = $(LDAP_LIBDIR)/libldap_r/libldap_r.la
 
+LDAP_LIBLDBM_A_no =
+LDAP_LIBLDBM_A_yes = $(LDAP_LIBDIR)/libldbm/libldbm.a
+
 LDAP_LIBAVL_A = $(LDAP_LIBDIR)/libavl/libavl.a
-LDAP_LIBLDBM_A = $(LDAP_LIBDIR)/libldbm/libldbm.a
+LDAP_LIBLDBM_A = $(LDAP_LIBLDBM_A_@BUILD_LDBM@)
 LDAP_LIBLDIF_A = $(LDAP_LIBDIR)/libldif/libldif.a
 LDAP_LIBREWRITE_A = $(LDAP_LIBDIR)/librewrite/librewrite.a
 LDAP_LIBLUNICODE_A = $(LDAP_LIBDIR)/liblunicode/liblunicode.a
index 31be49d5f0b4385c6e64b69997cc226eba7a9182..047f055cf5d647b15709c80c68d282a14b3d231b 100644 (file)
@@ -995,7 +995,7 @@ done:
        return( rc );
 }
 
-#if 1
+#ifdef OLD_WAY
 /* This is the original version, the old way of doing things. */
 static void
 print_entry(
@@ -1161,10 +1161,10 @@ print_entry(
        {
                if (bv.bv_val == NULL) break;
 
-               if ( attrsonly || !bvals ) {
+               if ( attrsonly ) {
                        write_ldif( LDIF_PUT_NOVALUE, bv.bv_val, NULL, 0 );
 
-               } else {
+               } else if ( bvals ) {
                        for ( i = 0; bvals[i].bv_val != NULL; i++ ) {
                                if ( vals2tmp > 1 || ( vals2tmp
                                        && ldif_is_not_printable( bvals[i].bv_val, bvals[i].bv_len ) ))
index 99f8afede35da2cf0f48577ca015d6ddb20e0c83..caed18a197be9c84964d174375485a76d52e76d5 100644 (file)
@@ -70,6 +70,11 @@ results if the data comes from a transaction that is later aborted.
 In this case, the modified data is discarded and a subsequent search
 will return a different result.
 .TP
+.B idlcachesize <integer>
+Specify the size of the in-memory index cache, in index slots. The
+default is zero. A larger value will speed up frequent searches of
+indexed entries.
+.TP
 .B
 index {<attrlist>|default} [pres,eq,approx,sub,<special>]
 Specify the indexes to maintain for the given attribute (or
@@ -119,6 +124,12 @@ allocations can have a major negative impact on server performance,
 but specifying too much stack will also consume a great deal of memory.
 Each search stack uses 512K bytes per level. The default stack depth
 is 16, thus 8MB per thread is used.
+.TP
+.B shm_key <integer>
+Specify a key for a shared memory BDB environment. By default the
+BDB environment uses memory mapped files. If a non-zero value is
+specified, it will be used as the key to identify a shared memory
+region that will house the environment.
 .SH FILES
 .TP
 ETCDIR/slapd.conf
index 728f575090fd96796802bb52e9c39402e0b4881c..77a32fa8915bd3893a4a85d4550089016cdf4e3b 100644 (file)
@@ -25,6 +25,7 @@
 #define _LBER_H
 
 #include <lber_types.h>
+#include <string.h>
 
 LDAP_BEGIN_DECL
 
index 9c92ac6e9679a23b6b37ff8270af2430f8cb8083..5a86a5fa70bfacb0eef17bc75fb102a8891eebb7 100644 (file)
@@ -15,6 +15,7 @@
 #define _LDBM_H_
 
 #include <ldap_cdefs.h>
+#include <string.h>
 
 /* dummy DB_ENV for non Berkeley DB */
 #if !defined( LDBM_USE_DBBTREE ) && !defined( LDBM_USE_DBHASH )
index 3f763428b259cdf8a812918050924d1c0303773f..fc6ac13ad240e898caed502d383344baf077ae73 100644 (file)
@@ -49,6 +49,9 @@ int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals );
 char *slapi_dn_normalize( char *dn );
 char *slapi_dn_normalize_case( char *dn );
 int slapi_dn_issuffix( char *dn, char *suffix );
+char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
+char *slapi_dn_parent( const char *dn );
+int slapi_dn_isparent( const char *parentdn, const char *childdn );
 char *slapi_dn_ignore_case( char *dn );
 
 /* DS 5.x SLAPI */
@@ -181,6 +184,8 @@ void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched,
        char *text, int nentries, struct berval **urls );
 int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
        LDAPControl **ectrls, char **attrs, int attrsonly );
+int slapi_send_ldap_search_reference( Slapi_PBlock *pb, Slapi_Entry *e,
+       struct berval **urls, LDAPControl **ectrls, struct berval **v2refs );
 
 /* filter routines */
 Slapi_Filter *slapi_str2filter( char *str );
index 440c37095379ae36ea2aa880920f75af7e0d1421..feae38b3630eacd48693506bbe91a2353f55ad7f 100644 (file)
@@ -40,5 +40,5 @@ idtest:  $(XLIBS) idtest.o
 install-local: FORCE
        -$(MKDIR) $(DESTDIR)$(libdir)
        $(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir)
-       $(LTFINISH) $(DESTDIR)$libdir
+       $(LTFINISH) $(DESTDIR)$(libdir)
 
index d687c4cec6ae9ea5adfafcfdc6376b52ca749aee..1816d8d7c386129a2bb9064c22f59be30265a0cf 100644 (file)
@@ -14,6 +14,7 @@
 #include <ac/time.h>
 #include <ac/errno.h>
 #include <ac/ctype.h>
+#include <ac/unistd.h>
 
 #include "ldap-int.h"
 
index 1509ccd3b18a1538e335d183099adc260ceea487..bd59ff58b2950697bcc72bdcc76a1d3b6349a4e0 100644 (file)
@@ -433,6 +433,7 @@ ldap_sasl_interactive_bind_s(
        void *defaults )
 {
        int rc;
+       char *smechs = NULL;
 
 #if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL )
        ldap_pvt_thread_mutex_lock( &ldap_int_sasl_mutex );
@@ -448,9 +449,14 @@ ldap_sasl_interactive_bind_s(
                goto done;
        } else
 #endif
-       if( mechs == NULL || *mechs == '\0' ) {
-               char *smechs;
 
+#ifdef HAVE_CYRUS_SASL
+       if( mechs == NULL || *mechs == '\0' ) {
+               mechs = ld->ld_options.ldo_def_sasl_mech;
+       }
+#endif
+               
+       if( mechs == NULL || *mechs == '\0' ) {
                rc = ldap_pvt_sasl_getmechs( ld, &smechs );
                if( rc != LDAP_SUCCESS ) {
                        goto done;
@@ -488,6 +494,7 @@ done:
 #if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL )
        ldap_pvt_thread_mutex_unlock( &ldap_int_sasl_mutex );
 #endif
+       if ( smechs ) LDAP_FREE( smechs );
 
        return rc;
 }
index 29153ccc7270ef1d7b260ef4d65ae627cfeb7fd4..88851efeb7adf5a63258847692bfb73c6516170c 100644 (file)
@@ -9,9 +9,10 @@
 
 #include <ac/stdarg.h>
 #include <ac/stdlib.h>
+#include <ac/errno.h>
+#include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
-#include <ac/errno.h>
 
 #include "ldap-int.h"
 #include "ldap_pvt_thread.h"
index c571c12f04eb22c422852168d8e49a79e1b9bb09..b5b76a2ef173b045bb46bf4a700330c0ec27e2f6 100644 (file)
@@ -47,12 +47,14 @@ SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a
 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
 
+SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
+
 XDEFS = $(MODULES_CPPFLAGS)
 XLDFLAGS = $(MODULES_LDFLAGS)
 
 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L)
 XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS)
-XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) @LIBSLAPI@ $(MODULES_LIBS)
+XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) $(MODULES_LIBS)
 
 BUILD_OPT = "--enable-slapd"
 BUILD_SRV = @BUILD_SLAPD@
@@ -228,13 +230,11 @@ slapd.exp: libslapd.a
        dlltool --dllname slapd.exe --input-def slapd.def \
                --base-file slapd.base --output-exp $@
 
-libslapi.a: .slapi
+slapi/.libs/libslapi.a: FORCE
        (cd slapi; $(MAKE) $(MFLAGS) all)
-       cp slapi/.libs/libslapi.a .
 
-.slapi: FORCE
-       $(AR) ruv slapi/libtmpslapd.a $(OBJS)
-       (cd slapi; $(MAKE) $(MFLAGS) all)
+libslapi.a: slapi/.libs/libslapi.a
+       cp slapi/.libs/libslapi.a .
 
 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
        $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
index 6260b8164e7eea35353e24f195cd8830036dae41..551a8813c18cbb77ea7845160dd633e2b84c053f 100644 (file)
@@ -37,7 +37,7 @@ bdb_add(Operation *op, SlapReply *rs )
 
        Operation* ps_list;
        int             rc;
-       EntryInfo       *suffix_ei;
+       EntryInfo       *suffix_ei = NULL;
        Entry           *ctxcsn_e;
        int                     ctxcsn_added = 0;
 
@@ -102,8 +102,8 @@ retry:      /* transaction retry */
                        rs->sr_text = "internal error";
                        goto return_results;
                }
-               bdb_trans_backoff( ++num_retries );
                ldap_pvt_thread_yield();
+               bdb_trans_backoff( ++num_retries );
        }
 
        /* begin transaction */
@@ -506,6 +506,7 @@ retry:      /* transaction retry */
        } else {
                char gid[DB_XIDDATASIZE];
 
+               memset( gid, 0, sizeof(gid) );
                snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
                        bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
 
index b5dc2fe0339093d52ffaa0a30c2dccf6e249ea77..1a249f41e68f1030d2130bf00072d67447176a3c 100644 (file)
@@ -87,6 +87,7 @@ typedef struct bdb_entry_info {
 #define        CACHE_ENTRY_DELETED     1
 #define        CACHE_ENTRY_NO_KIDS     2
 #define        CACHE_ENTRY_NOT_LINKED  4
+#define CACHE_ENTRY_NO_GRANDKIDS       8
 
        /*
         * remaining fields require backend cache lock to access
@@ -113,6 +114,7 @@ typedef struct bdb_cache {
        int             c_maxsize;
        int             c_cursize;
        EntryInfo       c_dntree;
+       EntryInfo       *c_eifree;      /* free list */
        Avlnode         *c_idtree;
        EntryInfo       *c_lruhead;     /* lru - add accessed entries here */
        EntryInfo       *c_lrutail;     /* lru - rem lru entries from here */
@@ -141,6 +143,7 @@ struct bdb_info {
 
        int                     bi_ndatabases;
        struct bdb_db_info **bi_databases;
+       ldap_pvt_thread_mutex_t bi_database_mutex;
        int             bi_db_opflags;  /* db-specific flags */
 
        slap_mask_t     bi_defaultmask;
@@ -182,7 +185,7 @@ struct bdb_op_info {
        int             boi_acl_cache;
 };
 
-#define        DB_OPEN(db, txn, file, name, type, flags, mode) \
+#define        DB_OPEN(db, file, name, type, flags, mode) \
        (db)->open(db, file, name, type, flags, mode)
 
 #if DB_VERSION_MAJOR < 4
@@ -213,8 +216,8 @@ struct bdb_op_info {
 /* BDB 4.1.17 adds txn arg to db->open */
 #if DB_VERSION_MINOR > 1 || DB_VERSION_PATCH >= 17
 #undef DB_OPEN
-#define        DB_OPEN(db, txn, file, name, type, flags, mode) \
-       (db)->open(db, txn, file, name, type, flags, mode)
+#define        DB_OPEN(db, file, name, type, flags, mode) \
+       (db)->open(db, NULL, file, name, type, (flags)|DB_AUTO_COMMIT, mode)
 #endif
 
 #endif
index 02db20c8c5ba58dc31e4b101d6e437e2a7e73ddb..f18e21ce20ae1f725dcc26fb252ee5a8d644b122 100644 (file)
@@ -23,12 +23,25 @@ static void bdb_lru_print(Cache *cache);
 #endif
 
 static EntryInfo *
-bdb_cache_entryinfo_new( )
+bdb_cache_entryinfo_new( Cache *cache )
 {
-       EntryInfo *ei;
+       EntryInfo *ei = NULL;
 
-       ei = ch_calloc(1, sizeof(struct bdb_entry_info));
-       ldap_pvt_thread_mutex_init( &ei->bei_kids_mutex );
+       if ( cache->c_eifree ) {
+               ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
+               if ( cache->c_eifree ) {
+                       ei = cache->c_eifree;
+                       cache->c_eifree = ei->bei_lrunext;
+               }
+               ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
+       }
+       if ( ei ) {
+               ei->bei_lrunext = NULL;
+               ei->bei_state = 0;
+       } else {
+               ei = ch_calloc(1, sizeof(struct bdb_entry_info));
+               ldap_pvt_thread_mutex_init( &ei->bei_kids_mutex );
+       }
 
        return ei;
 }
@@ -200,7 +213,7 @@ bdb_entryinfo_add_internal(
 
        *res = NULL;
 
-       ei2 = bdb_cache_entryinfo_new();
+       ei2 = bdb_cache_entryinfo_new( &bdb->bi_cache );
 
        ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock );
        bdb_cache_entryinfo_lock( ei->bei_parent );
@@ -356,7 +369,7 @@ hdb_cache_find_parent(
                ei2 = ein;
 
                /* Create a new node for the current ID */
-               ein = bdb_cache_entryinfo_new();
+               ein = bdb_cache_entryinfo_new( &bdb->bi_cache );
                ein->bei_id = ei.bei_id;
                ein->bei_kids = ei.bei_kids;
                ein->bei_nrdn = ei.bei_nrdn;
@@ -518,6 +531,23 @@ bdb_cache_lru_add(
        ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.lru_mutex );
 }
 
+EntryInfo *
+bdb_cache_find_info(
+       struct bdb_info *bdb,
+       ID id
+)
+{
+       EntryInfo ei, *ei2;
+
+       ei.bei_id = id;
+
+       ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
+       ei2 = (EntryInfo *) avl_find( bdb->bi_cache.c_idtree,
+                                       (caddr_t) &ei, bdb_id_cmp );
+       ldap_pvt_thread_rdwr_runlock( &bdb->bi_cache.c_rwlock );
+       return ei2;
+}
+
 /*
  * cache_find_id - find an entry in the cache, given id.
  * The entry is locked for Read upon return. Call with islocked TRUE if
@@ -683,7 +713,7 @@ bdb_cache_children(
        }
        rc = bdb_dn2id_children( op, txn, e );
        if ( rc == DB_NOTFOUND ) {
-               BEI(e)->bei_state |= CACHE_ENTRY_NO_KIDS;
+               BEI(e)->bei_state |= CACHE_ENTRY_NO_KIDS | CACHE_ENTRY_NO_GRANDKIDS;
        }
        return rc;
 }
@@ -716,8 +746,9 @@ bdb_cache_add(
        rc = bdb_entryinfo_add_internal( bdb, &ei, &new );
        new->bei_e = e;
        e->e_private = new;
-       new->bei_state = CACHE_ENTRY_NO_KIDS;
+       new->bei_state = CACHE_ENTRY_NO_KIDS | CACHE_ENTRY_NO_GRANDKIDS;
        eip->bei_state &= ~CACHE_ENTRY_NO_KIDS;
+       if (eip->bei_parent) eip->bei_parent->bei_state &= ~CACHE_ENTRY_NO_GRANDKIDS;
 
        /* set lru mutex */
        ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex );
@@ -890,15 +921,36 @@ bdb_cache_delete(
 
 void
 bdb_cache_delete_cleanup(
+       Cache *cache,
        Entry *e
 )
 {
-       bdb_cache_entryinfo_unlock( BEI(e) );
-       bdb_cache_entryinfo_destroy( e->e_private );
+       EntryInfo *ei = BEI(e);
+
+       ei->bei_e = NULL;
        e->e_private = NULL;
        bdb_entry_return( e );
+
+       free( ei->bei_nrdn.bv_val );
+       ei->bei_nrdn.bv_val = NULL;
+#ifdef BDB_HIER
+       free( ei->bei_rdn.bv_val );
+       ei->bei_rdn.bv_val = NULL;
+       ei->bei_modrdns = 0;
+       ei->bei_ckids = 0;
+       ei->bei_dkids = 0;
+#endif
+       ei->bei_parent = NULL;
+       ei->bei_kids = NULL;
+       ei->bei_lruprev = NULL;
+
+       ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
+       ei->bei_lrunext = cache->c_eifree;
+       cache->c_eifree = ei;
+       ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
+       bdb_cache_entryinfo_unlock( ei );
 }
-       
+
 static int
 bdb_cache_delete_internal(
     Cache      *cache,
@@ -1078,3 +1130,24 @@ bdb_locker_id( Operation *op, DB_ENV *env, int *locker )
        return 0;
 }
 #endif
+
+void
+bdb_cache_delete_entry(
+       struct bdb_info *bdb,
+       EntryInfo *ei,
+       u_int32_t locker,
+       DB_LOCK *lock )
+{
+       ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock );
+       if ( bdb_cache_entry_db_lock( bdb->bi_dbenv, locker, ei, 1, 1, lock ) == 0 ) {
+               if ( ei->bei_e && !(ei->bei_state & CACHE_ENTRY_NOT_LINKED )) {
+                       LRU_DELETE( &bdb->bi_cache, ei );
+                       ei->bei_e->e_private = NULL;
+                       bdb_entry_return( ei->bei_e );
+                       ei->bei_e = NULL;
+                       --bdb->bi_cache.c_cursize;
+               }
+               bdb_cache_entry_db_unlock( bdb->bi_dbenv, lock );
+       }
+       ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock );
+}
index c6655c11f1bf784570efb3b9022214c070488c44..3f9dfc1f6173eb63518f3f6ddcba97fcf229fdd6 100644 (file)
@@ -47,7 +47,7 @@ bdb_csn_commit(
        struct berval   ctxcsn_ndn = { 0, NULL };
        EntryInfo               *ctxcsn_ei = NULL;
        DB_LOCK                 ctxcsn_lock;
-       struct berval   *max_committed_csn = NULL;
+       struct berval   max_committed_csn;
        DB_LOCK                 suffix_lock;
        int                             rc, ret;
        ID                              ctxcsn_id;
@@ -61,16 +61,18 @@ bdb_csn_commit(
        }
 
        build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0],
-               (struct berval *)&slap_ldapsync_cn_bv );
-
-       rc = bdb_dn2entry( op, tid, &ctxcsn_ndn, &ctxcsn_ei,
-                                                          1, locker, &ctxcsn_lock );
+               (struct berval *)&slap_ldapsync_cn_bv, op->o_tmpmemctx );
 
+       rc =  bdb_dn2entry( op, tid, &ctxcsn_ndn, &ctxcsn_ei,
+                       1, locker, &ctxcsn_lock );
+       
        *ctxcsn_e = ctxcsn_ei->bei_e;
 
-       max_committed_csn = slap_get_commit_csn( op );
+       op->o_tmpfree( ctxcsn_ndn.bv_val, op->o_tmpmemctx );
+
+       slap_get_commit_csn( op, &max_committed_csn );
 
-       if ( max_committed_csn == NULL ) {
+       if ( max_committed_csn.bv_val == NULL ) {
                return BDB_CSN_COMMIT;
        }
 
@@ -81,13 +83,14 @@ bdb_csn_commit(
                if ( !*ctxcsn_e ) {
                        rs->sr_err = LDAP_OTHER;
                        rs->sr_text = "context csn not present";
-                       ber_bvfree( max_committed_csn );
+                       ch_free( max_committed_csn.bv_val );
                        return BDB_CSN_ABORT;
                } else {
                        Modifications mod;
                        struct berval modvals[2];
+                       Entry dummy;
 
-                       modvals[0] = *max_committed_csn;
+                       modvals[0] = max_committed_csn;
                        modvals[1].bv_val = NULL;
                        modvals[1].bv_len = 0;
 
@@ -98,11 +101,10 @@ bdb_csn_commit(
                        mod.sml_type = mod.sml_desc->ad_cname;
                        mod.sml_next = NULL;
 
-                       bdb_cache_entry_db_relock( bdb->bi_dbenv, locker, ctxcsn_ei, 1, 0, &ctxcsn_lock );
-
-                       ret = bdb_modify_internal( op, tid, &mod, *ctxcsn_e,
-                                                                       &rs->sr_text, textbuf, textlen );                                                               
-                       ber_bvfree( max_committed_csn );
+                       dummy = **ctxcsn_e;
+                       ret = bdb_modify_internal( op, tid, &mod, &dummy,
+                                                                       &rs->sr_text, textbuf, textlen );                                                      
+                       ch_free( max_committed_csn.bv_val );
                        if ( ret != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG ( OPERATION, ERR,
@@ -120,7 +122,7 @@ bdb_csn_commit(
                                }
                        }
 
-                       ret = bdb_id2entry_update( op->o_bd, tid, *ctxcsn_e );
+                       ret = bdb_id2entry_update( op->o_bd, tid, &dummy );
                        switch ( ret ) {
                        case 0 :
                                break;
@@ -132,6 +134,7 @@ bdb_csn_commit(
                                rs->sr_text = "context csn update failed";
                                return BDB_CSN_ABORT;
                        }
+                       bdb_cache_modify( *ctxcsn_e, dummy.e_attrs, bdb->bi_dbenv, locker, &ctxcsn_lock );
                }
                break;
        case DB_NOTFOUND:
@@ -159,8 +162,8 @@ bdb_csn_commit(
                        return BDB_CSN_ABORT;
                }
 
-               *ctxcsn_e = slap_create_context_csn_entry( op->o_bd, max_committed_csn );
-               ber_bvfree( max_committed_csn );
+               *ctxcsn_e = slap_create_context_csn_entry( op->o_bd, &max_committed_csn );
+               ch_free( max_committed_csn.bv_val );
                (*ctxcsn_e)->e_id = ctxcsn_id;
                *ctxcsn_added = 1;
 
@@ -266,9 +269,9 @@ bdb_get_commit_csn(
                        struct berval bv;
                        sprintf( substr, "cn=syncrepl%d", op->o_bd->syncinfo->id );
                        ber_str2bv( substr, 0, 0, &bv );
-                       build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &bv );
+                       build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &bv, NULL );
                } else {
-                       build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], (struct berval *)&slap_ldapsync_cn_bv );
+                       build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], (struct berval *)&slap_ldapsync_cn_bv, NULL );
                }
 
 ctxcsn_retry :
@@ -302,9 +305,8 @@ txn_retry:
                                                rs->sr_err = LDAP_OTHER;
                                                return rs->sr_err;
                                        }
-
-                                       bdb_trans_backoff( ++num_retries );
                                        ldap_pvt_thread_yield();
+                                       bdb_trans_backoff( ++num_retries );
                                }
                                rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL, &ltid, bdb->bi_db_opflags );
                                if ( rs->sr_err != 0 ) {
index 7c99c19196c6968602eb03d940cc2fce85cfa8f7..de55018803adae4092c5797411809735433b9c60 100644 (file)
@@ -46,19 +46,14 @@ bdb_db_hash(
 int
 bdb_db_cache(
        Backend *be,
-       DB_TXN *tid,
        const char *name,
        DB **dbout )
 {
        int i;
        int rc;
-       int flags;
        struct bdb_info *bdb = (struct bdb_info *) be->be_private;
        struct bdb_db_info *db;
        char *file;
-       DBT lockobj;
-       DB_LOCK lock;
-       u_int32_t locker = 0;
 
        *dbout = NULL;
 
@@ -69,33 +64,19 @@ bdb_db_cache(
                }
        }
 
-       lockobj.data = "bdb_db_cache";
-       lockobj.size = sizeof("bdb_db_cache");
-
-       if (tid) {
-               locker = TXN_ID( tid );
-       } else {
-#ifdef BDB_REUSE_LOCKERS
-#define        op      NULL    /* implicit arg in LOCK_ID */
-#endif
-               rc = LOCK_ID( bdb->bi_dbenv, &locker );
-               if (rc) return rc;
-       }
-       rc = LOCK_GET( bdb->bi_dbenv, locker, 0, &lockobj,
-               DB_LOCK_WRITE, &lock );
-       if (rc) return rc;
+       ldap_pvt_thread_mutex_lock( &bdb->bi_database_mutex );
 
        /* check again! may have been added by another thread */
        for( i=BDB_NDB; i < bdb->bi_ndatabases; i++ ) {
                if( !strcmp( bdb->bi_databases[i]->bdi_name, name) ) {
                        *dbout = bdb->bi_databases[i]->bdi_db;
-                       LOCK_PUT( bdb->bi_dbenv, &lock);
+                       ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
                        return 0;
                }
        }
 
        if( i >= BDB_INDICES ) {
-               LOCK_PUT( bdb->bi_dbenv, &lock);
+               ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
                return -1;
        }
 
@@ -114,7 +95,7 @@ bdb_db_cache(
                        "bdb_db_cache: db_create(%s) failed: %s (%d)\n",
                        bdb->bi_dbenv_home, db_strerror(rc), rc );
 #endif
-               LOCK_PUT( bdb->bi_dbenv, &lock);
+               ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
                return rc;
        }
 
@@ -129,11 +110,9 @@ bdb_db_cache(
 #ifdef HAVE_EBCDIC
        __atoe( file );
 #endif
-       flags = bdb->bi_db_opflags | DB_CREATE | DB_THREAD;
-       if ( !tid ) flags |= DB_AUTO_COMMIT;
-       rc = DB_OPEN( db->bdi_db, tid,
+       rc = DB_OPEN( db->bdi_db,
                file, NULL /* name */,
-               DB_HASH, flags,
+               DB_HASH, bdb->bi_db_opflags | DB_CREATE | DB_THREAD,
                bdb->bi_dbenv_mode );
 
        ch_free( file );
@@ -148,7 +127,7 @@ bdb_db_cache(
                        "bdb_db_cache: db_open(%s) failed: %s (%d)\n",
                        name, db_strerror(rc), rc );
 #endif
-               LOCK_PUT( bdb->bi_dbenv, &lock);
+               ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
                return rc;
        }
 
@@ -157,6 +136,6 @@ bdb_db_cache(
 
        *dbout = db->bdi_db;
 
-       LOCK_PUT( bdb->bi_dbenv, &lock );
+       ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
        return 0;
 }
index 945099b5ce8a17cdab4d30ebcc1ac5ea2c809595..9acab3aa189d8b30a0081d4fbab07bff613531ce 100644 (file)
@@ -73,8 +73,8 @@ retry:        /* transaction retry */
                        rs->sr_text = "internal error";
                        goto return_results;
                }
-               bdb_trans_backoff( ++num_retries );
                ldap_pvt_thread_yield();
+               bdb_trans_backoff( ++num_retries );
        }
 
        /* begin transaction */
@@ -554,7 +554,7 @@ done:
        if( e != NULL ) {
                if ( rs->sr_err == LDAP_SUCCESS ) {
                        /* Free the EntryInfo and the Entry */
-                       bdb_cache_delete_cleanup( e );
+                       bdb_cache_delete_cleanup( &bdb->bi_cache, e );
                } else {
                        bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
                }
index c3cef02e80d30311594fbb1952be28f90e7887e1..1ea506b676f0cd41c5e070872fa6375f5a6cc723 100644 (file)
@@ -899,26 +899,15 @@ struct dn2id_cookie {
        Operation *op;
 };
 
-/* Stuff for iterating over a bei_kids AVL tree and adding the
- * IDs to an IDL
- */
-struct apply_arg {
-       ID *idl;
-       EntryInfo **ei;
-};
-
 static int
 apply_func(
        void *data,
        void *arg )
 {
        EntryInfo *ei = data;
-       struct apply_arg *ap = arg;
+       ID *idl = arg;
 
-       bdb_idl_insert( ap->idl, ei->bei_id );
-       if ( ap->ei ) {
-               *(ap->ei)++ = ei;
-       }
+       bdb_idl_insert( idl, ei->bei_id );
        return 0;
 }
 
@@ -927,7 +916,6 @@ hdb_dn2idl_internal(
        struct dn2id_cookie *cx
 )
 {
-       EntryInfo **eilist = NULL, **ptr;
 #ifdef SLAP_IDL_CACHE
        if ( cx->bdb->bi_idl_cache_size ) {
                cx->rc = bdb_idl_cache_get(cx->bdb, cx->db, &cx->key, cx->tmp);
@@ -941,13 +929,26 @@ hdb_dn2idl_internal(
 #endif
        BDB_IDL_ZERO( cx->tmp );
 
+       if ( !cx->ei ) {
+               cx->ei = bdb_cache_find_info( cx->bdb, cx->id );
+               if ( !cx->ei ) {
+                       cx->rc = DB_NOTFOUND;
+                       goto saveit;
+               }
+       }
+
+       bdb_cache_entryinfo_lock( cx->ei );
+
        /* If number of kids in the cache differs from on-disk, load
         * up all the kids from the database
         */
        if ( cx->ei->bei_ckids+1 != cx->ei->bei_dkids ) {
                EntryInfo ei;
+               db_recno_t dkids = cx->ei->bei_dkids;
                ei.bei_parent = cx->ei;
 
+               bdb_cache_entryinfo_unlock( cx->ei );
+
                cx->rc = cx->db->cursor( cx->db, NULL, &cx->dbc,
                        cx->bdb->bi_db_opflags );
                if ( cx->rc ) return cx->rc;
@@ -959,27 +960,20 @@ hdb_dn2idl_internal(
 
                /* The first item holds the parent ID. Ignore it. */
                cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data, DB_SET );
-               if ( cx->rc == DB_NOTFOUND ) goto saveit;
-               if ( cx->rc ) return cx->rc;
+               if ( cx->rc ) {
+                       cx->dbc->c_close( cx->dbc );
+                       if ( cx->rc == DB_NOTFOUND ) goto saveit;
+                       return cx->rc;
+               }
 
                /* If the on-disk count is zero we've never checked it.
                 * Count it now.
                 */
-               if ( !cx->ei->bei_dkids ) {
-                       db_recno_t dkids;
+               if ( !dkids ) {
                        cx->dbc->c_count( cx->dbc, &dkids, 0 );
                        cx->ei->bei_dkids = dkids;
                }
 
-               /* If there are kids and this is a subtree search, allocate
-                * temp storage for the list of kids.
-                */
-               if ( cx->prefix == DN_SUBTREE_PREFIX && cx->ei->bei_dkids > 1 ) {
-                       eilist = cx->op->o_tmpalloc( sizeof(EntryInfo *) * cx->ei->bei_dkids, cx->op->o_tmpmemctx );
-                       eilist[cx->ei->bei_dkids-1] = NULL;
-                       ptr = eilist;
-               }
-
                cx->data.data = cx->buf;
                cx->data.ulen = BDB_IDL_UM_SIZE * sizeof(ID);
                cx->data.flags = DB_DBT_USERMEM;
@@ -995,9 +989,11 @@ hdb_dn2idl_internal(
                                if (j) {
                                        EntryInfo *ei2;
                                        diskNode *d = (diskNode *)j;
+                                       short nrlen;
 
                                        AC_MEMCPY( &ei.bei_id, &d->entryID, sizeof(ID) );
-                                       AC_MEMCPY( &ei.bei_nrdn.bv_len, &d->nrdnlen, sizeof(d->nrdnlen) );
+                                       AC_MEMCPY( &nrlen, &d->nrdnlen, sizeof(d->nrdnlen) );
+                                       ei.bei_nrdn.bv_len = nrlen;
                                        /* nrdn/rdn are set in-place.
                                         * hdb_cache_load will copy them as needed
                                         */
@@ -1006,39 +1002,23 @@ hdb_dn2idl_internal(
                                        ei.bei_rdn.bv_val = d->nrdn + ei.bei_nrdn.bv_len + 1;
                                        bdb_idl_insert( cx->tmp, ei.bei_id );
                                        hdb_cache_load( cx->bdb, &ei, &ei2 );
-                                       if ( eilist )
-                                               *ptr++ = ei2;
                                }
                        }
                }
-               cx->dbc->c_close( cx->dbc );
+               cx->rc = cx->dbc->c_close( cx->dbc );
        } else {
                /* The in-memory cache is in sync with the on-disk data.
                 * do we have any kids?
                 */
+               cx->rc = 0;
                if ( cx->ei->bei_ckids > 0 ) {
-                       struct apply_arg ap;
-
-                       /* Temp storage for subtree search */
-                       if ( cx->prefix == DN_SUBTREE_PREFIX ) {
-                               eilist = cx->op->o_tmpalloc( sizeof(EntryInfo *) * cx->ei->bei_dkids, cx->op->o_tmpmemctx );
-                               eilist[cx->ei->bei_dkids-1] = NULL;
-                       }
 
                        /* Walk the kids tree; order is irrelevant since bdb_idl_insert
                         * will insert in sorted order.
                         */
-                       ap.idl = cx->tmp;
-                       ap.ei = eilist;
-                       bdb_cache_entryinfo_lock( cx->ei );
-                       avl_apply( cx->ei->bei_kids, apply_func, &ap, -1, AVL_POSTORDER );
-                       bdb_cache_entryinfo_unlock( cx->ei );
+                       avl_apply( cx->ei->bei_kids, apply_func, cx->tmp, -1, AVL_POSTORDER );
                }
-       }
-
-       /* If we got some records, treat as success */
-       if (!BDB_IDL_IS_ZERO(cx->tmp)) {
-               cx->rc = 0;
+               bdb_cache_entryinfo_unlock( cx->ei );
        }
 
 saveit:
@@ -1049,17 +1029,33 @@ saveit:
 #endif
        ;
 gotit:
-       if ( cx->rc == 0 ) {
-               /* If eilist is NULL, cx->tmp is empty... */
-               if ( cx->prefix == DN_SUBTREE_PREFIX && eilist ) {
-                       bdb_idl_union( cx->ids, cx->tmp );
-                       for (ptr = eilist; *ptr; ptr++) {
-                               cx->ei = *ptr;
-                               cx->id = cx->ei->bei_id;
-                               hdb_dn2idl_internal( cx );
+       if ( !BDB_IDL_IS_ZERO( cx->tmp )) {
+               if ( cx->prefix == DN_SUBTREE_PREFIX ) {
+                       if (cx->ei->bei_state & CACHE_ENTRY_NO_GRANDKIDS) {
+                               bdb_idl_union( cx->ids, cx->tmp );
+                       } else {
+                               ID *save, idcurs;
+                               EntryInfo *ei = cx->ei;
+                               int nokids = 1;
+                               save = cx->op->o_tmpalloc( BDB_IDL_SIZEOF( cx->tmp ),
+                                       cx->op->o_tmpmemctx );
+                               BDB_IDL_CPY( save, cx->tmp );
+                               bdb_idl_union( cx->ids, cx->tmp );
+
+                               idcurs = 0;
+                               for ( cx->id = bdb_idl_first( save, &idcurs );
+                                       cx->id != NOID;
+                                       cx->id = bdb_idl_next( save, &idcurs )) {
+                                       cx->ei = NULL;
+                                       hdb_dn2idl_internal( cx );
+                                       if ( !BDB_IDL_IS_ZERO( cx->tmp ))
+                                               nokids = 0;
+                               }
+                               cx->op->o_tmpfree( save, cx->op->o_tmpmemctx );
+                               if ( nokids ) ei->bei_state |= CACHE_ENTRY_NO_GRANDKIDS;
                        }
-                       cx->op->o_tmpfree( eilist, cx->op->o_tmpmemctx );
                        cx->rc = 0;
+
                } else {
                        BDB_IDL_CPY( cx->ids, cx->tmp );
                }
index c4196495cbf6237fe231d8be60e2239d8f79a801..7916d98442da3ef3b973869a9414b63833f8584d 100644 (file)
@@ -97,7 +97,7 @@ int bdb_index_param(
                return LDAP_INAPPROPRIATE_MATCHING;
        }
 
-       rc = bdb_db_cache( be, NULL, prefixp->bv_val, &db );
+       rc = bdb_db_cache( be, prefixp->bv_val, &db );
 
        if( rc != LDAP_SUCCESS ) {
                return rc;
@@ -159,7 +159,7 @@ static int indexer(
 
        assert( mask );
 
-       rc = bdb_db_cache( op->o_bd, txn, atname->bv_val, &db );
+       rc = bdb_db_cache( op->o_bd, atname->bv_val, &db );
        
        if ( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
index 8a5a468af165e6157970f6833c6d311e00138870..77bb9e91cb7957a24c7e3e8dc2ba2ca9d01185fa 100644 (file)
@@ -93,6 +93,7 @@ bdb_db_init( BackendDB *be )
 
        LDAP_LIST_INIT (&bdb->bi_psearch_list);
 
+       ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
        ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
@@ -397,14 +398,14 @@ bdb_db_open( BackendDB *be )
 #ifdef HAVE_EBCDIC
                strcpy( path, bdbi_databases[i].file );
                __atoe( path );
-               rc = DB_OPEN( db->bdi_db, NULL,
+               rc = DB_OPEN( db->bdi_db,
                        path,
                /*      bdbi_databases[i].name, */ NULL,
                        bdbi_databases[i].type,
                        bdbi_databases[i].flags | flags | DB_AUTO_COMMIT,
                        bdb->bi_dbenv_mode );
 #else
-               rc = DB_OPEN( db->bdi_db, NULL,
+               rc = DB_OPEN( db->bdi_db,
                        bdbi_databases[i].file,
                /*      bdbi_databases[i].name, */ NULL,
                        bdbi_databases[i].type,
@@ -539,6 +540,7 @@ bdb_db_destroy( BackendDB *be )
        ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
        ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
+       ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
 #ifdef SLAP_IDL_CACHE
        if ( bdb->bi_idl_cache_max_size ) {
                ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
index 61cb5f79084eedfdfdb10e333356d3bdf2834bcd..71c80ec79881101a0c14c1468ae9d098866d748d 100644 (file)
@@ -348,8 +348,8 @@ retry:      /* transaction retry */
                        rs->sr_text = "internal error";
                        goto return_results;
                }
-               bdb_trans_backoff( ++num_retries );
                ldap_pvt_thread_yield();
+               bdb_trans_backoff( ++num_retries );
        }
 
        /* begin transaction */
index fe4d2d3ffa14d52cd33c2e5357e76fce932bb562..ff4dab5a725fcb026252b088d93ee3e76a720375 100644 (file)
@@ -92,7 +92,6 @@ retry:        /* transaction retry */
 #else
                Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
 #endif
-
                pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
                while ( pm_list != NULL ) {
                        LDAP_LIST_REMOVE ( pm_list, ps_link );
@@ -110,8 +109,8 @@ retry:      /* transaction retry */
                        rs->sr_text = "internal error";
                        goto return_results;
                }
-               bdb_trans_backoff( ++num_retries );
                ldap_pvt_thread_yield();
+               bdb_trans_backoff( ++num_retries );
        }
 
        /* begin transaction */
@@ -665,7 +664,7 @@ retry:      /* transaction retry */
        }
 
        /* Build target dn and make sure target entry doesn't exist already. */
-       if (!new_dn.bv_val) build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn ); 
+       if (!new_dn.bv_val) build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn, NULL ); 
 
        if (!new_ndn.bv_val) {
                struct berval bv = {0, NULL};
@@ -961,6 +960,7 @@ retry:      /* transaction retry */
        } else {
                char gid[DB_XIDDATASIZE];
 
+               memset( gid, 0, sizeof(gid) );
                snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
                        bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
 
@@ -1052,9 +1052,15 @@ done:
                Modifications *tmp;
                for (; mod; mod=tmp ) {
                        tmp = mod->sml_next;
+                       /* slap_modrdn2mods does things one way,
+                        * slap_mods_opattrs does it differently
+                        */
+                       if ( mod->sml_op != SLAP_MOD_SOFTADD &&
+                               mod->sml_op != LDAP_MOD_DELETE ) break;
                        if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
                        free( mod );
                }
+               slap_mods_free( mod );
        }
 
        /* LDAP v3 Support */
index e8ca8f70f76434e4aa7bc107504b4ce084057a03..890481c123785582aa59c001dbceaf77874478db 100644 (file)
@@ -120,8 +120,8 @@ retry:      /* transaction retry */
                        rs->sr_text = "internal error";
                        goto done;
                }
-               bdb_trans_backoff( ++num_retries );
                ldap_pvt_thread_yield();
+               bdb_trans_backoff( ++num_retries );
        }
 
        /* begin transaction */
index c791c028c9dcfe177da440e37fdbca44f6efa9f5..f9e14ee5604ea8ac435ee4bafeefa42681e57feb 100644 (file)
@@ -55,7 +55,6 @@ int bdb_get_commit_csn LDAP_P(( Operation *op, SlapReply *rs,
 int
 bdb_db_cache(
     Backend    *be,
-    DB_TXN *tid,
     const char *name,
        DB **db );
 
@@ -420,10 +419,12 @@ void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw );
 #define bdb_cache_delete                       BDB_SYMBOL(cache_delete)
 #define bdb_cache_delete_cleanup               BDB_SYMBOL(cache_delete_cleanup)
 #define bdb_cache_find_id                      BDB_SYMBOL(cache_find_id)
+#define bdb_cache_find_info                    BDB_SYMBOL(cache_find_info)
 #define bdb_cache_find_ndn                     BDB_SYMBOL(cache_find_ndn)
 #define bdb_cache_modify                       BDB_SYMBOL(cache_modify)
 #define bdb_cache_modrdn                       BDB_SYMBOL(cache_modrdn)
 #define bdb_cache_release_all          BDB_SYMBOL(cache_release_all)
+#define bdb_cache_delete_entry         BDB_SYMBOL(cache_delete_entry)
 
 int bdb_cache_children(
        Operation *op,
@@ -459,6 +460,10 @@ int bdb_cache_find_ndn(
        struct berval   *ndn,
        EntryInfo       **res
 );
+EntryInfo * bdb_cache_find_info(
+       struct bdb_info *bdb,
+       ID id
+);
 int bdb_cache_find_id(
        Operation *op,
        DB_TXN  *tid,
@@ -476,9 +481,16 @@ int bdb_cache_delete(
        DB_LOCK *lock
 );
 void bdb_cache_delete_cleanup(
+       Cache   *cache,
        Entry   *e
 );
 void bdb_cache_release_all( Cache *cache );
+void bdb_cache_delete_entry(
+       struct bdb_info *bdb,
+       EntryInfo *ei,
+       u_int32_t locker,
+       DB_LOCK *lock
+);
 
 #ifdef BDB_HIER
 int hdb_cache_load(
@@ -497,6 +509,10 @@ int bdb_cache_entry_db_relock(
        int tryOnly,
        DB_LOCK *lock );
 
+int bdb_cache_entry_db_unlock(
+       DB_ENV *env,
+       DB_LOCK *lock );
+
 #ifdef BDB_REUSE_LOCKERS
 
 #define bdb_locker_id                          BDB_SYMBOL(locker_id)
index 93a8714d333da7e171823432c364c5240f704177..2d3f245c50652d4e331a4cb01fcb08d3036ce400 100644 (file)
@@ -1218,7 +1218,10 @@ loop_continue:
                        /* free reader lock */
                        if (!IS_PSEARCH) {
                                bdb_cache_return_entry_r( bdb->bi_dbenv,
-                                       &bdb->bi_cache, e , &lock);
+                                       &bdb->bi_cache, e , &lock );
+                               if ( sop->o_nocaching ) {
+                                       bdb_cache_delete_entry( bdb, ei, locker, &lock );
+                               }
                        }
                        e = NULL;
                        rs->sr_entry = NULL;
index 51fecf418b78f8c9ff79352036a803a0242b7e03..e84bd5242fec6d173fff9220995c64b9cac0cc2b 100644 (file)
@@ -9,6 +9,7 @@
 #include "back-bdb.h"
 #include "external.h"
 #include "lber_pvt.h"
+#include "lutil.h"
 
 
 /* Congestion avoidance code
@@ -25,7 +26,7 @@ bdb_trans_backoff( int num_retries )
        unsigned long max_key = -1;
        struct timeval timeout;
 
-       lutil_entropy( &key, sizeof( unsigned long ));
+       lutil_entropy( (unsigned char *) &key, sizeof( unsigned long ));
 
        for ( i = 0; i < num_retries; i++ ) {
                if ( i >= 5 ) break;
index 7406a93d7e8bcfd5abb8a7230f24d343c765c859..e4a5130b774fccbfa6ea99cdb6b4e1cacf89e932 100644 (file)
@@ -134,7 +134,8 @@ ldbm_back_add(
 
                        ber_bvarray_free( rs->sr_ref );
                        free( (char *)rs->sr_matched );
-
+                       rs->sr_ref = NULL;
+                       rs->sr_matched = NULL;
                        return rs->sr_err;
                }
 
@@ -220,6 +221,8 @@ ldbm_back_add(
 
                        ber_bvarray_free( rs->sr_ref );
                        free( (char *)rs->sr_matched );
+                       rs->sr_ref = NULL;
+                       rs->sr_matched = NULL;
                        return rs->sr_err;
                }
 
@@ -408,6 +411,7 @@ ldbm_back_add(
        }
 
        rs->sr_err = LDAP_SUCCESS;
+       rs->sr_text = NULL;
        send_ldap_result( op, rs );
 
        /* marks the entry as committed, so it is added to the cache;
index 73ab8217d1874b788942a36550c105550eb59b3f..e84935af0ec5ec862a4916005852377a9e7ea399 100644 (file)
@@ -81,6 +81,8 @@ ldbm_back_bind(
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
                if ( rs->sr_matched ) free( (char *)rs->sr_matched );
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return rs->sr_err;
        }
 
@@ -145,7 +147,8 @@ ldbm_back_bind(
                send_ldap_result( op, rs );
 
                ber_bvarray_free( rs->sr_ref );
-
+               rs->sr_matched = NULL;
+               rs->sr_ref = NULL;
                rc = rs->sr_err;
                goto return_results;
        }
index 0f560e59d1f3cc06bdcd9849a46587ee1a99605b..0c41f24477997a4c9a0c9804c1869c6e9d4f2655 100644 (file)
@@ -50,7 +50,8 @@ ldbm_back_compare(
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
                free( (char *)rs->sr_matched );
-
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return( 1 );
        }
 
@@ -72,7 +73,8 @@ ldbm_back_compare(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
-
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                rs->sr_err = 1;
                goto return_results;
        }
index 73ce46668331250d936225a972ebdf7e5cbcacc4..edcfbf5be47a1486b21579261cf6da65884f02f5 100644 (file)
@@ -72,7 +72,8 @@ ldbm_back_delete(
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
                free( (char *)rs->sr_matched );
-
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return( -1 );
        }
 
@@ -115,7 +116,8 @@ ldbm_back_delete(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
-
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                rc = LDAP_REFERRAL;
                goto return_results;
        }
index 1e78935a79e4d5d7c3e58a4bc03d67c7520a2c58..5679f2dadc7ef110b4f8bafc5da45ea28c2f147c 100644 (file)
@@ -153,6 +153,7 @@ int ldbm_modify_internal(
 
                        rc = modify_add_values( e, mod, get_permissiveModify( op ),
                                                text, textbuf, textlen );
+                       mod->sm_op = SLAP_MOD_SOFTADD;
                        if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) {
                                rc = LDAP_SUCCESS;
                        }
@@ -335,6 +336,8 @@ ldbm_back_modify(
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
                free( (char *)rs->sr_matched );
 
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return rs->sr_err;
        }
 
@@ -357,7 +360,8 @@ ldbm_back_modify(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
-
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                goto error_return;
        }
        
@@ -381,6 +385,7 @@ ldbm_back_modify(
                goto error_return;
        }
 
+       rs->sr_text = NULL;
        send_ldap_error( op, rs, LDAP_SUCCESS,
                NULL );
 
@@ -392,5 +397,6 @@ ldbm_back_modify(
 error_return:;
        cache_return_entry_w( &li->li_cache, e );
        ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
+       rs->sr_text = NULL;
        return rs->sr_err;
 }
index 7200a7bc481abc49912a64fac339e0bc56a20df4..99440e9d4545d5f2666c51cc5d602a1324e13cb2 100644 (file)
@@ -104,7 +104,8 @@ ldbm_back_modrdn(
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
                free( (char *)rs->sr_matched );
-
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return rs->sr_err;
        }
 
@@ -146,6 +147,8 @@ ldbm_back_modrdn(
                send_ldap_result( op, rs );
 
                if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                goto return_results;
        }
 
@@ -469,7 +472,7 @@ ldbm_back_modrdn(
        }
        
        /* Build target dn and make sure target entry doesn't exist already. */
-       build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn ); 
+       build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn, NULL ); 
        dnNormalize( 0, NULL, NULL, &new_dn, &new_ndn, NULL );
 
 #ifdef NEW_LOGGING
@@ -633,6 +636,7 @@ ldbm_back_modrdn(
        }
 
        rs->sr_err = LDAP_SUCCESS;
+       rs->sr_text = NULL;
        send_ldap_result( op, rs );
        rc = 0;
        cache_entry_commit( e );
@@ -651,10 +655,16 @@ return_results:
        if ( mod != NULL ) {
                Modifications *tmp;
                for (; mod; mod = tmp ) {
+                       /* slap_modrdn2mods does things one way,
+                        * slap_mods_opattrs does it differently
+                        */
+                       if ( mod->sml_op != SLAP_MOD_SOFTADD &&
+                               mod->sml_op != LDAP_MOD_DELETE ) break;
                        if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
                        tmp = mod->sml_next;
                        free( mod );
                }
+               slap_mods_free( mod );
        }
 
        /* LDAP v3 Support */
@@ -677,5 +687,6 @@ return_results:
                entry_free( e );
        }
        ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
+       rs->sr_text = NULL;
        return( rc );
 }
index 6aedb91e5f294a2ebd11b881e98dd0ce50c28b0d..fc14eb993c51bb9aa223866cdc3ed62ecc8d3aa9 100644 (file)
@@ -79,6 +79,8 @@ ldbm_back_referrals(
                }
 
                if ( rs->sr_matched ) free( (char *)rs->sr_matched );
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return rs->sr_err;
        }
 
@@ -111,6 +113,8 @@ ldbm_back_referrals(
                }
 
                if( refs != NULL ) ber_bvarray_free( refs );
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
        }
 
        cache_return_entry_r( &li->li_cache, e );
index 4a463522085c54b6f25ace591d31aa018a643f4d..8d3949cc67a3760c5ffd2bc61c642c3f7ee999a9 100644 (file)
@@ -111,6 +111,8 @@ ldbm_back_search(
 
                ber_bvarray_free( rs->sr_ref );
                ber_memfree( matched_dn.bv_val );
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return LDAP_REFERRAL;
        }
 
@@ -155,6 +157,8 @@ ldbm_back_search(
                }
 
                ber_memfree( matched_dn.bv_val );
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
                return LDAP_OTHER;
        }
 
index 940ce702cc6f66c52f2442908e544b661673dc0a..2409e54a4027f4ba8554e07ba536d95f19537c78 100644 (file)
@@ -673,6 +673,8 @@ meta_send_entry(
 
        dc.ctx = "searchAttrDN";
        while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
+               int             last = 0;
+
                ldap_back_map( &li->targets[ target ]->rwmap.rwm_at, 
                                &a, &mapped, BACKLDAP_REMAP );
                if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) {
@@ -724,7 +726,6 @@ meta_send_entry(
 
                } else if ( attr->a_desc == slap_schema.si_ad_objectClass
                                || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) {
-                       int             last;
 
                        for ( last = 0; attr->a_vals[ last ].bv_val; ++last );
 
@@ -762,6 +763,25 @@ meta_send_entry(
                        ldap_dnattr_result_rewrite( &dc, attr->a_vals );
                }
 
+               if ( last && attr->a_desc->ad_type->sat_equality &&
+                       attr->a_desc->ad_type->sat_equality->smr_normalize ) {
+                       int i;
+
+                       attr->a_nvals = ch_malloc((last + 1)*sizeof(struct berval));
+                       for ( i = 0; i<last; i++ ) {
+                               attr->a_desc->ad_type->sat_equality->smr_normalize(
+                                       SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+                                       attr->a_desc->ad_type->sat_syntax,
+                                       attr->a_desc->ad_type->sat_equality,
+                                       &attr->a_vals[i], &attr->a_nvals[i],
+                                       op->o_tmpmemctx );
+                       }
+                       attr->a_nvals[i].bv_val = NULL;
+                       attr->a_nvals[i].bv_len = 0;
+               } else {
+                       attr->a_nvals = attr->a_vals;
+               }
+
                *attrp = attr;
                attrp = &attr->a_next;
        }
index b17e7cdfb5a8669a7d07452701511b96cb375b9f..88aaf6e79efa77c88993ded1c11d4cf38e549906 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index a09825de7ffc2fadfa621321ab28df1bb17665fd..b495b7ceb96eeaa3c8821dd59abb382b4d9ab083 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index 2e3252c3c1a12bed75f64500bc3b04cece67bf3a..30afe22994dd6af3aae9d8c13b8709b8e3d4619d 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index 1dfcb125f57f5b26256f63264623e28cf7bbb45f..4cb871461a7234cbe826b9c76508a6eab4c93481 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index ed9b9617113b2b92c5e0b18875d994a003ac45ac..63878e1d9b42b96720967dff6c46b21fac5d1e7d 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index 9bc51264686ff80073eae10ff08a0acd760d4aa3..9a812f479e09a37c51e91db57144c595a1d99a6e 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index 5f4bec4375edc27edec93a6a860da2c20935d036..1c8a2616eb3c617589a094460872f82789210448 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index f77f3087525a73df3f4362acbef19dcb9b18deed..fa6a89f21bdc2def6425a893c800a855604e83bd 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index 2befbb6ee7c8ff4669ffc14122a34302c582944d..704d25b3f0bd7f8b36f9d8ed7dc0f64f47b554e6 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index 50230e6efc4d6595d542387fe36d39e87c6ce412..2cf30dcd4bfb283e5ee5734aaddde78931c6eab7 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <EXTERN.h>
 #include <perl.h>
-#undef _ /* #defined used by both Perl and ac/localize.h */
+#undef _ /* #defined by both Perl and ac/localize.h */
 
 #ifdef HAVE_WIN32_ASPERL
 #include "asperl_undefs.h"
index 152165fa875384769dce80a0d2cc517ad35742ce..ce587646a973262dab90d88be8736521cfe21ede 100644 (file)
@@ -679,7 +679,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                goto modrdn_return;
        }
 
-       build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn );
+       build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn, NULL );
        rs->sr_err = dnNormalize( 0, NULL, NULL, &new_dn, &new_ndn,
                op->o_tmpmemctx );
        if ( rs->sr_err != LDAP_SUCCESS ) {
index f0adee39b08cd7304cae2768466c12e85074e11c..7458a2b910be7914833aa963d4579ea08840209c 100644 (file)
@@ -336,6 +336,23 @@ int backend_startup(Backend *be)
 
        /* open each backend database */
        for( i = 0; i < nBackendDB; i++ ) {
+               if ( backendDB[i].be_update_ndn.bv_val && (
+                       !backendDB[i].be_update_refs &&
+                       !backendDB[i].syncinfo &&
+                       !default_referral ) ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG( BACKEND, CRIT, 
+                               "backend_startup: slave \"%s\" updateref missing\n",
+                               backendDB[i].be_suffix[0].bv_val, 0, 0 );
+                               
+#else
+                       Debug( LDAP_DEBUG_ANY,
+                               "backend_startup: slave \"%s\" updateref missing\n",
+                               backendDB[i].be_suffix[0].bv_val, 0, 0 );
+#endif
+                       return -1;
+               }
+
                /* append global access controls */
                acl_append( &backendDB[i].be_acl, global_acl );
 
@@ -607,7 +624,8 @@ select_backend(
                                if( be == NULL ) {
                                        be = &backends[i];
 
-                                       if( manageDSAit && len == dnlen ) {
+                                       if( manageDSAit && len == dnlen &&
+                                               !SLAP_GLUE_SUBORDINATE( be ) ) {
                                                continue;
                                        }
                                } else {
@@ -1177,6 +1195,7 @@ backend_group(
 
        if ( target && dn_match( &target->e_nname, gr_ndn ) ) {
                e = target;
+               rc = 0;
        } else {
                rc = be_entry_get_rw(op, gr_ndn, group_oc, group_at, 0, &e );
        }
index 29edb8470c3615e61741752376c611ad166d173a..bb13448a46acb76a465d4f954e32d54abe993679 100644 (file)
@@ -165,7 +165,7 @@ over_op_func(
        BI_op_bind **func;
        BackendDB *be = op->o_bd, db = *op->o_bd;
        slap_callback cb = {over_back_response, NULL};
-       int rc = 0;
+       int rc = SLAP_CB_CONTINUE;
 
        op->o_bd = &db;
        cb.sc_private = op->o_callback;
@@ -176,15 +176,18 @@ over_op_func(
                if ( func[which] ) {
                        db.bd_info = (BackendInfo *)on;
                        rc = func[which]( op, rs );
-                       if ( rc ) break;
+                       if ( rc != SLAP_CB_CONTINUE ) break;
                }
        }
 
        func = &oi->oi_bd.bd_info->bi_op_bind;
-       if ( func[which] ) {
+       if ( func[which] && rc == SLAP_CB_CONTINUE ) {
                rc = func[which]( op, rs );
        }
-
+       /* should not fall thru this far without anything happening... */
+       if ( rc == SLAP_CB_CONTINUE ) {
+               rc = LDAP_UNWILLING_TO_PERFORM;
+       }
        op->o_bd = be;
        return rc;
 }
@@ -321,7 +324,7 @@ overlay_config( BackendDB *be, const char *ov )
         */
        oi = (slap_overinfo *) be->bd_info;
        for ( prev=NULL, on2 = oi->oi_list; on2; prev=on2, on2=on2->on_next );
-       on2 = ch_malloc( sizeof(slap_overinst) );
+       on2 = ch_calloc( 1, sizeof(slap_overinst) );
        if ( !prev ) {
                oi->oi_list = on2;
        } else {
@@ -329,6 +332,7 @@ overlay_config( BackendDB *be, const char *ov )
        }
        *on2 = *on;
        on2->on_next = NULL;
+       on2->on_info = oi;
 
        /* Any initialization needed? */
        if ( on->on_bi.bi_db_init ) {
index 0d87e303ed5a94733f1fe4e260b998caf9ad219c..b4095cf56bfd76c42bacc91a6e3aa17eb9b8eb46 100644 (file)
@@ -47,6 +47,7 @@ do_bind(
 
 #ifdef LDAP_SLAPI
        Slapi_PBlock *pb = op->o_pb;
+       int rc;
 #endif
 
 #ifdef NEW_LOGGING
@@ -526,8 +527,9 @@ do_bind(
        slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
        slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
+       slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
 
-       rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
+       rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
 
 #ifdef NEW_LOGGING
        LDAP_LOG( OPERATION, INFO,
@@ -539,7 +541,7 @@ do_bind(
                rs->sr_err, 0, 0);
 #endif
 
-       switch ( rs->sr_err ) {
+       switch ( rc ) {
        case SLAPI_BIND_SUCCESS:
                /* Continue with backend processing */
                break;
@@ -552,7 +554,7 @@ do_bind(
        case SLAPI_BIND_ANONYMOUS:
                /* SLAPI_BIND_ANONYMOUS is undocumented XXX */
        default:
-               /* Authoritative, plugin sent result */
+               /* Authoritative, plugin sent result, or no plugins called. */
                if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
                        (void *)&rs->sr_err) != 0 )
                {
@@ -564,7 +566,12 @@ do_bind(
 
                if ( rs->sr_err == LDAP_SUCCESS ) {
                        slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val );
-                       if ( op->orb_edn.bv_val != NULL ) {
+                       if ( op->orb_edn.bv_val == NULL ) {
+                               if ( rc == 1 ) {
+                                       /* No plugins were called; continue. */
+                                       break;
+                               }
+                       } else {
                                op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
                        }
                        rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
index e7effae3468768ec2ce5adedc1c40733959c3cc3..731f46bc8cc764f31d55bcfe9a66cd740be0ae0d 100644 (file)
@@ -193,6 +193,9 @@ int connections_timeout_idle(time_t now)
                c != NULL;
                c = connection_next( c, &connindex ) )
        {
+               /* Don't timeout a slow-running request */
+               if( c->c_n_ops_executing ) continue;
+
                if( difftime( c->c_activitytime+global_idletimeout, now) < 0 ) {
                        /* close it */
                        connection_closing( c );
@@ -1079,9 +1082,6 @@ operations_error:
 
        ldap_pvt_thread_mutex_lock( &conn->c_mutex );
 
-       conn->c_n_ops_executing--;
-       conn->c_n_ops_completed++;
-
        LDAP_STAILQ_REMOVE( &conn->c_ops, op, slap_op, o_next);
        LDAP_STAILQ_NEXT(op, o_next) = NULL;
 
@@ -1094,6 +1094,8 @@ operations_error:
 
 co_op_free:
 
+       conn->c_n_ops_executing--;
+       conn->c_n_ops_completed++;
        memctx = NULL;
        ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx );
        slap_op_free( op );
index bcf7a4f687ce222ba3f03ea016f278cd059535b7..459fc35583ada37470dfb31dd1414fc9d53dce72 100644 (file)
 #include "slap.h"
 #include "lutil_ldap.h"
 
-struct berval *
-slap_get_commit_csn( Operation *op )
+const struct berval slap_ldapsync_bv = BER_BVC("ldapsync");
+const struct berval slap_ldapsync_cn_bv = BER_BVC("cn=ldapsync");
+
+void
+slap_get_commit_csn( Operation *op, struct berval *csn )
 {
-       struct berval *max_committed_csn = NULL;
        struct slap_csn_entry *csne = NULL, *committed_csne = NULL;
        int i = 0;
 
+       csn->bv_val = NULL;
+       csn->bv_len = 0;
+
        ldap_pvt_thread_mutex_lock( &op->o_bd->be_pcl_mutex );
 
        LDAP_TAILQ_FOREACH( csne, &op->o_bd->be_pending_csn_list, csn_link ) {
@@ -61,10 +66,8 @@ slap_get_commit_csn( Operation *op )
        ldap_pvt_thread_mutex_unlock( &op->o_bd->be_pcl_mutex );
 
        if ( committed_csne ) {
-               max_committed_csn = ber_dupbv( NULL, committed_csne->csn );
+               ber_dupbv( csn, committed_csne->csn );
        }
-
-       return max_committed_csn;
 }
 
 void
@@ -91,6 +94,12 @@ slap_graduate_commit_csn( Operation *op )
 {
        struct slap_csn_entry *csne = NULL;
 
+       if ( op == NULL )
+               return;
+
+       if ( op->o_bd == NULL )
+               return;
+
        ldap_pvt_thread_mutex_lock( &op->o_bd->be_pcl_mutex );
 
        LDAP_TAILQ_FOREACH( csne, &op->o_bd->be_pending_csn_list, csn_link ) {
@@ -132,12 +141,9 @@ slap_create_context_csn_entry(
 
        attr_merge( e, slap_schema.si_ad_objectClass, ocbva, NULL );
 
-       bv.bv_val = "subentry";
-       bv.bv_len = sizeof("subentry")-1;
-
-       attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &bv, NULL );
+       attr_merge_one( e, slap_schema.si_ad_structuralObjectClass, &ocbva[1], NULL );
 
-       attr_merge_one( e, slap_schema.si_ad_cn, &slap_ldapsync_bv, NULL );
+       attr_merge_one( e, slap_schema.si_ad_cn, (struct berval *)&slap_ldapsync_bv, NULL );
 
        if ( context_csn ) {
                attr_merge_one( e, slap_schema.si_ad_contextCSN,
@@ -148,7 +154,7 @@ slap_create_context_csn_entry(
        bv.bv_len = sizeof("{}")-1;
        attr_merge_one( e, slap_schema.si_ad_subtreeSpecification, &bv, NULL );
 
-       build_new_dn( &e->e_name, &be->be_nsuffix[0], &slap_ldapsync_cn_bv );
+       build_new_dn( &e->e_name, &be->be_nsuffix[0], (struct berval *)&slap_ldapsync_cn_bv, NULL );
        ber_dupbv( &e->e_nname, &e->e_name );
 
        return e;
@@ -179,13 +185,13 @@ slap_get_csn(
 {
        struct  slap_csn_entry *pending;
 
+       if ( csn == NULL )
+               return LDAP_OTHER;
+
        if ( manage_ctxcsn ) {
                pending = (struct slap_csn_entry *) ch_calloc( 1, sizeof( struct slap_csn_entry ));
        }
 
-       if ( csn == NULL )
-               return LDAP_OTHER;
-
        csn->bv_len = lutil_csnstr( csnbuf, len, 0, 0 );
        csn->bv_val = csnbuf;
 
index be518eec58d58a8d9db1d0706d2f2515a121311a..5696dbf837f1ebcb2ac3b2c4fa3cc2bf6f494ce3 100644 (file)
 #include <ac/string.h>
 #include <ac/time.h>
 
-#include "ldap_pvt.h"
-
 #include "slap.h"
-
+#include "ldap_pvt.h" /* must be after slap.h, to get ldap_bv2dn_x() & co */
 #include "lutil.h"
 
 /*
@@ -819,7 +817,8 @@ rdnValidate( struct berval *rdn )
 void
 build_new_dn( struct berval * new_dn,
        struct berval * parent_dn,
-       struct berval * newrdn )
+       struct berval * newrdn,
+       void *memctx )
 {
        char *ptr;
 
@@ -829,7 +828,7 @@ build_new_dn( struct berval * new_dn,
        }
 
        new_dn->bv_len = parent_dn->bv_len + newrdn->bv_len + 1;
-       new_dn->bv_val = (char *) ch_malloc( new_dn->bv_len + 1 );
+       new_dn->bv_val = (char *) sl_malloc( new_dn->bv_len + 1, memctx );
 
        ptr = lutil_strcopy( new_dn->bv_val, newrdn->bv_val );
        *ptr++ = ',';
index d634b6850dd8122d61e07fd8ff11eb02145168b6..c998615157e26ecba92ba9cf9732d4a7bc674d80 100644 (file)
@@ -26,6 +26,11 @@ static int   get_ssa(
        SubstringsAssertion **s,
        const char **text );
 
+static int filter_escape_value_x(
+       struct berval *in,
+       struct berval *out,
+       void *ctx );
+
 static void simple_vrFilter2bv(
        Operation *op,
        ValuesReturnFilter *f,
@@ -854,7 +859,7 @@ filter2bv( Filter *f, struct berval *fstr )
        filter2bv_x( &op, f, fstr );
 }
 
-int
+static int
 filter_escape_value_x(
        struct berval *in,
        struct berval *out,
index f21065908fd8a4e2ce1f934fdbf21a8ff3b15026..fdc4c823a2a86df9d5393169368e6c80f6ecfd0e 100644 (file)
@@ -25,7 +25,3 @@ const struct berval slap_unknown_bv = BER_BVC("unknown");
 /* normalized boolean values */
 const struct berval slap_true_bv = BER_BVC("TRUE");
 const struct berval slap_false_bv = BER_BVC("FALSE");
-
-/* ldapsync items */
-const struct berval slap_ldapsync_bv = BER_BVC("ldapsync");
-const struct berval slap_ldapsync_cn_bv = BER_BVC("cn=ldapsync");
diff --git a/servers/slapd/overlays/README b/servers/slapd/overlays/README
new file mode 100644 (file)
index 0000000..b76594c
--- /dev/null
@@ -0,0 +1,23 @@
+# $OpenLDAP$
+
+This directory is still a work in progress. As such, no explicit makefile
+is provided.
+
+The overlays are meant to be built as dynamically loaded modules.
+To build a particular overlay, use commands of this form:
+
+       libtool --mode=compile cc -I../../../include -I.. -c dyngroup.c
+       libtool --mode=link cc -rpath /module/executable/path \
+               -module -o dyngroup.la dyngroup.lo
+
+To use the dyngroup overlay on a backend, set slapd.conf as follows:
+
+       moduleload /module/executable/path/dyngroup.la
+
+       database bdb
+       ... (BDB configuration)
+       overlay dyngroup
+       attrpair member memberurl
+
+Replace "/module/executable/path" with the full pathname of the directory
+where the module will be installed.
diff --git a/servers/slapd/overlays/dyngroup.c b/servers/slapd/overlays/dyngroup.c
new file mode 100644 (file)
index 0000000..c351065
--- /dev/null
@@ -0,0 +1,156 @@
+/* dyngroup.c - Demonstration of overlay code */
+/* $OpenLDAP$ */
+/*
+ * Copyright 2003 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*
+ * Copyright 2003, Howard Chu, All rights reserved. <hyc@symas.com>
+ * 
+ * Permission is granted to anyone to use this software for any purpose
+ * on any computer system, and to alter it and redistribute it, subject
+ * to the following restrictions:
+ * 
+ * 1. The author is not responsible for the consequences of use of this
+ *    software, no matter how awful, even if they arise from flaws in it.
+ * 
+ * 2. The origin of this software must not be misrepresented, either by
+ *    explicit claim or by omission.  Since few users ever read sources,
+ *    credits should appear in the documentation.
+ * 
+ * 3. Altered versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.  Since few users
+ *    ever read sources, credits should appear in the documentation.
+ * 
+ * 4. This notice may not be removed or altered.
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+
+/* This overlay extends the Compare operation to detect members of a
+ * dynamic group. It has no effect on any other operations. It must
+ * be configured with a pair of attributes to trigger on, e.g.
+ *     attrpair member memberURL
+ * will cause compares on "member" to trigger a compare on "memberURL".
+ */
+
+typedef struct adpair {
+       struct adpair *ap_next;
+       AttributeDescription *ap_mem;
+       AttributeDescription *ap_uri;
+} adpair;
+
+static int
+dyngroup_response( Operation *op, SlapReply *rs )
+{
+       slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
+       adpair *ap = on->on_bi.bi_private;
+
+       /* If we've been configured and the current response is
+        * what we're looking for...
+        */
+       if ( ap && op->o_tag == LDAP_REQ_COMPARE &&
+               rs->sr_err == LDAP_NO_SUCH_ATTRIBUTE ) {
+
+               for (;ap;ap=ap->ap_next) {
+                       if ( op->oq_compare.rs_ava->aa_desc == ap->ap_mem ) {
+                               /* This compare is for one of the attributes we're
+                                * interested in. We'll use slapd's existing dyngroup
+                                * evaluator to get the answer we want.
+                                */
+                               int cache = op->o_do_not_cache;
+                               
+                               op->o_do_not_cache = 1;
+                               if ( backend_group( op, NULL, &op->o_req_ndn,
+                                       &op->oq_compare.rs_ava->aa_value, NULL, ap->ap_uri ) == 0 )
+                                       rs->sr_err = LDAP_COMPARE_TRUE;
+                               op->o_do_not_cache = cache;
+                               break;
+                       }
+               }
+       }
+       /* Default is to just fall through to the normal processing */
+       return SLAP_CB_CONTINUE;
+}
+
+static int dyngroup_config(
+    BackendDB  *be,
+    const char *fname,
+    int                lineno,
+    int                argc,
+    char       **argv
+)
+{
+       slap_overinst *on = (slap_overinst *) be->bd_info;
+       adpair ap = { NULL, NULL, NULL }, *a2;
+
+       if ( strcasecmp( argv[0], "attrpair" ) == 0 ) {
+               const char *text;
+               if ( argc != 3 ) {
+                       Debug( LDAP_DEBUG_ANY,
+               "%s: line %d: attribute description missing in \"attrpair <member-attribute> <URL-attribute>\" line.\n",
+                       fname, lineno, 0 );
+                       return( 1 );
+               }
+               if ( slap_str2ad( argv[1], &ap.ap_mem, &text ) ) {
+                       Debug( LDAP_DEBUG_ANY,
+               "%s: line %d: attribute description unknown \"attrpair\" line: %s.\n",
+                       fname, lineno, text );
+                       return( 1 );
+               }
+               if ( slap_str2ad( argv[2], &ap.ap_uri, &text ) ) {
+                       Debug( LDAP_DEBUG_ANY,
+               "%s: line %d: attribute description unknown \"attrpair\" line: %s.\n",
+                       fname, lineno, text );
+                       return( 1 );
+               }
+               /* The on->on_bi.bi_private pointer can be used for
+                * anything this instance of the overlay needs.
+                */
+
+               a2 = ch_malloc( sizeof(adpair) );
+               a2->ap_next = on->on_bi.bi_private;
+               a2->ap_mem = ap.ap_mem;
+               a2->ap_uri = ap.ap_uri;
+               on->on_bi.bi_private = a2;
+       }
+       return 0;
+}
+
+static int
+dyngroup_close(
+       BackendDB *be
+)
+{
+       slap_overinst *on = (slap_overinst *) be->bd_info;
+       adpair *ap, *a2;
+
+       for ( ap = on->on_bi.bi_private; ap; ap = a2 ) {
+               a2 = ap->ap_next;
+               ch_free( ap );
+       }
+       return 0;
+}
+
+static slap_overinst dyngroup;
+
+/* This overlay is set up for dynamic loading via moduleload. For static
+ * configuration, you'll need to arrange for the slap_overinst to be
+ * initialized and registered by some other function inside slapd.
+ */
+
+int init_module(int argc, char *argv[]) {
+       dyngroup.on_bi.bi_type = "dyngroup";
+       dyngroup.on_bi.bi_db_config = dyngroup_config;
+       dyngroup.on_bi.bi_db_close = dyngroup_close;
+       dyngroup.on_response = dyngroup_response;
+
+       return overlay_register( &dyngroup );
+}
index 47803caa77330f5407f346b8c330700dbbc7f977..ed3762dd6f2038cda17fb7d347f8b8e411badf28 100644 (file)
@@ -358,7 +358,7 @@ LDAP_SLAPD_F (ContentRule *) cr_bvfind LDAP_P((
  * ctxcsn.c
  */
 
-LDAP_SLAPD_F (struct berval *) slap_get_commit_csn LDAP_P(( Operation * ));
+LDAP_SLAPD_F (void) slap_get_commit_csn LDAP_P(( Operation *, struct berval * ));
 LDAP_SLAPD_F (void) slap_rewind_commit_csn LDAP_P(( Operation * ));
 LDAP_SLAPD_F (void) slap_graduate_commit_csn LDAP_P(( Operation * ));
 LDAP_SLAPD_F (Entry *) slap_create_context_csn_entry LDAP_P(( Backend *, struct berval *));
@@ -427,7 +427,8 @@ LDAP_SLAPD_F (int) dn_rdnlen LDAP_P(( Backend *be, struct berval *dn ));
 LDAP_SLAPD_F (void) build_new_dn LDAP_P((
        struct berval * new_dn,
        struct berval * parent_dn,
-       struct berval * newrdn ));
+       struct berval * newrdn,
+       void *memctx ));
 
 LDAP_SLAPD_F (void) dnParent LDAP_P(( struct berval *dn, struct berval *pdn ));
 
index c4311df7363513904964028e15ba06d5444a5a44..08ddfda50f913cacdc873e450f6a35f8f99784e0 100644 (file)
@@ -372,8 +372,8 @@ send_ldap_response(
 
 #ifdef LDAP_SLAPI
        slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
-       slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, ( rs->sr_matched != NULL ) ? (void *)ch_strdup( rs->sr_matched ) : NULL );
-       slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, ( rs->sr_text != NULL ) ? (void *)ch_strdup( rs->sr_text ) : NULL );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
 #endif /* LDAP_SLAPI */
 
        ldap_pvt_thread_mutex_lock( &num_sent_mutex );
@@ -487,6 +487,20 @@ slap_send_ldap_result( Operation *op, SlapReply *rs )
                }
        }
 
+#ifdef LDAP_SLAPI
+       /*
+        * Call pre-result plugins. To avoid infinite recursion plugins
+        * should just set SLAPI_RESULT_CODE rather than sending a
+        * result if they wish to change the result.
+        */
+       slapi_x_pblock_set_operation( op->o_pb, op );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
+       slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
+
+       (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb );
+#endif /* LDAP_SLAPI */
+
        if ( op->o_protocol < LDAP_VERSION3 ) {
                tmp = v2ref( rs->sr_ref, rs->sr_text );
                rs->sr_text = tmp;
index 0cee21b3ddf4c24ac262107701b79d09d93eb357..30465dffdd4ab2e90162ce0559dbcd5d531e6207 100644 (file)
@@ -1981,6 +1981,7 @@ typedef struct slap_op {
        ValuesReturnFilter *o_vrFilter; /* ValuesReturnFilter */
 
        syncinfo_t*     o_si;
+       int o_nocaching;
 
 #ifdef LDAP_SLAPI
        void    *o_pb;                  /* NS-SLAPI plugin */
index d93f9d9fd2bf0fa7844f04b40a4314f4f8e29f6a..d803f02f80643e75d7e6701f4820bc7fac2b7eaf 100644 (file)
@@ -9,7 +9,6 @@
 ## written consent of IBM 
 
 LIBRARY = libslapi.la
-#XLIBRARY = libtmpslapd.a
 
 #all-common: $(LIBRARY) $(PROGRAMS)
 #      @touch plugin.c slapi_pblock.c slapi_utils.c slapi_ops.c slapi_ext.c
@@ -36,8 +35,6 @@ NT_LINK_LIBS = $(AC_LIBS)
 XINCPATH = -I$(srcdir)/.. -I$(srcdir)
 XDEFS = $(MODULES_CPPFLAGS)
 
-#UNIX_LINK_LIBS = ./libtmpslapd.a ../libbackends.a ../../../libraries/libavl/libavl.a ../../../libraries/liblber/.libs/liblber.a ../../../libraries/libldbm/libldbm.a ../../../libraries/libldif/libldif.a ../../../libraries/liblutil/liblutil.a ../../../libraries/liblunicode/liblunicode.a ../../../libraries/libldap_r/.libs/libldap_r.a ./libtmpslapd.a
-
 BUILD_MOD = @BUILD_SLAPI@
 
 install-local: FORCE
index b4e99b988446e07952270cf630d1a04d76bff67c..1814498ef62ce9f3b81699f3d52a6cc29846fe12 100644 (file)
@@ -60,6 +60,7 @@ newPlugin(
        char *argv[] ) 
 {
        Slapi_PBlock    *pPlugin = NULL; 
+       Slapi_PluginDesc *pPluginDesc = NULL;
        lt_dlhandle     hdLoadHandle;
        int             rc;
 
@@ -70,28 +71,37 @@ newPlugin(
        }
 
        rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)type );
-       if ( rc != LDAP_SUCCESS ) {
+       if ( rc != 0 ) {
                goto done;
        }
 
        rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGC, (void *)argc );
-       if ( rc != LDAP_SUCCESS ) {
+       if ( rc != 0 ) {
                goto done;
        }
 
        rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGV, (void *)argv );
-       if ( rc != LDAP_SUCCESS ) { 
+       if ( rc != 0 ) { 
                goto done;
        }
 
        rc = loadPlugin( pPlugin, path, initfunc, TRUE, NULL, &hdLoadHandle );
        if ( rc != 0 ) {
-               rc = LDAP_OTHER;
                goto done;
        }
 
+       if ( slapi_pblock_get( pPlugin, SLAPI_PLUGIN_DESCRIPTION, (void **)&pPluginDesc ) == 0 &&
+            pPluginDesc != NULL ) {
+               slapi_log_error(SLAPI_LOG_TRACE, "newPlugin",
+                               "Registered plugin %s %s [%s] (%s)\n",
+                               pPluginDesc->spd_id,
+                               pPluginDesc->spd_version,
+                               pPluginDesc->spd_vendor,
+                               pPluginDesc->spd_description);
+       }
+
 done:
-       if ( rc != LDAP_SUCCESS && pPlugin != NULL ) {
+       if ( rc != 0 && pPlugin != NULL ) {
                slapi_pblock_destroy( pPlugin );
                pPlugin = NULL;
        }
index f607a17d63a6f36b57277d2b5cb275747f652677..8fc2edd62c8b39571cf000590e965a75a16bc24c 100644 (file)
@@ -156,6 +156,9 @@ extern char * slapi_esc_dn_normalize( char *dn );
 extern char * slapi_esc_dn_normalize_case( char *dn );
 extern int slapi_dn_isroot( Slapi_PBlock *pb, char *dn );
 extern int slapi_dn_issuffix( char *dn, char *suffix );
+char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
+char *slapi_dn_parent( const char *dn );
+int slapi_dn_isparent( const char *parentdn, const char *childdn );
 extern char *slapi_dn_ignore_case( char *dn );
 extern char *slapi_get_hostname();
 extern void slapi_register_supported_saslmechanism( char *mechanism );
@@ -165,6 +168,9 @@ extern int slapi_send_ldap_extended_response(Connection *conn, Operation *op,
                        int errornum, char *respName, struct berval *response);
 extern int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e, 
                        LDAPControl **ectrls, char **attrs, int attrsonly ); 
+extern int slapi_send_ldap_search_reference( Slapi_PBlock *pb, Slapi_Entry *e,
+       struct berval **references, LDAPControl **ectrls, struct berval **v2refs );
+
 extern void slapi_register_supported_control(char *controloid, 
                                        unsigned long controlops);
 extern int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp);
index 546a241581e6a668547ee43c36013708595114de..000f8011671c2efef0171f24aab234b042aa73de 100644 (file)
@@ -268,7 +268,7 @@ static int
 set( Slapi_PBlock *pb, int param, void *val ) 
 {
 #if defined(LDAP_SLAPI)
-       int i;
+       int i, freeit;
 
        if ( isValidParam( pb, param ) == INVALID_PARAM ) {
                return PBLOCK_ERROR;
@@ -281,6 +281,17 @@ set( Slapi_PBlock *pb, int param, void *val )
                return PBLOCK_ERROR; 
        }
 
+       switch ( param ) {
+        case SLAPI_CONN_DN:
+        case SLAPI_CONN_AUTHMETHOD:
+        case SLAPI_IBM_CONN_DN_ALT:
+        case SLAPI_IBM_CONN_DN_ORIG:
+        case SLAPI_RESULT_TEXT:
+        case SLAPI_RESULT_MATCHED:
+               freeit = 1; break;
+       default:
+               freeit = 0; break;
+       }
        for( i = 0; i < pb->numParams; i++ ) { 
                if ( pb->curParams[i] == param ) {
                        break;
@@ -291,6 +302,7 @@ set( Slapi_PBlock *pb, int param, void *val )
                pb->curParams[i] = param;
                pb->numParams++;
        }
+       if ( freeit ) ch_free( pb->curVals[i] );
        pb->curVals[i] = val;
 
        unLock( pb );   
index 1bc731129214ed72a11406509a3e1f6325407085..4ed0816fd42af8c09fc1d5a4a94356e176296a54 100644 (file)
 #include <slap.h>
 #include <slapi.h>
 
-#ifdef _SPARC  
-#include <sys/systeminfo.h>
-#endif
-
 #include <netdb.h>
 
 /*
@@ -922,6 +918,139 @@ slapi_dn_issuffix(
 #endif /* LDAP_SLAPI */
 }
 
+int
+slapi_dn_isparent(
+       const char      *parentdn,
+       const char      *childdn )
+{
+#ifdef LDAP_SLAPI
+       struct berval   assertedParentDN, normalizedAssertedParentDN;
+       struct berval   childDN, normalizedChildDN;
+       struct berval   normalizedParentDN;
+       int             match;
+
+       assert( parentdn != NULL );
+       assert( childdn != NULL );
+
+       assertedParentDN.bv_val = (char *)parentdn;
+       assertedParentDN.bv_len = strlen( parentdn );
+
+       if ( dnNormalize( 0, NULL, NULL, &assertedParentDN,
+               &normalizedAssertedParentDN, NULL ) != LDAP_SUCCESS )
+       {
+               return 0;
+       }
+
+       childDN.bv_val = (char *)childdn;
+       childDN.bv_len = strlen( childdn );
+
+       if ( dnNormalize( 0, NULL, NULL, &childDN,
+               &normalizedChildDN, NULL ) != LDAP_SUCCESS )
+       {
+               slapi_ch_free( (void **)&normalizedAssertedParentDN.bv_val );
+               return 0;
+       }
+
+       dnParent( &normalizedChildDN, &normalizedParentDN );
+
+       if ( dnMatch( &match, 0, slap_schema.si_syn_distinguishedName, NULL,
+               &normalizedParentDN, (void *)&normalizedAssertedParentDN ) != LDAP_SUCCESS )
+       {
+               match = -1;
+       }
+
+       slapi_ch_free( (void **)&normalizedAssertedParentDN.bv_val );
+       slapi_ch_free( (void **)&normalizedChildDN.bv_val );
+
+       return ( match == 0 );
+#else
+       return 0;
+#endif /* LDAP_SLAPI */
+}
+
+/*
+ * Returns DN of the parent entry, or NULL if the DN is
+ * an empty string or NULL, or has no parent.
+ */
+char *
+slapi_dn_parent( const char *_dn )
+{
+#ifdef LDAP_SLAPI
+       struct berval   dn, prettyDN;
+       struct berval   parentDN;
+
+       if ( _dn == NULL ) {
+               return NULL;
+       }
+
+       dn.bv_val = (char *)_dn;
+       dn.bv_len = strlen( _dn );
+
+       if ( dn.bv_len == 0 ) {
+               return NULL;
+       }
+
+       if ( dnPretty( NULL, &dn, &prettyDN, NULL ) != LDAP_SUCCESS ) {
+               return NULL;
+       }
+
+       dnParent( &prettyDN, &parentDN ); /* in-place */
+
+       slapi_ch_free( (void **)&prettyDN.bv_val );
+
+       if ( parentDN.bv_len == 0 ) {
+               return NULL;
+       }
+
+       return slapi_ch_strdup( parentDN.bv_val );
+#else
+       return NULL;
+#endif /* LDAP_SLAPI */
+}
+
+/*
+ * Returns DN of the parent entry; or NULL if the DN is
+ * an empty string, if the DN has no parent, or if the
+ * DN is the suffix of the backend database
+ */
+char *slapi_dn_beparent( Slapi_PBlock *pb, const char *_dn )
+{
+#ifdef LDAP_SLAPI
+       Backend         *be;
+       struct berval   dn, prettyDN;
+       struct berval   normalizedDN, parentDN;
+
+       if ( slapi_pblock_get( pb, SLAPI_BACKEND, (void **)&be ) != 0 )
+               be = NULL;
+
+       dn.bv_val = (char *)_dn;
+       dn.bv_len = strlen( _dn );
+
+       if ( dnPrettyNormal( NULL, &dn, &prettyDN, &normalizedDN, NULL ) != LDAP_SUCCESS ) {
+               return NULL;
+       }
+
+       if ( be != NULL && be_issuffix( be, &normalizedDN ) ) {
+               slapi_ch_free( (void **)&prettyDN.bv_val );
+               slapi_ch_free( (void **)&normalizedDN.bv_val );
+               return NULL;
+       }
+
+       dnParent( &prettyDN, &parentDN );
+
+       slapi_ch_free( (void **)&prettyDN.bv_val );
+       slapi_ch_free( (void **)&normalizedDN.bv_val );
+
+       if ( parentDN.bv_len == 0 ) {
+               return NULL;
+       }
+
+       return slapi_ch_strdup( parentDN.bv_val );
+#else
+       return NULL;
+#endif /* LDAP_SLAPI */
+}
+
 char *
 slapi_dn_ignore_case( char *dn )
 {       
@@ -1273,7 +1402,7 @@ slapi_register_supported_saslmechanism( char *mechanism )
 {
 #ifdef LDAP_SLAPI
        /* FIXME -- can not add saslmechanism to OpenLDAP dynamically */
-       slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SASL",
+       slapi_log_error( SLAPI_LOG_FATAL, "slapi_register_supported_saslmechanism",
                        "OpenLDAP does not support dynamic registration of SASL mechanisms\n" );
 #endif /* LDAP_SLAPI */
 }
@@ -1283,7 +1412,7 @@ slapi_get_supported_saslmechanisms( void )
 {
 #ifdef LDAP_SLAPI
        /* FIXME -- can not get the saslmechanism without a connection. */
-       slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SASL",
+       slapi_log_error( SLAPI_LOG_FATAL, "slapi_get_supported_saslmechanisms",
                        "can not get the SASL mechanism list "
                        "without a connection\n" );
        return NULL;
@@ -1442,6 +1571,60 @@ slapi_send_ldap_search_entry(
 #endif /* LDAP_SLAPI */
 }
 
+int 
+slapi_send_ldap_search_reference(
+       Slapi_PBlock    *pb,
+       Slapi_Entry     *e,
+       struct berval   **references,
+       LDAPControl     **ectrls, 
+       struct berval   **v2refs
+       )
+{
+#ifdef LDAP_SLAPI
+       Operation       *pOp;
+       SlapReply       rs = { REP_SEARCHREF };
+       int             rc;
+
+       rs.sr_err = LDAP_SUCCESS;
+       rs.sr_matched = NULL;
+       rs.sr_text = NULL;
+
+       rc = bvptr2obj( references, &rs.sr_ref );
+       if ( rc != LDAP_SUCCESS ) {
+               return rc;
+       }
+
+       rs.sr_ctrls = ectrls;
+       rs.sr_attrs = NULL;
+       rs.sr_entry = e;
+
+       if ( v2refs != NULL ) {
+               rc = bvptr2obj( v2refs, &rs.sr_v2ref );
+               if ( rc != LDAP_SUCCESS ) {
+                       slapi_ch_free( (void **)&rs.sr_ref );
+                       return rc;
+               }
+       } else {
+               rs.sr_v2ref = NULL;
+       }
+
+       if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp ) != 0 ) {
+               return LDAP_OTHER;
+       }
+
+       rc = send_search_reference( pOp, &rs );
+
+       if ( rs.sr_ref != NULL )
+               slapi_ch_free( (void **)&rs.sr_ref );
+
+       if ( rs.sr_v2ref != NULL )
+               slapi_ch_free( (void **)&rs.sr_v2ref );
+
+       return rc;
+#else
+       return -1;
+#endif /* LDAP_SLAPI */
+}
 
 Slapi_Filter *
 slapi_str2filter( char *str ) 
@@ -1930,24 +2113,6 @@ slapi_get_hostname( void )
 {
 #ifdef LDAP_SLAPI
        char            *hn = NULL;
-
-       /*
-        * FIXME: I'd prefer a different check ...
-        */
-#if defined _SPARC 
-       hn = (char *)slapi_ch_malloc( MAX_HOSTNAME );
-       if ( hn == NULL) {
-               slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO",
-                               "can't malloc memory for hostname\n" );
-               hn = NULL;
-               
-       } else if ( sysinfo( SI_HOSTNAME, hn, MAX_HOSTNAME ) < 0 ) {
-               slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO",
-                               "can't get hostname\n" );
-               slapi_ch_free( (void **)&hn );
-               hn = NULL;
-       }
-#else /* !_SPARC */
        static int      been_here = 0;   
        static char     *static_hn = NULL;
 
@@ -1955,8 +2120,8 @@ slapi_get_hostname( void )
        if ( !been_here ) {
                static_hn = (char *)slapi_ch_malloc( MAX_HOSTNAME );
                if ( static_hn == NULL) {
-                       slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO",
-                                       "can't malloc memory for hostname\n" );
+                       slapi_log_error( SLAPI_LOG_FATAL, "slapi_get_hostname",
+                                       "Cannot allocate memory for hostname\n" );
                        static_hn = NULL;
                        ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex );
 
@@ -1965,7 +2130,7 @@ slapi_get_hostname( void )
                } else { 
                        if ( gethostname( static_hn, MAX_HOSTNAME ) != 0 ) {
                                slapi_log_error( SLAPI_LOG_FATAL,
-                                               "SLAPI_SYSINFO",
+                                               "SLAPI",
                                                "can't get hostname\n" );
                                slapi_ch_free( (void **)&static_hn );
                                static_hn = NULL;
@@ -1981,7 +2146,6 @@ slapi_get_hostname( void )
        ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex );
        
        hn = ch_strdup( static_hn );
-#endif /* !_SPARC */
 
        return hn;
 #else /* LDAP_SLAPI */
@@ -2244,13 +2408,15 @@ static int initConnectionPB( Slapi_PBlock *pb, Connection *conn )
                0 );
        if ( connAuthType != NULL ) {
                rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHMETHOD, (void *)connAuthType);
+               /* slapi_pblock_set dups this itself */
+               slapi_ch_free( (void **)&connAuthType );
                if ( rc != LDAP_SUCCESS )
                        return rc;
        }
 
        if ( conn->c_authz.sai_dn.bv_val != NULL ) {
-               char *connDn = slapi_ch_strdup(conn->c_authz.sai_dn.bv_val);
-               rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn);
+               /* slapi_pblock_set dups this itself */
+               rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)conn->c_authz.sai_dn.bv_val);
                if ( rc != LDAP_SUCCESS )
                        return rc;
        }
@@ -3405,7 +3571,7 @@ int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_En
        }
 
        if ( !access_allowed( op, e, desc, NULL, ACL_READ, &c->cac_acl_state) ) {
-               slapi_log_error( SLAPI_LOG_ACL, "SLAPI_COMPUTE",
+               slapi_log_error( SLAPI_LOG_ACL, "slapi_x_compute_output_ber",
                        "acl: access to attribute %s not allowed\n",
                        desc->ad_cname.bv_val );
                return 0;
@@ -3413,7 +3579,7 @@ int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_En
 
        rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname );
        if (rc == -1 ) {
-               slapi_log_error( SLAPI_LOG_BER, "SLAPI_COMPUTE",
+               slapi_log_error( SLAPI_LOG_BER, "slapi_x_compute_output_ber",
                        "ber_printf failed\n");
                return 1;
        }
@@ -3422,15 +3588,15 @@ int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_En
                for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
                        if ( !access_allowed( op, e,
                                desc, &a->a_vals[i], ACL_READ, &c->cac_acl_state)) {
-                               slapi_log_error( SLAPI_LOG_ACL, "SLAPI_COMPUTE",
-                                       "slapi_x_compute_output_ber: conn %lu "
+                               slapi_log_error( SLAPI_LOG_ACL, "slapi_x_compute_output_ber",
+                                       "conn %lu "
                                        "acl: access to %s, value %d not allowed\n",
                                        op->o_connid, desc->ad_cname.bv_val, i  );
                                continue;
                        }
        
                        if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
-                               slapi_log_error( SLAPI_LOG_BER, "SLAPI_COMPUTE",
+                               slapi_log_error( SLAPI_LOG_BER, "slapi_x_compute_output_ber",
                                        "ber_printf failed\n");
                                return 1;
                        }
@@ -3438,7 +3604,7 @@ int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_En
        }
 
        if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
-               slapi_log_error( SLAPI_LOG_BER, "SLAPI_COMPUTE",
+               slapi_log_error( SLAPI_LOG_BER, "slapi_x_compute_output_ber",
                        "ber_printf failed\n" );
                return 1;
        }
@@ -3741,8 +3907,6 @@ int slapi_x_access_allowed( Operation *op,
                return 1;
        }
 
-       slapi_x_pblock_set_operation( op->o_pb, op );
-
        switch ( access ) {
        case ACL_WRITE:
                slap_access |= SLAPI_ACL_ADD | SLAPI_ACL_DELETE | SLAPI_ACL_WRITE;
@@ -3766,6 +3930,8 @@ int slapi_x_access_allowed( Operation *op,
                return 1;
        }
 
+       slapi_x_pblock_set_operation( op->o_pb, op );
+
        rc = 1; /* default allow policy */
 
        for ( pGetPlugin = tmpPlugin; *pGetPlugin != NULL; pGetPlugin++ ) {
index 120c0aad06f0d2f3c9b74dcb8bd6209c96dfb85d..360d5740872982be16a8a24741827907792eb148 100644 (file)
@@ -364,9 +364,8 @@ do_syncrepl(
        op.ors_tlimit = 0;
        op.ors_attrsonly = 0;
        op.ors_attrs = NULL;
-       op.ors_filter = str2filter( def_filter_str = "(objectClass=*)" );
-       ber_str2bv( def_filter_str, strlen( def_filter_str ), 1,
-                               &op.ors_filterstr );
+       op.ors_filter = str2filter_x( &op, def_filter_str = "(objectClass=*)" );
+       ber_str2bv( def_filter_str, 0, 0, &op.ors_filterstr );
 
        si->conn = &conn;
        conn.c_send_ldap_result = slap_send_ldap_result;
@@ -374,22 +373,15 @@ do_syncrepl(
        conn.c_send_search_reference = slap_send_search_reference;
 
        /* get syncrepl cookie of shadow replica from subentry */
-       ber_str2bv( si->base, strlen(si->base), 1, &base_bv ); 
+       ber_str2bv( si->base, 0, 0, &base_bv ); 
        dnPrettyNormal( 0, &base_bv, &pbase, &nbase, op.o_tmpmemctx );
 
        sprintf( substr, "cn=syncrepl%d", si->id );
-       ber_str2bv( substr, strlen(substr), 1, &sub_bv );
+       ber_str2bv( substr, 0, 0, &sub_bv );
        dnPrettyNormal( 0, &sub_bv, &psubrdn, &nsubrdn, op.o_tmpmemctx );
 
-       build_new_dn( &op.o_req_dn, &pbase, &psubrdn );
-       build_new_dn( &op.o_req_ndn, &nbase, &nsubrdn );
-
-       ch_free( base_bv.bv_val );
-       ch_free( pbase.bv_val );
-       ch_free( nbase.bv_val );
-       ch_free( sub_bv.bv_val );
-       ch_free( psubrdn.bv_val );
-       ch_free( nsubrdn.bv_val );
+       build_new_dn( &op.o_req_dn, &pbase, &psubrdn, op.o_tmpmemctx );
+       build_new_dn( &op.o_req_ndn, &nbase, &nsubrdn, op.o_tmpmemctx );
 
        /* set callback function */
        cb.sc_response = cookie_callback;
@@ -401,11 +393,6 @@ do_syncrepl(
 
        ber_dupbv( &syncCookie_req, si->syncCookie );
 
-       ch_free( op.o_req_dn.bv_val );
-       ch_free( op.o_req_ndn.bv_val );
-       filter_free( op.ors_filter );
-       ch_free( op.ors_filterstr.bv_val );
-
        psub = be->be_nsuffix[0];
 
        for ( n = 0; si->attrs[ n ] != NULL; n++ ) ;
@@ -491,11 +478,11 @@ do_syncrepl(
                                if ( syncCookie.bv_len ) {
                                        syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie );
                                }
-                               if ( rc_efree )
+                               if ( modlist ) {
+                                       slap_mods_free( modlist );
+                               }
+                               if ( rc_efree ) {
                                        entry_free( entry );
-                               for ( ml = modlist; ml != NULL; ml = mlnext ) {
-                                       mlnext = ml->sml_next;
-                                       ber_memfree( ml );
                                }
                                break;
 
@@ -638,17 +625,27 @@ do_syncrepl(
                                break;
 
                        }
+                       if ( syncCookie.bv_val )
+                               ch_free( syncCookie.bv_val );
+                       if ( syncUUID.bv_val )
+                               ch_free( syncUUID.bv_val );
                }
                ldap_msgfree( res );
        }
 
        if ( rc == -1 ) {
+               int errno;
+               const char *errstr;
+
+               ldap_get_option( ld, LDAP_OPT_ERROR_NUMBER, &errno );
+               errstr = ldap_err2string( errno );
+               
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ERR,
-                       "do_syncrepl : unknown result\n", 0, 0, 0 );
+                       "do_syncrepl : %s\n", errstr, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
-                       "do_syncrepl : unknown result\n", 0, 0, 0 );
+                       "do_syncrepl : %s\n", errstr, 0, 0 );
 #endif
        }
 
@@ -814,6 +811,7 @@ syncrepl_message_to_entry(
                        ber_scanf( ctrl_ber, "o}", syncCookie );
                }
                ber_free( ctrl_ber, 1 );
+               ldap_controls_free( rctrls );
        } else {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ERR,"syncrepl_message_to_entry : "
@@ -824,10 +822,7 @@ syncrepl_message_to_entry(
 #endif
        }
 
-       if ( *syncstate == LDAP_SYNC_PRESENT ) {
-               e = NULL;
-               goto done;
-       } else if ( *syncstate == LDAP_SYNC_DELETE ) {
+       if ( *syncstate == LDAP_SYNC_PRESENT || *syncstate == LDAP_SYNC_DELETE ) {
                goto done;
        }
 
@@ -934,10 +929,11 @@ syncrepl_entry(
        }
 
        if ( syncstate == LDAP_SYNC_PRESENT ) {
-               if ( e )
+               if ( e ) {
                        return 1;
-               else
+               } else {
                        return 0;
+               }
        }
 
        filterstr = (char *) sl_malloc( strlen("entryUUID=") + syncUUID->bv_len + 1,
@@ -946,7 +942,6 @@ syncrepl_entry(
        strcat( filterstr, syncUUID->bv_val );
 
        si->e = e;
-       si->syncUUID = syncUUID;
        si->syncUUID_ndn = NULL;
 
        filter = str2filter( filterstr );
@@ -1023,9 +1018,8 @@ syncrepl_entry(
                                                        "syncrepl_entry : be_modify failed (%d)\n",
                                                        rc, 0, 0 );
 #endif
-                                               return 1;
                                        }
-                                       return 0;
+                                       return 1;
                                } else if ( rc == LDAP_REFERRAL ||
                                                        rc == LDAP_NO_SUCH_OBJECT ) {
                                        syncrepl_add_glue( si, ld, op, e,
@@ -1120,7 +1114,9 @@ syncrepl_del_nonpresent(
        op->ors_filter = filter;
        ber_str2bv( si->filterstr, strlen( si->filterstr ), 1, &op->ors_filterstr );
 
+       op->o_nocaching = 1;
        be->be_search( op, &rs );
+       op->o_nocaching = 0;
 
        if ( !LDAP_LIST_EMPTY( &si->nonpresentlist ) ) {
                np_list = LDAP_LIST_FIRST( &si->nonpresentlist );
@@ -1293,7 +1289,7 @@ syncrepl_updateCookie(
        Modifications *ml;
        Modifications *mlnext;
        Modifications *mod;
-       Modifications *modlist;
+       Modifications *modlist = NULL;
        Modifications **modtail = &modlist;
 
        struct berval* ocbva = NULL;
@@ -1307,7 +1303,7 @@ syncrepl_updateCookie(
        char txtbuf[SLAP_TEXT_BUFLEN];
        size_t textlen = sizeof txtbuf;
 
-       Entry* e;
+       Entry* e = NULL;
        int rc;
 
        struct berval sub_bv = { 0, NULL };
@@ -1399,7 +1395,7 @@ syncrepl_updateCookie(
 
        e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
 
-       build_new_dn( &sub_bv, pdn, &psubrdn );
+       build_new_dn( &sub_bv, pdn, &psubrdn, NULL );
        dnPrettyNormal( NULL, &sub_bv, &e->e_name, &e->e_nname, NULL );
        ch_free( sub_bv.bv_val );
        ch_free( psubrdn.bv_val );
@@ -1477,14 +1473,14 @@ update_cookie_retry:
                }
        }
 
-       if ( e != NULL )
+       if ( e != NULL ) {
                entry_free( e );
+       }
 
 done :
 
-       for ( ml = modlist; ml != NULL; ml = mlnext ) {
-               mlnext = ml->sml_next;
-               free( ml );
+       if ( modlist ) {
+               slap_mods_free( modlist );
        }
 
        return;
@@ -1497,9 +1493,9 @@ avl_ber_bvfree( void *bv )
                return;
        }
        if ( ((struct berval *)bv)->bv_val != NULL ) {
-               ber_memfree ( ((struct berval *)bv)->bv_val );
+               ch_free ( ((struct berval *)bv)->bv_val );
        }
-       ber_memfree ( (char *) bv );
+       ch_free ( (char *) bv );
 }
 
 static int
@@ -1587,6 +1583,8 @@ nonpresent_callback(
                } else {
                        avl_delete( &si->presentlist,
                                        &a->a_vals[0], syncuuid_cmp );
+                       ch_free( present_uuid->bv_val );
+                       ch_free( present_uuid );
                }
                return LDAP_SUCCESS;
        } else {
index dbddeb02c025d4a1ba3463578fdc0bcba5ca5ce2..081e9aea5695c770df6207f90377732e5abd9b69 100644 (file)
@@ -28,7 +28,7 @@ XXLIBS = $(SLAPD_LIBS) \
        $(LDBM_LIBS) $(SECURITY_LIBS) \
        $(LDIF_LIBS) $(LUTIL_LIBS)
 XXXLIBS = $(LTHREAD_LIBS)
-SLAPI_DEP_LIBS = $(LIBS) $(SLAPI_LIBS) @LIBSLAPITOOLS@ $(MODULES_LIBS)
+SLAPI_DEP_LIBS = $(LIBS) @LIBSLAPITOOLS@ @SLAPI_LIBS@ $(MODULES_LIBS)
 
 STATIC_DEPENDS=@SLAPD_NO_STATIC@ ../libbackends.a
 
index 87059a57b558b1c796fabc6beeffac39fae5d4af..da006c28eaf0422064bc0e1c29c377635f7845ac 100644 (file)
@@ -268,7 +268,6 @@ main( int argc, char **argv )
        if ( SLAP_LASTMOD(be) && update_ctxcsn == SLAP_TOOL_CTXCSN_BATCH && csn.bv_len > 0 ) {
                Entry *ctxcsn_e;
                ID      ctxcsn_id;
-               struct berval   ctxcsn_rdn = { 0, NULL };
                struct berval   ctxcsn_ndn = { 0, NULL };
                int ret;
                struct berval bvtext;
@@ -278,8 +277,7 @@ main( int argc, char **argv )
                bvtext.bv_val = textbuf;
                bvtext.bv_val[0] = '\0';
 
-               ber_str2bv( "cn=ldapsync", strlen( "cn=ldapsync" ), 0, &ctxcsn_rdn );
-               build_new_dn( &ctxcsn_ndn, &be->be_nsuffix[0], &ctxcsn_rdn );
+               build_new_dn( &ctxcsn_ndn, &be->be_nsuffix[0], (struct berval *)&slap_ldapsync_cn_bv, NULL );
                ctxcsn_id = be->be_dn2id_get( be, &ctxcsn_ndn );
                
                if ( ctxcsn_id == NOID ) {
index 6f3df19a0f95444217954371795a6984a7248d74..3f7a8f8b65f0f3b04d7256d05a24381b70a2fc47 100644 (file)
@@ -64,8 +64,10 @@ slurpd_read_config(
     FILE       *fp;
     char       *line;
 
+       if ( cargv == NULL ) {
        cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
        cargv_size = ARGS_STEP + 1;
+       }
 
 #ifdef NEW_LOGGING
     LDAP_LOG ( CONFIG, ARGS, 
index 17eb1592ca5a9a0b6be13e8ef0cbc6f45c35e2f9..3184786344c92f0506fb447a67e9908e38cb69e1 100644 (file)
@@ -27,7 +27,7 @@ test-bdb:     FORCE
        @if test "$(BUILD_BDB)" != "no"; then \
                echo "Initiating LDAP tests for BDB..." ; \
                $(MKDIR) test-db test-repl || true; \
-               $(srcdir)/scripts/all $(srcdir) bdb $(BUILD_BDB) $(BUILD_MONITOR) $(BUILD_CACHE) ; \
+               $(srcdir)/scripts/all $(srcdir) bdb $(BUILD_BDB) $(BUILD_MONITOR) $(BUILD_CACHE) bdb ; \
        else \
                echo "run configure with --enable-bdb" ; \
        fi
@@ -40,7 +40,7 @@ test-hdb:     FORCE
        @if test "$(BUILD_HDB)" != "no" ; then \
                echo "Initiating LDAP tests for HDB..." ; \
                $(MKDIR) test-db test-repl || true; \
-               $(srcdir)/scripts/all $(srcdir) hdb $(BUILD_HDB) $(BUILD_MONITOR) $(BUILD_CACHE) ; \
+               $(srcdir)/scripts/all $(srcdir) hdb $(BUILD_HDB) $(BUILD_MONITOR) $(BUILD_CACHE) hdb ; \
        else \
                echo "run configure with --enable-hdb" ; \
        fi
@@ -50,10 +50,18 @@ test-ldbm:  FORCE
        @-$(LN_S) $(srcdir)/data .
        @-$(LN_S) $(top_srcdir)/servers/slapd/schema .
        @-$(LN_S) ../libraries/liblunicode ucdata
-       @if test "$(BUILD_LDBM)" != "no"; then \
+       @if test "$(BUILD_LDBM)" != "no" ; then \
                echo "Initiating LDAP tests for LDBM..." ; \
                $(MKDIR) test-db test-repl || true; \
-               $(srcdir)/scripts/all $(srcdir) ldbm $(BUILD_LDBM) $(BUILD_MONITOR) $(BUILD_CACHE); \
+               if test "$(BUILD_BDB)" != "no"; then \
+                       $(srcdir)/scripts/all $(srcdir) ldbm $(BUILD_LDBM) $(BUILD_MONITOR) $(BUILD_CACHE) bdb ; \
+               else \
+                       if test "$(BUILD_HDB)" != "no"; then \
+                               $(srcdir)/scripts/all $(srcdir) ldbm $(BUILD_LDBM) $(BUILD_MONITOR) $(BUILD_CACHE) hdb ; \
+                       else \
+                               $(srcdir)/scripts/all $(srcdir) ldbm $(BUILD_LDBM) $(BUILD_MONITOR) $(BUILD_CACHE) no ; \
+                       fi ; \
+               fi ; \
        else \
                echo "run configure with --enable-ldbm" ; \
        fi
index 6e9cd1f3faf137862e987500ce07749ab680cbf3..ea0e29b643bb3be5e501e376febb1619359d5a00 100644 (file)
@@ -1,5 +1,10 @@
+o=university of michigan,c=us
 cn=Barbara Jensen
+ou=people,o=university of michigan,c=us
 cn=Bjorn Jensen
+ou=people,o=university of michigan,c=us
 cn=James A Jones 1
+o=university of michigan,c=us
 cn=Bjorn Jensen
+o=university of michigan,c=us
 cn=Alumni Assoc Staff
index a2a96f415a12419af3a760778030d6a95a7b8acb..4c5c9e2374337fad3619689286b65a8e3563c3e2 100644 (file)
@@ -35,7 +35,7 @@
 #define TMODRDNFILE            "do_modrdn.0"
 
 static char *get_file_name( char *dirname, char *filename );
-static int  get_search_filters( char *filename, char *filters[] );
+static int  get_search_filters( char *filename, char *filters[], char *bases[] );
 static int  get_read_entries( char *filename, char *entries[] );
 static void fork_child( char *prog, char **args );
 static void    wait4kids( int nkidval );
@@ -54,7 +54,7 @@ static char argbuf[BUFSIZ];
 static void
 usage( char *name )
 {
-       fprintf( stderr, "usage: %s [-h <host>] -p <port> -D <manager> -w <passwd> -d <datadir> -b <baseDN> [-j <maxchild>] [-l <loops>] -P <progdir>\n", name );
+       fprintf( stderr, "usage: %s -H <uri> | ([-h <host>] -p <port>) -D <manager> -w <passwd> -d <datadir> [-j <maxchild>] [-l <loops>] -P <progdir>\n", name );
        exit( EXIT_FAILURE );
 }
 
@@ -68,13 +68,13 @@ main( int argc, char **argv )
        char            *manager = NULL;
        char            *passwd = NULL;
        char            *dirname = NULL;
-       char        *sbase = NULL;
        char            *progdir = NULL;
        char            *loops = LOOPS;
        DIR                     *datadir;
        struct dirent   *file;
        char            *sfile = NULL;
        char            *sreqs[MAXREQS];
+       char            *sbase[MAXREQS];
        int         snum = 0;
        char            *rfile = NULL;
        char            *rreqs[MAXREQS];
@@ -119,10 +119,6 @@ main( int argc, char **argv )
                                passwd = ArgDup( optarg );
                                break;
 
-                       case 'b':               /* the base DN */
-                               sbase = ArgDup( optarg );
-                               break;
-
                        case 'd':               /* data directory */
                                dirname = strdup( optarg );
                        break;
@@ -145,7 +141,7 @@ main( int argc, char **argv )
                }
        }
 
-       if (( dirname == NULL ) || ( sbase == NULL ) || ( port == NULL && uri == NULL ) ||
+       if (( dirname == NULL ) || ( port == NULL && uri == NULL ) ||
                        ( manager == NULL ) || ( passwd == NULL ) || ( progdir == NULL ))
                usage( argv[0] );
 
@@ -184,7 +180,7 @@ main( int argc, char **argv )
 
        /* look for search requests */
        if ( sfile ) {
-               snum = get_search_filters( sfile, sreqs );
+               snum = get_search_filters( sfile, sreqs, sbase );
        }
 
        /* look for read requests */
@@ -214,10 +210,10 @@ main( int argc, char **argv )
                sargs[sanum++] = "-p";
                sargs[sanum++] = port;
        }
-       sargs[sanum++] = "-b";
-       sargs[sanum++] = sbase;
        sargs[sanum++] = "-l";
        sargs[sanum++] = loops;
+       sargs[sanum++] = "-b";
+       sargs[sanum++] = NULL;          /* will hold the search base */
        sargs[sanum++] = "-f";
        sargs[sanum++] = NULL;          /* will hold the search request */
        sargs[sanum++] = NULL;
@@ -304,6 +300,7 @@ main( int argc, char **argv )
                if ( j < snum ) {
 
                        sargs[sanum - 2] = sreqs[j];
+                       sargs[sanum - 4] = sbase[j];
                        fork_child( scmd, sargs );
 
                }
@@ -348,7 +345,7 @@ get_file_name( char *dirname, char *filename )
 
 
 static int
-get_search_filters( char *filename, char *filters[] )
+get_search_filters( char *filename, char *filters[], char *bases[] )
 {
        FILE    *fp;
        int     filter = 0;
@@ -361,6 +358,11 @@ get_search_filters( char *filename, char *filters[] )
 
                        if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
                                *nl = '\0';
+                       bases[filter] = ArgDup( line );
+                       fgets( line, BUFSIZ, fp );
+                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
+                               *nl = '\0';
+
                        filters[filter++] = ArgDup( line );
 
                }
index b0b9a94f990cbcaacbfedb9ebf13b6a340ae1d9d..46257d3690b0aa80d97289a74efd799b514d1470 100755 (executable)
@@ -44,12 +44,18 @@ else
        PROXYCACHE=$1; shift
 fi
 
+if test $# -eq 0 ; then
+       SYNCREPL=no
+else
+       SYNCREPL=$1; shift
+fi
+
 TB=`$SHTOOL echo -e "%B"`
 TN=`$SHTOOL echo -e "%b"`
 
 for CMD in $SRCDIR/scripts/test*; do
        echo ">>>>> Starting ${TB}`basename $CMD`${TN} ..."
-       $CMD $SRCDIR $BACKEND $BACKENDTYPE $MONITOR $PROXYCACHE
+       $CMD $SRCDIR $BACKEND $BACKENDTYPE $MONITOR $PROXYCACHE $SYNCREPL
        RC=$?
        if test $RC -eq 0 ; then
                echo ">>>>> $CMD completed ${TB}OK${TN}."
index bef77b0666f3af8c9ce6b7056259ba0ada88cf49..b13e8af097707c50d8f2447fe7c0e9e51e5c7037 100755 (executable)
@@ -20,6 +20,11 @@ if test $# -ge 1 ; then
         PROXYCACHE=$1; shift
 fi
 
+SYNCREPL=no
+if test $# -ge 1 ; then
+       SYNCREPL=$1; shift
+fi
+
 WAIT=0
 if test $# -ge 1 ; then
         WAIT=1; shift
index 4e0c7af7d246a558acef98e56419a10013695485..23f67993a30a8d3e5f61508370b97ba397612d1d 100755 (executable)
@@ -50,7 +50,7 @@ for i in 0 1 2 3 4 5; do
 done
 
 echo "Using tester for concurrent server access..."
-$SLAPDTESTER -b "$BASEDN" -P "$PROGDIR" -d "$DATADIR" -h $LOCALHOST -p $PORT -D "$MANAGERDN" -w $PASSWD -l 50
+$SLAPDTESTER -P "$PROGDIR" -d "$DATADIR" -h $LOCALHOST -p $PORT -D "$MANAGERDN" -w $PASSWD -l 50
 RC=$?
 
 if test $RC != 0 ; then
index be59b12298236b957414e0b154bf81c9180b944d..aed3a98050141eea89ec37aad89e7762776ace83 100755 (executable)
@@ -28,7 +28,11 @@ mkdir $R1REPLDIR
 
 SAVE=$BACKEND
 if test $BACKEND = ldbm; then
-       BACKEND=bdb
+       if test $SYNCREPL = no; then
+               echo "Sync replication requires back-bdb or back-hdb"
+               exit 0
+       fi
+       BACKEND=$SYNCREPL
 fi
 echo "Starting master slapd on TCP/IP port $PORT..."
 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $DBCONF
index 66f5637673511218aaf1df6bf5c451e384d6e213..0a62c9dcecbb2801a3c0834f750234f3d29163f7 100755 (executable)
@@ -28,7 +28,11 @@ mkdir $P1REPLDIR
 
 SAVE=$BACKEND
 if test $BACKEND = ldbm; then
-       BACKEND=bdb
+       if test $SYNCREPL = no; then
+               echo "Sync replication requires back-bdb or back-hdb"
+               exit 0
+       fi
+       BACKEND=$SYNCREPL
 fi
 echo "Starting master slapd on TCP/IP port $PORT..."
 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $DBCONF
index 7fff42ec59ee1af28248329dbc2d136ef3f97ca5..bae0f71bfa1736740ece62e35812f57435f5ca1e 100755 (executable)
@@ -40,7 +40,11 @@ mkdir $P3REPLDIR
 
 SAVE=$BACKEND
 if test $BACKEND = ldbm; then
-       BACKEND=bdb
+       if test $SYNCREPL = no; then
+               echo "Sync replication requires back-bdb or back-hdb"
+               exit 0
+       fi
+       BACKEND=$SYNCREPL
 fi
 echo "Starting master slapd on TCP/IP port $PORT..."
 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $DBCONF
@@ -78,7 +82,13 @@ if test $RC != 0 ; then
 fi
 
 SAVE=$BACKEND
-BACKEND=bdb
+if test $BACKEND = ldbm; then
+       if test $SYNCREPL = no; then
+               echo "Sync replication requires back-bdb or back-hdb"
+               exit 0
+       fi
+       BACKEND=$SYNCREPL
+fi
 echo "Starting R1 slave slapd on TCP/IP port $R1SLAVEPORT..."
 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $R1REPLCONF
 $SLAPD -f $R1REPLCONF -h $R1SLAVEURI -d $LVL $TIMING > $R1SLAVELOG 2>&1 &
@@ -129,7 +139,13 @@ echo "Waiting for the R2 slave to replicate..."
 sleep 10
 
 SAVE=$BACKEND
-BACKEND=bdb
+if test $BACKEND = ldbm; then
+       if test $SYNCREPL = no; then
+               echo "Sync replication requires back-bdb or back-hdb"
+               exit 0
+       fi
+       BACKEND=$SYNCREPL
+fi
 echo "Starting P1 slave slapd on TCP/IP port $P1SLAVEPORT..."
 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $P1REPLCONF
 $SLAPD -f $P1REPLCONF -h $P1SLAVEURI -d $LVL $TIMING > $P1SLAVELOG 2>&1 &