]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:lib/http: use http_conn in http_send_request_send() and http_read_response_send()
authorRalph Boehme <slow@samba.org>
Tue, 6 Aug 2019 10:33:40 +0000 (12:33 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 7 Aug 2019 12:54:40 +0000 (12:54 +0000)
Works, tested with

  $ bin/smbtorture -W RIVERSIDE --realm=RIVERSIDE.SITE -s /dev/null \
    -U Administrator%Passw0rd \
    ncacn_http:10.10.11.164[HttpProxy=10.10.11.164:593,HttpUseTls=false,HttpAuthOption=basic,HttpConnectOption=UseHttpProxy] \
    rpc.epmapper.epmapper.Lookup_simple

I get an ACCESS_DENIED error, but I get it over HTTP. :)

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@suse.de>
source4/lib/http/http.c
source4/lib/http/http.h
source4/lib/http/http_auth.c
source4/librpc/rpc/dcerpc_roh_channel_in.c
source4/librpc/rpc/dcerpc_roh_channel_out.c

index 53aed2463242fca4cafe4d3b7bbabd3f448bea7f..2d1f635d3808caa94dca37f7de5b4122add5aa6b 100644 (file)
@@ -559,7 +559,7 @@ static int http_read_response_next_vector(struct tstream_context *stream,
 static void http_read_response_done(struct tevent_req *);
 struct tevent_req *http_read_response_send(TALLOC_CTX *mem_ctx,
                                           struct tevent_context *ev,
-                                          struct tstream_context *stream,
+                                          struct http_conn *http_conn,
                                           size_t max_content_length)
 {
        struct tevent_req               *req;
@@ -569,7 +569,7 @@ struct tevent_req *http_read_response_send(TALLOC_CTX *mem_ctx,
        DEBUG(11, ("%s: Reading HTTP response\n", __func__));
 
        /* Sanity checks */
-       if (!ev || !stream) {
+       if (ev == NULL || http_conn == NULL) {
                DEBUG(0, ("%s: Invalid parameter\n", __func__));
                return NULL;
        }
@@ -587,7 +587,7 @@ struct tevent_req *http_read_response_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       subreq = tstream_readv_pdu_send(state, ev, stream,
+       subreq = tstream_readv_pdu_send(state, ev, http_conn->tstreams.active,
                                        http_read_response_next_vector,
                                        state);
        if (tevent_req_nomem(subreq,req)) {
@@ -776,8 +776,7 @@ struct http_send_request_state {
 static void http_send_request_done(struct tevent_req *);
 struct tevent_req *http_send_request_send(TALLOC_CTX *mem_ctx,
                                          struct tevent_context *ev,
-                                         struct tstream_context *stream,
-                                         struct tevent_queue *send_queue,
+                                         struct http_conn *http_conn,
                                          struct http_request *request)
 {
        struct tevent_req               *req;
@@ -788,7 +787,7 @@ struct tevent_req *http_send_request_send(TALLOC_CTX *mem_ctx,
        DEBUG(11, ("%s: Sending HTTP request\n", __func__));
 
        /* Sanity checks */
-       if (!ev || !stream || !send_queue || !request) {
+       if (ev == NULL || request == NULL || http_conn == NULL) {
                DEBUG(0, ("%s: Invalid parameter\n", __func__));
                return NULL;
        }
@@ -824,7 +823,10 @@ struct tevent_req *http_send_request_send(TALLOC_CTX *mem_ctx,
 
        state->iov.iov_base = (char *) state->buffer.data;
        state->iov.iov_len = state->buffer.length;
-       subreq = tstream_writev_queue_send(state, ev, stream, send_queue,
+       subreq = tstream_writev_queue_send(state,
+                                          ev,
+                                          http_conn->tstreams.active,
+                                          http_conn->send_queue,
                                           &state->iov, 1);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
index 25055c91007550cce3b2d4b776daa33ea1b1da69..f2196031f0321a919e2cee59013e0ca386d8448a 100644 (file)
@@ -118,15 +118,14 @@ struct tstream_context *http_conn_tstream(struct http_conn *http_conn);
 /* HTTP request */
 struct tevent_req *http_send_request_send(TALLOC_CTX *,
                                          struct tevent_context *,
-                                         struct tstream_context *,
-                                         struct tevent_queue *,
+                                         struct http_conn *,
                                          struct http_request *);
 NTSTATUS http_send_request_recv(struct tevent_req *);
 
 /* HTTP response */
 struct tevent_req *http_read_response_send(TALLOC_CTX *,
                                           struct tevent_context *,
-                                          struct tstream_context *,
+                                          struct http_conn *,
                                           size_t max_content_length);
 NTSTATUS http_read_response_recv(struct tevent_req *,
                            TALLOC_CTX *,
@@ -135,8 +134,7 @@ NTSTATUS http_read_response_recv(struct tevent_req *,
 /* HTTP authenticated request */
 struct tevent_req *http_send_auth_request_send(TALLOC_CTX *,
                                               struct tevent_context *,
-                                              struct tstream_context *,
-                                              struct tevent_queue *,
+                                              struct http_conn *,
                                               const struct http_request *,
                                               struct cli_credentials *,
                                               struct loadparm_context *,
index f561c4968537a84f859417815de5cca91bd1fc3e..ece660584f649c85925c06611e11aec201424ad6 100644 (file)
@@ -85,8 +85,7 @@ static NTSTATUS http_parse_auth_response(const DATA_BLOB prefix,
 struct http_auth_state {
        struct tevent_context *ev;
 
-       struct tstream_context *stream;
-       struct tevent_queue *send_queue;
+       struct http_conn *http_conn;
 
        enum http_auth_method auth;
        DATA_BLOB prefix;
@@ -106,8 +105,7 @@ static void http_send_auth_request_http_rep_done(struct tevent_req *subreq);
 
 struct tevent_req *http_send_auth_request_send(TALLOC_CTX *mem_ctx,
                                               struct tevent_context *ev,
-                                              struct tstream_context *stream,
-                                              struct tevent_queue *send_queue,
+                                              struct http_conn *http_conn,
                                               const struct http_request *original_request,
                                               struct cli_credentials *credentials,
                                               struct loadparm_context *lp_ctx,
@@ -126,8 +124,7 @@ struct tevent_req *http_send_auth_request_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
        state->ev = ev;
-       state->stream = stream;
-       state->send_queue = send_queue;
+       state->http_conn = http_conn;
        state->auth = auth;
        state->original_request = original_request;
 
@@ -264,8 +261,7 @@ static void http_send_auth_request_gensec_done(struct tevent_req *subreq)
        }
 
        subreq = http_send_request_send(state, state->ev,
-                                       state->stream,
-                                       state->send_queue,
+                                       state->http_conn,
                                        state->next_request);
        if (tevent_req_nomem(subreq, req)) {
                return;
@@ -312,7 +308,7 @@ static void http_send_auth_request_http_req_done(struct tevent_req *subreq)
         * from the socket, but for now we just ignore the bytes.
         */
        subreq = http_read_response_send(state, state->ev,
-                                        state->stream,
+                                        state->http_conn,
                                         UINT16_MAX);
        if (tevent_req_nomem(subreq, req)) {
                return;
index 3f9719627531d63255cd1bb8acc7d667da2d27da..cc53c2a7f419e9602ecd3dedfd0e639630c3b093 100644 (file)
@@ -162,8 +162,6 @@ struct tevent_req *roh_send_RPC_DATA_IN_send(TALLOC_CTX *mem_ctx,
        const char                      *path;
        char                            *query;
        char                            *uri;
-       struct tstream_context          *stream = NULL;
-       struct tevent_queue             *send_queue = NULL;
 
        DEBUG(8, ("%s: Sending RPC_IN_DATA request\n", __func__));
 
@@ -221,13 +219,9 @@ struct tevent_req *roh_send_RPC_DATA_IN_send(TALLOC_CTX *mem_ctx,
        http_add_header(state, &state->request->headers,
                        "Pragma", "no-cache");
 
-       stream = http_conn_tstream(roh->default_channel_in->http_conn);
-       send_queue = http_conn_send_queue(roh->default_channel_in->http_conn);
-
        subreq = http_send_auth_request_send(state,
                                        ev,
-                                       stream,
-                                       send_queue,
+                                       roh->default_channel_in->http_conn,
                                        state->request,
                                        credentials,
                                        lp_ctx,
index 3bd28b0fa1231c6f8b33e8fa4c8e159801be37ea..491bbadfa693be5616919fc8f410ecd0f4262612 100644 (file)
@@ -162,8 +162,6 @@ struct tevent_req *roh_send_RPC_DATA_OUT_send(TALLOC_CTX *mem_ctx,
        const char                      *path;
        char                            *query;
        char                            *uri;
-       struct tstream_context          *stream = NULL;
-       struct tevent_queue             *send_queue = NULL;
 
        DEBUG(8, ("%s: Sending RPC_OUT_DATA request\n", __func__));
 
@@ -221,13 +219,9 @@ struct tevent_req *roh_send_RPC_DATA_OUT_send(TALLOC_CTX *mem_ctx,
        http_add_header(state, &state->request->headers,
                        "Pragma", "no-cache");
 
-       stream = http_conn_tstream(roh->default_channel_out->http_conn);
-       send_queue = http_conn_send_queue(roh->default_channel_out->http_conn);
-
        subreq = http_send_auth_request_send(state,
                                        ev,
-                                       stream,
-                                       send_queue,
+                                       roh->default_channel_out->http_conn,
                                        state->request,
                                        credentials,
                                        lp_ctx,
@@ -412,7 +406,6 @@ struct tevent_req *roh_recv_out_channel_response_send(TALLOC_CTX *mem_ctx,
        struct tevent_req               *req;
        struct tevent_req               *subreq;
        struct roh_recv_response_state  *state;
-       struct tstream_context          *stream = NULL;
 
        DEBUG(8, ("%s: Waiting for RPC_OUT_DATA response\n", __func__));
 
@@ -421,10 +414,8 @@ struct tevent_req *roh_recv_out_channel_response_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       stream = http_conn_tstream(roh->default_channel_out->http_conn);
-
        subreq = http_read_response_send(state, ev,
-                                        stream,
+                                        roh->default_channel_out->http_conn,
                                         0); /* we'll get the content later */
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);