From 77b44fbe362660b65da0aa36aeeea3fecc4ae515 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 20 Jul 2017 16:11:48 +0200 Subject: [PATCH] s4:lib/http: pass down the target service/hostname to gensec Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- source4/lib/http/http_auth.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source4/lib/http/http_auth.c b/source4/lib/http/http_auth.c index 31f6a2b6307..f561c496853 100644 --- a/source4/lib/http/http_auth.c +++ b/source4/lib/http/http_auth.c @@ -118,6 +118,7 @@ struct tevent_req *http_send_auth_request_send(TALLOC_CTX *mem_ctx, struct tevent_req *subreq = NULL; DATA_BLOB gensec_in = data_blob_null; NTSTATUS status; + struct http_header *h = NULL; const char *mech_name = NULL; req = tevent_req_create(mem_ctx, &state, struct http_auth_state); @@ -146,6 +147,26 @@ struct tevent_req *http_send_auth_request_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } + for (h = original_request->headers; h != NULL; h = h->next) { + int cmp; + + cmp = strcasecmp(h->key, "Host"); + if (cmp != 0) { + continue; + } + + status = gensec_set_target_service(state->gensec_ctx, "http"); + if (tevent_req_nterror(req, status)) { + return tevent_req_post(req, ev); + } + + status = gensec_set_target_hostname(state->gensec_ctx, h->value); + if (tevent_req_nterror(req, status)) { + return tevent_req_post(req, ev); + } + break; + } + switch (state->auth) { case HTTP_AUTH_BASIC: mech_name = "http_basic";