summaryrefslogtreecommitdiff
path: root/source4/web_server/web_server.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-27 11:57:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:06 -0500
commitebb0b35242f5c2967afdba9e746679bc87c5b745 (patch)
tree9ebe0df98f2ab83dc595c84015879400b56184c2 /source4/web_server/web_server.c
parent631f9782a6f499b14aad035f1eee5b2aab18878c (diff)
downloadsamba-ebb0b35242f5c2967afdba9e746679bc87c5b745.tar.gz
samba-ebb0b35242f5c2967afdba9e746679bc87c5b745.tar.bz2
samba-ebb0b35242f5c2967afdba9e746679bc87c5b745.zip
r7013: added tls support to the builtin web server. It auto-detects if the client
is using tls by looking at the first byte on the connection. This allows both https and http services to be on the same port (This used to be commit 6369dfb6585ce4d4e3028c557395f2d73c290c92)
Diffstat (limited to 'source4/web_server/web_server.c')
-rw-r--r--source4/web_server/web_server.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c
index 9bbf423d29..faa30fc55f 100644
--- a/source4/web_server/web_server.c
+++ b/source4/web_server/web_server.c
@@ -68,7 +68,7 @@ static void websrv_recv(struct stream_connection *conn, uint16_t flags)
DATA_BLOB b;
/* not the most efficient http parser ever, but good enough for us */
- status = socket_recv(conn->socket, buf, sizeof(buf), &nread, 0);
+ status = tls_socket_recv(web, buf, sizeof(buf), &nread);
if (NT_STATUS_IS_ERR(status)) goto failed;
if (!NT_STATUS_IS_OK(status)) return;
@@ -128,7 +128,7 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags)
b.data += web->output.nsent;
b.length -= web->output.nsent;
- status = socket_send(conn->socket, &b, &nsent, 0);
+ status = tls_socket_send(web, &b, &nsent);
if (NT_STATUS_IS_ERR(status)) {
stream_terminate_connection(web->conn, "socket_send: failed");
return;
@@ -159,7 +159,8 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags)
web->output.content = data_blob_talloc(web, buf, nread);
}
- if (web->output.content.length == web->output.nsent) {
+ if (web->output.content.length == web->output.nsent &&
+ web->output.fd == -1) {
stream_terminate_connection(web->conn, NULL);
}
}
@@ -171,6 +172,7 @@ static void websrv_accept(struct stream_connection *conn)
{
struct task_server *task = talloc_get_type(conn->private, struct task_server);
struct websrv_context *web;
+ NTSTATUS status;
web = talloc_zero(conn, struct websrv_context);
if (web == NULL) goto failed;
@@ -184,6 +186,10 @@ static void websrv_accept(struct stream_connection *conn)
event_add_timed(conn->event.ctx, web,
timeval_current_ofs(HTTP_TIMEOUT, 0),
websrv_timeout, web);
+
+ status = tls_init_connection(web);
+ if (!NT_STATUS_IS_OK(status)) goto failed;
+
return;
failed:
@@ -235,6 +241,8 @@ static void websrv_task_init(struct task_server *task)
status = http_setup_esp(task);
if (!NT_STATUS_IS_OK(status)) goto failed;
+ tls_initialise(task);
+
return;
failed: