summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/winbind/wb_irpc.c25
-rw-r--r--source4/winbind/wb_update_rodc_dns.c175
2 files changed, 122 insertions, 78 deletions
diff --git a/source4/winbind/wb_irpc.c b/source4/winbind/wb_irpc.c
index 6c060d9434..628114e404 100644
--- a/source4/winbind/wb_irpc.c
+++ b/source4/winbind/wb_irpc.c
@@ -79,7 +79,7 @@ struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state {
struct winbind_DsrUpdateReadOnlyServerDnsRecords *req;
};
-static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct composite_context *ctx);
+static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq);
static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *msg,
struct winbind_DsrUpdateReadOnlyServerDnsRecords *req)
@@ -87,7 +87,7 @@ static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *m
struct wbsrv_service *service = talloc_get_type(msg->private_data,
struct wbsrv_service);
struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s;
- struct composite_context *ctx;
+ struct tevent_req *subreq;
DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords called\n"));
@@ -97,25 +97,30 @@ static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *m
s->msg = msg;
s->req = req;
- ctx = wb_update_rodc_dns_send(msg, service, req);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
+ subreq = wb_update_rodc_dns_send(s,
+ service->task->event_ctx,
+ service, req);
+ NT_STATUS_HAVE_NO_MEMORY(subreq);
- ctx->async.fn = wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback;
- ctx->async.private_data = s;
+ tevent_req_set_callback(subreq,
+ wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback,
+ s);
msg->defer_reply = true;
return NT_STATUS_OK;
}
-static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct composite_context *ctx)
+static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq)
{
- struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s = talloc_get_type(ctx->async.private_data,
- struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
+ struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s =
+ tevent_req_callback_data(subreq,
+ struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
NTSTATUS status;
DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback called\n"));
- status = wb_update_rodc_dns_recv(ctx, s, s->req);
+ status = wb_update_rodc_dns_recv(subreq, s, s->req);
+ TALLOC_FREE(subreq);
irpc_send_reply(s->msg, status);
}
diff --git a/source4/winbind/wb_update_rodc_dns.c b/source4/winbind/wb_update_rodc_dns.c
index 5ad2d0cbb0..7d4d1a8fae 100644
--- a/source4/winbind/wb_update_rodc_dns.c
+++ b/source4/winbind/wb_update_rodc_dns.c
@@ -27,6 +27,8 @@
*/
#include "includes.h"
+#include <tevent.h>
+#include "../lib/util/tevent_ntstatus.h"
#include "libcli/composite/composite.h"
#include "winbind/wb_server.h"
#include "smbd/service_task.h"
@@ -36,7 +38,7 @@
#include "librpc/gen_ndr/winbind.h"
struct wb_update_rodc_dns_state {
- struct composite_context *ctx;
+ struct tevent_context *ev;
struct winbind_DsrUpdateReadOnlyServerDnsRecords *req;
@@ -47,62 +49,76 @@ struct wb_update_rodc_dns_state {
struct netr_DsrUpdateReadOnlyServerDnsRecords r;
};
-static void wb_update_rodc_dns_recv_domain(struct composite_context *ctx);
+static void wb_update_rodc_dns_recv_domain(struct composite_context *csubreq);
static void wb_update_rodc_dns_recv_response(struct tevent_req *subreq);
/*
Find the connection to the DC (or find an existing connection)
*/
-struct composite_context *wb_update_rodc_dns_send(TALLOC_CTX *mem_ctx,
- struct wbsrv_service *service,
- struct winbind_DsrUpdateReadOnlyServerDnsRecords *req)
+struct tevent_req *wb_update_rodc_dns_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct wbsrv_service *service,
+ struct winbind_DsrUpdateReadOnlyServerDnsRecords *_req)
{
- struct composite_context *c, *creq;
- struct wb_update_rodc_dns_state *s;
-
- c = composite_create(mem_ctx, service->task->event_ctx);
- if (!c) return NULL;
-
- s = talloc_zero(c, struct wb_update_rodc_dns_state);
- if (composite_nomem(s, c)) return c;
- s->ctx = c;
- s->req = req;
+ struct tevent_req *req;
+ struct wb_update_rodc_dns_state *state;
+ struct composite_context *csubreq;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct wb_update_rodc_dns_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->req = _req;
- c->private_data = s;
+ csubreq = wb_sid2domain_send(state, service, service->primary_sid);
+ if (tevent_req_nomem(csubreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ csubreq->async.fn = wb_update_rodc_dns_recv_domain;
+ csubreq->async.private_data = req;
- creq = wb_sid2domain_send(s, service, service->primary_sid);
- composite_continue(c, creq, wb_update_rodc_dns_recv_domain, s);
- return c;
+ return req;
}
/*
Having finished making the connection to the DC
Send of a DsrUpdateReadOnlyServerDnsRecords request to authenticate a user.
*/
-static void wb_update_rodc_dns_recv_domain(struct composite_context *creq)
+static void wb_update_rodc_dns_recv_domain(struct composite_context *csubreq)
{
- struct wb_update_rodc_dns_state *s = talloc_get_type(creq->async.private_data,
- struct wb_update_rodc_dns_state);
+ struct tevent_req *req =
+ talloc_get_type_abort(csubreq->async.private_data,
+ struct tevent_req);
+ struct wb_update_rodc_dns_state *state =
+ tevent_req_data(req,
+ struct wb_update_rodc_dns_state);
+ NTSTATUS status;
struct wbsrv_domain *domain;
struct tevent_req *subreq;
- s->ctx->status = wb_sid2domain_recv(creq, &domain);
- if (!composite_is_ok(s->ctx)) return;
+ status = wb_sid2domain_recv(csubreq, &domain);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
- s->creds_state = cli_credentials_get_netlogon_creds(domain->libnet_ctx->cred);
- netlogon_creds_client_authenticator(s->creds_state, &s->auth1);
+ state->creds_state = cli_credentials_get_netlogon_creds(domain->libnet_ctx->cred);
+ netlogon_creds_client_authenticator(state->creds_state, &state->auth1);
- s->r.in.server_name = talloc_asprintf(s, "\\\\%s",
+ state->r.in.server_name = talloc_asprintf(state, "\\\\%s",
dcerpc_server_name(domain->netlogon_pipe));
- if (composite_nomem(s->r.in.server_name, s->ctx)) return;
+ if (tevent_req_nomem(state->r.in.server_name, req)) {
+ return;
+ }
- s->r.in.computer_name = cli_credentials_get_workstation(domain->libnet_ctx->cred);
- s->r.in.credential = &s->auth1;
- s->r.out.return_authenticator = &s->auth2;
- s->r.in.site_name = s->req->in.site_name;
- s->r.in.dns_ttl = s->req->in.dns_ttl;
- s->r.in.dns_names = s->req->in.dns_names;
- s->r.out.dns_names = s->req->in.dns_names;
+ state->r.in.computer_name = cli_credentials_get_workstation(domain->libnet_ctx->cred);
+ state->r.in.credential = &state->auth1;
+ state->r.out.return_authenticator = &state->auth2;
+ state->r.in.site_name = state->req->in.site_name;
+ state->r.in.dns_ttl = state->req->in.dns_ttl;
+ state->r.in.dns_names = state->req->in.dns_names;
+ state->r.out.dns_names = state->req->in.dns_names;
/*
* use a new talloc context for the DsrUpdateReadOnlyServerDnsRecords call
@@ -110,15 +126,19 @@ static void wb_update_rodc_dns_recv_domain(struct composite_context *creq)
* in the final _recv() function to give the caller all the content of
* the s->r.out.dns_names
*/
- s->r_mem_ctx = talloc_new(s);
- if (composite_nomem(s->r_mem_ctx, s->ctx)) return;
-
- subreq = dcerpc_netr_DsrUpdateReadOnlyServerDnsRecords_r_send(s,
- s->ctx->event_ctx,
- domain->netlogon_pipe->binding_handle,
- &s->r);
- if (composite_nomem(subreq, s->ctx)) return;
- tevent_req_set_callback(subreq, wb_update_rodc_dns_recv_response, s);
+ state->r_mem_ctx = talloc_new(state);
+ if (tevent_req_nomem(state->r_mem_ctx, req)) {
+ return;
+ }
+
+ subreq = dcerpc_netr_DsrUpdateReadOnlyServerDnsRecords_r_send(state,
+ state->ev,
+ domain->netlogon_pipe->binding_handle,
+ &state->r);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, wb_update_rodc_dns_recv_response, req);
}
/*
@@ -128,40 +148,59 @@ static void wb_update_rodc_dns_recv_domain(struct composite_context *creq)
*/
static void wb_update_rodc_dns_recv_response(struct tevent_req *subreq)
{
- struct wb_update_rodc_dns_state *s = tevent_req_callback_data(subreq,
- struct wb_update_rodc_dns_state);
-
- s->ctx->status = dcerpc_netr_DsrUpdateReadOnlyServerDnsRecords_r_recv(subreq, s->r_mem_ctx);
+ struct tevent_req *req =
+ tevent_req_callback_data(subreq,
+ struct tevent_req);
+ struct wb_update_rodc_dns_state *state =
+ tevent_req_data(req,
+ struct wb_update_rodc_dns_state);
+ NTSTATUS status;
+ bool ok;
+
+ status = dcerpc_netr_DsrUpdateReadOnlyServerDnsRecords_r_recv(subreq,
+ state->r_mem_ctx);
TALLOC_FREE(subreq);
- if (!composite_is_ok(s->ctx)) return;
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
- s->ctx->status = s->r.out.result;
- if (!composite_is_ok(s->ctx)) return;
+ if (tevent_req_nterror(req, state->r.out.result)) {
+ return;
+ }
- if ((s->r.out.return_authenticator == NULL) ||
- (!netlogon_creds_client_check(s->creds_state,
- &s->r.out.return_authenticator->cred))) {
+ if (state->r.out.return_authenticator == NULL) {
+ tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
+ return;
+ }
+
+ ok = netlogon_creds_client_check(state->creds_state,
+ &state->r.out.return_authenticator->cred);
+ if (!ok) {
DEBUG(0, ("Credentials check failed!\n"));
- composite_error(s->ctx, NT_STATUS_ACCESS_DENIED);
+ tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
return;
}
- composite_done(s->ctx);
+ tevent_req_done(req);
}
-NTSTATUS wb_update_rodc_dns_recv(struct composite_context *c,
- TALLOC_CTX *mem_ctx,
- struct winbind_DsrUpdateReadOnlyServerDnsRecords *req)
+NTSTATUS wb_update_rodc_dns_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ struct winbind_DsrUpdateReadOnlyServerDnsRecords *_req)
{
- struct wb_update_rodc_dns_state *s = talloc_get_type(c->private_data,
- struct wb_update_rodc_dns_state);
- NTSTATUS status = composite_wait(c);
-
- if (NT_STATUS_IS_OK(status)) {
- talloc_steal(mem_ctx, s->r_mem_ctx);
- req->out.dns_names = s->r.out.dns_names;
+ struct wb_update_rodc_dns_state *state =
+ tevent_req_data(req,
+ struct wb_update_rodc_dns_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
+ return status;
}
- talloc_free(s);
- return status;
+ talloc_steal(mem_ctx, state->r_mem_ctx);
+ _req->out.dns_names = state->r.out.dns_names;
+
+ tevent_req_received(req);
+ return NT_STATUS_OK;
}