From 351e436dcf037813cc378529f4fc6bd2c8ec9047 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 29 May 2001 01:51:37 +0000 Subject: [PATCH] Add an LDBM backend "directory" directive (in addition to the existing database "directory" directive) to allow setting of a DB_ENV directory. Should likely be database specific. --- doc/man/man5/slapd.conf.5 | 53 +++++++++++++++++++++-------- servers/slapd/back-ldbm/back-ldbm.h | 4 +++ servers/slapd/back-ldbm/config.c | 42 +++++++++++++++++++++++ servers/slapd/back-ldbm/external.h | 3 ++ servers/slapd/back-ldbm/init.c | 15 ++++++-- tests/data/slapd-acl.conf | 3 ++ tests/data/slapd-master.conf | 3 ++ tests/data/slapd-pw.conf | 3 ++ tests/data/slapd-ref-slave.conf | 3 ++ tests/data/slapd-repl-master.conf | 3 ++ tests/data/slapd-repl-slave.conf | 3 ++ tests/data/slapd-schema.conf | 3 ++ tests/data/slapd.conf | 3 ++ 13 files changed, 125 insertions(+), 16 deletions(-) diff --git a/doc/man/man5/slapd.conf.5 b/doc/man/man5/slapd.conf.5 index b03bbba9e5..70cebdda21 100644 --- a/doc/man/man5/slapd.conf.5 +++ b/doc/man/man5/slapd.conf.5 @@ -1,5 +1,5 @@ -.TH SLAPD.CONF 5 "17 October 2000" "OpenLDAP LDVERSION" -.\" Copyright 1998-2000 The OpenLDAP Foundation All Rights Reserved. +.TH SLAPD.CONF 5 "28 May 2001" "OpenLDAP LDVERSION" +.\" Copyright 1998-2001 The OpenLDAP Foundation All Rights Reserved. .\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" $OpenLDAP$ .SH NAME @@ -56,9 +56,10 @@ backslash character (`\\'), the character should be preceded by a backslash character. .LP The specific configuration options available are discussed below in the -Global Configuration Options, General Backend Options, LDBM -Backend-Specific Options, Shell Backend-Specific Options, and Password -Backend-Specific Options sections. Refer to the "OpenLDAP +Global Configuration Options, General Backend Options, General Database +Options, LDBM Backend-Specific Options, LDBM Database-Specific Options, +Shell Database-Specific Options, and Password +Database-Specific Options sections. Refer to the "OpenLDAP Administrator's Guide" for more details on the slapd configuration file. .SH GLOBAL CONFIGURATION OPTIONS @@ -480,7 +481,21 @@ is not available. Generally set to the name of the EGD/PRNGD socket. The environment variable RANDFILE can also be used to specify the filename. .SH GENERAL BACKEND OPTIONS Options in this section only apply to the configuration file section -for the backend in which they are defined. They are supported by every +for the specified backend. They are supported by every +type of backend. +.TP +.B backend +Mark the beginning of a backend definition. +should be one of +.B ldbm, +.B shell, +or +.B passwd +depending on which backend will serve the database. + +.SH GENERAL DATABASE OPTIONS +Options in this section only apply to the configuration file section +for the database in which they are defined. They are supported by every type of backend. .TP .B database @@ -590,10 +605,20 @@ Specify the referral to pass back when is asked to modify a replicated local database. If specified multiple times, each url is provided. .SH LDBM BACKEND-SPECIFIC OPTIONS -Options in this category only apply to the LDBM backend database. That is, -they must follow a "database ldbm" line and come before any subsequent -"database" lines. The LDBM backend is a high-performance database that -makes extensive use of indexing and caching to speed data access. +Options in this category only apply to the LDBM backend. That is, +they must follow "backend ldbm" line and come before any subsequent +"backend" or "database" lines. The LDBM backend is a high-performance +database that makes extensive use of indexing and caching to speed +data access. +.TP +.B directory +Specify the directory where shared LDBM files, namely those associated +with a BerkeleyDB environment, for all LDBM databases are kept. +The default is unset. +.SH LDBM DATABASE-SPECIFIC OPTIONS +Options in this category only apply to the LDBM databases. That is, +they must follow "database ldbm" line and come before any subsequent +"backend" or "database" lines. .TP .B cachesize Specify the size in entries of the in-memory cache maintained @@ -649,10 +674,10 @@ other subtypes. .B mode Specify the file protection mode that newly created database index files should have. The default is 0600. -.SH SHELL BACKEND-SPECIFIC OPTIONS +.SH SHELL DATABASE-SPECIFIC OPTIONS Options in this category only apply to the SHELL backend database. That is, they must follow a "database shell" line and come before any subsequent -"database" lines. The Shell backend executes external programs to +"backend" or "database" lines. The Shell backend executes external programs to implement operations, and is designed to make it easy to tie an existing database to the .B slapd @@ -681,10 +706,10 @@ to the given LDAP operation. Note that you need only supply configuration lines for those commands you want the backend to handle. Operations for which a command is not supplied will be refused with an "unwilling to perform" error. -.SH PASSWORD BACKEND-SPECIFIC OPTIONS +.SH PASSWORD DATABASE-SPECIFIC OPTIONS Options in this category only apply to the PASSWD backend database. That is, they must follow a "database passwd" line and come before any -subsequent "database" lines. The PASSWD database serves up the user +subsequent "backend" or "database" lines. The PASSWD database serves up the user account information listed in the system .BR passwd (5) file. diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index b1b374b1a7..04ef6c4637 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -119,6 +119,10 @@ struct ldbminfo { ldap_pvt_thread_cond_t li_dbcache_cv; }; +struct ldbm_backend_info { + char *lbi_directory; +}; + LDAP_END_DECL #include "proto-back-ldbm.h" diff --git a/servers/slapd/back-ldbm/config.c b/servers/slapd/back-ldbm/config.c index a6c3e15a5b..60c6f4609d 100644 --- a/servers/slapd/back-ldbm/config.c +++ b/servers/slapd/back-ldbm/config.c @@ -16,6 +16,48 @@ #include "back-ldbm.h" +int +ldbm_back_config( + BackendInfo *bi, + const char *fname, + int lineno, + int argc, + char **argv +) +{ + int rc; + struct ldbm_backend_info *lbi = + (struct ldbm_backend_info *) bi->bi_private; + + if ( lbi == NULL ) { + fprintf( stderr, "%s: line %d: ldbm backend info is null!\n", + fname, lineno ); + return 1; + } + + /* directory where database files live */ + if ( strcasecmp( argv[0], "directory" ) == 0 ) { + if ( argc < 2 ) { + fprintf( stderr, + "%s: line %d: missing dir in \"directory \" line\n", + fname, lineno ); + return( 1 ); + } + if ( lbi->lbi_directory ) { + free( lbi->lbi_directory ); + } + lbi->lbi_directory = ch_strdup( argv[1] ); + + /* anything else */ + } else { + fprintf( stderr, +"%s: line %d: unknown directive \"%s\" in ldbm backend definition (ignored)\n", + fname, lineno, argv[0] ); + } + + return 0; +} + int ldbm_back_db_config( Backend *be, diff --git a/servers/slapd/back-ldbm/external.h b/servers/slapd/back-ldbm/external.h index 76a3771f05..03d937ea54 100644 --- a/servers/slapd/back-ldbm/external.h +++ b/servers/slapd/back-ldbm/external.h @@ -13,6 +13,9 @@ extern int ldbm_back_initialize LDAP_P(( BackendInfo *bi )); extern int ldbm_back_open LDAP_P(( BackendInfo *bi )); extern int ldbm_back_close LDAP_P(( BackendInfo *bi )); extern int ldbm_back_destroy LDAP_P(( BackendInfo *bi )); +extern int ldbm_back_config LDAP_P(( BackendInfo *bi, + const char *fname, int lineno, + int argc, char **argv )); extern int ldbm_back_db_init LDAP_P(( BackendDB *bd )); extern int ldbm_back_db_open LDAP_P(( BackendDB *bd )); diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index 1072704083..0d339543d4 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -43,7 +43,7 @@ ldbm_back_initialize( bi->bi_controls = controls; bi->bi_open = ldbm_back_open; - bi->bi_config = 0; + bi->bi_config = ldbm_back_config; bi->bi_close = ldbm_back_close; bi->bi_destroy = ldbm_back_destroy; @@ -85,6 +85,14 @@ ldbm_back_initialize( bi->bi_connection_init = 0; bi->bi_connection_destroy = 0; + { + struct ldbm_backend_info *lbi = malloc( + sizeof( struct ldbm_backend_info ) ); + + bi->bi_private = lbi; + lbi->lbi_directory = NULL; + } + return 0; } @@ -103,8 +111,11 @@ ldbm_back_open( { int rc; + struct ldbm_backend_info *lbi + = (struct ldbm_backend_info *) bi->bi_private; + /* initialize the underlying database system */ - rc = ldbm_initialize( NULL ); + rc = ldbm_initialize( lbi->lbi_directory ); return rc; } diff --git a/tests/data/slapd-acl.conf b/tests/data/slapd-acl.conf index da39acbccd..eb2ed5237d 100644 --- a/tests/data/slapd-acl.conf +++ b/tests/data/slapd-acl.conf @@ -14,6 +14,9 @@ argsfile ./test-db/slapd.args # ldbm database definitions ####################################################################### +backend @BACKEND@ +#LDBM#directory ./test-db + database @BACKEND@ cachesize 0 suffix "o=University of Michigan, c=US" diff --git a/tests/data/slapd-master.conf b/tests/data/slapd-master.conf index 9934499be6..a6e92b4c92 100644 --- a/tests/data/slapd-master.conf +++ b/tests/data/slapd-master.conf @@ -14,6 +14,9 @@ argsfile ./test-db/slapd.args # ldbm database definitions ####################################################################### +backend @BACKEND@ +#LDBM#directory ./test-db + database @BACKEND@ suffix "o=University of Michigan, c=US" directory ./test-db diff --git a/tests/data/slapd-pw.conf b/tests/data/slapd-pw.conf index 509a1e21c1..4a894fd9f2 100644 --- a/tests/data/slapd-pw.conf +++ b/tests/data/slapd-pw.conf @@ -16,6 +16,9 @@ argsfile ./test-db/slapd.args # ldbm database definitions ####################################################################### +backend @BACKEND@ +#LDBM#directory ./test-db + database @BACKEND@ cachesize 0 suffix "o=University of Michigan, c=US" diff --git a/tests/data/slapd-ref-slave.conf b/tests/data/slapd-ref-slave.conf index 305faa8ead..4d81cd4137 100644 --- a/tests/data/slapd-ref-slave.conf +++ b/tests/data/slapd-ref-slave.conf @@ -18,6 +18,9 @@ argsfile ./test-repl/slapd.args referral "ldap://localhost:9009/" +backend @BACKEND@ +#LDBM#directory ./test-repl + database @BACKEND@ cachesize 0 suffix "o=University of Mich, c=US" diff --git a/tests/data/slapd-repl-master.conf b/tests/data/slapd-repl-master.conf index 9eea2a08da..4a8a22b2cf 100644 --- a/tests/data/slapd-repl-master.conf +++ b/tests/data/slapd-repl-master.conf @@ -16,6 +16,9 @@ argsfile ./test-db/slapd.args # ldbm database definitions ####################################################################### +backend @BACKEND@ +#LDBM#directory ./test-db + database @BACKEND@ cachesize 0 suffix "o=University of Michigan, c=US" diff --git a/tests/data/slapd-repl-slave.conf b/tests/data/slapd-repl-slave.conf index 8086ba7487..70c0d6b0b8 100644 --- a/tests/data/slapd-repl-slave.conf +++ b/tests/data/slapd-repl-slave.conf @@ -17,6 +17,9 @@ argsfile ./test-repl/slapd.args # ldbm database definitions ####################################################################### +backend @BACKEND@ +#LDBM#directory ./test-repl + database @BACKEND@ cachesize 0 suffix "o=University of Michigan, c=US" diff --git a/tests/data/slapd-schema.conf b/tests/data/slapd-schema.conf index c66d35127f..fd7ba59fd8 100644 --- a/tests/data/slapd-schema.conf +++ b/tests/data/slapd-schema.conf @@ -25,6 +25,9 @@ argsfile ./test-db/slapd.args # ldbm database definitions ####################################################################### +backend @BACKEND@ +#LDBM#directory ./test-db + database @BACKEND@ suffix "o=OpenLDAP Project, l=Internet" directory ./test-db diff --git a/tests/data/slapd.conf b/tests/data/slapd.conf index 5b47d50763..51c3076c12 100644 --- a/tests/data/slapd.conf +++ b/tests/data/slapd.conf @@ -15,6 +15,9 @@ argsfile ./test-db/slapd.args # ldbm database definitions ####################################################################### +backend @BACKEND@ +#LDBM#directory ./test-db + database @BACKEND@ suffix "o=University of Michigan, c=US" directory ./test-db