winbindd: Do not use group_list->out.resume_index after free
[samba.git] / source4 / winbind / wb_irpc.c
index efbc310b68180d6f50665c15ecec42d1f3e2baa4..7a4ca69baa840f2ad7ca9a9858f8be4a9d30e90c 100644 (file)
@@ -22,7 +22,6 @@
 #include "winbind/wb_server.h"
 #include "lib/messaging/irpc.h"
 #include "libcli/composite/composite.h"
-#include "libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_winbind.h"
 #include "smbd/service_task.h"
 
@@ -31,7 +30,7 @@ struct wb_irpc_SamLogon_state {
        struct winbind_SamLogon *req;
 };
 
-static void wb_irpc_SamLogon_callback(struct composite_context *ctx);
+static void wb_irpc_SamLogon_callback(struct tevent_req *subreq);
 
 static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg, 
                                 struct winbind_SamLogon *req)
@@ -39,7 +38,7 @@ static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
        struct wbsrv_service *service = talloc_get_type(msg->private_data,
                                        struct wbsrv_service);
        struct wb_irpc_SamLogon_state *s;
-       struct composite_context *ctx;
+       struct tevent_req *subreq;
 
        DEBUG(5, ("wb_irpc_SamLogon called\n"));
 
@@ -49,93 +48,79 @@ static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
        s->msg = msg;
        s->req = req;
 
-       ctx = wb_sam_logon_send(msg, service, req);
-       NT_STATUS_HAVE_NO_MEMORY(ctx);
+       subreq = wb_sam_logon_send(s,
+                                  service->task->event_ctx,
+                                  service, req);
+       NT_STATUS_HAVE_NO_MEMORY(subreq);
 
-       ctx->async.fn = wb_irpc_SamLogon_callback;
-       ctx->async.private_data = s;
+       tevent_req_set_callback(subreq, wb_irpc_SamLogon_callback, s);
 
        msg->defer_reply = true;
        return NT_STATUS_OK;
 }
 
-static void wb_irpc_SamLogon_callback(struct composite_context *ctx)
+static void wb_irpc_SamLogon_callback(struct tevent_req *subreq)
 {
-       struct wb_irpc_SamLogon_state *s = talloc_get_type(ctx->async.private_data,
-                                          struct wb_irpc_SamLogon_state);
+       struct wb_irpc_SamLogon_state *s =
+               tevent_req_callback_data(subreq,
+               struct wb_irpc_SamLogon_state);
        NTSTATUS status;
 
        DEBUG(5, ("wb_irpc_SamLogon_callback called\n"));
 
-       status = wb_sam_logon_recv(ctx, s, s->req);
+       status = wb_sam_logon_recv(subreq, s, s->req);
+       TALLOC_FREE(subreq);
 
        irpc_send_reply(s->msg, status);
 }
 
-struct wb_irpc_get_idmap_state {
+struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state {
        struct irpc_message *msg;
-       struct winbind_get_idmap *req;
-       int level;
+       struct winbind_DsrUpdateReadOnlyServerDnsRecords *req;
 };
 
-static void wb_irpc_get_idmap_callback(struct composite_context *ctx);
+static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq);
 
-static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg,
-                                 struct winbind_get_idmap *req)
+static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *msg,
+                                struct winbind_DsrUpdateReadOnlyServerDnsRecords *req)
 {
        struct wbsrv_service *service = talloc_get_type(msg->private_data,
                                        struct wbsrv_service);
-       struct wb_irpc_get_idmap_state *s;
-       struct composite_context *ctx = NULL;
+       struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s;
+       struct tevent_req *subreq;
 
-       DEBUG(5, ("wb_irpc_get_idmap called\n"));
+       DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords called\n"));
 
-       s = talloc(msg, struct wb_irpc_get_idmap_state);
+       s = talloc(msg, struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
        NT_STATUS_HAVE_NO_MEMORY(s);
 
        s->msg = msg;
        s->req = req;
-       s->level = req->in.level;
-
-       switch(s->level) {
-               case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
-                       ctx = wb_sids2xids_send(msg, service, req->in.count,
-                                               req->in.ids);
-                       break;
-               case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
-                       ctx = wb_xids2sids_send(msg, service, req->in.count,
-                                               req->in.ids);
-                       break;
-       }
-       NT_STATUS_HAVE_NO_MEMORY(ctx);
-
-       composite_continue(ctx, ctx, wb_irpc_get_idmap_callback, s);
-       msg->defer_reply = true;
 
+       subreq = wb_update_rodc_dns_send(s,
+                                        service->task->event_ctx,
+                                        service, req);
+       NT_STATUS_HAVE_NO_MEMORY(subreq);
+
+       tevent_req_set_callback(subreq,
+                               wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback,
+                               s);
+
+       msg->defer_reply = true;
        return NT_STATUS_OK;
 }
 
-static void wb_irpc_get_idmap_callback(struct composite_context *ctx)
+static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq)
 {
-       struct wb_irpc_get_idmap_state *s;
+       struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s =
+               tevent_req_callback_data(subreq,
+               struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
        NTSTATUS status;
 
-       DEBUG(5, ("wb_irpc_get_idmap_callback called\n"));
-
-       s = talloc_get_type(ctx->async.private_data,
-                           struct wb_irpc_get_idmap_state);
+       DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback called\n"));
 
-       switch(s->level) {
-               case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
-                       status = wb_sids2xids_recv(ctx, &s->req->out.ids);
-                       break;
-               case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
-                       status = wb_xids2sids_recv(ctx, &s->req->out.ids);
-                       break;
-               default:
-                       status = NT_STATUS_INTERNAL_ERROR;
-                       break;
-       }
+       status = wb_update_rodc_dns_recv(subreq, s, s->req);
+       TALLOC_FREE(subreq);
 
        irpc_send_reply(s->msg, status);
 }
@@ -150,8 +135,8 @@ NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
                               wb_irpc_SamLogon, service);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_GET_IDMAP,
-                              wb_irpc_get_idmap, service);
+       status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_DSRUPDATEREADONLYSERVERDNSRECORDS,
+                              wb_irpc_DsrUpdateReadOnlyServerDnsRecords, service);
        NT_STATUS_NOT_OK_RETURN(status);
 
        return NT_STATUS_OK;