From afd3f7c5ecdc2c84ec27f062b3813d1b1b370831 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 23 Apr 2005 17:21:45 +0000 Subject: [PATCH] Fix DB_CONFIG loading --- servers/slapd/back-bdb/config.c | 24 ++++++++++++++++++++++++ servers/slapd/back-bdb/init.c | 26 -------------------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index 6a396236c6..ad242744c7 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -353,6 +353,30 @@ bdb_cf_gen(ConfigArgs *c) break; case BDB_CONFIG: + if (( slapMode&SLAP_SERVER_MODE ) && !( bdb->bi_flags&BDB_IS_OPEN ) + && !bdb->bi_db_config ) { + char buf[SLAP_TEXT_BUFLEN]; + FILE *f = fopen( bdb->bi_db_config_path, "r" ); + struct berval bv; + + if ( f ) { + bdb->bi_flags |= BDB_HAS_CONFIG; + while ( fgets( buf, sizeof(buf), f )) { + ber_str2bv( buf, 0, 1, &bv ); + if ( bv.bv_val[bv.bv_len-1] == '\n' ) { + bv.bv_len--; + bv.bv_val[bv.bv_len] = '\0'; + } + /* shouldn't need this, but ... */ + if ( bv.bv_val[bv.bv_len-1] == '\r' ) { + bv.bv_len--; + bv.bv_val[bv.bv_len] = '\0'; + } + ber_bvarray_add( &bdb->bi_db_config, &bv ); + } + fclose( f ); + } + } if ( bdb->bi_db_config ) { int i; struct berval bv; diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 8821698660..21c4985d8f 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -527,32 +527,6 @@ bdb_db_open( BackendDB *be ) XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker); } - if (( slapMode&SLAP_SERVER_MODE ) && ( bdb->bi_flags&BDB_HAS_CONFIG )) { - char buf[SLAP_TEXT_BUFLEN]; - FILE *f = fopen( bdb->bi_db_config_path, "r" ); - struct berval bv; - - if ( f ) { - while ( fgets( buf, sizeof(buf), f )) { - ber_str2bv( buf, 0, 1, &bv ); - if ( bv.bv_val[bv.bv_len-1] == '\n' ) { - bv.bv_len--; - bv.bv_val[bv.bv_len] = '\0'; - } - /* shouldn't need this, but ... */ - if ( bv.bv_val[bv.bv_len-1] == '\r' ) { - bv.bv_len--; - bv.bv_val[bv.bv_len] = '\0'; - } - ber_bvarray_add( &bdb->bi_db_config, &bv ); - } - fclose( f ); - } else { - /* Eh? It disappeared between config and open?? */ - bdb->bi_flags &= ~BDB_HAS_CONFIG; - } - - } bdb->bi_flags |= BDB_IS_OPEN; return 0; -- 2.39.5