From ca0b72a1fdb7bd965065e833df34662afef0423e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Nov 2007 20:12:00 +0100 Subject: r26003: Split up DB_WRAP, as first step in an attempt to sanitize dependencies. (This used to be commit 56dfcb4f2f8e74c9d8b2fe3a0df043781188a555) --- source4/lib/ldb_wrap.c | 187 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 source4/lib/ldb_wrap.c (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c new file mode 100644 index 0000000000..659b91d254 --- /dev/null +++ b/source4/lib/ldb_wrap.c @@ -0,0 +1,187 @@ +/* + Unix SMB/CIFS implementation. + + LDB wrap functions + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + the stupidity of the unix fcntl locking design forces us to never + allow a database file to be opened twice in the same process. These + wrappers provide convenient access to a tdb or ldb, taking advantage + of talloc destructors to ensure that only a single open is done +*/ + +#include "includes.h" +#include "lib/events/events.h" +#include "lib/ldb/include/ldb.h" +#include "lib/ldb/include/ldb_errors.h" +#include "lib/ldb-samba/ldif_handlers.h" +#include "ldb_wrap.h" +#include "dsdb/samdb/samdb.h" +#include "dsdb/schema/proto.h" +#include "param/param.h" + +/* + this is used to catch debug messages from ldb +*/ +static void ldb_wrap_debug(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); + +static void ldb_wrap_debug(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap) +{ + int samba_level; + char *s = NULL; + switch (level) { + case LDB_DEBUG_FATAL: + samba_level = 0; + break; + case LDB_DEBUG_ERROR: + samba_level = 1; + break; + case LDB_DEBUG_WARNING: + samba_level = 2; + break; + case LDB_DEBUG_TRACE: + samba_level = 5; + break; + + }; + vasprintf(&s, fmt, ap); + if (!s) return; + DEBUG(level, ("ldb: %s\n", s)); + free(s); +} + +/* check for memory leaks on the ldb context */ +static int ldb_wrap_destructor(struct ldb_context *ldb) +{ + size_t *startup_blocks = (size_t *)ldb_get_opaque(ldb, "startup_blocks"); + if (startup_blocks && + talloc_total_blocks(ldb) > *startup_blocks + 400) { + DEBUG(0,("WARNING: probable memory leak in ldb %s - %lu blocks (startup %lu) %lu bytes\n", + (char *)ldb_get_opaque(ldb, "wrap_url"), + (unsigned long)talloc_total_blocks(ldb), + (unsigned long)*startup_blocks, + (unsigned long)talloc_total_size(ldb))); +#if 0 + talloc_report_full(ldb, stdout); + call_backtrace(); + smb_panic("probable memory leak in ldb"); +#endif + } + return 0; +} + +/* + wrapped connection to a ldb database + to close just talloc_free() the returned ldb_context + + TODO: We need an error_string parameter + */ +struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + const char *url, + struct auth_session_info *session_info, + struct cli_credentials *credentials, + unsigned int flags, + const char *options[]) +{ + struct ldb_context *ldb; + int ret; + struct event_context *ev; + char *real_url = NULL; + size_t *startup_blocks; + + ldb = ldb_init(mem_ctx); + if (ldb == NULL) { + return NULL; + } + + ldb_set_modules_dir(ldb, + talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx))); + + /* we want to use the existing event context if possible. This + relies on the fact that in smbd, everything is a child of + the main event_context */ + ev = event_context_find(ldb); + + if (ldb_set_opaque(ldb, "EventContext", ev)) { + talloc_free(ldb); + return NULL; + } + + if (ldb_set_opaque(ldb, "sessionInfo", session_info)) { + talloc_free(ldb); + return NULL; + } + + if (ldb_set_opaque(ldb, "credentials", credentials)) { + talloc_free(ldb); + return NULL; + } + + if (strcmp(lp_sam_url(lp_ctx), url) == 0) { + dsdb_set_global_schema(ldb); + } + + ret = ldb_register_samba_handlers(ldb); + if (ret == -1) { + talloc_free(ldb); + return NULL; + } + + ldb_set_debug(ldb, ldb_wrap_debug, NULL); + + ldb_set_utf8_fns(ldb, NULL, wrap_casefold); + + real_url = private_path(ldb, lp_ctx, url); + if (real_url == NULL) { + talloc_free(ldb); + return NULL; + } + + /* allow admins to force non-sync ldb for all databases */ + if (lp_parm_bool(lp_ctx, NULL, "ldb", "nosync", false)) { + flags |= LDB_FLG_NOSYNC; + } + + /* we usually want Samba databases to be private. If we later + find we need one public, we will need to add a parameter to + ldb_wrap_connect() */ + ldb_set_create_perms(ldb, 0600); + + ret = ldb_connect(ldb, real_url, flags, options); + if (ret != LDB_SUCCESS) { + talloc_free(ldb); + return NULL; + } + + /* setup for leak detection */ + ldb_set_opaque(ldb, "wrap_url", real_url); + startup_blocks = talloc(ldb, size_t); + *startup_blocks = talloc_total_blocks(ldb); + ldb_set_opaque(ldb, "startup_blocks", startup_blocks); + + talloc_set_destructor(ldb, ldb_wrap_destructor); + + return ldb; +} + + + -- cgit From e5e362567d6d4089a806fb1b628c2130d20de151 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 17 Nov 2007 22:48:01 +0100 Subject: r26018: dsdb/schema/proto.h doesn't exist anymore metze (This used to be commit 3b8215270ce477442dd98a4e4d26b5fcea73f98f) --- source4/lib/ldb_wrap.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index 659b91d254..21ca04997e 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -33,7 +33,6 @@ #include "lib/ldb-samba/ldif_handlers.h" #include "ldb_wrap.h" #include "dsdb/samdb/samdb.h" -#include "dsdb/schema/proto.h" #include "param/param.h" /* -- cgit From f2f16b45b58c2bbf3053ff55e7a290fc069e0efd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Nov 2007 14:49:47 +0100 Subject: r26197: Add bindings for libsecurity. (This used to be commit 8625cd403ba3a7d2b1b1fccfeb5efd7e21de0135) --- source4/lib/ldb_wrap.c | 186 ------------------------------------------------- 1 file changed, 186 deletions(-) delete mode 100644 source4/lib/ldb_wrap.c (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c deleted file mode 100644 index 21ca04997e..0000000000 --- a/source4/lib/ldb_wrap.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - LDB wrap functions - - Copyright (C) Andrew Tridgell 2004 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - the stupidity of the unix fcntl locking design forces us to never - allow a database file to be opened twice in the same process. These - wrappers provide convenient access to a tdb or ldb, taking advantage - of talloc destructors to ensure that only a single open is done -*/ - -#include "includes.h" -#include "lib/events/events.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb-samba/ldif_handlers.h" -#include "ldb_wrap.h" -#include "dsdb/samdb/samdb.h" -#include "param/param.h" - -/* - this is used to catch debug messages from ldb -*/ -static void ldb_wrap_debug(void *context, enum ldb_debug_level level, - const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); - -static void ldb_wrap_debug(void *context, enum ldb_debug_level level, - const char *fmt, va_list ap) -{ - int samba_level; - char *s = NULL; - switch (level) { - case LDB_DEBUG_FATAL: - samba_level = 0; - break; - case LDB_DEBUG_ERROR: - samba_level = 1; - break; - case LDB_DEBUG_WARNING: - samba_level = 2; - break; - case LDB_DEBUG_TRACE: - samba_level = 5; - break; - - }; - vasprintf(&s, fmt, ap); - if (!s) return; - DEBUG(level, ("ldb: %s\n", s)); - free(s); -} - -/* check for memory leaks on the ldb context */ -static int ldb_wrap_destructor(struct ldb_context *ldb) -{ - size_t *startup_blocks = (size_t *)ldb_get_opaque(ldb, "startup_blocks"); - if (startup_blocks && - talloc_total_blocks(ldb) > *startup_blocks + 400) { - DEBUG(0,("WARNING: probable memory leak in ldb %s - %lu blocks (startup %lu) %lu bytes\n", - (char *)ldb_get_opaque(ldb, "wrap_url"), - (unsigned long)talloc_total_blocks(ldb), - (unsigned long)*startup_blocks, - (unsigned long)talloc_total_size(ldb))); -#if 0 - talloc_report_full(ldb, stdout); - call_backtrace(); - smb_panic("probable memory leak in ldb"); -#endif - } - return 0; -} - -/* - wrapped connection to a ldb database - to close just talloc_free() the returned ldb_context - - TODO: We need an error_string parameter - */ -struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, - struct loadparm_context *lp_ctx, - const char *url, - struct auth_session_info *session_info, - struct cli_credentials *credentials, - unsigned int flags, - const char *options[]) -{ - struct ldb_context *ldb; - int ret; - struct event_context *ev; - char *real_url = NULL; - size_t *startup_blocks; - - ldb = ldb_init(mem_ctx); - if (ldb == NULL) { - return NULL; - } - - ldb_set_modules_dir(ldb, - talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx))); - - /* we want to use the existing event context if possible. This - relies on the fact that in smbd, everything is a child of - the main event_context */ - ev = event_context_find(ldb); - - if (ldb_set_opaque(ldb, "EventContext", ev)) { - talloc_free(ldb); - return NULL; - } - - if (ldb_set_opaque(ldb, "sessionInfo", session_info)) { - talloc_free(ldb); - return NULL; - } - - if (ldb_set_opaque(ldb, "credentials", credentials)) { - talloc_free(ldb); - return NULL; - } - - if (strcmp(lp_sam_url(lp_ctx), url) == 0) { - dsdb_set_global_schema(ldb); - } - - ret = ldb_register_samba_handlers(ldb); - if (ret == -1) { - talloc_free(ldb); - return NULL; - } - - ldb_set_debug(ldb, ldb_wrap_debug, NULL); - - ldb_set_utf8_fns(ldb, NULL, wrap_casefold); - - real_url = private_path(ldb, lp_ctx, url); - if (real_url == NULL) { - talloc_free(ldb); - return NULL; - } - - /* allow admins to force non-sync ldb for all databases */ - if (lp_parm_bool(lp_ctx, NULL, "ldb", "nosync", false)) { - flags |= LDB_FLG_NOSYNC; - } - - /* we usually want Samba databases to be private. If we later - find we need one public, we will need to add a parameter to - ldb_wrap_connect() */ - ldb_set_create_perms(ldb, 0600); - - ret = ldb_connect(ldb, real_url, flags, options); - if (ret != LDB_SUCCESS) { - talloc_free(ldb); - return NULL; - } - - /* setup for leak detection */ - ldb_set_opaque(ldb, "wrap_url", real_url); - startup_blocks = talloc(ldb, size_t); - *startup_blocks = talloc_total_blocks(ldb); - ldb_set_opaque(ldb, "startup_blocks", startup_blocks); - - talloc_set_destructor(ldb, ldb_wrap_destructor); - - return ldb; -} - - - -- cgit From e266efffec0763651b5c5f435d2923e972714251 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Nov 2007 15:08:27 +0100 Subject: r26200: Bring back some accidently removed files. (This used to be commit a71e40ab5dc7f0a5f6d2d1eb930f378cd143b186) --- source4/lib/ldb_wrap.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 source4/lib/ldb_wrap.c (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c new file mode 100644 index 0000000000..21ca04997e --- /dev/null +++ b/source4/lib/ldb_wrap.c @@ -0,0 +1,186 @@ +/* + Unix SMB/CIFS implementation. + + LDB wrap functions + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + the stupidity of the unix fcntl locking design forces us to never + allow a database file to be opened twice in the same process. These + wrappers provide convenient access to a tdb or ldb, taking advantage + of talloc destructors to ensure that only a single open is done +*/ + +#include "includes.h" +#include "lib/events/events.h" +#include "lib/ldb/include/ldb.h" +#include "lib/ldb/include/ldb_errors.h" +#include "lib/ldb-samba/ldif_handlers.h" +#include "ldb_wrap.h" +#include "dsdb/samdb/samdb.h" +#include "param/param.h" + +/* + this is used to catch debug messages from ldb +*/ +static void ldb_wrap_debug(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); + +static void ldb_wrap_debug(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap) +{ + int samba_level; + char *s = NULL; + switch (level) { + case LDB_DEBUG_FATAL: + samba_level = 0; + break; + case LDB_DEBUG_ERROR: + samba_level = 1; + break; + case LDB_DEBUG_WARNING: + samba_level = 2; + break; + case LDB_DEBUG_TRACE: + samba_level = 5; + break; + + }; + vasprintf(&s, fmt, ap); + if (!s) return; + DEBUG(level, ("ldb: %s\n", s)); + free(s); +} + +/* check for memory leaks on the ldb context */ +static int ldb_wrap_destructor(struct ldb_context *ldb) +{ + size_t *startup_blocks = (size_t *)ldb_get_opaque(ldb, "startup_blocks"); + if (startup_blocks && + talloc_total_blocks(ldb) > *startup_blocks + 400) { + DEBUG(0,("WARNING: probable memory leak in ldb %s - %lu blocks (startup %lu) %lu bytes\n", + (char *)ldb_get_opaque(ldb, "wrap_url"), + (unsigned long)talloc_total_blocks(ldb), + (unsigned long)*startup_blocks, + (unsigned long)talloc_total_size(ldb))); +#if 0 + talloc_report_full(ldb, stdout); + call_backtrace(); + smb_panic("probable memory leak in ldb"); +#endif + } + return 0; +} + +/* + wrapped connection to a ldb database + to close just talloc_free() the returned ldb_context + + TODO: We need an error_string parameter + */ +struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + const char *url, + struct auth_session_info *session_info, + struct cli_credentials *credentials, + unsigned int flags, + const char *options[]) +{ + struct ldb_context *ldb; + int ret; + struct event_context *ev; + char *real_url = NULL; + size_t *startup_blocks; + + ldb = ldb_init(mem_ctx); + if (ldb == NULL) { + return NULL; + } + + ldb_set_modules_dir(ldb, + talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx))); + + /* we want to use the existing event context if possible. This + relies on the fact that in smbd, everything is a child of + the main event_context */ + ev = event_context_find(ldb); + + if (ldb_set_opaque(ldb, "EventContext", ev)) { + talloc_free(ldb); + return NULL; + } + + if (ldb_set_opaque(ldb, "sessionInfo", session_info)) { + talloc_free(ldb); + return NULL; + } + + if (ldb_set_opaque(ldb, "credentials", credentials)) { + talloc_free(ldb); + return NULL; + } + + if (strcmp(lp_sam_url(lp_ctx), url) == 0) { + dsdb_set_global_schema(ldb); + } + + ret = ldb_register_samba_handlers(ldb); + if (ret == -1) { + talloc_free(ldb); + return NULL; + } + + ldb_set_debug(ldb, ldb_wrap_debug, NULL); + + ldb_set_utf8_fns(ldb, NULL, wrap_casefold); + + real_url = private_path(ldb, lp_ctx, url); + if (real_url == NULL) { + talloc_free(ldb); + return NULL; + } + + /* allow admins to force non-sync ldb for all databases */ + if (lp_parm_bool(lp_ctx, NULL, "ldb", "nosync", false)) { + flags |= LDB_FLG_NOSYNC; + } + + /* we usually want Samba databases to be private. If we later + find we need one public, we will need to add a parameter to + ldb_wrap_connect() */ + ldb_set_create_perms(ldb, 0600); + + ret = ldb_connect(ldb, real_url, flags, options); + if (ret != LDB_SUCCESS) { + talloc_free(ldb); + return NULL; + } + + /* setup for leak detection */ + ldb_set_opaque(ldb, "wrap_url", real_url); + startup_blocks = talloc(ldb, size_t); + *startup_blocks = talloc_total_blocks(ldb); + ldb_set_opaque(ldb, "startup_blocks", startup_blocks); + + talloc_set_destructor(ldb, ldb_wrap_destructor); + + return ldb; +} + + + -- cgit From cc04f143dcd35fb67884e385ffd3e6ed2d32a4c2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 19:04:33 +0100 Subject: r26229: Set loadparm context as opaque pointer in ldb, remove more uses of global_loadparm. (This used to be commit 37d05fdc7b0e6b3211ba6ae56b1b5da30a6a392a) --- source4/lib/ldb_wrap.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index 21ca04997e..d0abb5808a 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -134,6 +134,11 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, talloc_free(ldb); return NULL; } + + if (ldb_set_opaque(ldb, "loadparm", lp_ctx)) { + talloc_free(ldb); + return NULL; + } if (strcmp(lp_sam_url(lp_ctx), url) == 0) { dsdb_set_global_schema(ldb); -- cgit From 7c146c42d2cf51e891b9f29d3b61a40f173a3b23 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Dec 2007 16:36:31 -0600 Subject: r26593: - More work on the python versions of samba3dump and the samba3sam tests. - Initial work converting the upgrade code to Python. - Removed the old EJS upgrade code because it has been broken for a long time. (This used to be commit 150cf39fbd4fe088546870fb0d8f20c0d9eb4aca) --- source4/lib/ldb_wrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index d0abb5808a..63049b06fc 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -140,7 +140,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, return NULL; } - if (strcmp(lp_sam_url(lp_ctx), url) == 0) { + if (lp_ctx != NULL && strcmp(lp_sam_url(lp_ctx), url) == 0) { dsdb_set_global_schema(ldb); } -- cgit From 0e50fb5e917117de22c5b3c32865d8a40285e362 Mon Sep 17 00:00:00 2001 From: Andrew Kroeger Date: Thu, 6 Mar 2008 00:03:18 -0600 Subject: ldb_wrap: Debug at derived samba_level, not the level of the ldb debug enum. (This used to be commit eb9a7c3b3a7f113ff58e2ebea9886f997da4e085) --- source4/lib/ldb_wrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index 63049b06fc..71ba37b479 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -63,7 +63,7 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level, }; vasprintf(&s, fmt, ap); if (!s) return; - DEBUG(level, ("ldb: %s\n", s)); + DEBUG(samba_level, ("ldb: %s\n", s)); free(s); } -- cgit From 21fc7673780aa1d7c0caab7b17ff9171238913ba Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 12:23:44 +0200 Subject: Specify event_context to ldb_wrap_connect explicitly. (This used to be commit b4e1ae07a284c044704322446c94351c2decff91) --- source4/lib/ldb_wrap.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index 71ba37b479..b71adcbca2 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -94,6 +94,7 @@ static int ldb_wrap_destructor(struct ldb_context *ldb) TODO: We need an error_string parameter */ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, + struct event_context *ev, struct loadparm_context *lp_ctx, const char *url, struct auth_session_info *session_info, @@ -103,7 +104,6 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, { struct ldb_context *ldb; int ret; - struct event_context *ev; char *real_url = NULL; size_t *startup_blocks; @@ -115,10 +115,9 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, ldb_set_modules_dir(ldb, talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx))); - /* we want to use the existing event context if possible. This - relies on the fact that in smbd, everything is a child of - the main event_context */ - ev = event_context_find(ldb); + if (ev == NULL) { + ev = event_context_find(mem_ctx); + } if (ldb_set_opaque(ldb, "EventContext", ev)) { talloc_free(ldb); -- cgit From 4e83011f72ba3df387512755a17760b42a7bf2f2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 21 Apr 2008 17:58:23 -0400 Subject: Remove more event_context_init() uses from function calls within deep down the code. Make sure we pass around the event_context where we need it instead. All test but a few python ones fail. Jelmer promised to fix them. (This used to be commit 3045d391626fba169aa26be52174883e18d323e9) --- source4/lib/ldb_wrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index b71adcbca2..b564976524 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -116,7 +116,7 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx))); if (ev == NULL) { - ev = event_context_find(mem_ctx); + return NULL; } if (ldb_set_opaque(ldb, "EventContext", ev)) { -- cgit From a620882e15c1b33c1eb5a0d4d1a8d8c890cc23df Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 15 May 2008 18:09:56 +0200 Subject: Fix an uninitialized variable warning (This used to be commit b3d024676426000380ad86a2a4b83e7b21478978) --- source4/lib/ldb_wrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index b564976524..f47d0d5d39 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -44,7 +44,7 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level, static void ldb_wrap_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { - int samba_level; + int samba_level = -1; char *s = NULL; switch (level) { case LDB_DEBUG_FATAL: -- cgit From 929adc9efa5cf985f0585214d30d18521aa1a821 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 11:24:17 -0400 Subject: Make up the right dependencies now that ldb depends on libevents (This used to be commit 3b8eec7ca334528cad3cdcd5e3fc5ee555d8d0e0) --- source4/lib/ldb_wrap.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index f47d0d5d39..883597108a 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -107,22 +107,31 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, char *real_url = NULL; size_t *startup_blocks; - ldb = ldb_init(mem_ctx); - if (ldb == NULL) { + /* we want to use the existing event context if possible. This + relies on the fact that in smbd, everything is a child of + the main event_context */ + if (ev == NULL) { return NULL; } - ldb_set_modules_dir(ldb, - talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx))); - - if (ev == NULL) { + ldb = ldb_init(mem_ctx, ev); + if (ldb == NULL) { return NULL; } - if (ldb_set_opaque(ldb, "EventContext", ev)) { + ldb_set_modules_dir(ldb, + talloc_asprintf(ldb, + "%s/ldb", + lp_modulesdir(lp_ctx))); + +#if 0 + if (ev) { + ldb_event_sys_op_init(ldb, ev); + } else { talloc_free(ldb); return NULL; } +#endif if (ldb_set_opaque(ldb, "sessionInfo", session_info)) { talloc_free(ldb); -- cgit From 38f740529803054a3145ad547b3d7de8a25e983a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Aug 2008 17:29:47 +1000 Subject: Push loading the objectGUID and objectSID handlers earlier. Andrew Bartlett (This used to be commit 0b6e53f80b063d8702718c84409d7b069aee9c05) --- source4/lib/ldb_wrap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb_wrap.c') diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c index 883597108a..6c683a1e33 100644 --- a/source4/lib/ldb_wrap.c +++ b/source4/lib/ldb_wrap.c @@ -147,17 +147,21 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx, talloc_free(ldb); return NULL; } - - if (lp_ctx != NULL && strcmp(lp_sam_url(lp_ctx), url) == 0) { - dsdb_set_global_schema(ldb); - } + /* This must be done before we load the schema, as these + * handlers for objectSid and objectGUID etc must take + * precedence over the 'binary attribute' declaration in the + * schema */ ret = ldb_register_samba_handlers(ldb); if (ret == -1) { talloc_free(ldb); return NULL; } + if (lp_ctx != NULL && strcmp(lp_sam_url(lp_ctx), url) == 0) { + dsdb_set_global_schema(ldb); + } + ldb_set_debug(ldb, ldb_wrap_debug, NULL); ldb_set_utf8_fns(ldb, NULL, wrap_casefold); -- cgit