[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Wed Aug 7 14:13:02 UTC 2019


The branch, master has been updated
       via  959b77988d0 s4:librpc/rpc: Use generic roh_connect_channel_send/recv
       via  7189eb44d7f s4:librpc/rpc: Add roh_connect_channel_send/recv
       via  fc0371b9322 s4:lib/http: move to the toplevel
       via  a0065c57601 s4:lib/http: add support for http POST
       via  5ae515245c2 s4:lib/http: use http_conn in http_send_request_send() and http_read_response_send()
       via  53007b77116 s4:librpc/rpc: use http_connect_send/recv in ncacn_http
       via  94fe9afae42 s4:lib/http: remove stream and send_queue from state
       via  ab389bca9c6 s4:lib/http: move struct http_read_response_state to the implementation
       via  3ffd74e915f s4:lib/http: move struct http_send_request_state to the implementation
       via  314043828b3 s4:lib/http: add http_[dis]connect_send and recv
      from  2a902020525 charset: add tests for Unicode NFC <-> NFD conversion

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 959b77988d02731c032b5fcc91f7a62fd9b96340
Author: Samuel Cabrero <scabrero at suse.de>
Date:   Tue Aug 6 18:21:12 2019 +0200

    s4:librpc/rpc: Use generic roh_connect_channel_send/recv
    
    The HTTP connection code is common to in and out channels.
    
    Signed-off-by: Samuel Cabrero <scabrero at suse.de>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Wed Aug  7 14:12:40 UTC 2019 on sn-devel-184

commit 7189eb44d7f8a6514bb48645da89d7f9b148d599
Author: Samuel Cabrero <scabrero at suse.de>
Date:   Tue Aug 6 18:12:41 2019 +0200

    s4:librpc/rpc: Add roh_connect_channel_send/recv
    
    Generic function to connect a ROH channel. The use comes later to avoid
    duplicated code.
    
    Signed-off-by: Samuel Cabrero <scabrero at suse.de>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit fc0371b932286d4f50f8650b1e7a7132f83e565c
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Apr 2 18:34:24 2019 +0200

    s4:lib/http: move to the toplevel
    
    This is going to be used from the s3 RPC server soon...
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

commit a0065c57601a16011dc1a90688a724ae8acb3377
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Apr 3 14:33:12 2019 +0200

    s4:lib/http: add support for http POST
    
    Even though GET would work as well, only adding POST, as that's the only method
    that's going to be exersized in code and tests (RPC mdssvc elasticsearch
    backend).
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

commit 5ae515245c235427c5d07f473cf53015701ce4e1
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Aug 6 12:33:40 2019 +0200

    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 at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

commit 53007b77116c510e296995c8a0a8b836b88d7770
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 28 15:36:00 2019 +0100

    s4:librpc/rpc: use http_connect_send/recv in ncacn_http
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

commit 94fe9afae42ee09974b8c5ab802868e703318d95
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 26 15:04:28 2019 +0100

    s4:lib/http: remove stream and send_queue from state
    
    They're not used, so remove them.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

commit ab389bca9c6d0e1723b471eb1a2e8d38648efbc4
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 26 14:53:21 2019 +0100

    s4:lib/http: move struct http_read_response_state to the implementation
    
    This is only used by the implemementation of http_send_request_send/recv, no
    need to have this in the header file.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

commit 3ffd74e915f579bcf759f17c32aedb0c5a9f152b
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 26 14:53:21 2019 +0100

    s4:lib/http: move struct http_send_request_state to the implementation
    
    This is only used by the implemementation of http_send_request_send/recv, no
    need to have this in the header file.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

commit 314043828b3e3d70600f0f365caad37dbf171d1a
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Mar 25 14:39:59 2019 +0100

    s4:lib/http: add http_[dis]connect_send and recv
    
    Not used for now, that comes later.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Samuel Cabrero <scabrero at suse.de>

-----------------------------------------------------------------------

