auth/gensec: add some useful debugging to gensec_update_send/gensec_update_done
authorStefan Metzmacher <metze@samba.org>
Thu, 20 Jul 2017 13:42:58 +0000 (15:42 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 25 Jul 2017 11:51:11 +0000 (13:51 +0200)
This makes it easier to spot problems with all the abstraction and async layers.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
auth/gensec/gensec.c

index 014516f..6569c72 100644 (file)
@@ -454,6 +454,9 @@ _PUBLIC_ struct tevent_req *gensec_update_send(TALLOC_CTX *mem_ctx,
        }
        tevent_req_set_callback(subreq, gensec_update_done, req);
 
+       DBG_DEBUG("%s[%p]: subreq: %p\n", state->ops->name,
+                 state->gensec_security, subreq);
+
        return req;
 }
 
@@ -484,15 +487,35 @@ static void gensec_update_done(struct tevent_req *subreq)
                tevent_req_data(req,
                struct gensec_update_state);
        NTSTATUS status;
+       const char *debug_subreq = NULL;
+
+       if (CHECK_DEBUGLVL(DBGLVL_DEBUG)) {
+               /*
+                * We need to call tevent_req_print()
+                * before calling the _recv function,
+                * before tevent_req_received() was called.
+                * in order to print the pointer value of
+                * the subreq state.
+                */
+               debug_subreq = tevent_req_print(state, subreq);
+       }
 
        status = state->ops->update_recv(subreq, state, &state->out);
        TALLOC_FREE(subreq);
        state->status = status;
-       if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
-               tevent_req_done(req);
+       if (GENSEC_UPDATE_IS_NTERROR(status)) {
+               DBG_INFO("%s[%p]: %s%s%s\n", state->ops->name,
+                        state->gensec_security, nt_errstr(status),
+                        debug_subreq ? " " : "",
+                        debug_subreq ? debug_subreq : "");
+               tevent_req_nterror(req, status);
                return;
        }
-       if (tevent_req_nterror(req, status)) {
+       DBG_DEBUG("%s[%p]: %s %s\n", state->ops->name,
+                 state->gensec_security, nt_errstr(status),
+                 debug_subreq);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+               tevent_req_done(req);
                return;
        }