winbindd: complete WBFLAG_PAM_AUTH_PAC handling in winbindd_pam_auth_crap_send()
authorStefan Metzmacher <metze@samba.org>
Tue, 23 Jan 2018 22:10:42 +0000 (23:10 +0100)
committerRalph Boehme <slow@samba.org>
Sat, 10 Feb 2018 07:35:18 +0000 (08:35 +0100)
winbindd_pam_auth_crap_recv() should not have any real logic.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13262

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/winbindd/winbindd_pam_auth_crap.c

index fe0ce4ade62a4bdba1a6c31b70f77133ee5d97ea..afcce03172e09ec99303b38abc0190184a45cef9 100644 (file)
@@ -24,7 +24,6 @@
 
 struct winbindd_pam_auth_crap_state {
        struct winbindd_response *response;
-       struct netr_SamInfo3 *info3;
        uint32_t flags;
 };
 
@@ -50,16 +49,44 @@ struct tevent_req *winbindd_pam_auth_crap_send(
        state->flags = request->flags;
 
        if (state->flags & WBFLAG_PAM_AUTH_PAC) {
+               struct netr_SamInfo3 *info3 = NULL;
+               uint16_t validation_level;
+               union netr_Validation *validation = NULL;
                NTSTATUS status;
 
-               status = winbindd_pam_auth_pac_send(cli, &state->info3);
-               if (NT_STATUS_IS_OK(status)) {
-                       /* Defer filling out response to recv */
-                       tevent_req_done(req);
-               } else {
-                       tevent_req_nterror(req, status);
+               status = winbindd_pam_auth_pac_send(cli, &info3);
+               if (tevent_req_nterror(req, status)) {
+                       return tevent_req_post(req, ev);
+               }
+
+               state->response = talloc_zero(state,
+                                             struct winbindd_response);
+               if (tevent_req_nomem(state->response, req)) {
+                       return tevent_req_post(req, ev);
                }
+               state->response->result = WINBINDD_PENDING;
+               state->response->length = sizeof(struct winbindd_response);
 
+               status = map_info3_to_validation(talloc_tos(),
+                                                info3,
+                                                &validation_level,
+                                                &validation);
+               if (tevent_req_nterror(req, status)) {
+                       return tevent_req_post(req, ev);
+               }
+
+               status = append_auth_data(state->response,
+                                         state->response,
+                                         state->flags,
+                                         validation_level,
+                                         validation,
+                                         NULL, NULL);
+               TALLOC_FREE(validation);
+               if (tevent_req_nterror(req, status)) {
+                       return tevent_req_post(req, ev);
+               }
+
+               tevent_req_done(req);
                return tevent_req_post(req, ev);
        }
 
@@ -151,29 +178,6 @@ NTSTATUS winbindd_pam_auth_crap_recv(struct tevent_req *req,
                return status;
        }
 
-       if (state->flags & WBFLAG_PAM_AUTH_PAC) {
-               uint16_t validation_level;
-               union netr_Validation *validation = NULL;
-
-               status = map_info3_to_validation(talloc_tos(),
-                                                state->info3,
-                                                &validation_level,
-                                                &validation);
-               if (!NT_STATUS_IS_OK(status)) {
-                       return status;
-               }
-
-               status = append_auth_data(response,
-                                       response,
-                                       state->flags,
-                                       validation_level,
-                                       validation,
-                                       NULL, NULL);
-               TALLOC_FREE(validation);
-               return status;
-
-       }
-
        *response = *state->response;
        response->result = WINBINDD_PENDING;
        state->response = talloc_move(response, &state->response);