Summary of changes:
 {source4/lib => libcli}/http/gensec/basic.c   |   0
 {source4/lib => libcli}/http/gensec/generic.c |   0
 {source4/lib => libcli}/http/http.c           |  39 ++-
 {source4/lib => libcli}/http/http.h           |  31 ++-
 {source4/lib => libcli}/http/http_auth.c      |  14 +-
 libcli/http/http_conn.c                       | 348 ++++++++++++++++++++++++++
 {source4/lib => libcli}/http/http_internal.h  |  27 +-
 {source4/lib => libcli}/http/wscript_build    |   4 +-
 source4/librpc/rpc/dcerpc_connect.c           |   2 +-
 source4/librpc/rpc/dcerpc_roh.c               | 192 +++++++++++---
 source4/librpc/rpc/dcerpc_roh.h               |   7 +-
 source4/librpc/rpc/dcerpc_roh_channel_in.c    | 188 +-------------
 source4/librpc/rpc/dcerpc_roh_channel_out.c   | 203 ++-------------
 wscript_build                                 |   2 +-
 14 files changed, 602 insertions(+), 455 deletions(-)
 rename {source4/lib => libcli}/http/gensec/basic.c (100%)
 rename {source4/lib => libcli}/http/gensec/generic.c (100%)
 rename {source4/lib => libcli}/http/http.c (96%)
 rename {source4/lib => libcli}/http/http.h (81%)
 rename {source4/lib => libcli}/http/http_auth.c (97%)
 create mode 100644 libcli/http/http_conn.c
 rename {source4/lib => libcli}/http/http_internal.h (69%)
 rename {source4/lib => libcli}/http/wscript_build (82%)


Changeset truncated at 500 lines:

diff --git a/source4/lib/http/gensec/basic.c b/libcli/http/gensec/basic.c
similarity index 100%
rename from source4/lib/http/gensec/basic.c
rename to libcli/http/gensec/basic.c
diff --git a/source4/lib/http/gensec/generic.c b/libcli/http/gensec/generic.c
similarity index 100%
rename from source4/lib/http/gensec/generic.c
rename to libcli/http/gensec/generic.c
diff --git a/source4/lib/http/http.c b/libcli/http/http.c
similarity index 96%
rename from source4/lib/http/http.c
rename to libcli/http/http.c
index 9218c19ce31..6be053136c8 100644
--- a/source4/lib/http/http.c
+++ b/libcli/http/http.c
@@ -66,6 +66,13 @@ static int http_response_needs_body(struct http_request *req)
 	return 0;
 }
 
+struct http_read_response_state {
+	enum http_parser_state	parser_state;
+	size_t			max_headers_size;
+	uint64_t		max_content_length;
+	DATA_BLOB		buffer;
+	struct http_request	*response;
+};
 
 /**
  * Parses the HTTP headers
@@ -552,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;
@@ -562,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;
 	}
@@ -580,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)) {
@@ -649,6 +656,9 @@ static const char *http_method_str(enum http_cmd_type type)
 	const char *method;
 
 	switch (type) {
+	case HTTP_REQ_POST:
+		method = "POST";
+		break;
 	case HTTP_REQ_RPC_IN_DATA:
 		method = "RPC_IN_DATA";
 		break;
@@ -752,14 +762,24 @@ static NTSTATUS http_push_body(TALLOC_CTX *mem_ctx,
 	return NT_STATUS_OK;
 }
 
+struct http_send_request_state {
+	struct tevent_context	*ev;
+	struct loadparm_context	*lp_ctx;
+	struct cli_credentials	*credentials;
+	struct http_request	*request;
+	DATA_BLOB		buffer;
+	struct iovec		iov;
+	ssize_t			nwritten;
+	int			sys_errno;
+};
+
 /**
  * Sends and HTTP request
  */
 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;
@@ -770,7 +790,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;
 	}
@@ -781,8 +801,6 @@ struct tevent_req *http_send_request_send(TALLOC_CTX *mem_ctx,
 	}
 
 	state->ev = ev;
-	state->stream = stream;
-	state->send_queue = send_queue;
 	state->request = request;
 
 	/* Push the request line */
@@ -808,7 +826,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);
diff --git a/source4/lib/http/http.h b/libcli/http/http.h
similarity index 81%
rename from source4/lib/http/http.h
rename to libcli/http/http.h
index 0fa65ca89a0..f2196031f03 100644
--- a/source4/lib/http/http.h
+++ b/libcli/http/http.h
@@ -92,18 +92,40 @@ int http_remove_header(struct http_header **, const char *);
 int http_add_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
 int http_replace_header(TALLOC_CTX *, struct http_header **, const char *, const char *);
 
