wreplserver: add "wreplsrv:propagate name releases = yes" for replicated sgroup merges
[ira/wip.git] / source4 / wrepl_server / wrepl_server.c
index e750d9355aeb3f5d6a78b70afcc4103e2bd9d394..393712c76a56720c426b5759569d2d93f3807cd3 100644 (file)
@@ -20,7 +20,7 @@
 */
 
 #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 "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);
 }
@@ -54,10 +55,8 @@ static uint64_t wins_config_db_get_seqnumber(struct ldb_context *ldb)
        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) {
@@ -83,12 +82,12 @@ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service,
                owner = iface_n_ip(ifaces, 0);
        }
 
-       service->wins_db     = winsdb_connect(service, lp_ctx, owner, WINSDB_HANDLE_CALLER_WREPL);
+       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;
        }
@@ -156,10 +155,10 @@ NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service)
        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) {
@@ -390,11 +389,10 @@ static NTSTATUS wreplsrv_load_table(struct wreplsrv_service *service)
        }
 
        /* 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);