1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

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 f5ee40d6ce)
This commit is contained in:
Stefan Metzmacher 2004-11-16 09:00:52 +00:00 committed by Gerald (Jerry) Carter
parent e81157c737
commit 8a18778286
46 changed files with 373 additions and 144 deletions

View File

@ -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

View File

@ -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"

View File

@ -117,3 +117,5 @@ struct test_join;
struct test_join_ads_dc;
struct netr_LMSessionKey;
struct ldb_message;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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]

View File

@ -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

View File

@ -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;

View File

@ -33,6 +33,8 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
/*

View File

@ -37,6 +37,8 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
#include <ctype.h>

View File

@ -34,6 +34,8 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
#include "dlinklist.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -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) {

View File

@ -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

View File

@ -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 <ctype.h>

View File

@ -33,6 +33,8 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
#include <ctype.h>
/*

View File

@ -33,6 +33,8 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
/*

View File

@ -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
################################################

View File

@ -19,14 +19,8 @@
#include <sys/time.h>
#include <time.h>
#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)))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"
/*

View File

@ -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;
}

View File

@ -33,16 +33,17 @@
*/
#include "includes.h"
#include <fnmatch.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"
#include <fnmatch.h>
/*
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;j<el->num_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;j<msg->elements[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;i<tree->u.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;i<tree->u.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;
}

View File

@ -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;i<message->num_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;
}

View File

@ -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;
}

View File

@ -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;i<el->num_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 (i<el->num_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;
}

View File

@ -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);

View File

@ -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)

View File

@ -33,6 +33,8 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
#include <time.h>
static int timestamps_close(struct ldb_module *module)

View File

@ -33,6 +33,7 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
static int failures;

View File

@ -33,6 +33,7 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn)
{

View File

@ -33,6 +33,7 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
static int verbose;

View File

@ -33,6 +33,7 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
static int failures;

View File

@ -35,6 +35,7 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
static void usage(void)
{

View File

@ -33,6 +33,7 @@
*/
#include "includes.h"
#include "ldb/include/ldb.h"
static void usage(void)
{

View File

@ -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";

View File

@ -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)
{

View File

@ -22,6 +22,7 @@
*/
#include "includes.h"
#include "lib/ldb/include/ldb.h"
/*
search the sam for the specified attributes - va_list variant

View File

@ -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;

View File

@ -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

View File

@ -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"
/*

View File

@ -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

View File

@ -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

View File

@ -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) {