Rework samdb handling for 'netlogon' packets.
[kai/samba.git] / source4 / nbt_server / nbt_server.c
index abb4593b2cb76dfebbbf4dd4a6b5743e6a92598f..e6ff5003bf84faeeb822066d97c820f2a6c9da16 100644 (file)
@@ -28,6 +28,7 @@
 #include "lib/socket/netif.h"
 #include "auth/auth.h"
 #include "dsdb/samdb/samdb.h"
+#include "param/param.h"
 
 /*
   startup the nbtd task
@@ -36,8 +37,11 @@ static void nbtd_task_init(struct task_server *task)
 {
        struct nbtd_server *nbtsrv;
        NTSTATUS status;
+       struct interface *ifaces;
 
-       if (iface_count() == 0) {
+       load_interfaces(task, lp_interfaces(task->lp_ctx), &ifaces);
+
+       if (iface_count(ifaces) == 0) {
                task_server_terminate(task, "nbtd: no network interfaces configured");
                return;
        }
@@ -56,13 +60,13 @@ static void nbtd_task_init(struct task_server *task)
        nbtsrv->wins_interface  = NULL;
 
        /* start listening on the configured network interfaces */
-       status = nbtd_startup_interfaces(nbtsrv);
+       status = nbtd_startup_interfaces(nbtsrv, task->lp_ctx, ifaces);
        if (!NT_STATUS_IS_OK(status)) {
                task_server_terminate(task, "nbtd failed to setup interfaces");
                return;
        }
 
-       nbtsrv->sam_ctx = samdb_connect(nbtsrv, anonymous_session(nbtsrv));
+       nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->event_ctx, task->lp_ctx, system_session(nbtsrv, task->lp_ctx));
        if (nbtsrv->sam_ctx == NULL) {
                task_server_terminate(task, "nbtd failed to open samdb");
                return;
@@ -81,17 +85,6 @@ static void nbtd_task_init(struct task_server *task)
        nbtd_register_names(nbtsrv);
 
        irpc_add_name(task->msg_ctx, "nbt_server");
-
-
-}
-
-
-/*
-  initialise the nbt server
- */
-static NTSTATUS nbtd_init(struct event_context *event_ctx, const struct model_ops *model_ops)
-{
-       return task_server_startup(event_ctx, model_ops, nbtd_task_init);
 }
 
 
@@ -100,5 +93,5 @@ static NTSTATUS nbtd_init(struct event_context *event_ctx, const struct model_op
 */
 NTSTATUS server_service_nbtd_init(void)
 {
-       return register_server_service("nbt", nbtd_init);
+       return register_server_service("nbt", nbtd_task_init);
 }