1 /* init.c - initialize bdb backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2005 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
21 #include <ac/unistd.h>
22 #include <ac/stdlib.h>
30 static const struct bdbi_database {
35 } bdbi_databases[] = {
36 { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
37 { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
41 typedef void * db_malloc(size_t);
42 typedef void * db_realloc(void *, size_t);
45 bdb_db_init( BackendDB *be )
49 Debug( LDAP_DEBUG_TRACE,
50 LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
53 /* allocate backend-database-specific stuff */
54 bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
56 /* DBEnv parameters */
57 bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
58 bdb->bi_dbenv_xflags = 0;
59 bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
61 bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
63 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
64 bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
65 bdb->bi_search_stack = NULL;
67 ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
68 ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
69 ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
70 ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
71 ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
74 be->be_cf_table = be->bd_info->bi_cf_table;
80 * Unconditionally perform a database recovery. Only works on
81 * databases that were previously opened with transactions and
85 bdb_do_recovery( BackendDB *be )
87 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
91 char path[MAXPATHLEN], *ptr;
93 /* Create and init the recovery environment */
94 rc = db_env_create( &re_dbenv, 0 );
96 Debug( LDAP_DEBUG_ANY,
97 "bdb_do_recovery: db_env_create failed: %s (%d)\n",
98 db_strerror(rc), rc, 0 );
101 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
102 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
103 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_RECOVERY, 1);
104 #if DB_VERSION_FULL < 0x04030000
105 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_CHKPOINT, 1);
107 re_dbenv->set_msgcall( re_dbenv, bdb_msgcall );
110 flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
111 DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER;
113 /* Open the environment, which will also perform the recovery */
115 strcpy( path, bdb->bi_dbenv_home );
117 rc = re_dbenv->open( re_dbenv,
120 bdb->bi_dbenv_mode );
122 rc = re_dbenv->open( re_dbenv,
125 bdb->bi_dbenv_mode );
128 Debug( LDAP_DEBUG_ANY,
129 "bdb_do_recovery: dbenv_open failed: %s (%d)\n",
130 db_strerror(rc), rc, 0 );
133 (void) re_dbenv->close( re_dbenv, 0 );
135 /* By convention we reset the mtime for id2entry.bdb to the current time */
136 ptr = lutil_strcopy( path, bdb->bi_dbenv_home);
137 *ptr++ = LDAP_DIRSEP[0];
138 strcpy( ptr, bdbi_databases[0].file);
139 (void) utime( path, NULL);
145 * Database recovery logic:
146 * This function is called whenever the database appears to have been
147 * shut down uncleanly, as determined by the alock functions.
148 * Because of the -q function in slapadd, there is also the possibility
149 * that the shutdown happened when transactions weren't being used and
150 * the database is likely to be corrupt. The function checks for this
151 * condition by examining the environment to make sure it had previously
152 * been opened with transactions enabled. If this is the case, the
153 * database is recovered as usual. If transactions were not enabled,
154 * then this function will return a fail.
157 bdb_db_recover( BackendDB *be )
159 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
164 char path[MAXPATHLEN];
167 /* Create the recovery environment, then open it.
168 * We use the DB_JOIN in combination with a flags value of
169 * zero so we join an existing environment and can read the
170 * value of the flags that were used the last time the
171 * environment was opened. DB_CREATE is added because the
172 * open would fail if the only thing that had been done
173 * was an open with transactions and logs disabled.
175 rc = db_env_create( &re_dbenv, 0 );
177 Debug( LDAP_DEBUG_ANY,
178 "bdb_db_recover: db_env_create failed: %s (%d)\n",
179 db_strerror(rc), rc, 0 );
182 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
183 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
185 Debug( LDAP_DEBUG_TRACE,
186 "bdb_db_recover: dbenv_open(%s)\n",
187 bdb->bi_dbenv_home, 0, 0);
190 strcpy( path, bdb->bi_dbenv_home );
192 rc = re_dbenv->open( re_dbenv,
195 bdb->bi_dbenv_mode );
197 rc = re_dbenv->open( re_dbenv,
200 bdb->bi_dbenv_mode );
207 Debug( LDAP_DEBUG_ANY,
208 "bdb_db_recover: dbenv_open failed: %s (%d)\n",
209 db_strerror(rc), rc, 0 );
214 * Check the flags that had been used in the previous open.
215 * The environment needed to have had both
216 * DB_INIT_LOG and DB_INIT_TXN set for us to be willing to
217 * recover the database. Otherwise the an app failed while running
218 * without transactions and logs enabled and the dn2id and id2entry
219 * mapping is likely to be corrupt.
221 rc = re_dbenv->get_open_flags( re_dbenv, &flags );
223 Debug( LDAP_DEBUG_ANY,
224 "bdb_db_recover: get_open_flags failed: %s (%d)\n",
225 db_strerror(rc), rc, 0 );
229 (void) re_dbenv->close( re_dbenv, 0 );
231 if( (flags & DB_INIT_LOG) && (flags & DB_INIT_TXN) ) {
232 return bdb_do_recovery( be );
236 Debug( LDAP_DEBUG_ANY,
237 "bdb_db_recover: Database cannot be recovered. "\
238 "Restore from backup!\n", 0, 0, 0);
245 bdb_db_open( BackendDB *be )
248 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
249 struct stat stat1, stat2;
251 char path[MAXPATHLEN];
254 Debug( LDAP_DEBUG_ARGS,
256 be->be_suffix[0].bv_val, 0, 0 );
258 #ifndef BDB_MULTIPLE_SUFFIXES
259 if ( be->be_suffix[1].bv_val ) {
260 Debug( LDAP_DEBUG_ANY,
261 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
266 /* Check existence of dbenv_home. Any error means trouble */
267 rc = stat( bdb->bi_dbenv_home, &stat1 );
269 Debug( LDAP_DEBUG_ANY,
270 "bdb_db_open: Cannot access database directory %s (%d)\n",
271 bdb->bi_dbenv_home, errno, 0 );
275 /* Perform database use arbitration/recovery logic */
276 rc = alock_open( &bdb->bi_alock_info,
279 slapMode & SLAP_TOOL_READONLY ?
280 ALOCK_LOCKED : ALOCK_UNIQUE );
282 if( rc == ALOCK_RECOVER ) {
283 Debug( LDAP_DEBUG_ANY,
284 "bdb_db_open: unclean shutdown detected;"
285 " attempting recovery.\n",
287 if( bdb_db_recover( be ) != 0 ) {
288 Debug( LDAP_DEBUG_ANY,
289 "bdb_db_open: DB recovery failed.\n",
293 if( alock_recover (&bdb->bi_alock_info) != 0 ) {
294 Debug( LDAP_DEBUG_ANY,
295 "bdb_db_open: alock_recover failed\n",
300 } else if( rc == ALOCK_BUSY ) {
301 Debug( LDAP_DEBUG_ANY,
302 "bdb_db_open: database already in use\n",
305 } else if( rc != ALOCK_CLEAN ) {
306 Debug( LDAP_DEBUG_ANY,
307 "bdb_db_open: alock package is unstable\n",
313 * The DB_CONFIG file may have changed. If so, recover the
314 * database so that new settings are put into effect. Also
315 * note the possible absence of DB_CONFIG in the log.
317 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
318 ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
319 *ptr++ = LDAP_DIRSEP[0];
320 strcpy( ptr, bdbi_databases[0].file);
321 if( stat( path, &stat2 ) == 0 ) {
322 if( stat2.st_mtime <= stat1.st_mtime ) {
323 Debug( LDAP_DEBUG_ANY,
324 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
325 "Performing database recovery to activate new settings.\n",
326 be->be_suffix[0].bv_val, 0, 0 );
327 if( bdb_do_recovery( be ) != 0) {
328 Debug( LDAP_DEBUG_ANY,
329 "bdb_db_open: db recovery failed.\n",
338 Debug( LDAP_DEBUG_ANY,
339 "bdb_db_open: Warning - No DB_CONFIG file found "
340 "in directory %s: (%d)\n"
341 "Expect poor performance for suffix %s.\n",
342 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
345 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
346 if ( !( slapMode & SLAP_TOOL_QUICK ))
347 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
349 rc = db_env_create( &bdb->bi_dbenv, 0 );
351 Debug( LDAP_DEBUG_ANY,
352 "bdb_db_open: db_env_create failed: %s (%d)\n",
353 db_strerror(rc), rc, 0 );
357 /* If a key was set, use shared memory for the BDB environment */
358 if ( bdb->bi_shm_key ) {
359 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
360 flags |= DB_SYSTEM_MEM;
363 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
364 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
365 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
367 /* One long-lived TXN per thread, two TXNs per write op */
368 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
370 #ifdef SLAP_ZONE_ALLOC
371 if ( bdb->bi_cache.c_maxsize ) {
372 bdb->bi_cache.c_zctx = slap_zn_mem_create(
380 if ( bdb->bi_idl_cache_max_size ) {
381 bdb->bi_idl_tree = NULL;
382 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
383 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
384 bdb->bi_idl_cache_size = 0;
387 if( bdb->bi_dbenv_xflags != 0 ) {
388 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
389 bdb->bi_dbenv_xflags, 1);
391 Debug( LDAP_DEBUG_ANY,
392 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
393 db_strerror(rc), rc, 0 );
398 Debug( LDAP_DEBUG_TRACE,
399 "bdb_db_open: dbenv_open(%s)\n",
400 bdb->bi_dbenv_home, 0, 0);
403 strcpy( path, bdb->bi_dbenv_home );
405 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
408 bdb->bi_dbenv_mode );
410 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
413 bdb->bi_dbenv_mode );
416 Debug( LDAP_DEBUG_ANY,
417 "bdb_db_open: dbenv_open failed: %s (%d)\n",
418 db_strerror(rc), rc, 0 );
422 flags = DB_THREAD | bdb->bi_db_opflags;
424 #ifdef DB_AUTO_COMMIT
425 if ( !( slapMode & SLAP_TOOL_QUICK ))
426 flags |= DB_AUTO_COMMIT;
429 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
430 BDB_INDICES * sizeof(struct bdb_db_info *) );
432 /* open (and create) main database */
433 for( i = 0; bdbi_databases[i].name; i++ ) {
434 struct bdb_db_info *db;
436 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
438 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
440 Debug( LDAP_DEBUG_ANY,
441 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
442 bdb->bi_dbenv_home, db_strerror(rc), rc );
446 if( i == BDB_ID2ENTRY ) {
447 rc = db->bdi_db->set_pagesize( db->bdi_db,
448 BDB_ID2ENTRY_PAGESIZE );
449 if ( slapMode & SLAP_TOOL_READMAIN ) {
455 rc = db->bdi_db->set_flags( db->bdi_db,
456 DB_DUP | DB_DUPSORT );
458 if ( slapMode & SLAP_TOOL_READONLY ) {
464 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
470 rc = db->bdi_db->set_pagesize( db->bdi_db,
475 strcpy( path, bdbi_databases[i].file );
477 rc = DB_OPEN( db->bdi_db,
479 /* bdbi_databases[i].name, */ NULL,
480 bdbi_databases[i].type,
481 bdbi_databases[i].flags | flags,
482 bdb->bi_dbenv_mode );
484 rc = DB_OPEN( db->bdi_db,
485 bdbi_databases[i].file,
486 /* bdbi_databases[i].name, */ NULL,
487 bdbi_databases[i].type,
488 bdbi_databases[i].flags | flags,
489 bdb->bi_dbenv_mode );
493 char buf[SLAP_TEXT_BUFLEN];
495 snprintf( buf, sizeof(buf), "%s/%s",
496 bdb->bi_dbenv_home, bdbi_databases[i].file );
497 Debug( LDAP_DEBUG_ANY,
498 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
499 buf, db_strerror(rc), rc );
503 flags &= ~(DB_CREATE | DB_RDONLY);
504 db->bdi_name = bdbi_databases[i].name;
505 bdb->bi_databases[i] = db;
508 bdb->bi_databases[i] = NULL;
509 bdb->bi_ndatabases = i;
512 rc = bdb_last_id( be, NULL );
514 Debug( LDAP_DEBUG_ANY,
515 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
516 bdb->bi_dbenv_home, db_strerror(rc), rc );
520 if ( !( slapMode & SLAP_TOOL_QUICK )) {
521 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
524 if (( slapMode&SLAP_SERVER_MODE ) && ( bdb->bi_flags&BDB_HAS_CONFIG )) {
525 char buf[SLAP_TEXT_BUFLEN];
526 FILE *f = fopen( bdb->bi_db_config_path, "r" );
530 while ( fgets( buf, sizeof(buf), f )) {
531 ber_str2bv( buf, 0, 1, &bv );
532 if ( bv.bv_val[bv.bv_len-1] == '\n' ) {
534 bv.bv_val[bv.bv_len] = '\0';
536 /* shouldn't need this, but ... */
537 if ( bv.bv_val[bv.bv_len-1] == '\r' ) {
539 bv.bv_val[bv.bv_len] = '\0';
541 ber_bvarray_add( &bdb->bi_db_config, &bv );
545 /* Eh? It disappeared between config and open?? */
546 bdb->bi_flags &= ~BDB_HAS_CONFIG;
550 bdb->bi_flags |= BDB_IS_OPEN;
556 bdb_db_close( BackendDB *be )
559 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
560 struct bdb_db_info *db;
561 bdb_idl_cache_entry_t *entry, *next_entry;
563 bdb->bi_flags &= ~BDB_IS_OPEN;
565 ber_bvarray_free( bdb->bi_db_config );
567 while( bdb->bi_ndatabases-- ) {
568 db = bdb->bi_databases[bdb->bi_ndatabases];
569 rc = db->bdi_db->close( db->bdi_db, 0 );
570 /* Lower numbered names are not strdup'd */
571 if( bdb->bi_ndatabases >= BDB_NDB )
572 free( db->bdi_name );
575 free( bdb->bi_databases );
576 bdb_attr_index_destroy( bdb->bi_attrs );
578 bdb_cache_release_all (&bdb->bi_cache);
580 if ( bdb->bi_idl_cache_max_size ) {
581 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
582 avl_free( bdb->bi_idl_tree, NULL );
583 entry = bdb->bi_idl_lru_head;
584 while ( entry != NULL ) {
585 next_entry = entry->idl_lru_next;
588 free( entry->kstr.bv_val );
592 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
595 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
596 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
603 bdb_db_destroy( BackendDB *be )
606 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
608 /* close db environment */
609 if( bdb->bi_dbenv ) {
610 /* force a checkpoint */
611 if ( !( slapMode & SLAP_TOOL_QUICK )) {
612 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
614 Debug( LDAP_DEBUG_ANY,
615 "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
616 db_strerror(rc), rc, 0 );
620 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
621 bdb->bi_dbenv = NULL;
623 Debug( LDAP_DEBUG_ANY,
624 "bdb_db_destroy: close failed: %s (%d)\n",
625 db_strerror(rc), rc, 0 );
630 rc = alock_close( &bdb->bi_alock_info );
632 Debug( LDAP_DEBUG_ANY,
633 "bdb_db_destroy: alock_close failed\n", 0, 0, 0 );
637 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
638 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
640 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
641 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
642 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
643 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
644 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
645 if ( bdb->bi_idl_cache_max_size ) {
646 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
647 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
651 be->be_private = NULL;
662 static char *controls[] = {
664 LDAP_CONTROL_MANAGEDSAIT,
666 LDAP_CONTROL_PAGEDRESULTS,
667 #ifdef LDAP_CONTROL_SUBENTRIES
668 LDAP_CONTROL_SUBENTRIES,
670 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
671 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
676 /* initialize the underlying database system */
677 Debug( LDAP_DEBUG_TRACE,
678 LDAP_XSTRING(bdb_back_initialize) ": initialize "
679 BDB_UCTYPE " backend\n", 0, 0, 0 );
682 SLAP_BFLAG_INCREMENT |
683 #ifdef BDB_SUBENTRIES
684 SLAP_BFLAG_SUBENTRIES |
687 SLAP_BFLAG_REFERRALS;
689 bi->bi_controls = controls;
691 { /* version check */
692 int major, minor, patch, ver;
693 char *version = db_version( &major, &minor, &patch );
697 /* All our stdio does an ASCII to EBCDIC conversion on
698 * the output. Strings from the BDB library are already
699 * in EBCDIC; we have to go back and forth...
701 strcpy( v2, version );
706 ver = (major << 24) | (minor << 16) | patch;
707 if( ver != DB_VERSION_FULL ) {
708 /* fail if a versions don't match */
709 Debug( LDAP_DEBUG_ANY,
710 LDAP_XSTRING(bdb_back_initialize) ": "
711 "BDB library version mismatch:"
712 " expected " DB_VERSION_STRING ","
713 " got %s\n", version, 0, 0 );
717 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
718 ": %s\n", version, 0, 0 );
721 db_env_set_func_free( ber_memfree );
722 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
723 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
725 /* This is a no-op on a NO_THREAD build. Leave the default
726 * alone so that BDB will sleep on interprocess conflicts.
728 db_env_set_func_yield( ldap_pvt_thread_yield );
736 bi->bi_db_init = bdb_db_init;
737 bi->bi_db_config = config_generic_wrapper;
738 bi->bi_db_open = bdb_db_open;
739 bi->bi_db_close = bdb_db_close;
740 bi->bi_db_destroy = bdb_db_destroy;
742 bi->bi_op_add = bdb_add;
743 bi->bi_op_bind = bdb_bind;
744 bi->bi_op_compare = bdb_compare;
745 bi->bi_op_delete = bdb_delete;
746 bi->bi_op_modify = bdb_modify;
747 bi->bi_op_modrdn = bdb_modrdn;
748 bi->bi_op_search = bdb_search;
750 bi->bi_op_unbind = 0;
752 bi->bi_extended = bdb_extended;
754 bi->bi_chk_referrals = bdb_referrals;
755 bi->bi_operational = bdb_operational;
756 bi->bi_has_subordinates = bdb_hasSubordinates;
757 bi->bi_entry_release_rw = bdb_entry_release;
758 bi->bi_entry_get_rw = bdb_entry_get;
761 * hooks for slap tools
763 bi->bi_tool_entry_open = bdb_tool_entry_open;
764 bi->bi_tool_entry_close = bdb_tool_entry_close;
765 bi->bi_tool_entry_first = bdb_tool_entry_next;
766 bi->bi_tool_entry_next = bdb_tool_entry_next;
767 bi->bi_tool_entry_get = bdb_tool_entry_get;
768 bi->bi_tool_entry_put = bdb_tool_entry_put;
769 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
770 bi->bi_tool_sync = 0;
771 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
772 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
773 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
775 bi->bi_connection_init = 0;
776 bi->bi_connection_destroy = 0;
778 rc = bdb_back_init_cf( bi );
783 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
784 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
786 /* conditionally define the init_module() function */
788 SLAP_BACKEND_INIT_MODULE( hdb )
789 #else /* !BDB_HIER */
790 SLAP_BACKEND_INIT_MODULE( bdb )
791 #endif /* !BDB_HIER */
793 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */