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
return( rc );
}
-#if 1
+#ifdef OLD_WAY
/* This is the original version, the old way of doing things. */
static void
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 ) ))
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
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
#define _LBER_H
#include <lber_types.h>
+#include <string.h>
LDAP_BEGIN_DECL
#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 )
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 */
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 );
install-local: FORCE
-$(MKDIR) $(DESTDIR)$(libdir)
$(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir)
- $(LTFINISH) $(DESTDIR)$libdir
+ $(LTFINISH) $(DESTDIR)$(libdir)
#include <ac/time.h>
#include <ac/errno.h>
#include <ac/ctype.h>
+#include <ac/unistd.h>
#include "ldap-int.h"
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 );
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;
#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;
}
#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"
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@
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) \
Operation* ps_list;
int rc;
- EntryInfo *suffix_ei;
+ EntryInfo *suffix_ei = NULL;
Entry *ctxcsn_e;
int ctxcsn_added = 0;
rs->sr_text = "internal error";
goto return_results;
}
- bdb_trans_backoff( ++num_retries );
ldap_pvt_thread_yield();
+ bdb_trans_backoff( ++num_retries );
}
/* begin transaction */
} 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 );
#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
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 */
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;
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
/* 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
#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;
}
*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 );
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;
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
}
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;
}
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 );
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,
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 );
+}
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;
}
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;
}
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;
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,
}
}
- ret = bdb_id2entry_update( op->o_bd, tid, *ctxcsn_e );
+ ret = bdb_id2entry_update( op->o_bd, tid, &dummy );
switch ( ret ) {
case 0 :
break;
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:
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;
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 :
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, <id, bdb->bi_db_opflags );
if ( rs->sr_err != 0 ) {
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;
}
}
- 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;
}
"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;
}
#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 );
"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;
}
*dbout = db->bdi_db;
- LOCK_PUT( bdb->bi_dbenv, &lock );
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
return 0;
}
rs->sr_text = "internal error";
goto return_results;
}
- bdb_trans_backoff( ++num_retries );
ldap_pvt_thread_yield();
+ bdb_trans_backoff( ++num_retries );
}
/* begin transaction */
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);
}
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;
}
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);
#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;
/* 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;
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
*/
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:
#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 );
}
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;
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
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 );
#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,
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 );
rs->sr_text = "internal error";
goto return_results;
}
- bdb_trans_backoff( ++num_retries );
ldap_pvt_thread_yield();
+ bdb_trans_backoff( ++num_retries );
}
/* begin transaction */
#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 );
rs->sr_text = "internal error";
goto return_results;
}
- bdb_trans_backoff( ++num_retries );
ldap_pvt_thread_yield();
+ bdb_trans_backoff( ++num_retries );
}
/* begin transaction */
}
/* 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};
} 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 );
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 */
rs->sr_text = "internal error";
goto done;
}
- bdb_trans_backoff( ++num_retries );
ldap_pvt_thread_yield();
+ bdb_trans_backoff( ++num_retries );
}
/* begin transaction */
int
bdb_db_cache(
Backend *be,
- DB_TXN *tid,
const char *name,
DB **db );
#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,
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,
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(
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)
/* 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;
#include "back-bdb.h"
#include "external.h"
#include "lber_pvt.h"
+#include "lutil.h"
/* Congestion avoidance code
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;
ber_bvarray_free( rs->sr_ref );
free( (char *)rs->sr_matched );
-
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
return rs->sr_err;
}
ber_bvarray_free( rs->sr_ref );
free( (char *)rs->sr_matched );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
return rs->sr_err;
}
}
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;
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;
}
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;
}
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 );
}
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;
}
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 );
}
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;
}
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;
}
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;
}
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;
}
goto error_return;
}
+ rs->sr_text = NULL;
send_ldap_error( op, rs, LDAP_SUCCESS,
NULL );
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;
}
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;
}
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;
}
}
/* 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
}
rs->sr_err = LDAP_SUCCESS;
+ rs->sr_text = NULL;
send_ldap_result( op, rs );
rc = 0;
cache_entry_commit( e );
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 */
entry_free( e );
}
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
+ rs->sr_text = NULL;
return( rc );
}
}
if ( rs->sr_matched ) free( (char *)rs->sr_matched );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
return rs->sr_err;
}
}
if( refs != NULL ) ber_bvarray_free( refs );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
}
cache_return_entry_r( &li->li_cache, e );
ber_bvarray_free( rs->sr_ref );
ber_memfree( matched_dn.bv_val );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
return LDAP_REFERRAL;
}
}
ber_memfree( matched_dn.bv_val );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
return LDAP_OTHER;
}
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' ) {
} 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 );
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;
}
#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"
#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"
#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"
#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"
#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"
#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"
#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"
#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"
#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"
#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"
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 ) {
/* 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 );
if( be == NULL ) {
be = &backends[i];
- if( manageDSAit && len == dnlen ) {
+ if( manageDSAit && len == dnlen &&
+ !SLAP_GLUE_SUBORDINATE( be ) ) {
continue;
}
} else {
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 );
}
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;
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;
}
*/
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 {
}
*on2 = *on;
on2->on_next = NULL;
+ on2->on_info = oi;
/* Any initialization needed? */
if ( on->on_bi.bi_db_init ) {
#ifdef LDAP_SLAPI
Slapi_PBlock *pb = op->o_pb;
+ int rc;
#endif
#ifdef NEW_LOGGING
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,
rs->sr_err, 0, 0);
#endif
- switch ( rs->sr_err ) {
+ switch ( rc ) {
case SLAPI_BIND_SUCCESS:
/* Continue with backend processing */
break;
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 )
{
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,
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 );
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;
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 );
#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 ) {
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
{
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 ) {
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,
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;
{
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;
#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"
/*
void
build_new_dn( struct berval * new_dn,
struct berval * parent_dn,
- struct berval * newrdn )
+ struct berval * newrdn,
+ void *memctx )
{
char *ptr;
}
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++ = ',';
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,
filter2bv_x( &op, f, fstr );
}
-int
+static int
filter_escape_value_x(
struct berval *in,
struct berval *out,
/* 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");
--- /dev/null
+# $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.
--- /dev/null
+/* 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 );
+}
* 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 *));
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 ));
#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 );
}
}
+#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;
ValuesReturnFilter *o_vrFilter; /* ValuesReturnFilter */
syncinfo_t* o_si;
+ int o_nocaching;
#ifdef LDAP_SLAPI
void *o_pb; /* NS-SLAPI plugin */
## 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
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
char *argv[] )
{
Slapi_PBlock *pPlugin = NULL;
+ Slapi_PluginDesc *pPluginDesc = NULL;
lt_dlhandle hdLoadHandle;
int rc;
}
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;
}
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 );
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);
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;
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;
pb->curParams[i] = param;
pb->numParams++;
}
+ if ( freeit ) ch_free( pb->curVals[i] );
pb->curVals[i] = val;
unLock( pb );
#include <slap.h>
#include <slapi.h>
-#ifdef _SPARC
-#include <sys/systeminfo.h>
-#endif
-
#include <netdb.h>
/*
#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 )
{
{
#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 */
}
{
#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;
#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 )
{
#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;
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 );
} 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;
ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex );
hn = ch_strdup( static_hn );
-#endif /* !_SPARC */
return hn;
#else /* LDAP_SLAPI */
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;
}
}
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;
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;
}
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;
}
}
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;
}
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;
return 1;
}
+ slapi_x_pblock_set_operation( op->o_pb, op );
+
rc = 1; /* default allow policy */
for ( pGetPlugin = tmpPlugin; *pGetPlugin != NULL; pGetPlugin++ ) {
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;
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;
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++ ) ;
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;
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
}
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 : "
#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;
}
}
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,
strcat( filterstr, syncUUID->bv_val );
si->e = e;
- si->syncUUID = syncUUID;
si->syncUUID_ndn = NULL;
filter = str2filter( filterstr );
"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,
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 );
Modifications *ml;
Modifications *mlnext;
Modifications *mod;
- Modifications *modlist;
+ Modifications *modlist = NULL;
Modifications **modtail = &modlist;
struct berval* ocbva = NULL;
char txtbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof txtbuf;
- Entry* e;
+ Entry* e = NULL;
int rc;
struct berval sub_bv = { 0, NULL };
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 );
}
}
- 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;
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
} 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 {
$(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
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;
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 ) {
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,
@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
@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
@-$(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
+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
#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 );
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 );
}
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];
passwd = ArgDup( optarg );
break;
- case 'b': /* the base DN */
- sbase = ArgDup( optarg );
- break;
-
case 'd': /* data directory */
dirname = strdup( optarg );
break;
}
}
- 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] );
/* look for search requests */
if ( sfile ) {
- snum = get_search_filters( sfile, sreqs );
+ snum = get_search_filters( sfile, sreqs, sbase );
}
/* look for read requests */
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;
if ( j < snum ) {
sargs[sanum - 2] = sreqs[j];
+ sargs[sanum - 4] = sbase[j];
fork_child( scmd, sargs );
}
static int
-get_search_filters( char *filename, char *filters[] )
+get_search_filters( char *filename, char *filters[], char *bases[] )
{
FILE *fp;
int filter = 0;
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 );
}
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}."
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
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
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
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
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
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 &
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 &