summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-07-03 03:56:49 +0000
committerAndrew Tridgell <tridge@samba.org>2001-07-03 03:56:49 +0000
commitb470d157cd74d2278cb926974c61a5062928e24a (patch)
tree023097e5a04f6b5d3a1ad6dc2035fbc07611c641 /source3
parentf97323dc9a4e67c8be8ec95d973af0d258414860 (diff)
downloadsamba-b470d157cd74d2278cb926974c61a5062928e24a.tar.gz
samba-b470d157cd74d2278cb926974c61a5062928e24a.tar.bz2
samba-b470d157cd74d2278cb926974c61a5062928e24a.zip
fixed socketpair_tcp for OpenBSD
(This used to be commit d99ce6a5e3455ed38ca3c1ac676b5048edf8c706)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_sock.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index ccbc86bb0b..01cff85f65 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1156,7 +1156,7 @@ the resulting file descriptors are symmetrical
static int socketpair_tcp(int fd[2])
{
int listener;
- struct sockaddr sock;
+ struct sockaddr_in sock;
struct sockaddr_in sock2;
socklen_t socklen = sizeof(sock);
int connect_done = 0;
@@ -1177,19 +1177,21 @@ static int socketpair_tcp(int fd[2])
if (listen(listener, 1) != 0) goto failed;
- if (getsockname(listener, &sock, &socklen) != 0) goto failed;
+ if (getsockname(listener, (struct sockaddr *)&sock, &socklen) != 0) goto failed;
if ((fd[1] = socket(PF_INET, SOCK_STREAM, 0)) == -1) goto failed;
set_blocking(fd[1], 0);
+ sock.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
if (connect(fd[1],(struct sockaddr *)&sock,sizeof(sock)) == -1) {
if (errno != EINPROGRESS) goto failed;
} else {
connect_done = 1;
}
- if ((fd[0] = accept(listener, &sock, &socklen)) == -1) goto failed;
+ if ((fd[0] = accept(listener, (struct sockaddr *)&sock, &socklen)) == -1) goto failed;
close(listener);
if (connect_done == 0) {
@@ -1220,7 +1222,10 @@ attached to the original stderr
int sock_exec(const char *prog)
{
int fd[2];
- if (socketpair_tcp(fd) != 0) return -1;
+ if (socketpair_tcp(fd) != 0) {
+ DEBUG(0,("socketpair_tcp failed (%s)\n", strerror(errno)));
+ return -1;
+ }
if (fork() == 0) {
close(fd[0]);
close(0);