From f42402da83afa97f821d36b7974de98ddd5a2880 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 17 Oct 2004 05:07:07 +0000 Subject: r3013: added support for unix domain sockets in the generic socket library. I will shortly be using this for a rewrite of the intra-smbd messaging library, which is needed to get lock timeouts working properly (and share modes, oplocks etc) (This used to be commit 6f4926d846965a901e40d24546eab356c4a537c7) --- source4/lib/socket/socket_unix.c | 319 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 source4/lib/socket/socket_unix.c (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c new file mode 100644 index 0000000000..d87eaf49c4 --- /dev/null +++ b/source4/lib/socket/socket_unix.c @@ -0,0 +1,319 @@ +/* + Unix SMB/CIFS implementation. + + unix domain socket functions + + Copyright (C) Stefan Metzmacher 2004 + Copyright (C) Andrew Tridgell 2004 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +static NTSTATUS unixdom_init(struct socket_context *sock) +{ + sock->fd = socket(PF_UNIX, SOCK_STREAM, 0); + if (sock->fd == -1) { + return NT_STATUS_INSUFFICIENT_RESOURCES; + } + + return NT_STATUS_OK; +} + +static void unixdom_close(struct socket_context *sock) +{ + close(sock->fd); +} + +static NTSTATUS unixdom_connect(struct socket_context *sock, + const char *my_address, int my_port, + const char *srv_address, int srv_port, + uint32_t flags) +{ + struct sockaddr_un srv_addr; + int ret; + + if (strlen(srv_address)+1 > sizeof(srv_addr.sun_path)) { + return NT_STATUS_INVALID_PARAMETER; + } + + ZERO_STRUCT(srv_addr); + srv_addr.sun_family = AF_UNIX; + strncpy(srv_addr.sun_path, srv_address, sizeof(srv_addr.sun_path)); + + if (!(flags & SOCKET_FLAG_BLOCK)) { + ret = set_blocking(sock->fd, False); + if (ret == -1) { + return NT_STATUS_INVALID_PARAMETER; + } + } + + ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr)); + if (ret == -1) { + return NT_STATUS_CONNECTION_REFUSED; + } + + sock->state = SOCKET_STATE_CLIENT_CONNECTED; + + return NT_STATUS_OK; +} + +static NTSTATUS unixdom_listen(struct socket_context *sock, + const char *my_address, int port, + int queue_size, uint32_t flags) +{ + struct sockaddr_un my_addr; + int ret; + + if (strlen(my_address)+1 > sizeof(my_addr.sun_path)) { + return NT_STATUS_INVALID_PARAMETER; + } + + ZERO_STRUCT(my_addr); + my_addr.sun_family = AF_UNIX; + strncpy(my_addr.sun_path, my_address, sizeof(my_addr.sun_path)); + + ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); + if (ret == -1) { + return NT_STATUS_UNSUCCESSFUL; + } + + ret = listen(sock->fd, queue_size); + if (ret == -1) { + return NT_STATUS_INSUFFICIENT_RESOURCES; + } + + if (!(flags & SOCKET_FLAG_BLOCK)) { + ret = set_blocking(sock->fd, False); + if (ret == -1) { + return NT_STATUS_INVALID_PARAMETER; + } + } + + sock->state = SOCKET_STATE_SERVER_LISTEN; + + return NT_STATUS_OK; +} + +static NTSTATUS unixdom_accept(struct socket_context *sock, + struct socket_context **new_sock, + uint32_t flags) +{ + struct sockaddr_un cli_addr; + socklen_t cli_addr_len = sizeof(cli_addr); + int new_fd; + + new_fd = accept(sock->fd, (struct sockaddr *)&cli_addr, &cli_addr_len); + if (new_fd == -1) { + return NT_STATUS_INSUFFICIENT_RESOURCES; + } + + (*new_sock) = talloc_p(NULL, struct socket_context); + if (!(*new_sock)) { + close(new_fd); + return NT_STATUS_NO_MEMORY; + } + + /* copy the socket_context */ + (*new_sock)->type = sock->type; + (*new_sock)->state = SOCKET_STATE_SERVER_CONNECTED; + (*new_sock)->flags = flags; + + (*new_sock)->fd = new_fd; + + (*new_sock)->private_data = NULL; + (*new_sock)->ops = sock->ops; + + return NT_STATUS_OK; +} + +static NTSTATUS unixdom_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx, + DATA_BLOB *blob, size_t wantlen, uint32_t flags) +{ + ssize_t gotlen; + void *buf; + int flgs = 0; + + buf = talloc(mem_ctx, wantlen); + if (!buf) { + return NT_STATUS_NO_MEMORY; + } + + /* TODO: we need to map all flags here */ + if (flags & SOCKET_FLAG_PEEK) { + flgs |= MSG_PEEK; + } + + if (!(flags & SOCKET_FLAG_BLOCK)) { + flgs |= MSG_DONTWAIT; + } + + if (flags & SOCKET_FLAG_BLOCK) { + flgs |= MSG_WAITALL; + } + + gotlen = recv(sock->fd, buf, wantlen, flgs); + if (gotlen == 0) { + talloc_free(buf); + return NT_STATUS_END_OF_FILE; + } else if (gotlen == -1) { + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + switch (errno) { + case EBADF: + case ENOTCONN: + case ENOTSOCK: + case EFAULT: + case EINVAL: + status = NT_STATUS_INVALID_PARAMETER; + break; + case EAGAIN: + case EINTR: + status = STATUS_MORE_ENTRIES; + break; + case ECONNREFUSED: + status = NT_STATUS_CONNECTION_REFUSED; + break; + } + talloc_free(buf); + return status; + } + + blob->length = gotlen; + blob->data = talloc_realloc(mem_ctx, buf, gotlen); + if (!blob->data) { + return NT_STATUS_NO_MEMORY; + } + + return NT_STATUS_OK; +} + +static NTSTATUS unixdom_send(struct socket_context *sock, TALLOC_CTX *mem_ctx, + const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) +{ + ssize_t len; + int flgs = 0; + + /* TODO: we need to map all flags here */ + if (!(flags & SOCKET_FLAG_BLOCK)) { + flgs |= MSG_DONTWAIT; + } + + len = send(sock->fd, blob->data, blob->length, flgs); + if (len == -1) { + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + switch (errno) { + case EBADF: + case ENOTSOCK: + case EFAULT: + case EINVAL: + status = NT_STATUS_INVALID_PARAMETER; + break; + case EMSGSIZE: + status = NT_STATUS_INVALID_BUFFER_SIZE; + break; + case EAGAIN: + /*case EWOULDBLOCK: this is an alis of EAGAIN --metze */ + case EINTR: + *sendlen = 0; + status = STATUS_MORE_ENTRIES; + break; + case ENOBUFS: + status = NT_STATUS_FOOBAR; + break; + case ENOMEM: + status = NT_STATUS_NO_MEMORY; + break; + case EPIPE: + status = NT_STATUS_CONNECTION_DISCONNECTED; + break; + } + return status; + } + + *sendlen = len; + + return NT_STATUS_OK; +} + +static NTSTATUS unixdom_set_option(struct socket_context *sock, + const char *option, const char *val) +{ + set_socket_options(sock->fd, option); + return NT_STATUS_OK; +} + +static char *unixdom_get_peer_name(struct socket_context *sock, TALLOC_CTX *mem_ctx) +{ + return talloc_strdup(mem_ctx, "LOCAL/unixdom"); +} + +static char *unixdom_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) +{ + return talloc_strdup(mem_ctx, "LOCAL/unixdom"); +} + +static int unixdom_get_peer_port(struct socket_context *sock) +{ + return 0; +} + +static char *unixdom_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) +{ + return talloc_strdup(mem_ctx, "LOCAL/unixdom"); +} + +static int unixdom_get_my_port(struct socket_context *sock) +{ + return 0; +} + +static int unixdom_get_fd(struct socket_context *sock) +{ + return sock->fd; +} + +static const struct socket_ops unixdom_ops = { + .name = "unix", + .type = SOCKET_TYPE_STREAM, + + .init = unixdom_init, + .connect = unixdom_connect, + .listen = unixdom_listen, + .accept = unixdom_accept, + .recv = unixdom_recv, + .send = unixdom_send, + .close = unixdom_close, + + .set_option = unixdom_set_option, + + .get_peer_name = unixdom_get_peer_name, + .get_peer_addr = unixdom_get_peer_addr, + .get_peer_port = unixdom_get_peer_port, + .get_my_addr = unixdom_get_my_addr, + .get_my_port = unixdom_get_my_port, + + .get_fd = unixdom_get_fd +}; + +const struct socket_ops *socket_unixdom_ops(void) +{ + return &unixdom_ops; +} + +NTSTATUS socket_unixdom_init(void) +{ + return NT_STATUS_OK; +} -- cgit From 6591a226144d371a6b68fc5e7201a90a77dc9153 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 17 Oct 2004 10:04:49 +0000 Subject: r3016: - converted the events code to talloc - added the new messaging system, based on unix domain sockets. It gets over 10k messages/second on my laptop without any socket cacheing, which is better than I expected. - added a LOCAL-MESSAGING torture test (This used to be commit 3af06478da7ab34a272226d8d9ac87e0a4940cfb) --- source4/lib/socket/socket_unix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index d87eaf49c4..7e169c47a7 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -29,6 +29,7 @@ static NTSTATUS unixdom_init(struct socket_context *sock) if (sock->fd == -1) { return NT_STATUS_INSUFFICIENT_RESOURCES; } + sock->private_data = NULL; return NT_STATUS_OK; } @@ -36,6 +37,11 @@ static NTSTATUS unixdom_init(struct socket_context *sock) static void unixdom_close(struct socket_context *sock) { close(sock->fd); + /* if we were listening, then don't leave the socket lying + around in the filesystem */ + if (sock->private_data) { + unlink((const char *)sock->private_data); + } } static NTSTATUS unixdom_connect(struct socket_context *sock, @@ -82,6 +88,9 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, return NT_STATUS_INVALID_PARAMETER; } + /* delete if it already exists */ + unlink(my_address); + ZERO_STRUCT(my_addr); my_addr.sun_family = AF_UNIX; strncpy(my_addr.sun_path, my_address, sizeof(my_addr.sun_path)); @@ -104,6 +113,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, } sock->state = SOCKET_STATE_SERVER_LISTEN; + sock->private_data = (void *)talloc_strdup(sock, my_address); return NT_STATUS_OK; } -- cgit From b071fe60d7c819935064d9b3c66cbf8b6696e4f8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 17 Oct 2004 13:21:24 +0000 Subject: r3020: better error handling in socket_unix (This used to be commit 64514ff5b7734667a1364de925114091fe208b3a) --- source4/lib/socket/socket_unix.c | 93 +++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 50 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 7e169c47a7..1735c931b8 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -23,6 +23,40 @@ #include "includes.h" + + +/* + approximate errno mapping +*/ +static NTSTATUS unixdom_error(int ernum) +{ + switch (ernum) { + case EBADF: + case ENOTCONN: + case ENOTSOCK: + case EFAULT: + case EINVAL: + return NT_STATUS_INVALID_PARAMETER; + case EAGAIN: + case EINTR: + return STATUS_MORE_ENTRIES; + case ECONNREFUSED: + return NT_STATUS_CONNECTION_REFUSED; + case ENOBUFS: + case ENOMEM: + return NT_STATUS_NO_MEMORY; + case ENFILE: + case EMFILE: + return NT_STATUS_INSUFFICIENT_RESOURCES; + case EPIPE: + return NT_STATUS_CONNECTION_DISCONNECTED; + case EMSGSIZE: + return NT_STATUS_INVALID_BUFFER_SIZE; + } + + return NT_STATUS_UNSUCCESSFUL; +} + static NTSTATUS unixdom_init(struct socket_context *sock) { sock->fd = socket(PF_UNIX, SOCK_STREAM, 0); @@ -69,7 +103,7 @@ static NTSTATUS unixdom_connect(struct socket_context *sock, ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr)); if (ret == -1) { - return NT_STATUS_CONNECTION_REFUSED; + return unixdom_error(errno); } sock->state = SOCKET_STATE_CLIENT_CONNECTED; @@ -97,18 +131,18 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); if (ret == -1) { - return NT_STATUS_UNSUCCESSFUL; + return unixdom_error(errno); } ret = listen(sock->fd, queue_size); if (ret == -1) { - return NT_STATUS_INSUFFICIENT_RESOURCES; + return unixdom_error(errno); } if (!(flags & SOCKET_FLAG_BLOCK)) { ret = set_blocking(sock->fd, False); if (ret == -1) { - return NT_STATUS_INVALID_PARAMETER; + return unixdom_error(errno); } } @@ -128,7 +162,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, new_fd = accept(sock->fd, (struct sockaddr *)&cli_addr, &cli_addr_len); if (new_fd == -1) { - return NT_STATUS_INSUFFICIENT_RESOURCES; + return unixdom_error(errno); } (*new_sock) = talloc_p(NULL, struct socket_context); @@ -180,23 +214,7 @@ static NTSTATUS unixdom_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx, talloc_free(buf); return NT_STATUS_END_OF_FILE; } else if (gotlen == -1) { - NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - switch (errno) { - case EBADF: - case ENOTCONN: - case ENOTSOCK: - case EFAULT: - case EINVAL: - status = NT_STATUS_INVALID_PARAMETER; - break; - case EAGAIN: - case EINTR: - status = STATUS_MORE_ENTRIES; - break; - case ECONNREFUSED: - status = NT_STATUS_CONNECTION_REFUSED; - break; - } + NTSTATUS status = unixdom_error(errno); talloc_free(buf); return status; } @@ -216,6 +234,8 @@ static NTSTATUS unixdom_send(struct socket_context *sock, TALLOC_CTX *mem_ctx, ssize_t len; int flgs = 0; + *sendlen = 0; + /* TODO: we need to map all flags here */ if (!(flags & SOCKET_FLAG_BLOCK)) { flgs |= MSG_DONTWAIT; @@ -223,34 +243,7 @@ static NTSTATUS unixdom_send(struct socket_context *sock, TALLOC_CTX *mem_ctx, len = send(sock->fd, blob->data, blob->length, flgs); if (len == -1) { - NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - switch (errno) { - case EBADF: - case ENOTSOCK: - case EFAULT: - case EINVAL: - status = NT_STATUS_INVALID_PARAMETER; - break; - case EMSGSIZE: - status = NT_STATUS_INVALID_BUFFER_SIZE; - break; - case EAGAIN: - /*case EWOULDBLOCK: this is an alis of EAGAIN --metze */ - case EINTR: - *sendlen = 0; - status = STATUS_MORE_ENTRIES; - break; - case ENOBUFS: - status = NT_STATUS_FOOBAR; - break; - case ENOMEM: - status = NT_STATUS_NO_MEMORY; - break; - case EPIPE: - status = NT_STATUS_CONNECTION_DISCONNECTED; - break; - } - return status; + return unixdom_error(errno); } *sendlen = len; -- cgit From d164190debf9499ffa6dbf46ee24fa98da36c14f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 24 Oct 2004 23:30:47 +0000 Subject: r3169: unlink() is called on the listening unix socket every time a child process exits. Commenting it out until we have a clean way of doing this. (This used to be commit fa0760dd5fa361be3b72dc4adc8b736e8a862606) --- source4/lib/socket/socket_unix.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 1735c931b8..038ce3b3b6 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -73,9 +73,13 @@ static void unixdom_close(struct socket_context *sock) close(sock->fd); /* if we were listening, then don't leave the socket lying around in the filesystem */ + +#if 0 + /* FIXME - this doesn't work after fork(), etc */ if (sock->private_data) { unlink((const char *)sock->private_data); } +#endif } static NTSTATUS unixdom_connect(struct socket_context *sock, -- cgit From 75ed4f7cc4d39b85cf6dba040cbf188fac3ed464 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Oct 2004 03:30:39 +0000 Subject: r3183: moved the unlink of the messaging unixdom socket to the messaging destructor (This used to be commit ab222b236a091d31b1f5f2cba150a11585ab5836) --- source4/lib/socket/socket_unix.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 038ce3b3b6..df929d92b4 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -71,15 +71,6 @@ static NTSTATUS unixdom_init(struct socket_context *sock) static void unixdom_close(struct socket_context *sock) { close(sock->fd); - /* if we were listening, then don't leave the socket lying - around in the filesystem */ - -#if 0 - /* FIXME - this doesn't work after fork(), etc */ - if (sock->private_data) { - unlink((const char *)sock->private_data); - } -#endif } static NTSTATUS unixdom_connect(struct socket_context *sock, -- cgit From 6b280c130002f8b24b2e6ff7edeaa52629e5388a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Oct 2004 03:36:00 +0000 Subject: r3184: don't setup socket options on unix domain sockets (our smb.conf socket options are really meant for tcp) (This used to be commit 238febb0088f85933c869052f4f83ff31f164df1) --- source4/lib/socket/socket_unix.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index df929d92b4..d75bb973fc 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -249,7 +249,6 @@ static NTSTATUS unixdom_send(struct socket_context *sock, TALLOC_CTX *mem_ctx, static NTSTATUS unixdom_set_option(struct socket_context *sock, const char *option, const char *val) { - set_socket_options(sock->fd, option); return NT_STATUS_OK; } -- cgit From 9d055846f225bea4953822f40fab1d2f1a2e2d07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 27 Oct 2004 03:15:42 +0000 Subject: r3278: - rewrote the client side rpc connection code to use lib/socket/ rather than doing everything itself. This greatly simplifies the code, although I really don't like the socket_recv() interface (it always allocates memory for you, which means an extra memcpy in this code) - fixed several bugs in the socket_ipv4.c code, in particular client side code used a non-blocking connect but didn't handle EINPROGRESS, so it had no chance of working. Also fixed the error codes, using map_nt_error_from_unix() - cleaned up and expanded map_nt_error_from_unix() - changed interpret_addr2() to not take a mem_ctx. It makes absolutely no sense to allocate a fixed size 4 byte structure like this. Dozens of places in the code were also using interpret_addr2() incorrectly (precisely because the allocation made no sense) (This used to be commit 7f2c771b0e0e98c5c9e5cf662592d64d34ff1205) --- source4/lib/socket/socket_unix.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index d75bb973fc..90802eae66 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -30,31 +30,7 @@ */ static NTSTATUS unixdom_error(int ernum) { - switch (ernum) { - case EBADF: - case ENOTCONN: - case ENOTSOCK: - case EFAULT: - case EINVAL: - return NT_STATUS_INVALID_PARAMETER; - case EAGAIN: - case EINTR: - return STATUS_MORE_ENTRIES; - case ECONNREFUSED: - return NT_STATUS_CONNECTION_REFUSED; - case ENOBUFS: - case ENOMEM: - return NT_STATUS_NO_MEMORY; - case ENFILE: - case EMFILE: - return NT_STATUS_INSUFFICIENT_RESOURCES; - case EPIPE: - return NT_STATUS_CONNECTION_DISCONNECTED; - case EMSGSIZE: - return NT_STATUS_INVALID_BUFFER_SIZE; - } - - return NT_STATUS_UNSUCCESSFUL; + return map_nt_error_from_unix(ernum); } static NTSTATUS unixdom_init(struct socket_context *sock) -- cgit From 1f6fd130a35e4068ac7caa164b89516319c3d276 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 27 Oct 2004 03:45:35 +0000 Subject: r3279: Removed MSG_DONTWAIT flags as many platform don't have it. If a socket is non-blocking then adding MSG_DONTWAIT is pointless (it does nothing), so all we lose is the ability to set non-blocking on a packet-by-packet basis, which is not a very useful thing to have anyway if the socket is blocking then the code already adds MSG_WAITALL, so MSG_DONTWAIT is also not needed in that case. (This used to be commit b8a2afae67691a609b4a7a577fee3f9518adc9d2) --- source4/lib/socket/socket_unix.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 90802eae66..eda1597df7 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -172,10 +172,6 @@ static NTSTATUS unixdom_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx, flgs |= MSG_PEEK; } - if (!(flags & SOCKET_FLAG_BLOCK)) { - flgs |= MSG_DONTWAIT; - } - if (flags & SOCKET_FLAG_BLOCK) { flgs |= MSG_WAITALL; } @@ -207,11 +203,6 @@ static NTSTATUS unixdom_send(struct socket_context *sock, TALLOC_CTX *mem_ctx, *sendlen = 0; - /* TODO: we need to map all flags here */ - if (!(flags & SOCKET_FLAG_BLOCK)) { - flgs |= MSG_DONTWAIT; - } - len = send(sock->fd, blob->data, blob->length, flgs); if (len == -1) { return unixdom_error(errno); -- cgit From c6888da1487ab301292c3d4d05d0464833f3ce57 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 04:00:43 +0000 Subject: r3304: changed the API to lib/socket/ a little. The main change is to make socket_recv() take a pre-allocated buffer, rather than allocating one itself. This allows non-blocking users of this API to avoid a memcpy(). As a result our messaging code is now about 10% faster, and the ncacn_ip_tcp and ncalrpc code is also faster. The second change was to remove the unused mem_ctx argument from socket_send(). Having it there implied that memory could be allocated, which meant the caller had to worry about freeing that memory (if for example it is sending in a tight loop using the same memory context). Removing that unused argument keeps life simpler for users. (This used to be commit a16e4756cd68ca8aab4ffc59d4d9db0b6e44dbd1) --- source4/lib/socket/socket_unix.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index eda1597df7..3a3ce5fe8a 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -155,18 +155,12 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, return NT_STATUS_OK; } -static NTSTATUS unixdom_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx, - DATA_BLOB *blob, size_t wantlen, uint32_t flags) +static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf, + size_t wantlen, size_t *nread, uint32_t flags) { ssize_t gotlen; - void *buf; int flgs = 0; - buf = talloc(mem_ctx, wantlen); - if (!buf) { - return NT_STATUS_NO_MEMORY; - } - /* TODO: we need to map all flags here */ if (flags & SOCKET_FLAG_PEEK) { flgs |= MSG_PEEK; @@ -176,26 +170,21 @@ static NTSTATUS unixdom_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx, flgs |= MSG_WAITALL; } + *nread = 0; + gotlen = recv(sock->fd, buf, wantlen, flgs); if (gotlen == 0) { - talloc_free(buf); return NT_STATUS_END_OF_FILE; } else if (gotlen == -1) { - NTSTATUS status = unixdom_error(errno); - talloc_free(buf); - return status; + return unixdom_error(errno); } - blob->length = gotlen; - blob->data = talloc_realloc(mem_ctx, buf, gotlen); - if (!blob->data) { - return NT_STATUS_NO_MEMORY; - } + *nread = gotlen; return NT_STATUS_OK; } -static NTSTATUS unixdom_send(struct socket_context *sock, TALLOC_CTX *mem_ctx, +static NTSTATUS unixdom_send(struct socket_context *sock, const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) { ssize_t len; -- cgit From 34cd0662f0340720fa45dd16c82496cd76e92268 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 07:34:11 +0000 Subject: r3313: in socket_accept() make the new socket non-blocking unless SOCKET_FLAG_BLOCK is set. (This used to be commit a2d92aa431e0e9752387eebe741d9e6f376f74d7) --- source4/lib/socket/socket_unix.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 3a3ce5fe8a..239e4eb069 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -136,6 +136,14 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, return unixdom_error(errno); } + if (!(flags & SOCKET_FLAG_BLOCK)) { + int ret = set_blocking(new_fd, False); + if (ret == -1) { + close(new_fd); + return map_nt_error_from_unix(errno); + } + } + (*new_sock) = talloc_p(NULL, struct socket_context); if (!(*new_sock)) { close(new_fd); -- cgit From 990d76f7cbd4339c30f650781c40463234fc47e1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 07:55:33 +0000 Subject: r3314: added a option "socket:testnonblock" to the generic socket code. If you set this option (either on the command line using --option or in smb.conf) then every socket recv or send will return short by random amounts. This allows you to test that the non-blocking socket logic in your code works correctly. I also removed the flags argument to socket_accept(), and instead made the new socket inherit the flags of the old socket, which makes more sense to me. (This used to be commit 406d356e698da01c84e8aa5b7894752b4403f63c) --- source4/lib/socket/socket_unix.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 239e4eb069..d160d897ee 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -124,8 +124,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, } static NTSTATUS unixdom_accept(struct socket_context *sock, - struct socket_context **new_sock, - uint32_t flags) + struct socket_context **new_sock) { struct sockaddr_un cli_addr; socklen_t cli_addr_len = sizeof(cli_addr); @@ -136,7 +135,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, return unixdom_error(errno); } - if (!(flags & SOCKET_FLAG_BLOCK)) { + if (!(sock->flags & SOCKET_FLAG_BLOCK)) { int ret = set_blocking(new_fd, False); if (ret == -1) { close(new_fd); @@ -153,7 +152,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, /* copy the socket_context */ (*new_sock)->type = sock->type; (*new_sock)->state = SOCKET_STATE_SERVER_CONNECTED; - (*new_sock)->flags = flags; + (*new_sock)->flags = sock->flags; (*new_sock)->fd = new_fd; -- cgit From 452ddd94ba22bebe0fda5ee6a7ddceae2057fe40 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 02:01:04 +0000 Subject: r3450: portability fixes - fix rep_inet_ntoa() for IRIX - lib/signal.c needs system/wait.h - some systems define a macro "accept", which breaks the lib/socket/ structures. use fn_ as a prefix for the structure elements to avoid the problem (This used to be commit ced1a0fcdc8d8e47755ce4391c19f8b12862eb60) --- source4/lib/socket/socket_unix.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index d160d897ee..f09573802a 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -246,26 +246,26 @@ static int unixdom_get_fd(struct socket_context *sock) } static const struct socket_ops unixdom_ops = { - .name = "unix", - .type = SOCKET_TYPE_STREAM, - - .init = unixdom_init, - .connect = unixdom_connect, - .listen = unixdom_listen, - .accept = unixdom_accept, - .recv = unixdom_recv, - .send = unixdom_send, - .close = unixdom_close, - - .set_option = unixdom_set_option, - - .get_peer_name = unixdom_get_peer_name, - .get_peer_addr = unixdom_get_peer_addr, - .get_peer_port = unixdom_get_peer_port, - .get_my_addr = unixdom_get_my_addr, - .get_my_port = unixdom_get_my_port, - - .get_fd = unixdom_get_fd + .name = "unix", + .type = SOCKET_TYPE_STREAM, + + .fn_init = unixdom_init, + .fn_connect = unixdom_connect, + .fn_listen = unixdom_listen, + .fn_accept = unixdom_accept, + .fn_recv = unixdom_recv, + .fn_send = unixdom_send, + .fn_close = unixdom_close, + + .fn_set_option = unixdom_set_option, + + .fn_get_peer_name = unixdom_get_peer_name, + .fn_get_peer_addr = unixdom_get_peer_addr, + .fn_get_peer_port = unixdom_get_peer_port, + .fn_get_my_addr = unixdom_get_my_addr, + .fn_get_my_port = unixdom_get_my_port, + + .fn_get_fd = unixdom_get_fd }; const struct socket_ops *socket_unixdom_ops(void) -- cgit From e8e94a93b554d357c577850c4abf85d942333bec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 12:43:25 +0000 Subject: r3482: fixed a warning and an error from the IRIX 6.4 build (This used to be commit 8ec3cf8b2ba149b7d6a15689e9b77685c6da3179) --- source4/lib/socket/socket_unix.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index f09573802a..0ba4797219 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "system/network.h" -- cgit From 71db46ea665606384f2be1be708c74c97c9adfb2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Nov 2004 23:23:15 +0000 Subject: r3586: Fix some of the issues with the module init functions. Both subsystems and modules can now have init functions, which can be specified in .mk files (INIT_FUNCTION = ...) The build system will define : - SUBSYSTEM_init_static_modules that calls the init functions of all statically compiled modules. Failing to load will generate an error which is not fatal - BINARY_init_subsystems that calls the init functions (if defined) for the subsystems the binary depends on This removes the hack with the "static bool Initialised = " and the "lazy_init" functions (This used to be commit 7a8244761bfdfdfb48f8264d76951ebdfbf7bd8a) --- source4/lib/socket/socket_unix.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 0ba4797219..e35453e6e0 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -273,8 +273,3 @@ const struct socket_ops *socket_unixdom_ops(void) { return &unixdom_ops; } - -NTSTATUS socket_unixdom_init(void) -{ - return NT_STATUS_OK; -} -- cgit From 21aafc3536cb8a172805f0dd5d23b100f1ecb493 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Jan 2005 10:28:08 +0000 Subject: r4753: added the ability for the generic socket library to handle async connect(). This required a small API change (the addition of a socket_connect_complete() method) (This used to be commit b787dd166f5cca82b3710802eefb41e0a8851fc3) --- source4/lib/socket/socket_unix.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index e35453e6e0..60a4b9ec48 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -50,6 +50,33 @@ static void unixdom_close(struct socket_context *sock) close(sock->fd); } +static NTSTATUS unixdom_connect_complete(struct socket_context *sock, uint32_t flags) +{ + int error=0, ret; + socklen_t len = sizeof(error); + + /* check for any errors that may have occurred - this is needed + for non-blocking connect */ + ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &error, &len); + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + if (error != 0) { + return map_nt_error_from_unix(error); + } + + if (!(flags & SOCKET_FLAG_BLOCK)) { + ret = set_blocking(sock->fd, False); + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + } + + sock->state = SOCKET_STATE_CLIENT_CONNECTED; + + return NT_STATUS_OK; +} + static NTSTATUS unixdom_connect(struct socket_context *sock, const char *my_address, int my_port, const char *srv_address, int srv_port, @@ -66,21 +93,12 @@ static NTSTATUS unixdom_connect(struct socket_context *sock, srv_addr.sun_family = AF_UNIX; strncpy(srv_addr.sun_path, srv_address, sizeof(srv_addr.sun_path)); - if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, False); - if (ret == -1) { - return NT_STATUS_INVALID_PARAMETER; - } - } - ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr)); if (ret == -1) { return unixdom_error(errno); } - sock->state = SOCKET_STATE_CLIENT_CONNECTED; - - return NT_STATUS_OK; + return unixdom_connect_complete(sock, flags); } static NTSTATUS unixdom_listen(struct socket_context *sock, @@ -252,6 +270,7 @@ static const struct socket_ops unixdom_ops = { .fn_init = unixdom_init, .fn_connect = unixdom_connect, + .fn_connect_complete = unixdom_connect_complete, .fn_listen = unixdom_listen, .fn_accept = unixdom_accept, .fn_recv = unixdom_recv, -- cgit From 8783aa8ea57c3a6989e0722d5184e98d543352d4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 19 Jan 2005 03:20:20 +0000 Subject: r4831: added udp support to our generic sockets library. I decided to incorporate the udp support into the socket_ipv4.c backend (and later in socket_ipv6.c) rather than doing a separate backend, as so much of the code is shareable. Basically this adds a socket_sendto() and a socket_recvfrom() call and not much all. For udp servers, I decided to keep the call as socket_listen(), even though dgram servers don't actually call listen(). This keeps the API consistent. I also added a simple local sockets testsuite in smbtorture, LOCAL-SOCKET (This used to be commit 9f12a45a05c5c447fb4ec18c8dd28f70e90e32a5) --- source4/lib/socket/socket_unix.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 60a4b9ec48..bdd68f9d9d 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -4,7 +4,7 @@ unix domain socket functions Copyright (C) Stefan Metzmacher 2004 - Copyright (C) Andrew Tridgell 2004 + Copyright (C) Andrew Tridgell 2004-2005 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 @@ -266,8 +266,6 @@ static int unixdom_get_fd(struct socket_context *sock) static const struct socket_ops unixdom_ops = { .name = "unix", - .type = SOCKET_TYPE_STREAM, - .fn_init = unixdom_init, .fn_connect = unixdom_connect, .fn_connect_complete = unixdom_connect_complete, @@ -288,7 +286,10 @@ static const struct socket_ops unixdom_ops = { .fn_get_fd = unixdom_get_fd }; -const struct socket_ops *socket_unixdom_ops(void) +const struct socket_ops *socket_unixdom_ops(enum socket_type type) { + if (type != SOCKET_TYPE_STREAM) { + return NULL; + } return &unixdom_ops; } -- cgit From 759da3b915e2006d4c87b5ace47f399accd9ce91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 07:08:20 +0000 Subject: r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the large commit. I thought this was worthwhile to get done for consistency. (This used to be commit ec32b22ed5ec224f6324f5e069d15e92e38e15c0) --- source4/lib/socket/socket_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index bdd68f9d9d..e23aa0d97e 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -162,7 +162,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, } } - (*new_sock) = talloc_p(NULL, struct socket_context); + (*new_sock) = talloc(NULL, struct socket_context); if (!(*new_sock)) { close(new_fd); return NT_STATUS_NO_MEMORY; -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/lib/socket/socket_unix.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index e23aa0d97e..2bcce0eb11 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -23,6 +23,7 @@ #include "includes.h" #include "system/network.h" +#include "system/filesys.h" -- cgit From bed7c9ec32b7d4083ba4ed2abbf3b6126bee7a25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 06:59:29 +0000 Subject: r5304: removed lib/socket/socket.h from includes.h (This used to be commit b902ea546d2d1327b23f40ddaeeaa8e7e3662454) --- source4/lib/socket/socket_unix.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 2bcce0eb11..7cf12db4b2 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -22,6 +22,8 @@ */ #include "includes.h" +#include "lib/socket/socket.h" +#include "lib/socket/socket.h" #include "system/network.h" #include "system/filesys.h" -- cgit From 5ae38fb963cf1907043129b4d423c7bc8fe18fb1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 26 Mar 2005 01:08:59 +0000 Subject: r6070: Fix typo's and fallback to "" as default user name if no other username could be guessed. (This used to be commit 7fe77cd65901776b5a78e8398547f364379259d3) --- source4/lib/socket/socket_unix.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 7cf12db4b2..614229aaac 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -23,7 +23,6 @@ #include "includes.h" #include "lib/socket/socket.h" -#include "lib/socket/socket.h" #include "system/network.h" #include "system/filesys.h" -- cgit From b2584a403c6382ef478755979d955043fc9569a1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 1 May 2005 18:49:43 +0000 Subject: r6562: added support for datagram unix domain sockets in the socket library (This used to be commit 23b2046dcb5c4593cba6964f400a2e5246fb35f7) --- source4/lib/socket/socket_unix.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 614229aaac..3f265f7214 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -38,9 +38,22 @@ static NTSTATUS unixdom_error(int ernum) static NTSTATUS unixdom_init(struct socket_context *sock) { - sock->fd = socket(PF_UNIX, SOCK_STREAM, 0); + int type; + + switch (sock->type) { + case SOCKET_TYPE_STREAM: + type = SOCK_STREAM; + break; + case SOCKET_TYPE_DGRAM: + type = SOCK_DGRAM; + break; + default: + return NT_STATUS_INVALID_PARAMETER; + } + + sock->fd = socket(PF_UNIX, type, 0); if (sock->fd == -1) { - return NT_STATUS_INSUFFICIENT_RESOURCES; + return map_nt_error_from_unix(errno); } sock->private_data = NULL; @@ -126,9 +139,11 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, return unixdom_error(errno); } - ret = listen(sock->fd, queue_size); - if (ret == -1) { - return unixdom_error(errno); + if (sock->type == SOCKET_TYPE_STREAM) { + ret = listen(sock->fd, queue_size); + if (ret == -1) { + return unixdom_error(errno); + } } if (!(flags & SOCKET_FLAG_BLOCK)) { @@ -151,6 +166,10 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, socklen_t cli_addr_len = sizeof(cli_addr); int new_fd; + if (sock->type != SOCKET_TYPE_STREAM) { + return NT_STATUS_INVALID_PARAMETER; + } + new_fd = accept(sock->fd, (struct sockaddr *)&cli_addr, &cli_addr_len); if (new_fd == -1) { return unixdom_error(errno); @@ -290,8 +309,5 @@ static const struct socket_ops unixdom_ops = { const struct socket_ops *socket_unixdom_ops(enum socket_type type) { - if (type != SOCKET_TYPE_STREAM) { - return NULL; - } return &unixdom_ops; } -- cgit From e83b74244d9e5bc8dee202b86fb3ec192fe93185 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Jun 2005 04:19:32 +0000 Subject: r7205: added support for sendto() on unix domain sockets (This used to be commit 35ef6e3b153f527f79539b2d99c5ff1cd034ba4b) --- source4/lib/socket/socket_unix.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 3f265f7214..04ba89578f 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -249,6 +249,37 @@ static NTSTATUS unixdom_send(struct socket_context *sock, return NT_STATUS_OK; } + +static NTSTATUS unixdom_sendto(struct socket_context *sock, + const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, + const char *dest_addr, int dest_port) +{ + ssize_t len; + int flgs = 0; + struct sockaddr_un srv_addr; + + if (strlen(dest_addr)+1 > sizeof(srv_addr.sun_path)) { + return NT_STATUS_INVALID_PARAMETER; + } + + ZERO_STRUCT(srv_addr); + srv_addr.sun_family = AF_UNIX; + strncpy(srv_addr.sun_path, dest_addr, sizeof(srv_addr.sun_path)); + + *sendlen = 0; + + len = sendto(sock->fd, blob->data, blob->length, flgs, + (struct sockaddr *)&srv_addr, sizeof(srv_addr)); + if (len == -1) { + return map_nt_error_from_unix(errno); + } + + *sendlen = len; + + return NT_STATUS_OK; +} + + static NTSTATUS unixdom_set_option(struct socket_context *sock, const char *option, const char *val) { @@ -294,6 +325,7 @@ static const struct socket_ops unixdom_ops = { .fn_accept = unixdom_accept, .fn_recv = unixdom_recv, .fn_send = unixdom_send, + .fn_sendto = unixdom_sendto, .fn_close = unixdom_close, .fn_set_option = unixdom_set_option, -- cgit From 1692bbf2e267eabd7099f0b6153da0c7cf209d1d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Jun 2005 13:20:08 +0000 Subject: r7227: added a socket_pending() call to abstract away the FIONREAD ioctl. It will be interesting to see if this causes any portability problems, as it is a less commonly used call. (This used to be commit f6993db31d93059c70b44a23005ba444e205870f) --- source4/lib/socket/socket_unix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 04ba89578f..f27076b5d8 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -316,6 +316,16 @@ static int unixdom_get_fd(struct socket_context *sock) return sock->fd; } +static NTSTATUS unixdom_pending(struct socket_context *sock, size_t *npending) +{ + int value = 0; + if (ioctl(sock->fd, FIONREAD, &value) == 0) { + *npending = value; + return NT_STATUS_OK; + } + return map_nt_error_from_unix(errno); +} + static const struct socket_ops unixdom_ops = { .name = "unix", .fn_init = unixdom_init, @@ -327,6 +337,7 @@ static const struct socket_ops unixdom_ops = { .fn_send = unixdom_send, .fn_sendto = unixdom_sendto, .fn_close = unixdom_close, + .fn_pending = unixdom_pending, .fn_set_option = unixdom_set_option, -- cgit From 5d55ee570beded36f985c907fcf952659557849c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Jul 2005 08:27:23 +0000 Subject: r8044: give a better error code metze (This used to be commit fdbf822f1c90cba110d91720ea586ceef9de38b2) --- source4/lib/socket/socket_unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index f27076b5d8..9c19aaace5 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -101,7 +101,7 @@ static NTSTATUS unixdom_connect(struct socket_context *sock, int ret; if (strlen(srv_address)+1 > sizeof(srv_addr.sun_path)) { - return NT_STATUS_INVALID_PARAMETER; + return NT_STATUS_OBJECT_PATH_INVALID; } ZERO_STRUCT(srv_addr); @@ -124,7 +124,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, int ret; if (strlen(my_address)+1 > sizeof(my_addr.sun_path)) { - return NT_STATUS_INVALID_PARAMETER; + return NT_STATUS_OBJECT_PATH_INVALID; } /* delete if it already exists */ @@ -259,7 +259,7 @@ static NTSTATUS unixdom_sendto(struct socket_context *sock, struct sockaddr_un srv_addr; if (strlen(dest_addr)+1 > sizeof(srv_addr.sun_path)) { - return NT_STATUS_INVALID_PARAMETER; + return NT_STATUS_OBJECT_PATH_INVALID; } ZERO_STRUCT(srv_addr); -- cgit From 75c29073ce12723598e4e204ccb616cd52fa2c13 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 28 Aug 2005 02:37:38 +0000 Subject: r9704: r9684@blu: tridge | 2005-08-27 19:38:31 +1000 don't try to call the name resolver on non-ipv4 names! (This used to be commit 4bb3d36fe6705bc625fe4122500f681ab7f2dc53) --- source4/lib/socket/socket_unix.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 9c19aaace5..c5af48da0f 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -57,6 +57,8 @@ static NTSTATUS unixdom_init(struct socket_context *sock) } sock->private_data = NULL; + sock->backend_name = "unix"; + return NT_STATUS_OK; } -- cgit From 1ef362c89d98777651c8789af4b74a0a6fb9fcdc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 28 Aug 2005 02:37:49 +0000 Subject: r9705: r9685@blu: tridge | 2005-08-27 19:43:44 +1000 set the backend_name on socket_accept() too (This used to be commit 10ac2732881ac73dd9cb8162beb1efd741bfe3d2) --- source4/lib/socket/socket_unix.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index c5af48da0f..0c65bb46fb 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -200,6 +200,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, (*new_sock)->private_data = NULL; (*new_sock)->ops = sock->ops; + (*new_sock)->backend_name = sock->backend_name; return NT_STATUS_OK; } -- cgit From f55ea8bb3dca868e21663cd90eaea7a35cd7886c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 9 Jan 2006 22:12:53 +0000 Subject: r12804: This patch reworks the Samba4 sockets layer to use a socket_address structure that is more generic than just 'IP/port'. It now passes make test, and has been reviewed and updated by metze. (Thankyou *very* much). This passes 'make test' as well as kerberos use (not currently in the testsuite). The original purpose of this patch was to have Samba able to pass a socket address stucture from the BSD layer into the kerberos routines and back again. It also removes nbt_peer_addr, which was being used for a similar purpose. It is a large change, but worthwhile I feel. Andrew Bartlett (This used to be commit 88198c4881d8620a37086f80e4da5a5b71c5bbb2) --- source4/lib/socket/socket_unix.c | 175 +++++++++++++++++++++++++++------------ 1 file changed, 124 insertions(+), 51 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 0c65bb46fb..5e04ce0d4c 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -95,22 +95,26 @@ static NTSTATUS unixdom_connect_complete(struct socket_context *sock, uint32_t f } static NTSTATUS unixdom_connect(struct socket_context *sock, - const char *my_address, int my_port, - const char *srv_address, int srv_port, + const struct socket_address *my_address, + const struct socket_address *srv_address, uint32_t flags) { - struct sockaddr_un srv_addr; int ret; - if (strlen(srv_address)+1 > sizeof(srv_addr.sun_path)) { - return NT_STATUS_OBJECT_PATH_INVALID; - } - - ZERO_STRUCT(srv_addr); - srv_addr.sun_family = AF_UNIX; - strncpy(srv_addr.sun_path, srv_address, sizeof(srv_addr.sun_path)); + if (srv_address->sockaddr) { + ret = connect(sock->fd, srv_address->sockaddr, srv_address->sockaddrlen); + } else { + struct sockaddr_un srv_addr; + if (strlen(srv_address->addr)+1 > sizeof(srv_addr.sun_path)) { + return NT_STATUS_OBJECT_PATH_INVALID; + } + + ZERO_STRUCT(srv_addr); + srv_addr.sun_family = AF_UNIX; + strncpy(srv_addr.sun_path, srv_address->addr, sizeof(srv_addr.sun_path)); - ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr)); + ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr)); + } if (ret == -1) { return unixdom_error(errno); } @@ -119,24 +123,32 @@ static NTSTATUS unixdom_connect(struct socket_context *sock, } static NTSTATUS unixdom_listen(struct socket_context *sock, - const char *my_address, int port, + const struct socket_address *my_address, int queue_size, uint32_t flags) { struct sockaddr_un my_addr; int ret; - if (strlen(my_address)+1 > sizeof(my_addr.sun_path)) { - return NT_STATUS_OBJECT_PATH_INVALID; - } - /* delete if it already exists */ - unlink(my_address); - - ZERO_STRUCT(my_addr); - my_addr.sun_family = AF_UNIX; - strncpy(my_addr.sun_path, my_address, sizeof(my_addr.sun_path)); + if (my_address->addr) { + unlink(my_address->addr); + } - ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); + if (my_address && my_address->sockaddr) { + ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); + } else { + + if (strlen(my_address->addr)+1 > sizeof(my_addr.sun_path)) { + return NT_STATUS_OBJECT_PATH_INVALID; + } + + + ZERO_STRUCT(my_addr); + my_addr.sun_family = AF_UNIX; + strncpy(my_addr.sun_path, my_address->addr, sizeof(my_addr.sun_path)); + + ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); + } if (ret == -1) { return unixdom_error(errno); } @@ -156,7 +168,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, } sock->state = SOCKET_STATE_SERVER_LISTEN; - sock->private_data = (void *)talloc_strdup(sock, my_address); + sock->private_data = (void *)talloc_strdup(sock, my_address->addr); return NT_STATUS_OK; } @@ -255,24 +267,29 @@ static NTSTATUS unixdom_send(struct socket_context *sock, static NTSTATUS unixdom_sendto(struct socket_context *sock, const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, - const char *dest_addr, int dest_port) + const struct socket_address *dest) { ssize_t len; int flgs = 0; - struct sockaddr_un srv_addr; - - if (strlen(dest_addr)+1 > sizeof(srv_addr.sun_path)) { - return NT_STATUS_OBJECT_PATH_INVALID; - } - - ZERO_STRUCT(srv_addr); - srv_addr.sun_family = AF_UNIX; - strncpy(srv_addr.sun_path, dest_addr, sizeof(srv_addr.sun_path)); - *sendlen = 0; - - len = sendto(sock->fd, blob->data, blob->length, flgs, - (struct sockaddr *)&srv_addr, sizeof(srv_addr)); + + if (dest->sockaddr) { + len = sendto(sock->fd, blob->data, blob->length, flgs, + dest->sockaddr, dest->sockaddrlen); + } else { + struct sockaddr_un srv_addr; + + if (strlen(dest->addr)+1 > sizeof(srv_addr.sun_path)) { + return NT_STATUS_OBJECT_PATH_INVALID; + } + + ZERO_STRUCT(srv_addr); + srv_addr.sun_family = AF_UNIX; + strncpy(srv_addr.sun_path, dest->addr, sizeof(srv_addr.sun_path)); + + len = sendto(sock->fd, blob->data, blob->length, flgs, + (struct sockaddr *)&srv_addr, sizeof(srv_addr)); + } if (len == -1) { return map_nt_error_from_unix(errno); } @@ -294,24 +311,82 @@ static char *unixdom_get_peer_name(struct socket_context *sock, TALLOC_CTX *mem_ return talloc_strdup(mem_ctx, "LOCAL/unixdom"); } -static char *unixdom_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) +static struct socket_address *unixdom_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) { - return talloc_strdup(mem_ctx, "LOCAL/unixdom"); -} + struct sockaddr_in *peer_addr; + socklen_t len = sizeof(*peer_addr); + struct socket_address *peer; + int ret; -static int unixdom_get_peer_port(struct socket_context *sock) -{ - return 0; -} + peer = talloc(mem_ctx, struct socket_address); + if (!peer) { + return NULL; + } + + peer->family = sock->backend_name; + peer_addr = talloc(peer, struct sockaddr_in); + if (!peer_addr) { + talloc_free(peer); + return NULL; + } -static char *unixdom_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) -{ - return talloc_strdup(mem_ctx, "LOCAL/unixdom"); + peer->sockaddr = (struct sockaddr *)peer_addr; + + ret = getpeername(sock->fd, peer->sockaddr, &len); + if (ret == -1) { + talloc_free(peer); + return NULL; + } + + peer->sockaddrlen = len; + + peer->port = 0; + peer->addr = talloc_strdup(peer, "LOCAL/unixdom"); + if (!peer->addr) { + talloc_free(peer); + return NULL; + } + + return peer; } -static int unixdom_get_my_port(struct socket_context *sock) +static struct socket_address *unixdom_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) { - return 0; + struct sockaddr_in *local_addr; + socklen_t len = sizeof(*local_addr); + struct socket_address *local; + int ret; + + local = talloc(mem_ctx, struct socket_address); + if (!local) { + return NULL; + } + + local->family = sock->backend_name; + local_addr = talloc(local, struct sockaddr_in); + if (!local_addr) { + talloc_free(local); + return NULL; + } + + local->sockaddr = (struct sockaddr *)local_addr; + + ret = getsockname(sock->fd, local->sockaddr, &len); + if (ret == -1) { + talloc_free(local); + return NULL; + } + + local->sockaddrlen = len; + + local->port = 0; + local->addr = talloc_strdup(local, "LOCAL/unixdom"); + if (!local->addr) { + talloc_free(local); + return NULL; + } + + return local; } static int unixdom_get_fd(struct socket_context *sock) @@ -346,9 +421,7 @@ static const struct socket_ops unixdom_ops = { .fn_get_peer_name = unixdom_get_peer_name, .fn_get_peer_addr = unixdom_get_peer_addr, - .fn_get_peer_port = unixdom_get_peer_port, .fn_get_my_addr = unixdom_get_my_addr, - .fn_get_my_port = unixdom_get_my_port, .fn_get_fd = unixdom_get_fd }; -- cgit From cd63d287dfcbf4db5af37c5346037f44c782d217 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Mar 2006 06:57:11 +0000 Subject: r14307: fixed dereference of my_address->addr when NULL (This used to be commit e017246f1052f3344b90500e04c73277923baa20) --- source4/lib/socket/socket_unix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 5e04ce0d4c..3feb1bf234 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -134,10 +134,11 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, unlink(my_address->addr); } - if (my_address && my_address->sockaddr) { + if (my_address->sockaddr) { ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); + } else if (my_address->addr == NULL) { + return NT_STATUS_INVALID_PARAMETER; } else { - if (strlen(my_address->addr)+1 > sizeof(my_addr.sun_path)) { return NT_STATUS_OBJECT_PATH_INVALID; } -- cgit From c2cc10c7869221c7f43cbbb151feb4c4db173cb9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 30 Apr 2006 05:58:31 +0000 Subject: r15356: Remove unused 'flags' argument from socket_send() and friends. This is in preperation for making TLS a socket library. Andrew Bartlett (This used to be commit a312812b92f5ac7e6bd2c4af725dbbbc900d4452) --- source4/lib/socket/socket_unix.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 3feb1bf234..d59ef02ba9 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -219,23 +219,13 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, } static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags) + size_t wantlen, size_t *nread) { ssize_t gotlen; - int flgs = 0; - - /* TODO: we need to map all flags here */ - if (flags & SOCKET_FLAG_PEEK) { - flgs |= MSG_PEEK; - } - - if (flags & SOCKET_FLAG_BLOCK) { - flgs |= MSG_WAITALL; - } *nread = 0; - gotlen = recv(sock->fd, buf, wantlen, flgs); + gotlen = recv(sock->fd, buf, wantlen, 0); if (gotlen == 0) { return NT_STATUS_END_OF_FILE; } else if (gotlen == -1) { @@ -248,14 +238,13 @@ static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf, } static NTSTATUS unixdom_send(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) + const DATA_BLOB *blob, size_t *sendlen) { ssize_t len; - int flgs = 0; *sendlen = 0; - len = send(sock->fd, blob->data, blob->length, flgs); + len = send(sock->fd, blob->data, blob->length, 0); if (len == -1) { return unixdom_error(errno); } @@ -267,15 +256,14 @@ static NTSTATUS unixdom_send(struct socket_context *sock, static NTSTATUS unixdom_sendto(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, + const DATA_BLOB *blob, size_t *sendlen, const struct socket_address *dest) { ssize_t len; - int flgs = 0; *sendlen = 0; if (dest->sockaddr) { - len = sendto(sock->fd, blob->data, blob->length, flgs, + len = sendto(sock->fd, blob->data, blob->length, 0, dest->sockaddr, dest->sockaddrlen); } else { struct sockaddr_un srv_addr; @@ -288,7 +276,7 @@ static NTSTATUS unixdom_sendto(struct socket_context *sock, srv_addr.sun_family = AF_UNIX; strncpy(srv_addr.sun_path, dest->addr, sizeof(srv_addr.sun_path)); - len = sendto(sock->fd, blob->data, blob->length, flgs, + len = sendto(sock->fd, blob->data, blob->length, 0, (struct sockaddr *)&srv_addr, sizeof(srv_addr)); } if (len == -1) { -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/socket/socket_unix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index d59ef02ba9..7686fea1d8 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -8,7 +8,7 @@ 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 2 of the License, or + 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, @@ -17,8 +17,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 719a4ae0d32ab9ba817fd01f2b8f4cba220a8c60 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Oct 2007 18:03:01 +0000 Subject: r25522: Convert to standard bool types. (This used to be commit 5e814287ba475e12f8cc934fdd09b199dcdfdb86) --- source4/lib/socket/socket_unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 7686fea1d8..cac4b8e913 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -82,7 +82,7 @@ static NTSTATUS unixdom_connect_complete(struct socket_context *sock, uint32_t f } if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, False); + ret = set_blocking(sock->fd, false); if (ret == -1) { return map_nt_error_from_unix(errno); } @@ -161,7 +161,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock, } if (!(flags & SOCKET_FLAG_BLOCK)) { - ret = set_blocking(sock->fd, False); + ret = set_blocking(sock->fd, false); if (ret == -1) { return unixdom_error(errno); } @@ -190,7 +190,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, } if (!(sock->flags & SOCKET_FLAG_BLOCK)) { - int ret = set_blocking(new_fd, False); + int ret = set_blocking(new_fd, false); if (ret == -1) { close(new_fd); return map_nt_error_from_unix(errno); -- cgit From 39a6495c86679d5e970012a0d1f5cd375e56450c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 19:40:20 +0100 Subject: Make more module init functions public, since they are compiled with -fvisibility=hidden. Not doing this causes failures on Mac OS X. (This used to be commit da1a9438bd89569077ef1eaa9dc977b5f9d62836) --- source4/lib/socket/socket_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/socket/socket_unix.c') diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index cac4b8e913..af7d2bb79f 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -414,7 +414,7 @@ static const struct socket_ops unixdom_ops = { .fn_get_fd = unixdom_get_fd }; -const struct socket_ops *socket_unixdom_ops(enum socket_type type) +_PUBLIC_ const struct socket_ops *socket_unixdom_ops(enum socket_type type) { return &unixdom_ops; } -- cgit