s4:rpc_server: make use of dcesrv_auth_prepare_bind_ack() in dcesrv_bind()
authorStefan Metzmacher <metze@samba.org>
Mon, 15 May 2017 12:02:07 +0000 (14:02 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 21 May 2017 19:05:13 +0000 (21:05 +0200)
It means we also need to call gensec_update_ev() and dcesrv_auth_complete()
directly in dcesrv_bind(). Doing that will make it easier to make dcesrv_bind()
async in the next commits.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/rpc_server/dcerpc_server.c

index c2b531fa7ab4d5c7d2e1d091b83a03d4b755031a..2f322ceadb6f2d13f489aea0765340e5236c0cd8 100644 (file)
@@ -782,6 +782,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
        uint16_t max_rep = 0;
        const char *ep_prefix = "";
        const char *endpoint = NULL;
+       struct dcesrv_auth *auth = &call->conn->auth_state;
        struct dcerpc_ack_ctx *ack_ctx_list = NULL;
        struct dcerpc_ack_ctx *ack_features = NULL;
        size_t i;
@@ -964,7 +965,6 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
         * is being requested.
         */
        if (!dcesrv_auth_bind(call)) {
-               struct dcesrv_auth *auth = &call->conn->auth_state;
 
                if (auth->auth_level == DCERPC_AUTH_LEVEL_NONE) {
                        /*
@@ -1019,7 +1019,21 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
        pkt->u.bind_ack.ctx_list = ack_ctx_list;
        pkt->u.bind_ack.auth_info = data_blob_null;
 
-       status = dcesrv_auth_bind_ack(call, pkt);
+       status = dcesrv_auth_prepare_bind_ack(call, pkt);
+       if (!NT_STATUS_IS_OK(status)) {
+               return dcesrv_bind_nak(call, 0);
+       }
+
+       if (auth->auth_finished) {
+               return dcesrv_auth_reply(call);
+       }
+
+       status = gensec_update_ev(auth->gensec_security,
+                                 call, call->event_ctx,
+                                 call->in_auth_info.credentials,
+                                 &call->out_auth_info->credentials);
+
+       status = dcesrv_auth_complete(call, status);
        if (!NT_STATUS_IS_OK(status)) {
                return dcesrv_bind_nak(call, 0);
        }