1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

s4:lib/http: use http_conn in http_send_request_send() and http_read_response_send()

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>
This commit is contained in:
Ralph Boehme 2019-08-06 12:33:40 +02:00
parent 53007b7711
commit 5ae515245c
5 changed files with 20 additions and 39 deletions

View 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);

View 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 *,

View 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;

View 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,

View 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);