--- /dev/null
+/* back-bdb.h - ldap ldbm back-end header file */
+/* $OpenLDAP$ */
+/*
+ * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#ifndef _BACK_BDB_H_
+#define _BACK_BDB_H_
+
+#include <portable.h>
+#include <db.h>
+
+LDAP_BEGIN_DECL
+
+#define DEFAULT_MODE 0600
+#define DEFAULT_CACHE_SIZE 1000
+
+#define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE)
+
+#define DEFAULT_DB_DIRECTORY LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
+
+#define DEFAULT_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb-home"
+#define DEFAULT_DBENV_MODE DEFAULT_MODE
+
+#define DEFAULT_BLOCKSIZE 8192
+
+struct bdb_dbinfo {
+ DB_ENV *bdi_dbenv;
+
+ /* DBenv parameters */
+ char *bdi_dbenv_home;
+ u_int32_t bdi_dbenv_xflags; /* extra flags */
+ int bdi_dbenv_mode;
+
+ slap_mask_t bdi_db_mode;
+ char *bdi_db_directory;
+};
+
+LDAP_END_DECL
+
+#endif /* _BACK_BDB_H_ */
--- /dev/null
+# Microsoft Developer Studio Project File - Name="backbdb" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=backbdb - Win32 Single Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "backbdb.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "backbdb.mak" CFG="backbdb - Win32 Single Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "backbdb - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "backbdb - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE "backbdb - Win32 Single Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE "backbdb - Win32 Single Release" (based on\
+ "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+
+!IF "$(CFG)" == "backbdb - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\..\Release"
+# PROP Intermediate_Dir "..\..\..\Release\backbdb"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\\" /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "backbdb - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\..\..\Debug"
+# PROP Intermediate_Dir "..\..\..\Debug\backbdb"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\\" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "backbdb - Win32 Single Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "backbdb"
+# PROP BASE Intermediate_Dir "backbdb"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\..\..\SDebug"
+# PROP Intermediate_Dir "..\..\..\SDebug\backbdb"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\\" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
+# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\\" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "backbdb - Win32 Single Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "backldb0"
+# PROP BASE Intermediate_Dir "backldb0"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\..\SRelease"
+# PROP Intermediate_Dir "..\..\..\SRelease\backbdb"
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\\" /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\\" /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "backbdb - Win32 Release"
+# Name "backbdb - Win32 Debug"
+# Name "backbdb - Win32 Single Debug"
+# Name "backbdb - Win32 Single Release"
+# Begin Source File
+
+SOURCE=".\back-bdb.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\external.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\init.c
+# End Source File
+# Begin Source File
+
+SOURCE=".\proto-back-bdb.h"
+# End Source File
+# End Target
+# End Project
--- /dev/null
+/* $OpenLDAP$ */
+/*
+ * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#ifndef _BDB_EXTERNAL_H
+#define _BDB_EXTERNAL_H
+
+LDAP_BEGIN_DECL
+
+extern int bdb_back_initialize LDAP_P(( BackendInfo *bi ));
+extern int bdb_back_open LDAP_P(( BackendInfo *bi ));
+extern int bdb_back_close LDAP_P(( BackendInfo *bi ));
+extern int bdb_back_destroy LDAP_P(( BackendInfo *bi ));
+
+extern int bdb_back_db_init LDAP_P(( BackendDB *bd ));
+extern int bdb_back_db_open LDAP_P(( BackendDB *bd ));
+extern int bdb_back_db_close LDAP_P(( BackendDB *bd ));
+extern int bdb_back_db_destroy LDAP_P(( BackendDB *bd ));
+
+extern int bdb_back_db_config LDAP_P(( BackendDB *bd,
+ const char *fname, int lineno,
+ int argc, char **argv ));
+
+extern int bdb_back_extended LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *reqoid,
+ struct berval *reqdata,
+ char **rspoid,
+ struct berval **rspdata,
+ LDAPControl *** rspctrls,
+ const char **text,
+ struct berval *** refs ));
+
+extern int bdb_back_bind LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *dn, const char *ndn, int method,
+ struct berval *cred, char** edn ));
+
+extern int bdb_back_unbind LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op ));
+
+extern int bdb_back_search LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *base, const char *nbase,
+ int scope, int deref, int sizelimit, int timelimit,
+ Filter *filter, const char *filterstr,
+ char **attrs, int attrsonly ));
+
+extern int bdb_back_compare LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *dn, const char *ndn,
+ AttributeAssertion *ava ));
+
+extern int bdb_back_modify LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *dn, const char *ndn, Modifications *ml ));
+
+extern int bdb_back_modrdn LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *dn, const char *ndn,
+ const char* newrdn, int deleteoldrdn,
+ const char *newSuperior ));
+
+extern int bdb_back_add LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op, Entry *e ));
+
+extern int bdb_back_delete LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *dn, const char *ndn ));
+
+extern int bdb_back_abandon LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op, ber_int_t msgid ));
+
+extern int bdb_back_group LDAP_P(( BackendDB *bd,
+ Entry *target,
+ const char* gr_ndn,
+ const char* op_ndn,
+ ObjectClass* group_oc,
+ AttributeDescription* group_at));
+
+extern int bdb_back_attribute LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ Entry *target,
+ const char* e_ndn,
+ AttributeDescription* entry_at,
+ struct berval ***vals));
+
+
+/* hooks for slap tools */
+extern int bdb_tool_entry_open LDAP_P(( BackendDB *be, int mode ));
+extern int bdb_tool_entry_close LDAP_P(( BackendDB *be ));
+extern ID bdb_tool_entry_first LDAP_P(( BackendDB *be ));
+extern ID bdb_tool_entry_next LDAP_P(( BackendDB *be ));
+extern Entry* bdb_tool_entry_get LDAP_P(( BackendDB *be, ID id ));
+extern ID bdb_tool_entry_put LDAP_P(( BackendDB *be, Entry *e ));
+
+extern int bdb_tool_entry_reindex LDAP_P(( BackendDB *be, ID id ));
+extern int bdb_tool_sync LDAP_P(( BackendDB *be ));
+
+extern int bdb_back_referrals LDAP_P(( BackendDB *bd,
+ Connection *conn, Operation *op,
+ const char *dn, const char *ndn,
+ const char **text ));
+
+LDAP_END_DECL
+
+#endif /* _BDB_EXTERNAL_H */
+
--- /dev/null
+/* init.c - initialize bdb backend */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-bdb.h"
+
+#ifdef SLAPD_BDB_DYNAMIC
+
+int back_bdb_LTX_init_module(int argc, char *argv[]) {
+ BackendInfo bi;
+
+ memset( &bi, '\0', sizeof(bi) );
+ bi.bi_type = "bdb";
+ bi.bi_init = bdb_back_initialize;
+
+ backend_add(&bi);
+ return 0;
+}
+
+#endif /* SLAPD_BDB_DYNAMIC */
+
+int
+bdb_back_initialize(
+ BackendInfo *bi
+)
+{
+ static char *controls[] = {
+ LDAP_CONTROL_MANAGEDSAIT,
+ NULL
+ };
+
+ { /* version check */
+ int major, minor, patch;
+ char *version = db_version( &major, &minor, &patch );
+
+ if( major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR ||
+ patch < DB_VERSION_PATCH )
+ {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_back_initialize: version mismatch\n"
+ "\texpected: " DB_VERSION_STRING "\n"
+ "\tgot: %s \n", version, 0, 0 );
+ }
+
+ Debug( LDAP_DEBUG_ANY, "bdb_back_initialize: %s\n",
+ version, 0, 0 );
+ }
+
+#if 0
+ bi->bi_controls = controls;
+
+ bi->bi_open = bdb_back_open;
+ bi->bi_config = 0;
+ bi->bi_close = bdb_back_close;
+ bi->bi_destroy = bdb_back_destroy;
+
+ bi->bi_db_init = bdb_back_db_init;
+ bi->bi_db_config = bdb_back_db_config;
+ bi->bi_db_open = bdb_back_db_open;
+ bi->bi_db_close = bdb_back_db_close;
+ bi->bi_db_destroy = bdb_back_db_destroy;
+
+ bi->bi_op_bind = bdb_back_bind;
+ bi->bi_op_unbind = bdb_back_unbind;
+ bi->bi_op_search = bdb_back_search;
+ bi->bi_op_compare = bdb_back_compare;
+ bi->bi_op_modify = bdb_back_modify;
+ bi->bi_op_modrdn = bdb_back_modrdn;
+ bi->bi_op_add = bdb_back_add;
+ bi->bi_op_delete = bdb_back_delete;
+ bi->bi_op_abandon = bdb_back_abandon;
+
+ bi->bi_extended = bdb_back_extended;
+
+ bi->bi_entry_release_rw = bdb_back_entry_release_rw;
+ bi->bi_acl_group = bdb_back_group;
+ bi->bi_acl_attribute = bdb_back_attribute;
+ bi->bi_chk_referrals = bdb_back_referrals;
+
+ /*
+ * hooks for slap tools
+ */
+ bi->bi_tool_entry_open = bdb_tool_entry_open;
+ bi->bi_tool_entry_close = bdb_tool_entry_close;
+ bi->bi_tool_entry_first = bdb_tool_entry_first;
+ bi->bi_tool_entry_next = bdb_tool_entry_next;
+ bi->bi_tool_entry_get = bdb_tool_entry_get;
+ bi->bi_tool_entry_put = bdb_tool_entry_put;
+ bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
+ bi->bi_tool_sync = bdb_tool_sync;
+
+ bi->bi_connection_init = 0;
+ bi->bi_connection_destroy = 0;
+#endif
+
+ return 0;
+}
+
+int
+bdb_back_destroy(
+ BackendInfo *bi
+)
+{
+ return 0;
+}
+
+int
+bdb_back_open(
+ BackendInfo *bi
+)
+{
+ /* initialize the underlying database system */
+ return 0;
+}
+
+int
+bdb_back_close(
+ BackendInfo *bi
+)
+{
+ /* terminate the underlying database system */
+ return 0;
+}
+
+int
+bdb_back_db_init(
+ Backend *be
+)
+{
+ struct bdb_dbinfo *bdi;
+
+ /* allocate backend-database-specific stuff */
+ bdi = (struct bdb_dbinfo *) ch_calloc( 1, sizeof(struct bdb_dbinfo) );
+
+ /* DBEnv parameters */
+ bdi->bdi_dbenv_home = ch_strdup( DEFAULT_DBENV_HOME );
+ bdi->bdi_dbenv_xflags = 0;
+ bdi->bdi_dbenv_mode = DEFAULT_DBENV_MODE;
+
+ /* default database directories */
+ bdi->bdi_db_directory = ch_strdup( DEFAULT_DB_DIRECTORY );
+
+ be->be_private = bdi;
+ return 0;
+}
+
+int
+bdb_back_db_open(
+ BackendDB *be
+)
+{
+ int rc;
+ struct bdb_dbinfo *bdi = (struct bdb_dbinfo *) be->be_private;
+ u_int32_t flags;
+
+ /* we should check existance of dbenv_home and db_directory */
+
+ rc = db_env_create( &bdi->bdi_dbenv, 0 );
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_back_db_open: db_env_create failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ return rc;
+ }
+
+ flags = DB_INIT_LOCK | DB_INIT_TXN |
+ DB_PRIVATE | DB_RECOVER | DB_THREAD;
+
+ rc = bdi->bdi_dbenv->open( bdi->bdi_dbenv,
+ bdi->bdi_dbenv_home,
+ flags | bdi->bdi_dbenv_xflags,
+ bdi->bdi_dbenv_mode );
+
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_back_db_open: db_open failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ return rc;
+ }
+
+ return 0;
+}
+
+int
+bdb_back_db_destroy(
+ BackendDB *be
+)
+{
+ int rc;
+ struct bdb_dbinfo *bdi = (struct bdb_dbinfo *) be->be_private;
+
+ rc = bdi->bdi_dbenv->close( bdi->bdi_dbenv, 0 );
+ bdi->bdi_dbenv = NULL;
+
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_back_db_open: db_open failed: %s (%d)\n",
+ db_strerror(rc), rc, 0 );
+ return rc;
+ }
+
+ return 0;
+}
/* initialize the underlying database system */
rc = ldbm_initialize( NULL );
-
return rc;
}
{
/* terminate the underlying database system */
ldbm_shutdown();
-
return 0;
}
#include "slap.h"
#include "lutil.h"
+#ifdef SLAPD_BDB
+#include "back-bdb/external.h"
+#endif
#ifdef SLAPD_DNSSRV
#include "back-dnssrv/external.h"
#endif
#endif
static BackendInfo binfo[] = {
+#if defined(SLAPD_BDB) && !defined(SLAPD_BDB_DYNAMIC)
+ {"bdb", bdb_back_initialize},
+#endif
#if defined(SLAPD_DNSSRV) && !defined(SLAPD_DNSSRV_DYNAMIC)
{"dnssrv", dnssrv_back_initialize},
#endif