1 /* config.c - bdb backend configuration file routine */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
17 # define SLAP_BDB_ALLOW_DIRTY_READ
28 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
31 fprintf( stderr, "%s: line %d: "
32 "bdb database info is null!\n",
37 /* directory is the DB_HOME */
38 if ( strcasecmp( argv[0], "directory" ) == 0 ) {
40 fprintf( stderr, "%s: line %d: "
41 "missing dir in \"directory <dir>\" line\n",
45 if ( bdb->bi_dbenv_home ) {
46 free( bdb->bi_dbenv_home );
48 bdb->bi_dbenv_home = ch_strdup( argv[1] );
50 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
51 } else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
52 bdb->bi_db_opflags |= DB_DIRTY_READ;
54 /* transaction logging configuration */
55 } else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
56 bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
58 /* transaction checkpoint configuration */
59 } else if ( strcasecmp( argv[0], "checkpoint" ) == 0 ) {
61 fprintf( stderr, "%s: line %d: "
62 "missing parameters in \"checkpoint <kbyte> <min>\" line\n",
67 bdb->bi_txn_cp_kbyte = strtol( argv[1], NULL, 0 );
68 bdb->bi_txn_cp_min = strtol( argv[2], NULL, 0 );
70 /* lock detect configuration */
71 } else if ( strcasecmp( argv[0], "lockdetect" ) == 0 ) {
73 fprintf( stderr, "%s: line %d: "
74 "missing parameters in \"lockDetect <policy>\" line\n",
79 if( strcasecmp( argv[1], "default" ) == 0 ) {
80 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
82 } else if( strcasecmp( argv[1], "oldest" ) == 0 ) {
83 bdb->bi_lock_detect = DB_LOCK_OLDEST;
85 } else if( strcasecmp( argv[1], "random" ) == 0 ) {
86 bdb->bi_lock_detect = DB_LOCK_RANDOM;
88 } else if( strcasecmp( argv[1], "youngest" ) == 0 ) {
89 bdb->bi_lock_detect = DB_LOCK_YOUNGEST;
91 } else if( strcasecmp( argv[1], "fewest" ) == 0 ) {
92 bdb->bi_lock_detect = DB_LOCK_MINLOCKS;
95 fprintf( stderr, "%s: line %d: "
96 "bad policy (%s) in \"lockDetect <policy>\" line\n",
97 fname, lineno, argv[1] );
101 /* mode with which to create new database files */
102 } else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
104 fprintf( stderr, "%s: line %d: "
105 "missing mode in \"mode <mode>\" line\n",
109 bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
111 /* attribute to index */
112 } else if ( strcasecmp( argv[0], "index" ) == 0 ) {
115 fprintf( stderr, "%s: line %d: "
116 "missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
119 } else if ( argc > 3 ) {
120 fprintf( stderr, "%s: line %d: "
121 "extra junk after \"index <attr> [pres,eq,approx,sub]\" "
125 rc = bdb_attr_index_config( bdb, fname, lineno, argc - 1, &argv[1] );
127 if( rc != LDAP_SUCCESS ) return 1;
129 /* unique key for shared memory regions */
130 } else if ( strcasecmp( argv[0], "shm_key" ) == 0 ) {
133 "%s: line %d: missing key in \"shm_key <key>\" line\n",
137 bdb->bi_shm_key = atoi( argv[1] );
139 /* size of the cache in entries */
140 } else if ( strcasecmp( argv[0], "cachesize" ) == 0 ) {
143 "%s: line %d: missing size in \"cachesize <size>\" line\n",
147 bdb->bi_cache.c_maxsize = atoi( argv[1] );
149 /* depth of search stack cache in units of (IDL)s */
150 } else if ( strcasecmp( argv[0], "searchstack" ) == 0 ) {
153 "%s: line %d: missing depth in \"searchstack <depth>\" line\n",
157 bdb->bi_search_stack_depth = atoi( argv[1] );
158 if ( bdb->bi_search_stack_depth < MINIMUM_SEARCH_STACK_DEPTH ) {
160 "%s: line %d: depth %d too small, using %d\n",
161 fname, lineno, bdb->bi_search_stack_depth,
162 MINIMUM_SEARCH_STACK_DEPTH );
163 bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH;
166 #ifdef SLAP_IDL_CACHE
167 /* size of the IDL cache in entries */
168 } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) {
171 "%s: line %d: missing size in \"idlcachesize <size>\" line\n",
175 if ( !( slapMode & SLAP_TOOL_MODE ) )
176 bdb->bi_idl_cache_max_size = atoi( argv[1] );
179 } else if ( strcasecmp( argv[0], "sessionlog" ) == 0 ) {
180 int se_id = 0, se_size = 0;
181 struct slap_session_entry *sent;
184 LDAP_LOG( CONFIG, CRIT,
185 "%s: line %d: missing arguments in \"sessionlog <id> <size>\""
186 " line.\n", fname, lineno , 0 );
188 Debug( LDAP_DEBUG_ANY,
189 "%s: line %d: missing arguments in \"sessionlog <id> <size>\""
190 " line\n", fname, lineno, 0 );
195 se_id = atoi( argv[1] );
196 se_size = atoi( argv[2] );
198 if ( se_id < 0 || se_id > 999 ) {
200 LDAP_LOG( CONFIG, CRIT,
201 "%s: line %d: session log id %d is out of range [0..999]\n",
202 fname, lineno , se_id );
204 Debug( LDAP_DEBUG_ANY,
205 "%s: line %d: session log id %d is out of range [0..999]\n",
206 fname, lineno , se_id );
211 if ( se_size < 0 || se_size > 999 ) {
213 LDAP_LOG( CONFIG, CRIT,
214 "%s: line %d: session log size %d is negative\n",
215 fname, lineno , se_size );
217 Debug( LDAP_DEBUG_ANY,
218 "%s: line %d: session log size %d is negative\n",
219 fname, lineno , se_size );
224 LDAP_LIST_FOREACH( sent, &bdb->bi_session_list, se_link ) {
225 if ( sent->se_id == se_id ) {
227 LDAP_LOG( CONFIG, CRIT,
228 "%s: line %d: session %d already exists\n",
229 fname, lineno , se_id );
231 Debug( LDAP_DEBUG_ANY,
232 "%s: line %d: session %d already exists\n",
233 fname, lineno , se_id );
238 sent = (struct slap_session_entry *) ch_calloc( 1,
239 sizeof( struct slap_session_entry ));
241 sent->se_size = se_size;
242 LDAP_LIST_INSERT_HEAD( &bdb->bi_session_list, sent, se_link );
246 fprintf( stderr, "%s: line %d: "
247 "unknown directive \"%s\" in bdb database definition (ignored)\n",
248 fname, lineno, argv[0] );