"MAJOR_VERSION" => "string",
"MINOR_VERSION" => "string",
"RELEASE_VERSION" => "string",
+
+ "INIT_FUNCTION_TYPE" => "string",
"OBJ_FILES" => "list",
my $DEFINE = ();
next if ($key->{TYPE} ne "LIBRARY" and $key->{TYPE} ne "SUBSYSTEM");
next unless defined($key->{INIT_FUNCTIONS});
-
+
$DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
$DEFINE->{KEY} = "STATIC_$key->{NAME}_MODULES";
$DEFINE->{VAL} = "{ \\\n";
foreach (@{$key->{INIT_FUNCTIONS}}) {
$DEFINE->{VAL} .= "\t$_, \\\n";
- $output .= "NTSTATUS $_(void);\n";
+ my $fn = $key->{INIT_FUNCTION_TYPE};
+ unless(defined($fn)) { $fn = "NTSTATUS (*) (void)"; }
+ $fn =~ s/\(\*\)/$_/;
+ $output .= "$fn;\n";
}
$DEFINE->{VAL} .= "\tNULL \\\n }";
return;
}
+ unless (defined($lib->{INIT_FUNCTION_TYPE})) {
+ $lib->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)";
+ }
+
$lib->{INSTALLDIR} = "LIBDIR";
}
# Start MODULE libldb_objectguid
[MODULE::libldb_objectguid]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = objectguid_module_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
objectguid.o
# Start MODULE libldb_samldb
[MODULE::libldb_samldb]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = samldb_module_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
samldb.o
# Start MODULE libldb_samba3sam
[MODULE::libldb_samba3sam]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = ldb_samba3sam_module_init
+ENABLE = NO
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
samba3sam.o
# Start MODULE libldb_proxy
[MODULE::libldb_proxy]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = proxy_module_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
proxy.o
# Start MODULE libldb_rootdse
[MODULE::libldb_rootdse]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = rootdse_module_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
rootdse.o
# Start MODULE libldb_password_hash
[MODULE::libldb_password_hash]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = password_hash_module_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
password_hash.o
# Start MODULE libldb_cludge_acl
[MODULE::libldb_kludge_acl]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = ldb_kludge_acl_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
kludge_acl.o
# Start MODULE libldb_extended_dn
[MODULE::libldb_extended_dn]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = ldb_extended_dn_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
extended_dn.o
}
}
-static int extended_init_2(struct ldb_module *module)
+static int extended_init(struct ldb_module *module)
{
struct ldb_request request;
int ret;
return LDB_ERR_OTHER;
}
- return ldb_next_second_stage_init(module);
+ return ldb_next_init(module);
}
static const struct ldb_module_ops extended_dn_ops = {
.name = "extended_dn",
.request = extended_request,
- .second_stage_init = extended_init_2
+ .init_context = extended_init
};
-struct ldb_module *extended_dn_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_extended_dn_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &extended_dn_ops;
- ctx->private_data = NULL;
-
- return ctx;
+ return ldb_register_module(&extended_dn_ops);
}
}
}
-static int kludge_acl_init_2(struct ldb_module *module)
+static int kludge_acl_init(struct ldb_module *module)
{
int ret, i;
TALLOC_CTX *mem_ctx = talloc_new(module);
struct ldb_message *msg;
struct ldb_message_element *password_attributes;
- struct kludge_private_data *data = talloc_get_type(module->private_data, struct kludge_private_data);
+ struct kludge_private_data *data;
+
+ data = talloc(module, struct kludge_private_data);
+ if (data == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
data->password_attrs = NULL;
+ module->private_data = data;
if (!mem_ctx) {
return LDB_ERR_OPERATIONS_ERROR;
done:
talloc_free(mem_ctx);
- return ldb_next_second_stage_init(module);
+ return ldb_next_init(module);
}
static const struct ldb_module_ops kludge_acl_ops = {
.start_transaction = kludge_acl_start_trans,
.end_transaction = kludge_acl_end_trans,
.del_transaction = kludge_acl_del_trans,
- .second_stage_init = kludge_acl_init_2
+ .init_context = kludge_acl_init
};
-struct ldb_module *kludge_acl_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_kludge_acl_init(void)
{
- struct ldb_module *ctx;
- struct kludge_private_data *data;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- data = talloc(ctx, struct kludge_private_data);
- if (data == NULL) {
- talloc_free(ctx);
- return NULL;
- }
-
- data->password_attrs = NULL;
- ctx->private_data = data;
-
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &kludge_acl_ops;
-
- return ctx;
+ return ldb_register_module(&kludge_acl_ops);
}
};
-/* the init function */
-struct ldb_module *objectguid_module_init(struct ldb_context *ldb, const char *options[])
+int objectguid_module_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->private_data = NULL;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &objectguid_ops;
-
- return ctx;
+ return ldb_register_module(&objectguid_ops);
}
};
-/* the init function */
-struct ldb_module *password_hash_module_init(struct ldb_context *ldb, const char *options[])
+int password_hash_module_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->private_data = NULL;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &password_hash_ops;
-
- return ctx;
+ return ldb_register_module(&password_hash_ops);
}
.request = proxy_request
};
-struct ldb_module *proxy_module_init(struct ldb_context *ldb, const char *options[])
+int proxy_module_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &proxy_ops;
-
- ctx->private_data = talloc_zero(ctx, struct proxy_data);
- if (ctx->private_data == NULL) {
- return NULL;
- }
-
- return ctx;
+ return ldb_register_module(&proxy_ops);
}
return ldb_next_request(module, req);
}
-static const struct ldb_module_ops rootdse_ops = {
- .name = "rootdse",
- .request = rootdse_request
-};
-
-struct ldb_module *rootdse_module_init(struct ldb_context *ldb, const char *options[])
+static int rootdse_init(struct ldb_module *module)
{
- struct ldb_module *ctx;
struct private_data *data;
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- data = talloc(ctx, struct private_data);
+ data = talloc(module, struct private_data);
if (data == NULL) {
- talloc_free(ctx);
- return NULL;
+ return -1;
}
data->num_controls = 0;
data->controls = NULL;
- ctx->private_data = data;
+ module->private_data = data;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &rootdse_ops;
+ return ldb_next_init(module);
+}
- return ctx;
+static const struct ldb_module_ops rootdse_ops = {
+ .name = "rootdse",
+ .init_context = rootdse_init,
+ .request = rootdse_request
+};
+
+int rootdse_module_init(void)
+{
+ return ldb_register_module(&rootdse_ops);
}
}
};
- /* the init function */
-struct ldb_module *ldb_samba3sam_module_init(struct ldb_context *ldb, const char *options[])
+/* the init function */
+int ldb_samba3sam_module_init(void)
{
return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, "samba3sam");
}
}
}
+static int samldb_init(struct ldb_module *module)
+{
+ talloc_set_destructor(module, samldb_destructor);
+ return ldb_next_init(module);
+}
+
static const struct ldb_module_ops samldb_ops = {
.name = "samldb",
+ .init_context = samldb_init,
.request = samldb_request
};
-/* the init function */
-struct ldb_module *samldb_module_init(struct ldb_context *ldb, const char *options[])
+int samldb_module_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->private_data = NULL;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &samldb_ops;
-
- talloc_set_destructor(ctx, samldb_destructor);
-
- return ctx;
+ return ldb_register_module(&samldb_ops);
}
struct ldapsrv_service *ldap_service;
NTSTATUS status;
+ ldb_global_init();
+
ldap_service = talloc_zero(task, struct ldapsrv_service);
if (ldap_service == NULL) goto failed;
if (module == NULL) return -1; \
} while (0)
-/*
- second stage init all modules loaded
-*/
-int ldb_second_stage_init(struct ldb_context *ldb)
-{
- struct ldb_module *module;
-
- FIRST_OP(ldb, second_stage_init);
-
- return module->ops->second_stage_init(module);
-}
-
-
/*
start a transaction
*/
/* modules are called in inverse order on the stack.
Lets place them as an admin would think the right order is.
- Modules order is imprtant */
+ Modules order is important */
static char **ldb_modules_list_from_string(struct ldb_context *ldb, const char *string)
{
char **modules = NULL;
return modules;
}
+static struct ops_list_entry {
+ const struct ldb_module_ops *ops;
+ struct ops_list_entry *next;
+} *registered_modules = NULL;
+
+static const struct ldb_module_ops *ldb_find_module_ops(const char *name)
+{
+ struct ops_list_entry *e;
+
+ for (e = registered_modules; e; e = e->next) {
+ if (strcmp(e->ops->name, name) == 0)
+ return e->ops;
+ }
+
+ return NULL;
+}
+
+
+#ifndef STATIC_LIBLDB_MODULES
+#define STATIC_LIBLDB_MODULES \
+ { \
+ ldb_schema_init, \
+ ldb_operational_init, \
+ ldb_rdn_name_init, \
+ ldb_objectclass_init, \
+ ldb_paged_results_init, \
+ ldb_sort_init, \
+ NULL \
+ }
+#endif
+
+int ldb_global_init(void)
+{
+ static int (*static_init_fns[])(void) = STATIC_LIBLDB_MODULES;
+
+ static int initialized = 0;
+ int ret = 0, i;
+
+ if (initialized)
+ return 0;
+
+ initialized = 1;
+
+ for (i = 0; static_init_fns[i]; i++) {
+ if (static_init_fns[i]() == -1)
+ ret = -1;
+ }
+
+ return ret;
+}
+
+int ldb_register_module(const struct ldb_module_ops *ops)
+{
+ struct ops_list_entry *entry = talloc(talloc_autofree_context(), struct ops_list_entry);
+
+ if (ldb_find_module_ops(ops->name) != NULL)
+ return -1;
+
+ if (entry == NULL)
+ return -1;
+
+ entry->ops = ops;
+ entry->next = registered_modules;
+ registered_modules = entry;
+
+ return 0;
+}
+
int ldb_load_modules(struct ldb_context *ldb, const char *options[])
{
char **modules = NULL;
+ struct ldb_module *module;
int i;
- const struct {
- const char *name;
- ldb_module_init_t init;
- } well_known_modules[] = {
- { "schema", schema_module_init },
- { "operational", operational_module_init },
- { "rdn_name", rdn_name_module_init },
- { "objectclass", objectclass_module_init },
- { "paged_results", paged_results_module_init },
- { "server_sort", server_sort_module_init },
- { "asq", asq_module_init },
-#ifdef _SAMBA_BUILD_
- { "objectguid", objectguid_module_init },
- { "samldb", samldb_module_init },
- { "samba3sam", ldb_samba3sam_module_init },
- { "proxy", proxy_module_init },
- { "rootdse", rootdse_module_init },
- { "extended_dn", extended_dn_module_init },
- { "password_hash", password_hash_module_init },
- { "kludge_acl", kludge_acl_module_init },
- { "wins_ldb", wins_ldb_module_init },
-#endif
- { NULL, NULL }
- };
-
/* find out which modules we are requested to activate */
/* check if we have a custom module list passd as ldb option */
}
}
- /* if not overloaded by options and the backend is not ldap try to load the modules list form ldb */
+ /* if not overloaded by options and the backend is not ldap try to load the modules list from ldb */
if ((modules == NULL) && (strcmp("ldap", ldb->modules->ops->name) != 0)) {
int ret;
const char * const attrs[] = { "@LIST" , NULL};
for (i = 0; modules[i] != NULL; i++) {
struct ldb_module *current;
- int m;
- for (m=0;well_known_modules[m].name;m++) {
- if (strcmp(modules[i], well_known_modules[m].name) == 0) {
- current = well_known_modules[m].init(ldb, options);
- if (current == NULL) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
- return -1;
- }
- DLIST_ADD(ldb->modules, current);
- break;
- }
- }
- if (well_known_modules[m].name == NULL) {
+ const struct ldb_module_ops *ops;
+
+ ops = ldb_find_module_ops(modules[i]);
+ if (ops == NULL) {
ldb_debug(ldb, LDB_DEBUG_WARNING, "WARNING: Module [%s] not found\n",
modules[i]);
+ continue;
}
+
+ current = talloc_zero(ldb, struct ldb_module);
+ if (current == NULL) {
+ return -1;
+ }
+
+ current->ldb = ldb;
+ current->ops = ops;
+
+ DLIST_ADD(ldb->modules, current);
}
- /* second stage init */
- if (ldb_second_stage_init(ldb) != LDB_SUCCESS) {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "ERROR: Second stage init failed!\n");
+ module = ldb->modules;
+
+ while (module && module->ops->init_context == NULL)
+ module = module->next;
+
+ if (module && module->ops->init_context &&
+ module->ops->init_context(module) != LDB_SUCCESS) {
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "module initialization failed\n");
return -1;
}
return module->ops->request(module, request);
}
-int ldb_next_second_stage_init(struct ldb_module *module)
+int ldb_next_init(struct ldb_module *module)
{
- FIND_OP(module, second_stage_init);
- return module->ops->second_stage_init(module);
+ /* init is different in that it is not an error if modules
+ * do not require initialization */
+
+ module = module->next;
+
+ while (module && module->ops->init_context == NULL)
+ module = module->next;
+
+ if (module == NULL)
+ return LDB_SUCCESS;
+
+ return module->ops->init_context(module);
}
int ldb_next_start_trans(struct ldb_module *module)
################################################
# Start MODULE libldb_asq
[MODULE::libldb_asq]
+INIT_FUNCTION = ldb_asq_init
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
################################################
# Start MODULE libldb_sort
[MODULE::libldb_sort]
+INIT_FUNCTION = ldb_sort_init
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
################################################
# Start MODULE libldb_paged_results
[MODULE::libldb_paged_results]
+INIT_FUNCTION = ldb_paged_results_init
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
# Start MODULE libldb_operational
[MODULE::libldb_operational]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = ldb_operational_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
modules/operational.o
################################################
# Start MODULE libldb_objectclass
[MODULE::libldb_objectclass]
+INIT_FUNCTION = ldb_objectclass_init
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
# Start MODULE libldb_rdn_name
[MODULE::libldb_rdn_name]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = ldb_rdn_name_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
modules/rdn_name.o
################################################
# Start MODULE libldb_schema
[MODULE::libldb_schema]
+INIT_FUNCTION = ldb_schema_init
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
# Start MODULE libldb_skel
[MODULE::libldb_skel]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = ldb_skel_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = modules/skel.o
# End MODULE libldb_skel
MAJOR_VERSION = 0
MINOR_VERSION = 0
DESCRIPTION = LDAP-like embedded database library
+INIT_FUNCTION_TYPE = int (*) (void)
RELEASE_VERSION = 1
OBJ_FILES = \
common/ldb.o \
#include "system/iconv.h"
#include "system/time.h"
+#include "build.h"
+
#else /*_SAMBA_BUILD_*/
#ifndef _GNU_SOURCE
int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type);
+/**
+ Initialise ldbs' global information
+
+ This is required before any other LDB call
+
+ \return 0 if initialisation succeeded, -1 otherwise
+*/
+int ldb_global_init(void);
+
/**
Initialise an ldb context
*/
struct ldb_module_ops {
const char *name;
+ int (*init_context) (struct ldb_module *);
int (*request)(struct ldb_module *, struct ldb_request *);
int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *);
int (*del_transaction)(struct ldb_module *);
- int (*second_stage_init)(struct ldb_module *);
};
uint64_t (*sequence_number)(struct ldb_context *);
};
-/* the modules init function */
-typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **);
-
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#endif
*/
#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
-/* The following definitions come from lib/ldb/common/ldb.c */
-int ldb_second_stage_init(struct ldb_context *ldb);
-
/* 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_start_trans(struct ldb_module *module);
int ldb_next_end_trans(struct ldb_module *module);
int ldb_next_del_trans(struct ldb_module *module);
-int ldb_next_second_stage_init(struct ldb_module *module);
+int ldb_next_init(struct ldb_module *module);
void ldb_set_errstring(struct ldb_context *ldb, char *err_string);
void ldb_reset_err_string(struct ldb_context *ldb);
+int ldb_register_module(const struct ldb_module_ops *);
+
/* 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);
void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
const char *url,
unsigned int flags,
const char *options[]);
-struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]);
-struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]);
-struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[]);
-struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]);
-struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]);
-struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[]);
-struct ldb_module *asq_module_init(struct ldb_context *ldb, const char *options[]);
+int ldb_objectclass_init(void);
+int ldb_operational_init(void);
+int ldb_paged_results_init(void);
+int ldb_rdn_name_init(void);
+int ldb_schema_init(void);
+int ldb_sort_init(void);
int ldb_match_msg(struct ldb_context *ldb,
struct ldb_message *msg,
}
}
-
static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
{
struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
/*
fetch the rootDSE for later use
*/
-static int ildb_init_2(struct ldb_module *module)
+static int ildb_init(struct ldb_module *module)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldb_result *res = NULL;
.start_transaction = ildb_start_trans,
.end_transaction = ildb_end_trans,
.del_transaction = ildb_del_trans,
- .second_stage_init = ildb_init_2
+ .init_context = ildb_init
};
/*
}
}
-static int lldb_init_2(struct ldb_module *module)
-{
- return LDB_SUCCESS;
-}
-
static const struct ldb_module_ops lldb_ops = {
.name = "ldap",
.request = lldb_request,
.start_transaction = lldb_start_trans,
.end_transaction = lldb_end_trans,
.del_transaction = lldb_del_trans,
- .second_stage_init = lldb_init_2
};
return seq_num;
}
-static int ltdb_init_2(struct ldb_module *module)
-{
- return LDB_SUCCESS;
-}
-
static const struct ldb_module_ops ltdb_ops = {
.name = "tdb",
.request = ltdb_request,
.start_transaction = ltdb_start_trans,
.end_transaction = ltdb_end_trans,
- .del_transaction = ltdb_del_trans,
- .second_stage_init = ltdb_init_2
+ .del_transaction = ltdb_del_trans
};
}
}
-static int asq_init_2(struct ldb_module *module)
+static int asq_init(struct ldb_module *module)
{
struct ldb_request request;
int ret;
return LDB_ERR_OTHER;
}
- return ldb_next_second_stage_init(module);
+ return ldb_next_init(module);
}
static const struct ldb_module_ops asq_ops = {
.name = "asq",
.request = asq,
- .second_stage_init = asq_init_2
+ .init_context = asq_init
};
-struct ldb_module *asq_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_asq_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &asq_ops;
- ctx->private_data = NULL;
-
- return ctx;
+ return ldb_register_module(&asq_ops);
}
.request = objectclass_request,
};
-struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_objectclass_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->private_data = NULL;
-
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &objectclass_ops;
-
- return ctx;
+ return ldb_register_module(&objectclass_ops);
}
}
}
+static int operational_init(struct ldb_module *ctx)
+{
+ /* setup some standard attribute handlers */
+ ldb_set_attrib_handler_syntax(ctx->ldb, "whenCreated", LDB_SYNTAX_UTC_TIME);
+ ldb_set_attrib_handler_syntax(ctx->ldb, "whenChanged", LDB_SYNTAX_UTC_TIME);
+ ldb_set_attrib_handler_syntax(ctx->ldb, "subschemaSubentry", LDB_SYNTAX_DN);
+ ldb_set_attrib_handler_syntax(ctx->ldb, "structuralObjectClass", LDB_SYNTAX_OBJECTCLASS);
+
+ return ldb_next_init(ctx);
+}
+
static const struct ldb_module_ops operational_ops = {
.name = "operational",
- .request = operational_request
+ .request = operational_request,
+ .init_context = operational_init
};
-
-/* the init function */
-struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_operational_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->private_data = NULL;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &operational_ops;
-
- /* setup some standard attribute handlers */
- ldb_set_attrib_handler_syntax(ldb, "whenCreated", LDB_SYNTAX_UTC_TIME);
- ldb_set_attrib_handler_syntax(ldb, "whenChanged", LDB_SYNTAX_UTC_TIME);
- ldb_set_attrib_handler_syntax(ldb, "subschemaSubentry", LDB_SYNTAX_DN);
- ldb_set_attrib_handler_syntax(ldb, "structuralObjectClass", LDB_SYNTAX_OBJECTCLASS);
-
- return ctx;
+ return ldb_register_module(&operational_ops);
}
}
}
-static int paged_request_init_2(struct ldb_module *module)
+static int paged_request_init(struct ldb_module *module)
{
struct ldb_request request;
int ret;
+ struct private_data *data;
+
+ data = talloc(module, struct private_data);
+ if (data == NULL) {
+ return LDB_ERR_OTHER;
+ }
+
+ data->next_free_id = 1;
+ data->store = NULL;
+ module->private_data = data;
request.operation = LDB_REQ_REGISTER;
request.op.reg.oid = LDB_CONTROL_PAGED_RESULTS_OID;
return LDB_ERR_OTHER;
}
- return ldb_next_second_stage_init(module);
+ return ldb_next_init(module);
}
static const struct ldb_module_ops paged_ops = {
- .name = "paged_results",
- .request = paged_request,
- .second_stage_init = paged_request_init_2
+ .name = "paged_results",
+ .request = paged_request,
+ .init_context = paged_request_init
};
-struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_paged_results_init(void)
{
- struct ldb_module *ctx;
- struct private_data *data;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- data = talloc(ctx, struct private_data);
- if (data == NULL) {
- talloc_free(ctx);
- return NULL;
- }
-
- data->next_free_id = 1;
- data->store = NULL;
- ctx->private_data = data;
-
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &paged_ops;
-
- return ctx;
+ return ldb_register_module(&paged_ops);
}
+
};
-/* the init function */
-struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_rdn_name_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->private_data = NULL;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &rdn_name_ops;
-
- return ctx;
+ return ldb_register_module(&rdn_name_ops);
}
.request = schema_request
};
-struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_schema_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx) {
- return NULL;
- }
-
- ctx->private_data = NULL;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &schema_ops;
-
- return ctx;
+ return ldb_register_module(&schema_ops);
}
}
}
-static int skel_init_2(struct ldb_module *module)
+static int skel_init(struct ldb_module *ctx)
{
- /* second stage init stuff */
- /* see control modules as example */
- return ldb_next_second_stage_init(module);
-}
-
-static const struct ldb_module_ops skel_ops = {
- .name = "skel",
- .request = skel_request,
- .start_transaction = skel_start_trans,
- .end_transaction = skel_end_trans,
- .del_transaction = skel_del_trans,
- .second_stage_init = skel_init_2
-};
-
-struct ldb_module *skel_module_init(struct ldb_context *ldb, const char *options[])
-{
- struct ldb_module *ctx;
struct private_data *data;
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
data = talloc(ctx, struct private_data);
if (data == NULL) {
- talloc_free(ctx);
- return NULL;
+ return 1;
}
data->some_private_data = NULL;
ctx->private_data = data;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &skel_ops;
-
talloc_set_destructor (ctx, skel_destructor);
- return ctx;
+ return ldb_next_init(ctx);
+}
+
+static const struct ldb_module_ops skel_ops = {
+ .name = "skel",
+ .init_context = skel_init,
+ .request = skel_request,
+ .start_transaction = skel_start_trans,
+ .end_transaction = skel_end_trans,
+ .del_transaction = skel_del_trans,
+};
+
+int ldb_skel_init(void)
+{
+ return ldb_register_module(&skel_ops);
}
}
}
-static int server_sort_init_2(struct ldb_module *module)
+static int server_sort_init(struct ldb_module *module)
{
struct ldb_request request;
int ret;
return LDB_ERR_OTHER;
}
- return ldb_next_second_stage_init(module);
+ return ldb_next_init(module);
}
static const struct ldb_module_ops server_sort_ops = {
.name = "server_sort",
.request = server_sort,
- .second_stage_init = server_sort_init_2
+ .init_context = server_sort_init
};
-struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[])
+int ldb_sort_init(void)
{
- struct ldb_module *ctx;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx)
- return NULL;
-
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &server_sort_ops;
- ctx->private_data = NULL;
-
- return ctx;
+ return ldb_register_module(&server_sort_ops);
}
POPT_TABLEEND
};
+ ldb_global_init();
+
#ifdef _SAMBA_BUILD_
r = ldb_register_samba_handlers(ldb);
if (r != 0) {
- int main(int argc, const char **argv)
+int main(int argc, const char **argv)
{
struct ldb_context *ldb;
int i, count=0;
struct ldb_cmdline *options;
+ ldb_global_init();
+
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
int ret, i;
struct ldb_cmdline *options;
+ ldb_global_init();
+
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
const char *expression = "(|(objectClass=*)(distinguishedName=*))";
const char * const * attrs = NULL;
+ ldb_global_init();
+
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
int i;
struct ldb_cmdline *options;
+ ldb_global_init();
+
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
struct ldb_cmdline *options;
const struct ldb_dn *dn1, *dn2;
+ ldb_global_init();
+
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
return 0;
}
- int main(int argc, const char **argv)
+int main(int argc, const char **argv)
{
struct ldb_context *ldb;
struct ldb_dn *basedn = NULL;
int ret = -1;
const char *expression = "(|(objectClass=*)(distinguishedName=*))";
+ ldb_global_init();
+
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct ldb_context *ldb;
+ ldb_global_init();
+
ldb = ldb_init(mem_ctx);
options = ldb_cmdline_process(ldb, argc, argv, usage);
FILE *in = stdin;
FILE *out = stdout;
+ ldb_global_init();
+
ctx = talloc_new(NULL);
ldb_ctx = ldb_init(ctx);
# Start MODULE libldb_wins_ldb
[MODULE::libldb_wins_ldb]
SUBSYSTEM = LIBLDB
+INIT_FUNCTION = wins_ldb_module_init
OUTPUT_TYPE = MERGEDOBJ
OBJ_FILES = \
wins/wins_ldb.o
return ldb_next_request(module, req);
}
-static const struct ldb_module_ops wins_ldb_ops = {
- .name = "wins_ldb",
- .request = wins_ldb_request
-};
-
-
-/* the init function */
-struct ldb_module *wins_ldb_module_init(struct ldb_context *ldb, const char *options[])
+static int wins_ldb_init(struct ldb_module *ctx)
{
- struct ldb_module *ctx;
struct winsdb_handle *h;
const char *owner;
- int ret;
-
- ctx = talloc(ldb, struct ldb_module);
- if (!ctx) return NULL;
ctx->private_data = NULL;
- ctx->ldb = ldb;
- ctx->prev = ctx->next = NULL;
- ctx->ops = &wins_ldb_ops;
owner = lp_parm_string(-1, "winsdb", "local_owner");
if (!owner) {
h = talloc(ctx, struct winsdb_handle);
if (!h) goto failed;
- h->ldb = ldb;
+ h->ldb = ctx->ldb;
h->caller = WINSDB_HANDLE_CALLER_ADMIN;
h->local_owner = talloc_strdup(h, owner);
if (!h->local_owner) goto failed;
- ret = ldb_set_opaque(ldb, "winsdb_handle", h);
- if (ret != LDB_SUCCESS) goto failed;
-
- return ctx;
+ return ldb_set_opaque(ctx->ldb, "winsdb_handle", h);
failed:
- talloc_free(ctx);
- return NULL;
+ talloc_free(h);
+ return LDB_ERR_OTHER;
+}
+
+static const struct ldb_module_ops wins_ldb_ops = {
+ .name = "wins_ldb",
+ .request = wins_ldb_request,
+ .init_context = wins_ldb_init
+};
+
+
+/* the init function */
+int wins_ldb_module_init(void)
+{
+ return ldb_register_module(&wins_ldb_ops);
}
#include "libcli/composite/composite.h"
#include "smbd/service_task.h"
#include "lib/socket/socket.h"
+#include "lib/ldb/include/ldb.h"
/*
work out the ttl we will use given a client requested ttl
return NT_STATUS_OK;
}
+ ldb_global_init();
+
nbtsrv->winssrv = talloc_zero(nbtsrv, struct wins_server);
NT_STATUS_HAVE_NO_MEMORY(nbtsrv->winssrv);
#include "lib/appweb/ejs/ejsInternal.h"
#include "scripting/ejs/smbcalls.h"
#include "auth/gensec/gensec.h"
+#include "ldb/include/ldb.h"
static EjsId eid;
exit(127);
}
- int main(int argc, const char **argv)
+int main(int argc, const char **argv)
{
EjsHandle handle = 0;
MprVar result;
int exit_status, i;
fault_setup(argv[0]);
+
+ ldb_global_init();
+
gensec_init();
mprSetCtx(mem_ctx);
#include "smb_server/smb_server.h"
#include "mutex.h"
-/* For sepecifiying event context to GSSAPI below */
+/* For specifying event context to GSSAPI below */
#include "system/kerberos.h"
#include "heimdal/lib/gssapi/gssapi_locl.h"