1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

netlogon_creds_cli: Remove tevent_req handling from netlogon_creds_cli_lock_fetch

Disentangle concerns, make netlogon_creds_cli_lock_fetch usable for
other callers

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Volker Lendecke 2017-09-13 08:51:25 -07:00
parent b92b10d7c3
commit b750a6dbb5

View File

@ -707,7 +707,9 @@ struct netlogon_creds_cli_lock_state {
}; };
static void netlogon_creds_cli_lock_done(struct tevent_req *subreq); static void netlogon_creds_cli_lock_done(struct tevent_req *subreq);
static void netlogon_creds_cli_lock_fetch(struct tevent_req *req); static NTSTATUS netlogon_creds_cli_lock_fetch(
struct netlogon_creds_cli_context *context,
TALLOC_CTX *mem_ctx, struct netlogon_creds_CredentialState **pcreds);
struct tevent_req *netlogon_creds_cli_lock_send(TALLOC_CTX *mem_ctx, struct tevent_req *netlogon_creds_cli_lock_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev, struct tevent_context *ev,
@ -741,8 +743,11 @@ struct tevent_req *netlogon_creds_cli_lock_send(TALLOC_CTX *mem_ctx,
state->locked_state = locked_state; state->locked_state = locked_state;
if (context->db.g_ctx == NULL) { if (context->db.g_ctx == NULL) {
netlogon_creds_cli_lock_fetch(req); NTSTATUS status;
if (!tevent_req_is_in_progress(req)) {
status = netlogon_creds_cli_lock_fetch(
context, state, &state->creds);
if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev); return tevent_req_post(req, ev);
} }
@ -778,38 +783,39 @@ static void netlogon_creds_cli_lock_done(struct tevent_req *subreq)
} }
state->locked_state->is_glocked = true; state->locked_state->is_glocked = true;
netlogon_creds_cli_lock_fetch(req); status = netlogon_creds_cli_lock_fetch(state->locked_state->context,
state, &state->creds);
if (tevent_req_nterror(req, status)) {
return;
}
tevent_req_done(req);
} }
static void netlogon_creds_cli_lock_fetch(struct tevent_req *req) static NTSTATUS netlogon_creds_cli_lock_fetch(
struct netlogon_creds_cli_context *context,
TALLOC_CTX *mem_ctx, struct netlogon_creds_CredentialState **pcreds)
{ {
struct netlogon_creds_cli_lock_state *state =
tevent_req_data(req,
struct netlogon_creds_cli_lock_state);
struct netlogon_creds_cli_context *context = state->locked_state->context;
struct netlogon_creds_cli_fetch_state fstate = { struct netlogon_creds_cli_fetch_state fstate = {
.status = NT_STATUS_INTERNAL_ERROR, .status = NT_STATUS_INTERNAL_ERROR,
.required_flags = context->client.required_flags, .required_flags = context->client.required_flags,
}; };
NTSTATUS status; NTSTATUS status;
fstate.mem_ctx = state; fstate.mem_ctx = mem_ctx;
status = dbwrap_parse_record(context->db.ctx, status = dbwrap_parse_record(context->db.ctx,
context->db.key_data, context->db.key_data,
netlogon_creds_cli_fetch_parser, netlogon_creds_cli_fetch_parser,
&fstate); &fstate);
if (tevent_req_nterror(req, status)) { if (!NT_STATUS_IS_OK(status)) {
return; return status;
} }
status = fstate.status; if (!NT_STATUS_IS_OK(fstate.status)) {
if (tevent_req_nterror(req, status)) { return fstate.status;
return;
} }
if (context->server.cached_flags == fstate.creds->negotiate_flags) { if (context->server.cached_flags == fstate.creds->negotiate_flags) {
state->creds = fstate.creds; *pcreds = fstate.creds;
tevent_req_done(req); return NT_STATUS_OK;
return;
} }
context->server.cached_flags = fstate.creds->negotiate_flags; context->server.cached_flags = fstate.creds->negotiate_flags;
@ -825,9 +831,8 @@ static void netlogon_creds_cli_lock_fetch(struct tevent_req *req)
context->server.try_validation6 = false; context->server.try_validation6 = false;
} }
state->creds = fstate.creds; *pcreds = fstate.creds;
tevent_req_done(req); return NT_STATUS_OK;
return;
} }
NTSTATUS netlogon_creds_cli_lock_recv(struct tevent_req *req, NTSTATUS netlogon_creds_cli_lock_recv(struct tevent_req *req,