+/* HTTP(s) connect */
+
+struct http_conn;
+struct tstream_tls_params;
+
+struct tevent_req *http_connect_send(TALLOC_CTX *mem_ctx,
+				     struct tevent_context *ev,
+				     const char *http_server,
+				     uint16_t http_port,
+				     struct cli_credentials *credentials,
+				     struct tstream_tls_params *tls_params);
+int http_connect_recv(struct tevent_req *req,
+		      TALLOC_CTX *mem_ctx,
+		      struct http_conn **http_conn);
+
+struct tevent_req *http_disconnect_send(TALLOC_CTX *mem_ctx,
+					struct tevent_context *ev,
+					struct http_conn *http_conn);
+int http_disconnect_recv(struct tevent_req *req);
+
+struct tevent_queue *http_conn_send_queue(struct http_conn *http_conn);
+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 *,
@@ -112,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 *,
diff --git a/source4/lib/http/http_auth.c b/libcli/http/http_auth.c
similarity index 97%
rename from source4/lib/http/http_auth.c
rename to libcli/http/http_auth.c
index f561c496853..ece660584f6 100644
--- a/source4/lib/http/http_auth.c
+++ b/libcli/http/http_auth.c
@@ -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;
diff --git a/libcli/http/http_conn.c b/libcli/http/http_conn.c
new file mode 100644
index 00000000000..de1be3f2d8e
--- /dev/null
+++ b/libcli/http/http_conn.c
@@ -0,0 +1,348 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   HTTP library
+
+   Copyright (C) 2019 Ralph Boehme <slow at samba.org>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "lib/util/tevent_ntstatus.h"
+#include "libcli/dns/dns_lookup.h"
+#include "lib/tsocket/tsocket.h"
+#include "lib/util/util_net.h"
+#include "lib/tls/tls.h"
+#include "lib/util/tevent_unix.h"
+#include "http.h"
+#include "http_internal.h"
+
+struct http_connect_state {
+	struct tevent_context *ev;
+	const char *http_server;
+	const char *http_server_ip;
+	uint16_t http_port;
+	struct tsocket_address *local_address;
+	struct tsocket_address *remote_address;
+	struct cli_credentials *credentials;
+	struct tstream_tls_params *tls_params;
+
+	struct http_conn *http_conn;
+};
+
+static void http_connect_dns_done(struct tevent_req *subreq);
+static void http_connect_tcp_connect(struct tevent_req *req);
+static void http_connect_tcp_done(struct tevent_req *subreq);
+static void http_connect_tls_done(struct tevent_req *subreq);
+
+struct tevent_req *http_connect_send(TALLOC_CTX *mem_ctx,
+				     struct tevent_context *ev,
+				     const char *http_server,
+				     uint16_t http_port,
+				     struct cli_credentials *credentials,
+				     struct tstream_tls_params *tls_params)
+{
+	struct tevent_req *req = NULL;
+	struct tevent_req *subreq = NULL;
+	struct http_connect_state *state = NULL;
+	int ret;
+
+	DBG_DEBUG("Connecting to [%s] over HTTP%s\n",
+		  http_server, tls_params != NULL ? "S" : "");
+
+	req = tevent_req_create(mem_ctx, &state, struct http_connect_state);
+	if (req == NULL) {
+		return NULL;
+	}
+
+	*state = (struct http_connect_state) {
+		.ev = ev,
+		.http_port = http_port,
+		.credentials = credentials,
+		.tls_params = tls_params,
+	};
+
+	state->http_server = talloc_strdup(state, http_server);
+	if (tevent_req_nomem(state->http_server, req)) {
+		return tevent_req_post(req, ev);
+	}
+
+	state->http_conn = talloc_zero(state, struct http_conn);
+	if (tevent_req_nomem(state->http_conn, req)) {
+		return tevent_req_post(req, ev);
+	}
+
+	state->http_conn->send_queue = tevent_queue_create(state->http_conn,
+							   "HTTP send queue");
+	if (tevent_req_nomem(state->http_conn->send_queue, req)) {
+		return tevent_req_post(req, ev);
+	}
+
+	ret = tsocket_address_inet_from_strings(state,
+						"ip",
+						NULL,
+						0,
+						&state->local_address);
+	if (ret != 0) {
+		tevent_req_error(req, errno);
+		return tevent_req_post(req, ev);
+	}
+
+	if (!is_ipaddress(http_server)) {
+		subreq = dns_lookup_send(state,
+					 ev,
+					 NULL,
+					 http_server,
+					 DNS_QCLASS_IN,
+					 DNS_QTYPE_A);
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
+		}
+		tevent_req_set_callback(subreq, http_connect_dns_done, req);
+		return req;
+	}
+	state->http_server_ip = state->http_server;
+
+	http_connect_tcp_connect(req);
+	if (!tevent_req_is_in_progress(req)) {
+		return tevent_req_post(req, ev);
+	}
+
+	return req;
+}
+
+static void http_connect_dns_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct http_connect_state *state = tevent_req_data(
+		req, struct http_connect_state);
+	struct dns_name_packet *dns_reply = NULL;
+	struct dns_res_rec *an = NULL;
+	uint16_t i;
+	int ret;
+
+	ret = dns_lookup_recv(subreq, state, &dns_reply);
+	TALLOC_FREE(subreq);
+	if (ret != 0) {
+		tevent_req_error(req, ret);
+		return;
+	}
+
+	for (i = 0; i < dns_reply->ancount; i++) {
+		an = &dns_reply->answers[i];
+		if (an->rr_type == DNS_QTYPE_A) {
+			break;
+		}
+	}
+	if (i >= dns_reply->ancount) {
+		tevent_req_error(req, ENOENT);
+		return;
+	}
+
+	state->http_server_ip = talloc_strdup(state, an->rdata.ipv4_record);
+	if (tevent_req_nomem(state->http_server_ip, req)) {
+		return;
+	}
+
+	return http_connect_tcp_connect(req);
+}
+
+static void http_connect_tcp_connect(struct tevent_req *req)
+{
+	struct http_connect_state *state = tevent_req_data(
+		req, struct http_connect_state);
+	struct tevent_req *subreq = NULL;
+	int ret;
+
+	ret = tsocket_address_inet_from_strings(state,
+						"ip",
+						state->http_server_ip,
+						state->http_port,
+						&state->remote_address);
+	if (ret != 0) {
+		int saved_errno = errno;
+
+		DBG_ERR("Cannot create remote socket address, error: %s (%d)\n",
+			strerror(errno), errno);
+		tevent_req_error(req, saved_errno);
+		return;
+	}
+
+	subreq = tstream_inet_tcp_connect_send(state,
+					       state->ev,
+					       state->local_address,
+					       state->remote_address);
+	if (tevent_req_nomem(subreq, req)) {
+		return;
+	}
+	tevent_req_set_callback(subreq, http_connect_tcp_done, req);
+}
+
+static void http_connect_tcp_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct http_connect_state *state = tevent_req_data(
+		req, struct http_connect_state);
+	int error;
+	int ret;
+
+	ret = tstream_inet_tcp_connect_recv(subreq,
+					    &error,
+					    state->http_conn,
+					    &state->http_conn->tstreams.raw,
+					    NULL);
+	TALLOC_FREE(subreq);
+	if (ret != 0) {
+		tevent_req_error(req, error);
+		return;
+	}
+
+	state->http_conn->tstreams.active = state->http_conn->tstreams.raw;
+	DBG_DEBUG("Socket connected\n");
+
+	if (state->tls_params == NULL) {
+		tevent_req_done(req);
+		return;
+	}
+
+	DBG_DEBUG("Starting TLS\n");
+
+	subreq = tstream_tls_connect_send(state,
+					  state->ev,
+					  state->http_conn->tstreams.active,
+					  state->tls_params);
+	if (tevent_req_nomem(subreq, req)) {
+		return;
+	}
+	tevent_req_set_callback(subreq, http_connect_tls_done, req);
+}
+
+static void http_connect_tls_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct http_connect_state *state = tevent_req_data(
+		req, struct http_connect_state);
+	int error;
+	int ret;
+
+	ret = tstream_tls_connect_recv(subreq,
+				       &error,
+				       state->http_conn,
+				       &state->http_conn->tstreams.tls);
+	TALLOC_FREE(subreq);
+	if (ret != 0) {
+		tevent_req_error(req, error);
+		return;
+	}
+
+	state->http_conn->tstreams.active = state->http_conn->tstreams.tls;
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list