]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/init.c
back_attribute() should use ACL_AUTH not ACL_READ (at
[openldap] / servers / slapd / back-bdb / init.c
1 /* init.c - initialize bdb backend */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11 #include <ac/string.h>
12 #include <ac/unistd.h>
13 #include <ac/stdlib.h>
14
15 #include <lutil.h>
16
17 #include "back-bdb.h"
18 #include "external.h"
19
20 static struct bdbi_database {
21         char *file;
22         char *name;
23         int type;
24         int flags;
25 } bdbi_databases[] = {
26         { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
27 #ifdef BDB_HIER
28         { "id2parent" BDB_SUFFIX, "id2parent", DB_BTREE, 0 },
29 #else
30         { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
31 #endif
32         { NULL, NULL, 0, 0 }
33 };
34
35 struct berval bdb_uuid = { 0, NULL };
36
37 typedef void * db_malloc(size_t);
38 typedef void * db_realloc(void *, size_t);
39
40 static int
41 bdb_open( BackendInfo *bi )
42 {
43         return 0;
44 }
45
46 #if 0
47 static int
48 bdb_destroy( BackendInfo *bi )
49 {
50         return 0;
51 }
52
53 static int
54 bdb_close( BackendInfo *bi )
55 {
56         /* terminate the underlying database system */
57         return 0;
58 }
59 #endif
60
61 static int
62 bdb_db_init( BackendDB *be )
63 {
64         struct bdb_info *bdb;
65
66 #ifdef NEW_LOGGING
67         LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_init", 0, 0, 0 );
68 #else
69         Debug( LDAP_DEBUG_ANY,
70                 "bdb_db_init: Initializing BDB database\n",
71                 0, 0, 0 );
72 #endif
73
74         /* indicate system schema supported */
75         be->be_flags |=
76 #ifdef BDB_SUBENTRIES
77                 SLAP_BFLAG_SUBENTRIES |
78 #endif
79 #ifdef BDB_ALIASES
80                 SLAP_BFLAG_ALIASES |
81 #endif
82                 SLAP_BFLAG_REFERRALS;
83
84         /* allocate backend-database-specific stuff */
85         bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
86
87         /* DBEnv parameters */
88         bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
89         bdb->bi_dbenv_xflags = 0;
90         bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
91
92         bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
93
94 #ifndef NO_THREADS
95 #if 0
96         bdb->bi_lock_detect = DB_LOCK_NORUN;
97 #else
98         bdb->bi_lock_detect = DB_LOCK_DEFAULT;
99 #endif
100 #endif
101
102         ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
103         ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
104         ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
105         ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
106 #ifdef BDB_HIER
107         ldap_pvt_thread_rdwr_init( &bdb->bi_tree_rdwr );
108 #endif
109
110         be->be_private = bdb;
111         return 0;
112 }
113
114 #if 0 /* ifndef NO_THREADS */
115 static void *lock_detect_task( void *arg )
116 {
117         struct bdb_info *bdb = (struct bdb_info *) arg;
118
119         while( bdb->bi_dbenv != NULL ) {
120                 int rc;
121                 int aborted;
122                 sleep( bdb->bi_lock_detect_seconds );
123
124                 rc = LOCK_DETECT( bdb->bi_dbenv, 0,
125                         bdb->bi_lock_detect, &aborted );
126
127                 if( rc != 0 ) {
128                         break;
129                 }
130
131 #ifdef NEW_LOGGING
132                 LDAP_LOG( BACK_BDB, ERR, "bdb_db_init: aborted %d locks\n", 
133                         aborted, 0, 0 );
134 #else
135                 Debug( LDAP_DEBUG_ANY,
136                         "bdb_lock_detect: aborted %d locks\n",
137                         aborted, 0, 0 );
138 #endif
139         }
140
141         return NULL;
142 }
143 #endif
144
145 int
146 bdb_bt_compare(
147         DB *db, 
148         const DBT *usrkey,
149         const DBT *curkey
150 )
151 {
152         unsigned char *u, *c;
153         int i;
154
155         u = usrkey->data;
156         c = curkey->data;
157
158 #ifdef WORDS_BIGENDIAN
159         for( i = 0; i < sizeof(ID); i++)
160 #else
161         for( i = sizeof(ID)-1; i >= 0; i--)
162 #endif
163         {
164                 if( u[i] - c[i] )
165                         return u[i] - c[i];
166         }
167         return 0;
168 }
169
170 static int
171 bdb_db_open( BackendDB *be )
172 {
173         int rc, i;
174         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
175         u_int32_t flags;
176 #ifdef HAVE_EBCDIC
177         char path[MAXPATHLEN];
178 #endif
179
180 #ifdef NEW_LOGGING
181         LDAP_LOG( BACK_BDB, ARGS, 
182                 "bdb_db_open: %s\n", be->be_suffix[0].bv_val, 0, 0 );
183 #else
184         Debug( LDAP_DEBUG_ARGS,
185                 "bdb_db_open: %s\n",
186                 be->be_suffix[0].bv_val, 0, 0 );
187 #endif
188
189         /* we should check existance of dbenv_home and db_directory */
190
191         rc = db_env_create( &bdb->bi_dbenv, 0 );
192         if( rc != 0 ) {
193 #ifdef NEW_LOGGING
194                 LDAP_LOG( BACK_BDB, ERR, 
195                         "bdb_db_open: db_env_create failed: %s (%d)\n", 
196                         db_strerror(rc), rc, 0 );
197 #else
198                 Debug( LDAP_DEBUG_ANY,
199                         "bdb_db_open: db_env_create failed: %s (%d)\n",
200                         db_strerror(rc), rc, 0 );
201 #endif
202                 return rc;
203         }
204
205         bdb->bi_dbenv->set_alloc( bdb->bi_dbenv, (db_malloc *)ber_memalloc,
206                 (db_realloc *)ber_memrealloc, ber_memfree );
207
208         flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE
209                 | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
210         
211 #if 0
212         /* Never do automatic recovery, must perform it manually.
213          * Otherwise restarting with gentlehup will corrupt the
214          * database.
215          */
216         if( !(slapMode & SLAP_TOOL_MODE) ) flags |= DB_RECOVER;
217 #endif
218
219         bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
220         bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
221 #ifndef NO_THREADS
222         bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
223 #endif
224
225 #ifdef BDB_SUBDIRS
226         {
227                 char dir[MAXPATHLEN];
228                 size_t len = strlen( bdb->bi_dbenv_home );
229
230                 strcpy( dir, bdb->bi_dbenv_home );
231                 strcat( &dir[len], BDB_TMP_SUBDIR );
232                 
233                 rc = bdb->bi_dbenv->set_tmp_dir( bdb->bi_dbenv, dir );
234                 if( rc != 0 ) {
235 #ifdef NEW_LOGGING
236                         LDAP_LOG( BACK_BDB, ERR, 
237                                 "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n", 
238                                 dir, db_strerror(rc), rc );
239 #else
240                         Debug( LDAP_DEBUG_ANY,
241                                 "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n",
242                                 dir, db_strerror(rc), rc );
243 #endif
244                         return rc;
245                 }
246
247                 strcat( &dir[len], BDB_LG_SUBDIR );
248
249                 rc = bdb->bi_dbenv->set_lg_dir( bdb->bi_dbenv, dir );
250                 if( rc != 0 ) {
251 #ifdef NEW_LOGGING
252                         LDAP_LOG( BACK_BDB, ERR, 
253                                 "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", 
254                                 dir, db_strerror(rc), rc );
255 #else
256                         Debug( LDAP_DEBUG_ANY,
257                                 "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n",
258                                 dir, db_strerror(rc), rc );
259 #endif
260                         return rc;
261                 }
262
263                 strcat( &dir[len], BDB_DATA_SUBDIR );
264
265                 rc = bdb->bi_dbenv->set_data_dir( bdb->bi_dbenv, dir );
266                 if( rc != 0 ) {
267 #ifdef NEW_LOGGING
268                         LDAP_LOG( BACK_BDB, ERR, 
269                                 "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n",
270                                 dir, db_strerror(rc), rc );
271 #else
272                         Debug( LDAP_DEBUG_ANY,
273                                 "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n",
274                                 dir, db_strerror(rc), rc );
275 #endif
276                         return rc;
277                 }
278         }
279 #endif
280
281 #ifdef NEW_LOGGING
282         LDAP_LOG( BACK_BDB, DETAIL1, 
283                 "bdb_db_open: dbenv_open %s\n", bdb->bi_dbenv_home, 0, 0 );
284 #else
285         Debug( LDAP_DEBUG_TRACE,
286                 "bdb_db_open: dbenv_open(%s)\n",
287                 bdb->bi_dbenv_home, 0, 0);
288 #endif
289
290 #ifdef HAVE_EBCDIC
291         strcpy( path, bdb->bi_dbenv_home );
292         __atoe( path );
293         rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
294                 path,
295                 flags,
296                 bdb->bi_dbenv_mode );
297 #else
298         rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
299                 bdb->bi_dbenv_home,
300                 flags,
301                 bdb->bi_dbenv_mode );
302 #endif
303         if( rc != 0 ) {
304 #ifdef NEW_LOGGING
305                 LDAP_LOG( BACK_BDB, ERR, 
306                         "bdb_db_open: dbenv_open failed: %s (%d)\n", 
307                         db_strerror(rc), rc, 0 );
308 #else
309                 Debug( LDAP_DEBUG_ANY,
310                         "bdb_db_open: dbenv_open failed: %s (%d)\n",
311                         db_strerror(rc), rc, 0 );
312 #endif
313                 return rc;
314         }
315
316         if( bdb->bi_dbenv_xflags != 0 ) {
317                 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
318                         bdb->bi_dbenv_xflags, 1);
319                 if( rc != 0 ) {
320 #ifdef NEW_LOGGING
321                         LDAP_LOG( BACK_BDB, ERR, 
322                                 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", 
323                                 db_strerror(rc), rc, 0 );
324 #else
325                         Debug( LDAP_DEBUG_ANY,
326                                 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
327                                 db_strerror(rc), rc, 0 );
328 #endif
329                         return rc;
330                 }
331         }
332
333         flags = DB_THREAD | DB_CREATE | bdb->bi_db_opflags;
334
335         bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
336                 BDB_INDICES * sizeof(struct bdb_db_info *) );
337
338         /* open (and create) main database */
339         for( i = 0; bdbi_databases[i].name; i++ ) {
340                 struct bdb_db_info *db;
341
342                 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
343
344                 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
345                 if( rc != 0 ) {
346 #ifdef NEW_LOGGING
347                         LDAP_LOG( BACK_BDB, ERR, 
348                                 "bdb_db_open: db_create(%s) failed: %s (%d)\n", 
349                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
350 #else
351                         Debug( LDAP_DEBUG_ANY,
352                                 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
353                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
354 #endif
355                         return rc;
356                 }
357
358                 if( i == BDB_ID2ENTRY ) {
359                         rc = db->bdi_db->set_bt_compare( db->bdi_db,
360                                 bdb_bt_compare );
361                         rc = db->bdi_db->set_pagesize( db->bdi_db,
362                                 BDB_ID2ENTRY_PAGESIZE );
363                 } else {
364 #ifdef BDB_HIER
365                         rc = db->bdi_db->set_bt_compare( db->bdi_db,
366                                 bdb_bt_compare );
367 #elif defined(BDB_IDL_MULTI)
368                         rc = db->bdi_db->set_flags( db->bdi_db, 
369                                 DB_DUP | DB_DUPSORT );
370                         rc = db->bdi_db->set_dup_compare( db->bdi_db,
371                                 bdb_bt_compare );
372 #endif
373                         rc = db->bdi_db->set_pagesize( db->bdi_db,
374                                 BDB_PAGESIZE );
375                 }
376
377 #ifdef HAVE_EBCDIC
378                 strcpy( path, bdbi_databases[i].file );
379                 __atoe( path );
380                 rc = DB_OPEN( db->bdi_db, 
381                         path,
382                 /*      bdbi_databases[i].name, */ NULL,
383                         bdbi_databases[i].type,
384                         bdbi_databases[i].flags | flags,
385                         bdb->bi_dbenv_mode );
386 #else
387                 rc = DB_OPEN( db->bdi_db, 
388                         bdbi_databases[i].file,
389                 /*      bdbi_databases[i].name, */ NULL,
390                         bdbi_databases[i].type,
391                         bdbi_databases[i].flags | flags,
392                         bdb->bi_dbenv_mode );
393 #endif
394
395                 if( rc != 0 ) {
396 #ifdef NEW_LOGGING
397                         LDAP_LOG( BACK_BDB, ERR, 
398                                 "bdb_db_open: db_create(%s) failed: %s (%d)\n", 
399                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
400 #else
401                         Debug( LDAP_DEBUG_ANY,
402                                 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
403                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
404 #endif
405                         return rc;
406                 }
407
408                 db->bdi_name = bdbi_databases[i].name;
409                 bdb->bi_databases[i] = db;
410         }
411
412         bdb->bi_databases[i] = NULL;
413         bdb->bi_ndatabases = i;
414
415         /* get nextid */
416         rc = bdb_last_id( be, NULL );
417         if( rc != 0 ) {
418 #ifdef NEW_LOGGING
419                         LDAP_LOG( BACK_BDB, ERR, 
420                                 "bdb_db_open: last_id(%s) failed: %s (%d)\n", 
421                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
422 #else
423                 Debug( LDAP_DEBUG_ANY,
424                         "bdb_db_open: last_id(%s) failed: %s (%d)\n",
425                         bdb->bi_dbenv_home, db_strerror(rc), rc );
426 #endif
427                 return rc;
428         }
429
430         /* <insert> open (and create) index databases */
431 #ifdef BDB_HIER
432         rc = bdb_build_tree( be );
433 #endif
434
435 #if 0 /* ifndef NO_THREADS */
436         if( bdb->bi_lock_detect != DB_LOCK_NORUN ) {
437                 /* listener as a separate THREAD */
438                 rc = ldap_pvt_thread_create( &bdb->bi_lock_detect_tid,
439                         1, lock_detect_task, bdb );
440         }
441 #endif
442         return 0;
443 }
444
445 static int
446 bdb_db_close( BackendDB *be )
447 {
448         int rc;
449         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
450         struct bdb_db_info *db;
451
452         while( bdb->bi_ndatabases-- ) {
453                 db = bdb->bi_databases[bdb->bi_ndatabases];
454                 rc = db->bdi_db->close( db->bdi_db, 0 );
455                 /* Lower numbered names are not strdup'd */
456                 if( bdb->bi_ndatabases >= BDB_NDB )
457                         free( db->bdi_name );
458                 free( db );
459         }
460         free( bdb->bi_databases );
461         bdb_attr_index_destroy( bdb->bi_attrs );
462
463         bdb_cache_release_all (&bdb->bi_cache);
464
465         return 0;
466 }
467
468 static int
469 bdb_db_destroy( BackendDB *be )
470 {
471         int rc;
472         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
473
474         /* close db environment */
475         if( bdb->bi_dbenv ) {
476                 /* force a checkpoint */
477                 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
478                 if( rc != 0 ) {
479 #ifdef NEW_LOGGING
480                         LDAP_LOG( BACK_BDB, ERR, 
481                                 "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
482                                 db_strerror(rc), rc, 0 );
483 #else
484                         Debug( LDAP_DEBUG_ANY,
485                                 "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
486                                 db_strerror(rc), rc, 0 );
487 #endif
488                 }
489
490                 bdb_cache_release_all (&bdb->bi_cache);
491
492                 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
493                 bdb->bi_dbenv = NULL;
494                 if( rc != 0 ) {
495 #ifdef NEW_LOGGING
496                         LDAP_LOG( BACK_BDB, ERR, 
497                                 "bdb_db_destroy: close failed: %s (%d)\n", 
498                                 db_strerror(rc), rc, 0 );
499 #else
500                         Debug( LDAP_DEBUG_ANY,
501                                 "bdb_db_destroy: close failed: %s (%d)\n",
502                                 db_strerror(rc), rc, 0 );
503 #endif
504                         return rc;
505                 }
506         }
507
508         if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
509
510 #ifdef BDB_HIER
511         ldap_pvt_thread_rdwr_destroy( &bdb->bi_tree_rdwr );
512 #endif
513         ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
514         ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
515         ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
516         ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
517
518         ch_free( bdb );
519         be->be_private = NULL;
520
521         return 0;
522 }
523
524 #ifdef SLAPD_BDB_DYNAMIC
525 int back_bdb_LTX_init_module( int argc, char *argv[] ) {
526         BackendInfo bi;
527
528         memset( &bi, '\0', sizeof(bi) );
529         bi.bi_type = "bdb";
530         bi.bi_init = bdb_initialize;
531
532         backend_add( &bi );
533         return 0;
534 }
535 #endif /* SLAPD_BDB_DYNAMIC */
536
537 int
538 bdb_initialize(
539         BackendInfo     *bi
540 )
541 {
542         static char *controls[] = {
543                 LDAP_CONTROL_MANAGEDSAIT,
544 #ifdef LDAP_CONTROL_SUBENTRIES
545                 LDAP_CONTROL_SUBENTRIES,
546 #endif
547 #ifdef LDAP_CONTROL_NOOP
548                 LDAP_CONTROL_NOOP,
549 #endif
550 #ifdef LDAP_CONTROL_VALUESRETURNFILTER
551                 LDAP_CONTROL_VALUESRETURNFILTER,
552 #endif
553                 NULL
554         };
555
556         bi->bi_controls = controls;
557
558         /* initialize the underlying database system */
559 #ifdef NEW_LOGGING
560         LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_initialize\n", 0, 0, 0 );
561 #else
562         Debug( LDAP_DEBUG_TRACE, "bdb_open: initialize BDB backend\n",
563                 0, 0, 0 );
564 #endif
565
566         {       /* version check */
567                 int major, minor, patch;
568                 char *version = db_version( &major, &minor, &patch );
569 #ifdef HAVE_EBCDIC
570                 char v2[1024];
571
572                 /* All our stdio does an ASCII to EBCDIC conversion on
573                  * the output. Strings from the BDB library are already
574                  * in EBCDIC; we have to go back and forth...
575                  */
576                 strcpy( v2, version );
577                 __etoa( v2 );
578                 version = v2;
579 #endif
580
581                 if( major != DB_VERSION_MAJOR ||
582                         minor != DB_VERSION_MINOR ||
583                         patch < DB_VERSION_PATCH )
584                 {
585 #ifdef NEW_LOGGING
586                         LDAP_LOG( BACK_BDB, ERR, 
587                                 "bdb_db_initialize: version mismatch: "
588                                 "\texpected: %s \tgot: %s\n", DB_VERSION_STRING, version, 0 );
589 #else
590                         Debug( LDAP_DEBUG_ANY,
591                                 "bdb_open: version mismatch\n"
592                                 "\texpected: " DB_VERSION_STRING "\n"
593                                 "\tgot: %s \n", version, 0, 0 );
594 #endif
595                 }
596
597 #ifdef NEW_LOGGING
598                 LDAP_LOG( BACK_BDB, DETAIL1, 
599                         "bdb_db_initialize: bdb_open: %s\n", version, 0, 0 );
600 #else
601                 Debug( LDAP_DEBUG_ANY, "bdb_open: %s\n",
602                         version, 0, 0 );
603 #endif
604         }
605
606 #if 0
607         db_env_set_func_malloc( ch_malloc );
608         db_env_set_func_realloc( ch_realloc );
609         db_env_set_func_free( ch_free );
610 #endif
611
612         db_env_set_func_yield( ldap_pvt_thread_yield );
613
614         {
615                 static char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
616
617                 bdb_uuid.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ));
618                 bdb_uuid.bv_val = uuidbuf;
619         }
620
621         bi->bi_open = 0;
622         bi->bi_close = 0;
623         bi->bi_config = 0;
624         bi->bi_destroy = 0;
625
626         bi->bi_db_init = bdb_db_init;
627         bi->bi_db_config = bdb_db_config;
628         bi->bi_db_open = bdb_db_open;
629         bi->bi_db_close = bdb_db_close;
630         bi->bi_db_destroy = bdb_db_destroy;
631
632         bi->bi_op_add = bdb_add;
633         bi->bi_op_bind = bdb_bind;
634         bi->bi_op_compare = bdb_compare;
635         bi->bi_op_delete = bdb_delete;
636         bi->bi_op_modify = bdb_modify;
637         bi->bi_op_modrdn = bdb_modrdn;
638         bi->bi_op_search = bdb_search;
639
640         bi->bi_op_unbind = 0;
641         bi->bi_op_abandon = 0;
642
643         bi->bi_extended = bdb_extended;
644
645 #if 1
646         /*
647          * these routines (and their callers) are not yet designed
648          * to work with transaction.  Using them may cause deadlock.
649          */
650         bi->bi_acl_group = bdb_group;
651         bi->bi_acl_attribute = bdb_attribute;
652 #else
653         bi->bi_acl_group = 0;
654         bi->bi_acl_attribute = 0;
655 #endif
656
657         bi->bi_chk_referrals = bdb_referrals;
658         bi->bi_operational = bdb_operational;
659         bi->bi_entry_release_rw = bdb_entry_release;
660
661         /*
662          * hooks for slap tools
663          */
664         bi->bi_tool_entry_open = bdb_tool_entry_open;
665         bi->bi_tool_entry_close = bdb_tool_entry_close;
666         bi->bi_tool_entry_first = bdb_tool_entry_next;
667         bi->bi_tool_entry_next = bdb_tool_entry_next;
668         bi->bi_tool_entry_get = bdb_tool_entry_get;
669         bi->bi_tool_entry_put = bdb_tool_entry_put;
670         bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
671         bi->bi_tool_sync = 0;
672
673         bi->bi_connection_init = 0;
674         bi->bi_connection_destroy = 0;
675
676         return 0;
677 }