summaryrefslogtreecommitdiff
path: root/source4/lib/socket_wrapper
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-05 15:26:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:05 -0500
commit529b03be1363396ab8c1df811c44891deeb238b5 (patch)
treec8496524ec265a47aad20b388507a5ccf763726c /source4/lib/socket_wrapper
parentc53a5c4f3e17496fa944c80cf911f8780de7ae67 (diff)
downloadsamba-529b03be1363396ab8c1df811c44891deeb238b5.tar.gz
samba-529b03be1363396ab8c1df811c44891deeb238b5.tar.bz2
samba-529b03be1363396ab8c1df811c44891deeb238b5.zip
r12074: in accept() we need to set socket name of the child socket by looking
up what address the client has used, as the socket is maybe bound to '0.0.0.0' metze (This used to be commit 81d322f91aa7097a51c13648211a0556b0424fa4)
Diffstat (limited to 'source4/lib/socket_wrapper')
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index d517a4c1b5..1114234437 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -426,8 +426,12 @@ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
struct socket_info *parent_si, *child_si;
int fd;
- socklen_t un_addrlen = sizeof(struct sockaddr_un);
struct sockaddr_un un_addr;
+ socklen_t un_addrlen = sizeof(un_addr);
+ struct sockaddr_un un_my_addr;
+ socklen_t un_my_addrlen = sizeof(un_my_addr);
+ struct sockaddr my_addr;
+ socklen_t my_addrlen = sizeof(my_addr);
int ret;
parent_si = find_socket_info(s);
@@ -436,6 +440,8 @@ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
}
memset(&un_addr, 0, sizeof(un_addr));
+ memset(&un_my_addr, 0, sizeof(un_my_addr));
+ memset(&my_addr, 0, sizeof(my_addr));
ret = real_accept(s, (struct sockaddr *)&un_addr, &un_addrlen);
if (ret == -1) return ret;
@@ -450,10 +456,20 @@ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
memset(child_si, 0, sizeof(*child_si));
child_si->fd = fd;
+ child_si->domain = parent_si->domain;
+ child_si->type = parent_si->type;
+ child_si->protocol = parent_si->protocol;
child_si->bound = 1;
- child_si->myname_len = parent_si->myname_len;
- child_si->myname = sockaddr_dup(parent_si->myname, parent_si->myname_len);
+ ret = real_getsockname(fd, &un_my_addr, &un_my_addrlen);
+ if (ret == -1) return ret;
+
+ ret = sockaddr_convert_from_un(child_si, &un_my_addr, un_my_addrlen,
+ child_si->domain, &my_addr, &my_addrlen);
+ if (ret == -1) return ret;
+
+ child_si->myname_len = my_addrlen;
+ child_si->myname = sockaddr_dup(&my_addr, my_addrlen);
child_si->peername_len = *addrlen;
child_si->peername = sockaddr_dup(addr, *addrlen);