summaryrefslogtreecommitdiffstats
path: root/source4/smbd/service_stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/smbd/service_stream.c')
-rw-r--r--source4/smbd/service_stream.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index 916393253b..6e65122063 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -27,6 +27,7 @@
#include "cluster/cluster.h"
#include "param/param.h"
#include "../lib/tsocket/tsocket.h"
+#include "lib/util/util_net.h"
/* the range of ports to try for dcerpc over tcp endpoints */
#define SERVER_TCP_LOW_PORT 1024
@@ -122,7 +123,7 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev,
struct loadparm_context *lp_ctx,
const struct model_ops *model_ops,
const struct stream_server_ops *stream_ops,
- struct messaging_context *msg_ctx,
+ struct imessaging_context *msg_ctx,
void *private_data,
struct stream_connection **_srv_conn)
{
@@ -186,11 +187,11 @@ static void stream_new_connection(struct tevent_context *ev,
}
/* setup to receive internal messages on this connection */
- srv_conn->msg_ctx = messaging_init(srv_conn,
- lpcfg_messaging_path(srv_conn, lp_ctx),
+ srv_conn->msg_ctx = imessaging_init(srv_conn,
+ lpcfg_imessaging_path(srv_conn, lp_ctx),
srv_conn->server_id, ev);
if (!srv_conn->msg_ctx) {
- stream_terminate_connection(srv_conn, "messaging_init() failed");
+ stream_terminate_connection(srv_conn, "imessaging_init() failed");
return;
}
@@ -216,7 +217,7 @@ static void stream_new_connection(struct tevent_context *ev,
stream_socket->ops->name,
tsocket_address_string(srv_conn->remote_address, tmp_ctx),
tsocket_address_string(srv_conn->local_address, tmp_ctx),
- cluster_id_string(tmp_ctx, server_id));
+ server_id_str(tmp_ctx, &server_id));
if (title) {
stream_connection_set_title(srv_conn, title);
}
@@ -271,12 +272,34 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx,
struct socket_address *socket_address;
struct tevent_fd *fde;
int i;
+ struct sockaddr_storage ss;
stream_socket = talloc_zero(mem_ctx, struct stream_socket);
NT_STATUS_HAVE_NO_MEMORY(stream_socket);
- status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0);
- NT_STATUS_NOT_OK_RETURN(status);
+ if (strcmp(family, "ip") == 0) {
+ /* we will get the real family from the address itself */
+ if (!interpret_string_addr(&ss, sock_addr, 0)) {
+ talloc_free(stream_socket);
+ return NT_STATUS_INVALID_ADDRESS;
+ }
+
+ socket_address = socket_address_from_sockaddr_storage(stream_socket, &ss, port?*port:0);
+ NT_STATUS_HAVE_NO_MEMORY_AND_FREE(socket_address, stream_socket);
+
+ status = socket_create(socket_address->family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0);
+ NT_STATUS_NOT_OK_RETURN(status);
+ } else {
+ status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ /* this is for non-IP sockets, eg. unix domain sockets */
+ socket_address = socket_address_from_strings(stream_socket,
+ stream_socket->sock->backend_name,
+ sock_addr, port?*port:0);
+ NT_STATUS_HAVE_NO_MEMORY(socket_address);
+ }
+
talloc_steal(stream_socket, stream_socket->sock);
@@ -297,34 +320,19 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx,
/* Some sockets don't have a port, or are just described from
* the string. We are indicating this by having port == NULL */
if (!port) {
- socket_address = socket_address_from_strings(stream_socket,
- stream_socket->sock->backend_name,
- sock_addr, 0);
- NT_STATUS_HAVE_NO_MEMORY(socket_address);
status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0);
- talloc_free(socket_address);
-
} else if (*port == 0) {
for (i=SERVER_TCP_LOW_PORT;i<= SERVER_TCP_HIGH_PORT;i++) {
- socket_address = socket_address_from_strings(stream_socket,
- stream_socket->sock->backend_name,
- sock_addr, i);
- NT_STATUS_HAVE_NO_MEMORY(socket_address);
+ socket_address->port = i;
status = socket_listen(stream_socket->sock, socket_address,
SERVER_LISTEN_BACKLOG, 0);
- talloc_free(socket_address);
if (NT_STATUS_IS_OK(status)) {
*port = i;
break;
}
}
} else {
- socket_address = socket_address_from_strings(stream_socket,
- stream_socket->sock->backend_name,
- sock_addr, *port);
- NT_STATUS_HAVE_NO_MEMORY(socket_address);
status = socket_listen(stream_socket->sock, socket_address, SERVER_LISTEN_BACKLOG, 0);
- talloc_free(socket_address);
}
if (!NT_STATUS_IS_OK(status)) {
@@ -362,6 +370,7 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+
/*
setup a connection title
*/