From 8a18778286a16423d7d6e483fdb308a91e294efe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Nov 2004 09:00:52 +0000 Subject: r3783: - don't use make proto for ldb anymore - split ldh.h out of samba's includes.h - make ldb_context and ldb_module private to the subsystem - use ltdb_ prefix for all ldb_tdb functions metze (This used to be commit f5ee40d6ce8224e280070975efc9911558fe675c) --- source4/auth/auth_sam.c | 1 + source4/include/includes.h | 5 +- source4/include/structs.h | 2 + source4/ldap_server/ldap_rootdse.c | 6 +- source4/ldap_server/ldap_simple_ldb.c | 1 + source4/lib/db_wrap.c | 1 + source4/lib/ldb/Makefile.ldb | 3 - source4/lib/ldb/common/ldb.c | 2 + source4/lib/ldb/common/ldb_alloc.c | 4 +- source4/lib/ldb/common/ldb_debug.c | 2 + source4/lib/ldb/common/ldb_ldif.c | 2 + source4/lib/ldb/common/ldb_modules.c | 10 +- source4/lib/ldb/common/ldb_msg.c | 27 +++++ source4/lib/ldb/common/ldb_parse.c | 2 + source4/lib/ldb/common/ldb_utf8.c | 2 + source4/lib/ldb/common/util.c | 2 + source4/lib/ldb/config.mk | 3 + source4/lib/ldb/include/includes.h | 8 +- source4/lib/ldb/include/ldb.h | 93 ++++++--------- source4/lib/ldb/include/ldb_parse.h | 3 + source4/lib/ldb/include/ldb_private.h | 126 +++++++++++++++++++++ source4/lib/ldb/ldb_ldap/ldb_ldap.c | 2 + source4/lib/ldb/ldb_tdb/ldb_cache.c | 2 + source4/lib/ldb/ldb_tdb/ldb_index.c | 8 +- source4/lib/ldb/ldb_tdb/ldb_match.c | 43 +++---- source4/lib/ldb/ldb_tdb/ldb_pack.c | 13 ++- source4/lib/ldb/ldb_tdb/ldb_search.c | 40 ++----- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 12 +- source4/lib/ldb/ldb_tdb/ldb_tdb.h | 69 +++++++++++ source4/lib/ldb/modules/skel.c | 2 + source4/lib/ldb/modules/timestamps.c | 2 + source4/lib/ldb/tools/ldbadd.c | 1 + source4/lib/ldb/tools/ldbdel.c | 1 + source4/lib/ldb/tools/ldbedit.c | 1 + source4/lib/ldb/tools/ldbmodify.c | 1 + source4/lib/ldb/tools/ldbrename.c | 1 + source4/lib/ldb/tools/ldbsearch.c | 1 + source4/lib/ldb/tools/ldbtest.c | 1 + .../lib/registry/reg_backend_ldb/reg_backend_ldb.c | 1 + source4/rpc_server/common/gendb.c | 1 + source4/rpc_server/netlogon/dcerpc_netlogon.c | 1 + source4/rpc_server/netlogon/schannel_state.c | 1 + source4/rpc_server/samr/dcesrv_samr.c | 2 +- source4/rpc_server/samr/samdb.c | 1 + source4/rpc_server/samr/samr_password.c | 1 + source4/rpc_server/spoolss/spoolssdb.c | 4 +- 46 files changed, 373 insertions(+), 144 deletions(-) create mode 100644 source4/lib/ldb/include/ldb_private.h diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c index 7cba6e83b3..501b5ca080 100644 --- a/source4/auth/auth_sam.c +++ b/source4/auth/auth_sam.c @@ -23,6 +23,7 @@ #include "librpc/gen_ndr/ndr_samr.h" #include "system/time.h" #include "auth/auth.h" +#include "lib/ldb/include/ldb.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH diff --git a/source4/include/includes.h b/source4/include/includes.h index c7cc1338f5..10516f8989 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -155,12 +155,12 @@ extern int errno; #include "version.h" #include "xfile.h" #include "talloc.h" -#include "lib/ldb/include/ldb.h" +#include "nt_status.h" +#include "structs.h" #include "lib/tdb/include/tdb.h" #include "lib/tdb/include/spinlock.h" #include "lib/tdb/include/tdbutil.h" #include "db_wrap.h" -#include "nt_status.h" #include "trans2.h" #include "nterr.h" #include "charset.h" @@ -188,7 +188,6 @@ extern int errno; #include "smb_interfaces.h" #include "smbd/server.h" #include "smbd/service.h" -#include "structs.h" #include "ntvfs/ntvfs.h" #include "cli_context.h" #include "nsswitch/winbind_client.h" diff --git a/source4/include/structs.h b/source4/include/structs.h index 229c489072..4ec8f1f4d3 100644 --- a/source4/include/structs.h +++ b/source4/include/structs.h @@ -117,3 +117,5 @@ struct test_join; struct test_join_ads_dc; struct netr_LMSessionKey; + +struct ldb_message; diff --git a/source4/ldap_server/ldap_rootdse.c b/source4/ldap_server/ldap_rootdse.c index 2b9efa11b4..5780809c78 100644 --- a/source4/ldap_server/ldap_rootdse.c +++ b/source4/ldap_server/ldap_rootdse.c @@ -22,6 +22,7 @@ #include "dynconfig.h" #include "ldap_server/ldap_server.h" #include "system/time.h" +#include "lib/ldb/include/ldb.h" #define ATTR_BLOB_CONST(val) data_blob_talloc(mem_ctx, val, sizeof(val)-1) #define ATTR_SINGLE_NOVAL(ctx, attr, blob, num, nam) do { \ @@ -47,7 +48,8 @@ struct rootdse_db_context { /* this is used to catch debug messages from ldb */ -void rootdse_db_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) _PRINTF_ATTRIBUTE(3,0) +static void rootdse_db_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); +static void rootdse_db_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { char *s = NULL; if (DEBUGLEVEL < 4 && level > LDB_DEBUG_WARNING) { @@ -73,7 +75,7 @@ static int rootdse_db_destructor(void *ctx) connect to the SAM database return an opaque context pointer on success, or NULL on failure */ -void *rootdse_db_connect(TALLOC_CTX *mem_ctx) +static void *rootdse_db_connect(TALLOC_CTX *mem_ctx) { static struct rootdse_db_context *ctx; char *db_path; diff --git a/source4/ldap_server/ldap_simple_ldb.c b/source4/ldap_server/ldap_simple_ldb.c index 4edd456c6e..1b000f53ea 100644 --- a/source4/ldap_server/ldap_simple_ldb.c +++ b/source4/ldap_server/ldap_simple_ldb.c @@ -22,6 +22,7 @@ #include "includes.h" #include "ldap_server/ldap_server.h" #include "ldap_parse.h" +#include "lib/ldb/include/ldb.h" /* TODO: samdb_context is not a pulblic struct */ struct samdb_context { diff --git a/source4/lib/db_wrap.c b/source4/lib/db_wrap.c index c786185499..e9055399ad 100644 --- a/source4/lib/db_wrap.c +++ b/source4/lib/db_wrap.c @@ -29,6 +29,7 @@ #include "includes.h" #include "dlinklist.h" +#include "lib/ldb/include/ldb.h" static struct ldb_wrap *ldb_list; static struct tdb_wrap *tdb_list; diff --git a/source4/lib/ldb/Makefile.ldb b/source4/lib/ldb/Makefile.ldb index 7666f5bd31..a7c86b4e82 100644 --- a/source4/lib/ldb/Makefile.ldb +++ b/source4/lib/ldb/Makefile.ldb @@ -74,9 +74,6 @@ manpages: clean: rm -f */*.o *~ */*~ $(BINS) $(LDB_LIB) man/man?/*.[13] -proto: - perl ../../script/mkproto.pl */*.c > include/proto.h - etags: etags */*.[ch] diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 4fe2088daf..0fb371011f 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" /* connect to a database. The URL can either be one of the following forms diff --git a/source4/lib/ldb/common/ldb_alloc.c b/source4/lib/ldb/common/ldb_alloc.c index 0053c5e73f..7dc12b142e 100644 --- a/source4/lib/ldb/common/ldb_alloc.c +++ b/source4/lib/ldb/common/ldb_alloc.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" /* @@ -122,7 +124,7 @@ void *ldb_strdup(struct ldb_context *ldb, const char *str) /* a ldb wrapper for asprintf(), using ldb_malloc() */ -int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) _PRINTF_ATTRIBUTE(3, 4) +int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) { int len, len2; va_list ap; diff --git a/source4/lib/ldb/common/ldb_debug.c b/source4/lib/ldb/common/ldb_debug.c index 0a187cd62d..6ba3f30b2d 100644 --- a/source4/lib/ldb/common/ldb_debug.c +++ b/source4/lib/ldb/common/ldb_debug.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" /* diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index 01706304d9..bd99468182 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -37,6 +37,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 37be07c1ca..1a6a334b8d 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -34,6 +34,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "dlinklist.h" #include #include @@ -82,10 +84,10 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) if (!modules && strcmp("ldap", ldb->modules->ops->name)) { /* no modules in the options, look for @MODULES in the db (not for ldap) */ int ret, j, k; - char * attrs[] = { "@MODULE" }; + const char * const attrs[] = { "@MODULE" , NULL}; struct ldb_message **msg; - ret = ldb_search(ldb, "", LDB_SCOPE_BASE, "dn=@MODULES", (const char * const *)attrs, &msg); + ret = ldb_search(ldb, "", LDB_SCOPE_BASE, "dn=@MODULES", attrs, &msg); if (ret == 0) { ldb_debug(ldb, LDB_DEBUG_TRACE, "no modules required by the db\n"); } else { @@ -144,7 +146,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) #ifdef HAVE_DLOPEN_DISABLED { void *handle; - init_ldb_module_function init; + ldb_module_init_function init; struct stat st; const char *errstr; @@ -160,7 +162,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) return -1; } - init = (init_ldb_module_function)dlsym(handle, "init_module"); + init = (ldb_module_init_function)dlsym(handle, "init_module"); errstr = dlerror(); if (errstr) { diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 170a7ae5e4..18859c86dd 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" /* @@ -83,6 +85,31 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, return NULL; } +/* + duplicate a ldb_val structure +*/ +struct ldb_val ldb_val_dup(struct ldb_context *ldb, + const struct ldb_val *v) +{ + struct ldb_val v2; + v2.length = v->length; + if (v->length == 0) { + v2.data = NULL; + return v2; + } + + /* the +1 is to cope with buggy C library routines like strndup + that look one byte beyond */ + v2.data = ldb_malloc(ldb, v->length+1); + if (!v2.data) { + v2.length = 0; + return v2; + } + + memcpy(v2.data, v->data, v->length); + ((char *)v2.data)[v->length] = 0; + return v2; +} /* add an empty element to a message diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index feec8fc0f2..1e00a05d55 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -42,6 +42,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/include/ldb_parse.h" #include diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index e92d318bae..01bd8eb9ac 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include /* diff --git a/source4/lib/ldb/common/util.c b/source4/lib/ldb/common/util.c index c8aa5019e2..af738f352a 100644 --- a/source4/lib/ldb/common/util.c +++ b/source4/lib/ldb/common/util.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" /* diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk index 46fd4e12ae..a026ae1229 100644 --- a/source4/lib/ldb/config.mk +++ b/source4/lib/ldb/config.mk @@ -15,6 +15,7 @@ INIT_OBJ_FILES = \ lib/ldb/ldb_ldap/ldb_ldap.o REQUIRED_SUBSYSTEMS = \ EXT_LIB_LDAP +NOPROTO = YES # End MODULE libldb_tdb ################################################ @@ -32,6 +33,7 @@ ADD_OBJ_FILES = \ lib/ldb/ldb_tdb/ldb_cache.o REQUIRED_SUBSYSTEMS = \ LIBTDB +NOPROTO = YES # End MODULE libldb_tdb ################################################ @@ -51,6 +53,7 @@ ADD_OBJ_FILES = \ lib/ldb/common/ldb_modules.o REQUIRED_SUBSYSTEMS = \ LIBREPLACE +NOPROTO = YES # # End SUBSYSTEM LIBLDB ################################################ diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 44ff672266..4926e1524a 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -19,14 +19,8 @@ #include #include - -#ifndef _PRINTF_ATTRIBUTE -#define _PRINTF_ATTRIBUTE(a,b) -#endif - #include "ldb.h" -#include "tdb.h" -#include "proto.h" +#include "ldb_private.h" #ifdef HAVE_INTPTR_T #define discard_const(ptr) ((void *)((intptr_t)(ptr))) diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6a06678e0e..03d0cc7a3b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -121,39 +121,7 @@ struct ldb_context; typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); -struct ldb_module_ops; - -/* basic module structure */ -struct ldb_module { - struct ldb_module *prev, *next; - struct ldb_context *ldb; - void *private_data; - const struct ldb_module_ops *ops; -}; - -/* - these function pointers define the operations that a ldb module must perform - they correspond exactly to the ldb_*() interface -*/ -struct ldb_module_ops { - const char *name; - int (*close)(struct ldb_module *); - int (*search)(struct ldb_module *, const char *, enum ldb_scope, - const char *, const char * const [], struct ldb_message ***); - int (*search_free)(struct ldb_module *, struct ldb_message **); - int (*add_record)(struct ldb_module *, const struct ldb_message *); - int (*modify_record)(struct ldb_module *, const struct ldb_message *); - int (*delete_record)(struct ldb_module *, const char *); - int (*rename_record)(struct ldb_module *, const char *, const char *); - const char * (*errstring)(struct ldb_module *); - - /* this is called when the alloc ops changes to ensure we - don't have any old allocated data in the context */ - void (*cache_free)(struct ldb_module *); -}; - -/* the modules init function */ -typedef struct ldb_module *(*init_ldb_module_function)(void); +struct ldb_module; /* the user can optionally supply a allocator function. It is presumed @@ -180,22 +148,6 @@ struct ldb_debug_ops { void *context; }; - -/* - every ldb connection is started by establishing a ldb_context -*/ -struct ldb_context { - /* the operations provided by the backend */ - struct ldb_module *modules; - - /* memory allocation info */ - struct ldb_alloc_ops alloc_ops; - - /* memory allocation info */ - struct ldb_debug_ops debug_ops; -}; - - #define LDB_FLG_RDONLY 1 /* @@ -285,6 +237,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif /* useful functions for ldb_message structure manipulation */ +int ldb_dn_cmp(const char *dn1, const char *dn2); +int ldb_attr_cmp(const char *dn1, const char *dn2); + /* find an element within an message */ struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); @@ -305,6 +260,12 @@ int ldb_msg_add(struct ldb_context *ldb, struct ldb_message *msg, const struct ldb_message_element *el, int flags); +int ldb_msg_add_value(struct ldb_context *ldb, + struct ldb_message *msg, + const char *attr_name, + struct ldb_val *val); +int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, + const char *attr_name, char *str); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, @@ -313,19 +274,27 @@ int ldb_msg_element_compare(struct ldb_message_element *el1, /* find elements in a message and convert to a specific type, with a give default value if not found. Assumes that elements are single valued */ +const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name); int ldb_msg_find_int(const struct ldb_message *msg, const char *attr_name, int default_value); unsigned int ldb_msg_find_uint(const struct ldb_message *msg, const char *attr_name, unsigned int default_value); +int64_t ldb_msg_find_int64(const struct ldb_message *msg, + const char *attr_name, + int64_t default_value); +uint64_t ldb_msg_find_uint64(const struct ldb_message *msg, + const char *attr_name, + uint64_t default_value); double ldb_msg_find_double(const struct ldb_message *msg, const char *attr_name, double default_value); const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); - +struct ldb_val ldb_val_dup(struct ldb_context *ldb, + const struct ldb_val *v); /* this allows the user to choose their own allocation function @@ -341,6 +310,24 @@ int ldb_set_alloc(struct ldb_context *ldb, void *(*alloc)(const void *context, void *ptr, size_t size), void *context); +/* these are used as type safe versions of the ldb allocation functions */ +#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) +#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) +#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) + +void *ldb_realloc(struct ldb_context *ldb, void *ptr, size_t size); +void *ldb_malloc(struct ldb_context *ldb, size_t size); +void ldb_free(struct ldb_context *ldb, void *ptr); +void *ldb_strndup(struct ldb_context *ldb, const char *str, size_t maxlen); +void *ldb_strdup(struct ldb_context *ldb, const char *str); +void *ldb_realloc_array(struct ldb_context *ldb, + void *ptr, size_t el_size, unsigned count); + +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif +int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); + /* this allows the user to set a debug function for error reporting */ @@ -352,10 +339,4 @@ int ldb_set_debug(struct ldb_context *ldb, /* this sets up debug to print messages on stderr */ int ldb_set_debug_stderr(struct ldb_context *ldb); - -/* these are used as type safe versions of the ldb allocation functions */ -#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) -#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) - #endif diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h index 930799d7b6..d9125d05ed 100644 --- a/source4/lib/ldb/include/ldb_parse.h +++ b/source4/lib/ldb/include/ldb_parse.h @@ -54,4 +54,7 @@ struct ldb_parse_tree { } u; }; +struct ldb_parse_tree *ldb_parse_tree(struct ldb_context *ldb, const char *s); +void ldb_parse_tree_free(struct ldb_context *ldb, struct ldb_parse_tree *tree); + #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h new file mode 100644 index 0000000000..dfd388b8c6 --- /dev/null +++ b/source4/lib/ldb/include/ldb_private.h @@ -0,0 +1,126 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + Copyright (C) Stefan Metzmacher 2004 + + ** 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 + version 2 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb private header + * + * Description: defines internal ldb structures used by th esubsystem and modules + * + * Author: Andrew Tridgell + * Author: Stefan Metzmacher + */ + +#ifndef _LDB_PRIVATE_H_ +#define _LDB_PRIVATE_H_ 1 + +struct ldb_context; + +struct ldb_module_ops; + +/* basic module structure */ +struct ldb_module { + struct ldb_module *prev, *next; + struct ldb_context *ldb; + void *private_data; + const struct ldb_module_ops *ops; +}; + +/* + these function pointers define the operations that a ldb module must perform + they correspond exactly to the ldb_*() interface +*/ +struct ldb_module_ops { + const char *name; + int (*close)(struct ldb_module *); + int (*search)(struct ldb_module *, const char *, enum ldb_scope, + const char *, const char * const [], struct ldb_message ***); + int (*search_free)(struct ldb_module *, struct ldb_message **); + int (*add_record)(struct ldb_module *, const struct ldb_message *); + int (*modify_record)(struct ldb_module *, const struct ldb_message *); + int (*delete_record)(struct ldb_module *, const char *); + int (*rename_record)(struct ldb_module *, const char *, const char *); + const char * (*errstring)(struct ldb_module *); + + /* this is called when the alloc ops changes to ensure we + don't have any old allocated data in the context */ + void (*cache_free)(struct ldb_module *); +}; + +/* the modules init function */ +typedef struct ldb_module *(*ldb_module_init_function)(void); + +/* + every ldb connection is started by establishing a ldb_context +*/ +struct ldb_context { + /* the operations provided by the backend */ + struct ldb_module *modules; + + /* memory allocation info */ + struct ldb_alloc_ops alloc_ops; + + /* memory allocation info */ + struct ldb_debug_ops debug_ops; +}; + +/* The following definitions come from lib/ldb/common/ldb_modules.c */ + +int ldb_load_modules(struct ldb_context *ldb, const char *options[]); +int ldb_next_close(struct ldb_module *module); +int ldb_next_search(struct ldb_module *module, + const char *base, + enum ldb_scope scope, + const char *expression, + const char * const *attrs, struct ldb_message ***res); +int ldb_next_search_free(struct ldb_module *module, struct ldb_message **msg); +int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message); +int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); +int ldb_next_delete_record(struct ldb_module *module, const char *dn); +int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn); +const char *ldb_next_errstring(struct ldb_module *module); +void ldb_next_cache_free(struct ldb_module *module); + +/* The following definitions come from lib/ldb/common/util.c */ +int ldb_list_find(const void *needle, + const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn); + +/* The following definitions come from lib/ldb/common/ldb_debug.c */ +void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); + +/* The following definitions come from lib/ldb/common/ldb_ldif.c */ +char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len); +int ldb_should_b64_encode(const struct ldb_val *val); + +struct ldb_context *ltdb_connect(const char *url, + unsigned int flags, + const char *options[]); +struct ldb_context *lldb_connect(const char *url, + unsigned int flags, + const char *options[]); +struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); + +#endif diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 7fb6a0b3f7..85604dfe76 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/ldb_ldap/ldb_ldap.h" #if 0 diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c index cf175090e6..a8eb9ae916 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/ldb_tdb/ldb_tdb.h" /* diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 93e358e4d2..b651aa38c1 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/ldb_tdb/ldb_tdb.h" #include "ldb/include/ldb_parse.h" @@ -523,7 +525,7 @@ static int ldb_index_filter(struct ldb_module *module, struct ldb_parse_tree *tr return -1; } - if (ldb_message_match(module, &msg, tree, base, scope) == 1) { + if (ltdb_message_match(module, &msg, tree, base, scope) == 1) { ret = ltdb_add_attr_results(module, &msg, attrs, &count, res); } ltdb_search_dn1_free(module, &msg); @@ -860,7 +862,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * return 0; } - ret = ltdb_unpack_data(module->ldb, &data, &msg); + ret = ltdb_unpack_data(module, &data, &msg); if (ret != 0) { return -1; } @@ -871,7 +873,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * ret = ltdb_index_add(module, &msg); - ltdb_unpack_data_free(module->ldb, &msg); + ltdb_unpack_data_free(module, &msg); return ret; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_match.c b/source4/lib/ldb/ldb_tdb/ldb_match.c index 52e9f5afc7..4a51cfddf0 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_match.c +++ b/source4/lib/ldb/ldb_tdb/ldb_match.c @@ -33,16 +33,17 @@ */ #include "includes.h" -#include +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/ldb_tdb/ldb_tdb.h" #include "ldb/include/ldb_parse.h" - +#include /* see if two ldb_val structures contain the same data as integers return 1 for a match, 0 for a mis-match */ -static int ldb_val_equal_integer(const struct ldb_val *v1, const struct ldb_val *v2) +static int ltdb_val_equal_integer(const struct ldb_val *v1, const struct ldb_val *v2) { int i1, i2; @@ -56,7 +57,7 @@ static int ldb_val_equal_integer(const struct ldb_val *v1, const struct ldb_val see if two ldb_val structures contain the same data as case insensitive strings return 1 for a match, 0 for a mis-match */ -static int ldb_val_equal_case_insensitive(const struct ldb_val *v1, +static int ltdb_val_equal_case_insensitive(const struct ldb_val *v1, const struct ldb_val *v2) { if (v1->length != v2->length) { @@ -73,10 +74,11 @@ static int ldb_val_equal_case_insensitive(const struct ldb_val *v1, and case insensitive return 1 for a match, 0 for a mis-match */ -static int ldb_val_equal_wildcard_ci(struct ldb_context *ldb, +static int ltdb_val_equal_wildcard_ci(struct ldb_module *module, const struct ldb_val *v1, const struct ldb_val *v2) { + struct ldb_context *ldb = module->ldb; char *s1, *s2; int ret; @@ -110,13 +112,13 @@ static int ldb_val_equal_wildcard_ci(struct ldb_context *ldb, see if two ldb_val structures contain the same data with wildcards return 1 for a match, 0 for a mis-match */ -static int ldb_val_equal_wildcard(struct ldb_context *ldb, +static int ltdb_val_equal_wildcard(struct ldb_module *module, const struct ldb_val *v1, const struct ldb_val *v2, int flags) { if (flags & LTDB_FLAG_CASE_INSENSITIVE) { - return ldb_val_equal_wildcard_ci(ldb, v1, v2); + return ltdb_val_equal_wildcard_ci(module, v1, v2); } if (!v1->data || !v2->data) { return v1->data == v2->data; @@ -137,13 +139,13 @@ static int ldb_val_equal_wildcard(struct ldb_context *ldb, return 1 for a match, 0 for a mis-match */ -static int ldb_val_equal_objectclass(struct ldb_module *module, +static int ltdb_val_equal_objectclass(struct ldb_module *module, const struct ldb_val *v1, const struct ldb_val *v2) { struct ltdb_private *ltdb = module->private_data; unsigned int i; - if (ldb_val_equal_case_insensitive(v1, v2) == 1) { + if (ltdb_val_equal_case_insensitive(v1, v2) == 1) { return 1; } @@ -152,7 +154,7 @@ static int ldb_val_equal_objectclass(struct ldb_module *module, if (ldb_attr_cmp(el->name, v2->data) == 0) { unsigned int j; for (j=0;jnum_values;j++) { - if (ldb_val_equal_objectclass(module, v1, &el->values[j])) { + if (ltdb_val_equal_objectclass(module, v1, &el->values[j])) { return 1; } } @@ -171,27 +173,26 @@ static int ldb_val_equal_objectclass(struct ldb_module *module, return 1 for a match, 0 for a mis-match */ -int ldb_val_equal(struct ldb_module *module, +int ltdb_val_equal(struct ldb_module *module, const char *attr_name, const struct ldb_val *v1, const struct ldb_val *v2) { - struct ldb_context *ldb = module->ldb; int flags = ltdb_attribute_flags(module, attr_name); if (flags & LTDB_FLAG_OBJECTCLASS) { - return ldb_val_equal_objectclass(module, v1, v2); + return ltdb_val_equal_objectclass(module, v1, v2); } if (flags & LTDB_FLAG_INTEGER) { - return ldb_val_equal_integer(v1, v2); + return ltdb_val_equal_integer(v1, v2); } if (flags & LTDB_FLAG_WILDCARD) { - return ldb_val_equal_wildcard(ldb, v1, v2, flags); + return ltdb_val_equal_wildcard(module, v1, v2, flags); } if (flags & LTDB_FLAG_CASE_INSENSITIVE) { - return ldb_val_equal_case_insensitive(v1, v2); + return ltdb_val_equal_case_insensitive(v1, v2); } if (v1->length != v2->length) return 0; @@ -280,7 +281,7 @@ static int match_leaf(struct ldb_module *module, return 1; } for (j=0;jelements[i].num_values;j++) { - if (ldb_val_equal(module, msg->elements[i].name, + if (ltdb_val_equal(module, msg->elements[i].name, &msg->elements[i].values[j], &tree->u.simple.value)) { return 1; @@ -300,7 +301,7 @@ static int match_leaf(struct ldb_module *module, this is a recursive function, and does short-circuit evaluation */ -int ldb_message_match(struct ldb_module *module, +int ltdb_message_match(struct ldb_module *module, struct ldb_message *msg, struct ldb_parse_tree *tree, const char *base, @@ -314,11 +315,11 @@ int ldb_message_match(struct ldb_module *module, break; case LDB_OP_NOT: - return ! ldb_message_match(module, msg, tree->u.not.child, base, scope); + return ! ltdb_message_match(module, msg, tree->u.not.child, base, scope); case LDB_OP_AND: for (i=0;iu.list.num_elements;i++) { - v = ldb_message_match(module, msg, tree->u.list.elements[i], + v = ltdb_message_match(module, msg, tree->u.list.elements[i], base, scope); if (!v) return 0; } @@ -326,7 +327,7 @@ int ldb_message_match(struct ldb_module *module, case LDB_OP_OR: for (i=0;iu.list.num_elements;i++) { - v = ldb_message_match(module, msg, tree->u.list.elements[i], + v = ltdb_message_match(module, msg, tree->u.list.elements[i], base, scope); if (v) return 1; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c index ad856d2faf..9515beeaa7 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_pack.c +++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/ldb_tdb/ldb_tdb.h" /* change this if the data format ever changes */ @@ -65,10 +67,11 @@ static unsigned int pull_uint32(uint8_t *p, int ofs) caller frees the data buffer after use */ -int ltdb_pack_data(struct ldb_context *ldb, +int ltdb_pack_data(struct ldb_module *module, const struct ldb_message *message, struct TDB_DATA *data) { + struct ldb_context *ldb = module->ldb; unsigned int i, j, real_elements=0; size_t size; char *p; @@ -138,9 +141,10 @@ int ltdb_pack_data(struct ldb_context *ldb, /* free the memory allocated from a ltdb_unpack_data() */ -void ltdb_unpack_data_free(struct ldb_context *ldb, +void ltdb_unpack_data_free(struct ldb_module *module, struct ldb_message *message) { + struct ldb_context *ldb = module->ldb; unsigned int i; for (i=0;inum_elements;i++) { @@ -160,10 +164,11 @@ void ltdb_unpack_data_free(struct ldb_context *ldb, TDB_DATA data. This means the caller only has to free the elements and values arrays. This can be done with ltdb_unpack_data_free() */ -int ltdb_unpack_data(struct ldb_context *ldb, +int ltdb_unpack_data(struct ldb_module *module, const struct TDB_DATA *data, struct ldb_message *message) { + struct ldb_context *ldb = module->ldb; char *p; unsigned int remaining; unsigned int i, j; @@ -274,7 +279,7 @@ int ltdb_unpack_data(struct ldb_context *ldb, return 0; failed: - ltdb_unpack_data_free(ldb, message); + ltdb_unpack_data_free(module, message); return -1; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index cb93483881..903c4cb802 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/ldb_tdb/ldb_tdb.h" #include "ldb/include/ldb_parse.h" @@ -55,34 +57,6 @@ static void msg_free_all_parts(struct ldb_context *ldb, struct ldb_message *msg) } -/* - duplicate a ldb_val structure -*/ -struct ldb_val ldb_val_dup(struct ldb_context *ldb, - const struct ldb_val *v) -{ - struct ldb_val v2; - v2.length = v->length; - if (v->length == 0) { - v2.data = NULL; - return v2; - } - - /* the +1 is to cope with buggy C library routines like strndup - that look one byte beyond */ - v2.data = ldb_malloc(ldb, v->length+1); - if (!v2.data) { - v2.length = 0; - return v2; - } - - memcpy(v2.data, v->data, v->length); - ((char *)v2.data)[v->length] = 0; - return v2; -} - - - /* add one element to a message */ @@ -319,7 +293,7 @@ int ltdb_search_dn1(struct ldb_module *module, const char *dn, struct ldb_messag msg->num_elements = 0; msg->elements = NULL; - ret = ltdb_unpack_data(ldb, &tdb_data2, msg); + ret = ltdb_unpack_data(module, &tdb_data2, msg); if (ret == -1) { ldb_free(ldb, tdb_data2.dptr); return -1; @@ -439,7 +413,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi } /* unpack the record */ - ret = ltdb_unpack_data(sinfo->module->ldb, &data, &msg); + ret = ltdb_unpack_data(sinfo->module, &data, &msg); if (ret == -1) { sinfo->failures++; return 0; @@ -450,9 +424,9 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi } /* see if it matches the given expression */ - if (!ldb_message_match(sinfo->module, &msg, sinfo->tree, + if (!ltdb_message_match(sinfo->module, &msg, sinfo->tree, sinfo->base, sinfo->scope)) { - ltdb_unpack_data_free(sinfo->module->ldb, &msg); + ltdb_unpack_data_free(sinfo->module, &msg); return 0; } @@ -462,7 +436,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi sinfo->failures++; } - ltdb_unpack_data_free(sinfo->module->ldb, &msg); + ltdb_unpack_data_free(sinfo->module, &msg); return ret; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index a2aa5a7aca..5f6af43f94 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -36,6 +36,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include "ldb/ldb_tdb/ldb_tdb.h" /* @@ -195,7 +197,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg return -1; } - ret = ltdb_pack_data(ldb, msg, &tdb_data); + ret = ltdb_pack_data(module, msg, &tdb_data); if (ret == -1) { ldb_free(ldb, tdb_key.dptr); return -1; @@ -439,7 +441,7 @@ static int msg_delete_element(struct ldb_module *module, el = &msg->elements[found]; for (i=0;inum_values;i++) { - if (ldb_val_equal(module, msg->elements[i].name, &el->values[i], val)) { + if (ltdb_val_equal(module, msg->elements[i].name, &el->values[i], val)) { if (inum_values-1) { memmove(&el->values[i], &el->values[i+1], sizeof(el->values[i])*(el->num_values-(i+1))); @@ -483,7 +485,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms return -1; } - ret = ltdb_unpack_data(ldb, &tdb_data, &msg2); + ret = ltdb_unpack_data(module, &tdb_data, &msg2); if (ret == -1) { ldb_free(ldb, tdb_key.dptr); free(tdb_data.dptr); @@ -551,13 +553,13 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms ldb_free(ldb, tdb_key.dptr); free(tdb_data.dptr); - ltdb_unpack_data_free(ldb, &msg2); + ltdb_unpack_data_free(module, &msg2); return ret; failed: ldb_free(ldb, tdb_key.dptr); free(tdb_data.dptr); - ltdb_unpack_data_free(ldb, &msg2); + ltdb_unpack_data_free(module, &msg2); return -1; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h index b6660c5825..7b926e21a2 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h @@ -1,3 +1,8 @@ + +#ifdef STANDALONE +#include "tdb.h" +#endif + /* this private structure is used by the ltdb backend in the ldb_context */ struct ltdb_private { @@ -43,3 +48,67 @@ struct ltdb_private { #define LTDB_FLAG_WILDCARD (1<<2) #define LTDB_FLAG_OBJECTCLASS (1<<3) #define LTDB_FLAG_HIDDEN (1<<4) + +/* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */ + +void ltdb_cache_free(struct ldb_module *module); +int ltdb_cache_load(struct ldb_module *module); +int ltdb_increase_sequence_number(struct ldb_module *module); +int ltdb_attribute_flags(struct ldb_module *module, const char *attr_name); + +/* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */ + +struct ldb_parse_tree; + +int ltdb_search_indexed(struct ldb_module *module, + const char *base, + enum ldb_scope scope, + struct ldb_parse_tree *tree, + const char * const attrs[], struct ldb_message ***res); +int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg); +int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg); +int ltdb_reindex(struct ldb_module *module); + +/* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c */ + +int ltdb_pack_data(struct ldb_module *module, + const struct ldb_message *message, + struct TDB_DATA *data); +void ltdb_unpack_data_free(struct ldb_module *module, + struct ldb_message *message); +int ltdb_unpack_data(struct ldb_module *module, + const struct TDB_DATA *data, + struct ldb_message *message); + +/* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */ + +int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, + const struct ldb_val *val); +void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg); +int ltdb_search_dn1(struct ldb_module *module, const char *dn, struct ldb_message *msg); +int ltdb_search_dn(struct ldb_module *module, char *dn, + const char * const attrs[], struct ldb_message ***res); +int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg, + const char * const attrs[], + unsigned int *count, + struct ldb_message ***res); +int ltdb_search_free(struct ldb_module *module, struct ldb_message **msgs); +int ltdb_search(struct ldb_module *module, const char *base, + enum ldb_scope scope, const char *expression, + const char * const attrs[], struct ldb_message ***res); + +/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */ +struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn); +int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs); +int ltdb_delete_noindex(struct ldb_module *module, const char *dn); +int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg); + +/* The following definitions come from lib/ldb/ldb_tdb/ldb_match.c */ +int ltdb_val_equal(struct ldb_module *module, + const char *attr_name, + const struct ldb_val *v1, const struct ldb_val *v2); +int ltdb_message_match(struct ldb_module *module, + struct ldb_message *msg, + struct ldb_parse_tree *tree, + const char *base, + enum ldb_scope scope); diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c index 1d6314ee74..331a2de5e4 100644 --- a/source4/lib/ldb/modules/skel.c +++ b/source4/lib/ldb/modules/skel.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" /* close */ static int skel_close(struct ldb_module *module) diff --git a/source4/lib/ldb/modules/timestamps.c b/source4/lib/ldb/modules/timestamps.c index 64d7616fb1..521c59d241 100644 --- a/source4/lib/ldb/modules/timestamps.c +++ b/source4/lib/ldb/modules/timestamps.c @@ -33,6 +33,8 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" +#include "ldb/include/ldb_private.h" #include static int timestamps_close(struct ldb_module *module) diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index b0c9d8a366..d7f890b155 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static int failures; diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 839cb4cbe2..dc1c734284 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn) { diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index fc3b28872e..fd45248c0e 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static int verbose; diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c index ac8958f4ac..a660b814da 100644 --- a/source4/lib/ldb/tools/ldbmodify.c +++ b/source4/lib/ldb/tools/ldbmodify.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static int failures; diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c index 17b445c9e5..f702cbd7f2 100644 --- a/source4/lib/ldb/tools/ldbrename.c +++ b/source4/lib/ldb/tools/ldbrename.c @@ -35,6 +35,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static void usage(void) { diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index 81c46b437c..9f6b2f617a 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static void usage(void) { diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c index 5d90dc797d..f3be8e1e5c 100644 --- a/source4/lib/ldb/tools/ldbtest.c +++ b/source4/lib/ldb/tools/ldbtest.c @@ -33,6 +33,7 @@ */ #include "includes.h" +#include "ldb/include/ldb.h" static const char *ldb_url; static const char *base_dn = "ou=Ldb Test,ou=People,o=University of Michigan,c=US"; diff --git a/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c index bdebe34ff4..380a8010f2 100644 --- a/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c +++ b/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c @@ -20,6 +20,7 @@ #include "includes.h" #include "registry.h" +#include "lib/ldb/include/ldb.h" static char *reg_path_to_ldb(TALLOC_CTX *mem_ctx, const char *path, const char *add) { diff --git a/source4/rpc_server/common/gendb.c b/source4/rpc_server/common/gendb.c index 0e6ddb0693..2aea42787a 100644 --- a/source4/rpc_server/common/gendb.c +++ b/source4/rpc_server/common/gendb.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "lib/ldb/include/ldb.h" /* search the sam for the specified attributes - va_list variant diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index dcdcd7237c..c4a4208667 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -26,6 +26,7 @@ #include "rpc_server/common/common.h" #include "librpc/gen_ndr/ndr_dcom.h" #include "auth/auth.h" +#include "lib/ldb/include/ldb.h" struct server_pipe_state { struct netr_Credential client_challenge; diff --git a/source4/rpc_server/netlogon/schannel_state.c b/source4/rpc_server/netlogon/schannel_state.c index 61e755bc0f..e02ef04ad5 100644 --- a/source4/rpc_server/netlogon/schannel_state.c +++ b/source4/rpc_server/netlogon/schannel_state.c @@ -23,6 +23,7 @@ #include "includes.h" #include "system/time.h" #include "auth/auth.h" +#include "lib/ldb/include/ldb.h" /* a reasonable amount of time to keep credentials live */ #define SCHANNEL_CREDENTIALS_EXPIRY 600 diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c index 4ed5948b6a..6aec38a4fb 100644 --- a/source4/rpc_server/samr/dcesrv_samr.c +++ b/source4/rpc_server/samr/dcesrv_samr.c @@ -26,7 +26,7 @@ #include "rpc_server/common/common.h" #include "rpc_server/samr/dcesrv_samr.h" #include "system/time.h" - +#include "lib/ldb/include/ldb.h" /* diff --git a/source4/rpc_server/samr/samdb.c b/source4/rpc_server/samr/samdb.c index 15796a695e..488c48cd50 100644 --- a/source4/rpc_server/samr/samdb.c +++ b/source4/rpc_server/samr/samdb.c @@ -22,6 +22,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_netlogon.h" +#include "lib/ldb/include/ldb.h" /* connect to the SAM database diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c index c45bababa6..8e88abfc16 100644 --- a/source4/rpc_server/samr/samr_password.c +++ b/source4/rpc_server/samr/samr_password.c @@ -27,6 +27,7 @@ #include "rpc_server/samr/dcesrv_samr.h" #include "system/time.h" #include "lib/crypto/crypto.h" +#include "lib/ldb/include/ldb.h" /* samr_ChangePasswordUser diff --git a/source4/rpc_server/spoolss/spoolssdb.c b/source4/rpc_server/spoolss/spoolssdb.c index a19ad14981..cec9ade0d4 100644 --- a/source4/rpc_server/spoolss/spoolssdb.c +++ b/source4/rpc_server/spoolss/spoolssdb.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "lib/ldb/include/ldb.h" struct spoolssdb_context { struct ldb_context *ldb; @@ -30,7 +31,8 @@ struct spoolssdb_context { /* this is used to catch debug messages from ldb */ -void spoolssdb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) _PRINTF_ATTRIBUTE(3, 0) +static void spoolssdb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0); +static void spoolssdb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { char *s = NULL; if (DEBUGLEVEL < 4 && level > LDB_DEBUG_WARNING) { -- cgit