summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rwxr-xr-xsource4/lib/ldb/autogen.sh1
-rw-r--r--source4/lib/ldb/common/ldb.c34
-rw-r--r--source4/lib/ldb/config.mk20
-rw-r--r--source4/lib/ldb/configure.ac1
-rw-r--r--source4/lib/ldb/examples/ldbreader.c2
-rw-r--r--source4/lib/ldb/examples/ldifreader.c2
-rw-r--r--source4/lib/ldb/include/ldb.h4
-rw-r--r--source4/lib/ldb/include/ldb_includes.h1
-rw-r--r--source4/lib/ldb/include/ldb_private.h2
-rw-r--r--source4/lib/ldb/ldb.pc.in2
-rw-r--r--source4/lib/ldb/ldb_wrap.c3
-rw-r--r--source4/lib/ldb/nssldb/ldb-nss.c2
-rw-r--r--source4/lib/ldb/python.mk2
-rwxr-xr-xsource4/lib/ldb/standalone.sh3
-rw-r--r--source4/lib/ldb/tools/ad2oLschema.c2
-rw-r--r--source4/lib/ldb/tools/ldbadd.c2
-rw-r--r--source4/lib/ldb/tools/ldbdel.c2
-rw-r--r--source4/lib/ldb/tools/ldbedit.c2
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c2
-rw-r--r--source4/lib/ldb/tools/ldbrename.c2
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c5
-rw-r--r--source4/lib/ldb/tools/ldbtest.c4
-rw-r--r--source4/lib/ldb/tools/oLschema2ldif.c2
23 files changed, 68 insertions, 34 deletions
diff --git a/source4/lib/ldb/autogen.sh b/source4/lib/ldb/autogen.sh
index cb837b3af9..b81e5b094e 100755
--- a/source4/lib/ldb/autogen.sh
+++ b/source4/lib/ldb/autogen.sh
@@ -4,6 +4,7 @@ rm -rf autom4te.cache
rm -f configure config.h.in
IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
+IPATHS="$IPATHS -I lib/events -I events -I ../events"
IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
IPATHS="$IPATHS -I lib/tdb -I tdb -I ../tdb"
IPATHS="$IPATHS -I lib/popt -I popt -I ../popt"
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index b51c288993..bfce12bdd3 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -1,13 +1,13 @@
-/*
+/*
ldb database library
Copyright (C) Andrew Tridgell 2004
- Copyright (C) Simo Sorce 2005-2006
+ Copyright (C) Simo Sorce 2005-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@@ -34,15 +34,21 @@
#include "ldb_includes.h"
-/*
+/*
initialise a ldb context
- The mem_ctx is optional
+ The mem_ctx is required
+ The event_ctx is required
*/
-struct ldb_context *ldb_init(void *mem_ctx)
+struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx)
{
- struct ldb_context *ldb = talloc_zero(mem_ctx, struct ldb_context);
+ struct ldb_context *ldb;
int ret;
+ ldb = talloc_zero(mem_ctx, struct ldb_context);
+ if (ev_ctx == NULL) {
+ ev_ctx = event_context_init(ldb);
+ }
+
ret = ldb_setup_wellknown_attributes(ldb);
if (ret != 0) {
talloc_free(ldb);
@@ -52,6 +58,10 @@ struct ldb_context *ldb_init(void *mem_ctx)
ldb_set_utf8_default(ldb);
ldb_set_create_perms(ldb, 0666);
ldb_set_modules_dir(ldb, LDB_MODULESDIR);
+ ldb_set_event_context(ldb, ev_ctx);
+
+ /* TODO: get timeout from options if available there */
+ ldb->default_timeout = 300; /* set default to 5 minutes */
return ldb;
}
@@ -568,6 +578,16 @@ void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms)
ldb->create_perms = perms;
}
+void ldb_set_event_context(struct ldb_context *ldb, struct event_context *ev)
+{
+ ldb->ev_ctx = ev;
+}
+
+struct event_context * ldb_get_event_context(struct ldb_context *ldb)
+{
+ return ldb->ev_ctx;
+}
+
/*
start an ldb request
NOTE: the request must be a talloc context.
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index cc8f1e36ab..40b4e31cc7 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -1,7 +1,7 @@
################################################
# Start MODULE ldb_asq
[MODULE::ldb_asq]
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS
CFLAGS = -I$(ldbdir)/include
INIT_FUNCTION = LDB_MODULE(asq)
SUBSYSTEM = LIBLDB
@@ -13,7 +13,7 @@ ldb_asq_OBJ_FILES = $(ldbdir)/modules/asq.o
################################################
# Start MODULE ldb_server_sort
[MODULE::ldb_server_sort]
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS
CFLAGS = -I$(ldbdir)/include
INIT_FUNCTION = LDB_MODULE(server_sort)
SUBSYSTEM = LIBLDB
@@ -27,7 +27,7 @@ ldb_server_sort_OBJ_FILES = $(ldbdir)/modules/sort.o
[MODULE::ldb_paged_results]
INIT_FUNCTION = LDB_MODULE(paged_results)
CFLAGS = -I$(ldbdir)/include
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS
SUBSYSTEM = LIBLDB
# End MODULE ldb_paged_results
################################################
@@ -39,7 +39,7 @@ ldb_paged_results_OBJ_FILES = $(ldbdir)/modules/paged_results.o
[MODULE::ldb_paged_searches]
INIT_FUNCTION = LDB_MODULE(paged_searches)
CFLAGS = -I$(ldbdir)/include
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS
SUBSYSTEM = LIBLDB
# End MODULE ldb_paged_results
################################################
@@ -51,7 +51,7 @@ ldb_paged_searches_OBJ_FILES = $(ldbdir)/modules/paged_searches.o
[MODULE::ldb_operational]
SUBSYSTEM = LIBLDB
CFLAGS = -I$(ldbdir)/include
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS
INIT_FUNCTION = LDB_MODULE(operational)
# End MODULE ldb_operational
################################################
@@ -63,7 +63,7 @@ ldb_operational_OBJ_FILES = $(ldbdir)/modules/operational.o
[MODULE::ldb_rdn_name]
SUBSYSTEM = LIBLDB
CFLAGS = -I$(ldbdir)/include
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS
INIT_FUNCTION = LDB_MODULE(rdn_name)
# End MODULE ldb_rdn_name
################################################
@@ -79,7 +79,7 @@ $(ldb_map_OBJ_FILES): CFLAGS+=-I$(ldbdir)/ldb_map
[MODULE::ldb_skel]
SUBSYSTEM = LIBLDB
CFLAGS = -I$(ldbdir)/include
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS
INIT_FUNCTION = LDB_MODULE(skel)
# End MODULE ldb_skel
################################################
@@ -91,7 +91,7 @@ ldb_skel_OBJ_FILES = $(ldbdir)/modules/skel.o
[MODULE::ldb_sqlite3]
SUBSYSTEM = LIBLDB
CFLAGS = -I$(ldbdir)/include
-PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBEVENTS
# End MODULE ldb_sqlite3
################################################
@@ -103,7 +103,7 @@ ldb_sqlite3_OBJ_FILES = $(ldbdir)/ldb_sqlite3/ldb_sqlite3.o
SUBSYSTEM = LIBLDB
CFLAGS = -I$(ldbdir)/include -I$(ldbdir)/ldb_tdb
PRIVATE_DEPENDENCIES = \
- LIBTDB LIBTALLOC
+ LIBTDB LIBTALLOC LIBEVENTS
# End MODULE ldb_tdb
################################################
@@ -116,7 +116,7 @@ ldb_tdb_OBJ_FILES = $(addprefix $(ldbdir)/ldb_tdb/, ldb_tdb.o ldb_search.o ldb_p
CFLAGS = -I$(ldbdir)/include
INIT_FUNCTION_TYPE = extern const struct ldb_module_ops
PUBLIC_DEPENDENCIES = \
- LIBTALLOC
+ LIBTALLOC LIBEVENTS
PRIVATE_DEPENDENCIES = \
SOCKET_WRAPPER
diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac
index 4d9444ad10..4a703e8139 100644
--- a/source4/lib/ldb/configure.ac
+++ b/source4/lib/ldb/configure.ac
@@ -46,6 +46,7 @@ EXTRA_OBJ=""
m4_include(libpopt.m4)
m4_include(libtalloc.m4)
m4_include(libtdb.m4)
+m4_include(libevents.m4)
m4_include(ldap.m4)
if test x"$with_ldap_support" = x"yes"; then
diff --git a/source4/lib/ldb/examples/ldbreader.c b/source4/lib/ldb/examples/ldbreader.c
index c8f26c3860..6e58114531 100644
--- a/source4/lib/ldb/examples/ldbreader.c
+++ b/source4/lib/ldb/examples/ldbreader.c
@@ -67,7 +67,7 @@ int main(int argc, const char **argv)
Note that you can use the context structure as a parent
for talloc allocations as well
*/
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
/*
We now open the database. In this example we just hard code the connection path.
diff --git a/source4/lib/ldb/examples/ldifreader.c b/source4/lib/ldb/examples/ldifreader.c
index 926d99f838..12e7a1a6fd 100644
--- a/source4/lib/ldb/examples/ldifreader.c
+++ b/source4/lib/ldb/examples/ldifreader.c
@@ -71,7 +71,7 @@ int main(int argc, const char **argv)
Note that you can use the context structure as a parent
for talloc allocations as well
*/
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
fileStream = fopen(argv[1], "r");
if (0 == fileStream) {
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 2e13a774b9..c43d425585 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -782,6 +782,8 @@ int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeou
int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq);
void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms);
void ldb_set_modules_dir(struct ldb_context *ldb, const char *path);
+void ldb_set_event_context(struct ldb_context *ldb, struct event_context *ev);
+struct event_context * ldb_get_event_context(struct ldb_context *ldb);
/**
Initialise ldbs' global information
@@ -803,7 +805,7 @@ int ldb_global_init(void);
\return pointer to ldb_context that should be free'd (using talloc_free())
at the end of the program.
*/
-struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx);
+struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx);
/**
Connect to a database.
diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h
index cc9b46ac1f..29c7b2dc5a 100644
--- a/source4/lib/ldb/include/ldb_includes.h
+++ b/source4/lib/ldb/include/ldb_includes.h
@@ -20,6 +20,7 @@
#include "system/filesys.h"
#include "system/time.h"
#include "talloc.h"
+#include "events.h"
#include "ldb.h"
#include "ldb_errors.h"
#include "ldb_private.h"
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index ea8533bc38..d7c2efe8a1 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -133,6 +133,8 @@ struct ldb_context {
unsigned int create_perms;
char *modules_dir;
+
+ struct event_context *ev_ctx;
};
#ifndef ARRAY_SIZE
diff --git a/source4/lib/ldb/ldb.pc.in b/source4/lib/ldb/ldb.pc.in
index 248fb05c4f..8d1e3cabe3 100644
--- a/source4/lib/ldb/ldb.pc.in
+++ b/source4/lib/ldb/ldb.pc.in
@@ -8,7 +8,7 @@ Name: ldb
Description: An LDAP-like embedded database
Version: @PACKAGE_VERSION@
Requires.private: tdb
-Requires: talloc
+Requires: talloc events
Libs: -L${libdir} -lldb
Libs.private: @LDAP_LIBS@
Cflags: -I${includedir}
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index 744033cbf6..ee374b85be 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -2546,6 +2546,7 @@ static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0};
#include <stdint.h>
#include <stdbool.h>
#include "talloc.h"
+#include "events.h"
#include "ldb.h"
#include "ldb_errors.h"
#include "ldb_private.h"
@@ -3066,7 +3067,7 @@ static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *
PyObject *PyExc_LdbError;
-SWIGINTERN ldb *new_ldb(){ return ldb_init(NULL); }
+SWIGINTERN ldb *new_ldb(){ return ldb_init(NULL, NULL); }
SWIGINTERN int
SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
diff --git a/source4/lib/ldb/nssldb/ldb-nss.c b/source4/lib/ldb/nssldb/ldb-nss.c
index e256f41a4d..8f7321031b 100644
--- a/source4/lib/ldb/nssldb/ldb-nss.c
+++ b/source4/lib/ldb/nssldb/ldb-nss.c
@@ -45,7 +45,7 @@ NSS_STATUS _ldb_nss_init(void)
_ldb_nss_ctx->pid = mypid;
- _ldb_nss_ctx->ldb = ldb_init(_ldb_nss_ctx);
+ _ldb_nss_ctx->ldb = ldb_init(_ldb_nss_ctx, NULL);
if (_ldb_nss_ctx->ldb == NULL) {
goto failed;
}
diff --git a/source4/lib/ldb/python.mk b/source4/lib/ldb/python.mk
index 8d48f5d810..45f4f044ba 100644
--- a/source4/lib/ldb/python.mk
+++ b/source4/lib/ldb/python.mk
@@ -1,6 +1,6 @@
[PYTHON::swig_ldb]
LIBRARY_REALNAME = _ldb.$(SHLIBEXT)
-PUBLIC_DEPENDENCIES = LIBLDB
+PUBLIC_DEPENDENCIES = LIBLDB LIBEVENTS
swig_ldb_OBJ_FILES = $(ldbsrcdir)/ldb_wrap.o
$(swig_ldb_OBJ_FILES): CFLAGS+=-I$(ldbsrcdir)/include
diff --git a/source4/lib/ldb/standalone.sh b/source4/lib/ldb/standalone.sh
index fa1b9bafe3..8ab081e0f3 100755
--- a/source4/lib/ldb/standalone.sh
+++ b/source4/lib/ldb/standalone.sh
@@ -9,6 +9,9 @@ make clean
cd ../tdb
make clean
+cd ../events
+make clean
+
cd ../ldb
make clean
diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c
index 0a89656fa2..ac343c783f 100644
--- a/source4/lib/ldb/tools/ad2oLschema.c
+++ b/source4/lib/ldb/tools/ad2oLschema.c
@@ -657,7 +657,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
enum convert_target target;
ctx = talloc_new(NULL);
- ldb = ldb_init(ctx);
+ ldb = ldb_init(ctx, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index 4ee66c4fc0..15376e7342 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -88,7 +88,7 @@ int main(int argc, const char **argv)
int i, ret=0, count=0;
struct ldb_cmdline *options;
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index 184172b22b..e66d4fb973 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -77,7 +77,7 @@ int main(int argc, const char **argv)
int ret = 0, i;
struct ldb_cmdline *options;
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index a9fd064bf8..e58a5a271e 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -279,7 +279,7 @@ int main(int argc, const char **argv)
const char *expression = "(|(objectClass=*)(distinguishedName=*))";
const char * const * attrs = NULL;
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index dd6206b824..6e355a10cf 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -89,7 +89,7 @@ int main(int argc, const char **argv)
int i, ret=LDB_SUCCESS;
struct ldb_cmdline *options;
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c
index b36310a500..a5feb7a091 100644
--- a/source4/lib/ldb/tools/ldbrename.c
+++ b/source4/lib/ldb/tools/ldbrename.c
@@ -56,7 +56,7 @@ int main(int argc, const char **argv)
struct ldb_cmdline *options;
struct ldb_dn *dn1, *dn2;
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index e25bd19965..b3d1f934a6 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -276,7 +276,10 @@ int main(int argc, const char **argv)
int ret = -1;
const char *expression = "(|(objectClass=*)(distinguishedName=*))";
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
+ if (ldb == NULL) {
+ return -1;
+ }
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index 57a7848733..6d141478ad 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -344,7 +344,7 @@ static void start_test_index(struct ldb_context **ldb)
exit(1);
}
- (*ldb) = ldb_init(options);
+ (*ldb) = ldb_init(options, NULL);
ret = ldb_connect(*ldb, options->url, flags, NULL);
if (ret != 0) {
@@ -393,7 +393,7 @@ int main(int argc, const char **argv)
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct ldb_context *ldb;
- ldb = ldb_init(mem_ctx);
+ ldb = ldb_init(mem_ctx, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/oLschema2ldif.c b/source4/lib/ldb/tools/oLschema2ldif.c
index 1846a2c852..3c31f37c55 100644
--- a/source4/lib/ldb/tools/oLschema2ldif.c
+++ b/source4/lib/ldb/tools/oLschema2ldif.c
@@ -561,7 +561,7 @@ static void usage(void)
FILE *in = stdin;
FILE *out = stdout;
ctx = talloc_new(NULL);
- ldb_ctx = ldb_init(ctx);
+ ldb_ctx = ldb_init(ctx, NULL);
setenv("LDB_URL", "NONE", 1);
options = ldb_cmdline_process(ldb_ctx, argc, argv, usage);