auth: Simplify struct auth4_context
authorVolker Lendecke <vl@samba.org>
Thu, 2 Jan 2020 21:58:06 +0000 (22:58 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 6 Jan 2020 23:34:00 +0000 (23:34 +0000)
The fake async code has been pushed down into the 3 users, remove the sync
callback. Overall it's more lines of code, but the central interface is
simplified.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Jan  6 23:34:00 UTC 2020 on sn-devel-184

auth/common_auth.h
auth/ntlmssp/ntlmssp_server.c
source3/auth/auth_generic.c

index 9f04c9b9cbbbb8be0d373e268b3a49998890d096..0452c673ebcec7c0b14ec30a74de3f60b41f0df3 100644 (file)
@@ -129,12 +129,6 @@ struct auth4_context {
        /* Private data for the callbacks on this auth context */
        void *private_data;
 
-       NTSTATUS (*check_ntlm_password)(struct auth4_context *auth_ctx,
-                                       TALLOC_CTX *mem_ctx,
-                                       const struct auth_usersupplied_info *user_info,
-                                       uint8_t *pauthoritative,
-                                       void **server_returned_info,
-                                       DATA_BLOB *nt_session_key, DATA_BLOB *lm_session_key);
        struct tevent_req *(*check_ntlm_password_send)(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
                                        struct auth4_context *auth_ctx,
index 29559b3fe02e112cef2febe0175c8e70bfb70f2b..001238278d7ff66b58b9a373c7750f35dd2b9dae 100644 (file)
@@ -335,8 +335,8 @@ struct tevent_req *ntlmssp_server_auth_send(TALLOC_CTX *mem_ctx,
                                      struct gensec_ntlmssp_context);
        struct auth4_context *auth_context = gensec_security->auth_context;
        struct tevent_req *req = NULL;
+       struct tevent_req *subreq = NULL;
        struct ntlmssp_server_auth_state *state = NULL;
-       uint8_t authoritative = 0;
        NTSTATUS status;
 
        req = tevent_req_create(mem_ctx, &state,
@@ -355,54 +355,13 @@ struct tevent_req *ntlmssp_server_auth_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (auth_context->check_ntlm_password_send != NULL) {
-               struct tevent_req *subreq = NULL;
-
-               subreq = auth_context->check_ntlm_password_send(state, ev,
-                                               auth_context,
-                                               state->user_info);
-               if (tevent_req_nomem(subreq, req)) {
-                       return tevent_req_post(req, ev);
-               }
-               tevent_req_set_callback(subreq,
-                                       ntlmssp_server_auth_done,
-                                       req);
-               return req;
-       }
-
-       if (auth_context->check_ntlm_password == NULL) {
-               tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+       subreq = auth_context->check_ntlm_password_send(
+               state, ev, auth_context, state->user_info);
+       if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
-
-       status = auth_context->check_ntlm_password(auth_context,
-                                                  gensec_ntlmssp,
-                                                  state->user_info,
-                                                  &authoritative,
-                                                  &gensec_ntlmssp->server_returned_info,
-                                                  &state->user_session_key,
-                                                  &state->lm_session_key);
-       if (!NT_STATUS_IS_OK(status)) {
-               DBG_INFO("Checking NTLMSSP password for %s\\%s failed: %s\n",
-                        state->user_info->client.domain_name,
-                        state->user_info->client.account_name,
-                        nt_errstr(status));
-       }
-       if (tevent_req_nterror(req, status)) {
-               return tevent_req_post(req, ev);
-       }
-       talloc_steal(state, state->user_session_key.data);
-       talloc_steal(state, state->lm_session_key.data);
-
-       status = ntlmssp_server_postauth(gensec_security,
-                                        gensec_ntlmssp,
-                                        state, in);
-       if (tevent_req_nterror(req, status)) {
-               return tevent_req_post(req, ev);
-       }
-
-       tevent_req_done(req);
-       return tevent_req_post(req, ev);
+       tevent_req_set_callback(subreq, ntlmssp_server_auth_done, req);
+       return req;
 }
 
 /**
index 326ca46627e998803c11ffe36d58d008e518f7b3..9243a0ba02d33d89db4ae04afc1cbbb9f16302a7 100644 (file)
@@ -415,48 +415,35 @@ NTSTATUS auth_check_password_session_info(struct auth4_context *auth_context,
        NTSTATUS nt_status;
        void *server_info;
        uint8_t authoritative = 0;
+       struct tevent_context *ev = NULL;
+       struct tevent_req *subreq = NULL;
+       bool ok;
 
-       if (auth_context->check_ntlm_password_send != NULL) {
-               struct tevent_context *ev = NULL;
-               struct tevent_req *subreq = NULL;
-               bool ok;
-
-               ev = samba_tevent_context_init(talloc_tos());
-               if (ev == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+       ev = samba_tevent_context_init(talloc_tos());
+       if (ev == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
-               subreq = auth_context->check_ntlm_password_send(ev, ev,
-                                                               auth_context,
-                                                               user_info);
-               if (subreq == NULL) {
-                       TALLOC_FREE(ev);
-                       return NT_STATUS_NO_MEMORY;
-               }
-               ok = tevent_req_poll_ntstatus(subreq, ev, &nt_status);
-               if (!ok) {
-                       TALLOC_FREE(ev);
-                       return nt_status;
-               }
-               nt_status = auth_context->check_ntlm_password_recv(subreq,
-                                                                  talloc_tos(),
-                                                                  &authoritative,
-                                                                  &server_info,
-                                                                  NULL, NULL);
+       subreq = auth_context->check_ntlm_password_send(ev, ev,
+                                                       auth_context,
+                                                       user_info);
+       if (subreq == NULL) {
                TALLOC_FREE(ev);
-               if (!NT_STATUS_IS_OK(nt_status)) {
-                       return nt_status;
-               }
-       } else {
-               nt_status = auth_context->check_ntlm_password(auth_context,
-                                                             talloc_tos(),
-                                                             user_info,
-                                                             &authoritative,
-                                                             &server_info,
-                                                             NULL, NULL);
-               if (!NT_STATUS_IS_OK(nt_status)) {
-                       return nt_status;
-               }
+               return NT_STATUS_NO_MEMORY;
+       }
+       ok = tevent_req_poll_ntstatus(subreq, ev, &nt_status);
+       if (!ok) {
+               TALLOC_FREE(ev);
+               return nt_status;
+       }
+       nt_status = auth_context->check_ntlm_password_recv(subreq,
+                                                          talloc_tos(),
+                                                          &authoritative,
+                                                          &server_info,
+                                                          NULL, NULL);
+       TALLOC_FREE(ev);
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               return nt_status;
        }
 
        nt_status = auth_context->generate_session_info(auth_context,