s3:rpc_client: use rpc_api_pipe_send() for auth3
authorStefan Metzmacher <metze@samba.org>
Tue, 7 Sep 2010 18:52:58 +0000 (20:52 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 17 Sep 2010 13:42:35 +0000 (15:42 +0200)
metze

source3/rpc_client/cli_pipe.c

index 363d83e6827a1b9bf103cf71c45d462aa9f62f67..bec22877ddbceb5fb0123d911ce31e7fb3274098 100644 (file)
@@ -1651,11 +1651,11 @@ struct rpc_pipe_bind_state {
        struct event_context *ev;
        struct rpc_pipe_client *cli;
        DATA_BLOB rpc_out;
+       bool auth3;
        uint32_t rpc_call_id;
 };
 
 static void rpc_pipe_bind_step_one_done(struct tevent_req *subreq);
-static void rpc_bind_auth3_write_done(struct tevent_req *subreq);
 static NTSTATUS rpc_bind_next_send(struct tevent_req *req,
                                   struct rpc_pipe_bind_state *state,
                                   DATA_BLOB *credentials);
@@ -1686,7 +1686,6 @@ struct tevent_req *rpc_pipe_bind_send(TALLOC_CTX *mem_ctx,
        state->ev = ev;
        state->cli = cli;
        state->rpc_call_id = get_rpc_call_id();
-       state->rpc_out = data_blob_null;
 
        cli->auth = talloc_move(cli, &auth);
 
@@ -1740,6 +1739,11 @@ static void rpc_pipe_bind_step_one_done(struct tevent_req *subreq)
                return;
        }
 
+       if (state->auth3) {
+               tevent_req_done(req);
+               return;
+       }
+
        if (!check_bind_response(&pkt->u.bind_ack, &state->cli->transfer_syntax)) {
                DEBUG(2, ("rpc_pipe_bind: check_bind_response failed.\n"));
                tevent_req_nterror(req, NT_STATUS_BUFFER_TOO_SMALL);
@@ -1862,21 +1866,6 @@ err_out:
        tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
 }
 
-static void rpc_bind_auth3_write_done(struct tevent_req *subreq)
-{
-       struct tevent_req *req = tevent_req_callback_data(
-               subreq, struct tevent_req);
-       NTSTATUS status;
-
-       status = rpc_write_recv(subreq);
-       TALLOC_FREE(subreq);
-       if (!NT_STATUS_IS_OK(status)) {
-               tevent_req_nterror(req, status);
-               return;
-       }
-       tevent_req_done(req);
-}
-
 static NTSTATUS rpc_bind_next_send(struct tevent_req *req,
                                   struct rpc_pipe_bind_state *state,
                                   DATA_BLOB *auth_token)
@@ -1917,6 +1906,8 @@ static NTSTATUS rpc_bind_finish_send(struct tevent_req *req,
        struct tevent_req *subreq;
        NTSTATUS status;
 
+       state->auth3 = true;
+
        /* Now prepare the auth3 context pdu. */
        data_blob_free(&state->rpc_out);
 
@@ -1930,12 +1921,12 @@ static NTSTATUS rpc_bind_finish_send(struct tevent_req *req,
                return status;
        }
 
-       subreq = rpc_write_send(state, state->ev, state->cli->transport,
-                               state->rpc_out.data, state->rpc_out.length);
+       subreq = rpc_api_pipe_send(state, state->ev, state->cli,
+                                  &state->rpc_out, DCERPC_PKT_AUTH3);
        if (subreq == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
-       tevent_req_set_callback(subreq, rpc_bind_auth3_write_done, req);
+       tevent_req_set_callback(subreq, rpc_pipe_bind_step_one_done, req);
        return NT_STATUS_OK;
 }