*/
#include "includes.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
#include "smbd/service_task.h"
#include "smbd/service.h"
#include "lib/messaging/irpc.h"
#include "auth/auth.h"
#include "ldb_wrap.h"
#include "param/param.h"
+#include "lib/socket/netif.h"
static struct ldb_context *wins_config_db_connect(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev_ctx,
struct loadparm_context *lp_ctx)
{
- return ldb_wrap_connect(mem_ctx, lp_ctx, private_path(mem_ctx,
+ return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, private_path(mem_ctx,
lp_ctx, lp_wins_config_url(lp_ctx)),
system_session(mem_ctx, lp_ctx), NULL, 0, NULL);
}
if (!dn) goto failed;
/* find the record in the WINS database */
- ret = ldb_search(ldb, dn, LDB_SCOPE_BASE,
- NULL, NULL, &res);
+ ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL);
if (ret != LDB_SUCCESS) goto failed;
- talloc_steal(tmp_ctx, res);
if (res->count > 1) goto failed;
if (res->count == 1) {
static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service,
struct loadparm_context *lp_ctx)
{
- service->wins_db = winsdb_connect(service, lp_ctx, WINSDB_HANDLE_CALLER_WREPL);
+ const char *owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner");
+
+ if (owner == NULL) {
+ struct interface *ifaces;
+ load_interfaces(service, lp_interfaces(lp_ctx), &ifaces);
+ owner = iface_n_ip(ifaces, 0);
+ }
+
+ service->wins_db = winsdb_connect(service, service->task->event_ctx, lp_ctx, owner, WINSDB_HANDLE_CALLER_WREPL);
if (!service->wins_db) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
- service->config.ldb = wins_config_db_connect(service, lp_ctx);
+ service->config.ldb = wins_config_db_connect(service, service->task->event_ctx, lp_ctx);
if (!service->config.ldb) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
service->config.seqnumber = new_seqnumber;
/* find the record in the WINS database */
- ret = ldb_search(service->config.ldb, ldb_dn_new(tmp_ctx, service->config.ldb, "CN=PARTNERS"), LDB_SCOPE_SUBTREE,
- "(objectClass=wreplPartner)", NULL, &res);
+ ret = ldb_search(service->config.ldb, tmp_ctx, &res,
+ ldb_dn_new(tmp_ctx, service->config.ldb, "CN=PARTNERS"),
+ LDB_SCOPE_SUBTREE, NULL, "(objectClass=wreplPartner)");
if (ret != LDB_SUCCESS) goto failed;
- talloc_steal(tmp_ctx, res);
/* first disable all existing partners */
for (partner=service->partners; partner; partner = partner->next) {
}
/* find the record in the WINS database */
- ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE,
- "(objectClass=winsRecord)", attrs, &res);
+ ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
+ attrs, "(objectClass=winsRecord)");
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
if (ret != LDB_SUCCESS) goto failed;
- talloc_steal(tmp_ctx, res);
for (i=0; i < res->count; i++) {
wins_owner = ldb_msg_find_attr_as_string(res->msgs[i], "winsOwner", NULL);
NTSTATUS status;
struct wreplsrv_service *service;
+ if (!lp_wins_support(task->lp_ctx)) {
+ return;
+ }
+
task_server_set_title(task, "task[wreplsrv]");
service = talloc_zero(task, struct wreplsrv_service);
irpc_add_name(task->msg_ctx, "wrepl_server");
}
-/*
- initialise the WREPL server
- */
-static NTSTATUS wreplsrv_init(struct event_context *event_ctx, struct loadparm_context *lp_ctx, const struct model_ops *model_ops)
-{
- if (!lp_wins_support(lp_ctx)) {
- return NT_STATUS_OK;
- }
-
- return task_server_startup(event_ctx, model_ops, wreplsrv_task_init);
-}
-
/*
register ourselves as a available server
*/
NTSTATUS server_service_wrepl_init(void)
{
- return register_server_service("wrepl", wreplsrv_init);
+ return register_server_service("wrepl", wreplsrv_task_init);
}