summaryrefslogtreecommitdiff
path: root/source4/nbt_server
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-03-02 16:32:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:52:11 -0500
commit26af14c39b88b0e7eb53657b89be65d865804688 (patch)
treeac73da63e8b053514ff8ecf465027d02227feea1 /source4/nbt_server
parent0efc7293181dc06d79c0edc21677f900597fc760 (diff)
downloadsamba-26af14c39b88b0e7eb53657b89be65d865804688.tar.gz
samba-26af14c39b88b0e7eb53657b89be65d865804688.tar.bz2
samba-26af14c39b88b0e7eb53657b89be65d865804688.zip
r13786: [merge] Add registration functions for LDB modules
Applications that use LDB modules will now have to run ldb_global_init() before they can use LDB. The next step will be adding support for loading LDB modules from .so files. This will also allow us to use one LDB without difference between the standalone and the Samba-specific build (This used to be commit 52a235650514039bf8ffee99a784bbc1b6ae6b92)
Diffstat (limited to 'source4/nbt_server')
-rw-r--r--source4/nbt_server/config.mk1
-rw-r--r--source4/nbt_server/wins/wins_ldb.c41
-rw-r--r--source4/nbt_server/wins/winsserver.c3
3 files changed, 22 insertions, 23 deletions
diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk
index 4d5f90e9fb..94c3e9efce 100644
--- a/source4/nbt_server/config.mk
+++ b/source4/nbt_server/config.mk
@@ -16,6 +16,7 @@ REQUIRED_SUBSYSTEMS = \
# 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
diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c
index d348c3231f..5efe6bd3ab 100644
--- a/source4/nbt_server/wins/wins_ldb.c
+++ b/source4/nbt_server/wins/wins_ldb.c
@@ -89,27 +89,12 @@ call_next:
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) {
@@ -121,17 +106,27 @@ struct ldb_module *wins_ldb_module_init(struct ldb_context *ldb, const char *opt
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);
}
diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c
index 7f67429996..62e152e05c 100644
--- a/source4/nbt_server/wins/winsserver.c
+++ b/source4/nbt_server/wins/winsserver.c
@@ -29,6 +29,7 @@
#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
@@ -840,6 +841,8 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv)
return NT_STATUS_OK;
}
+ ldb_global_init();
+
nbtsrv->winssrv = talloc_zero(nbtsrv, struct wins_server);
NT_STATUS_HAVE_NO_MEMORY(nbtsrv->winssrv);