[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Tue Dec 10 01:31:37 MST 2013


The branch, master has been updated
       via  9f7d7b4 swrap: Remove obsolete init functions.
       via  e5899b8 swrap: Add libc_writev().
       via  d344002 swrap: Add libc_socket().
       via  4b72d30 swrap: Add libc_setsockopt().
       via  a6bbc38 swrap: Add libc_sendto().
       via  5b7e896 swrap: Add libc_sendmsg().
       via  ab6f0be swrap: Add libc_send().
       via  fb02405 swrap: Add libc_recv().
       via  c7b7039 swrap: Add libc_recvfrom().
       via  c1b2021 swrap: Add libc_readv().
       via  430abba swrap: Add libc_read().
       via  89fcdfb swrap: Add libc_listen().
       via  6015f67 swrap: Correctly load ioctl().
       via  5a34128 squash swrap_load_lib_handle
       via  7af4d58 swrap: Add libc_getsockopt().
       via  9dd5276 swrap: Add libc_getsockname().
       via  3c67ca0 swrap: Add libc_getpeername().
       via  999ace2 swrap: Add libc_dup2().
       via  84e6729 swrap: Add libc_dup().
       via  2cfbea1 swrap: Add libc_connect().
       via  f3b03d7 swrap: Add libc_close().
       via  f7d9020 swrap: Add libc_bind().
       via  5f0fa21 swrap: Add libc_accept().
       via  2947b39 swrap: Add a swrap_load_lib_function macro.
       via  e69f51d swrap: Add new function to load libraries.
      from  76baedf swrap: Remove deprecated functions.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9f7d7b4bdf1a17619fc4b1bb9569621e6f0b20c9
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 08:21:12 2013 +0100

    swrap: Remove obsolete init functions.
    
    This fixes preloading libsocket_wrapper.so with gdb.

commit e5899b84480c46c3ba5d7d24a97d9bc63d7baa7c
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 08:16:53 2013 +0100

    swrap: Add libc_writev().

commit d344002876675e8a77f4d93303b8c2448fe02489
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 08:15:08 2013 +0100

    swrap: Add libc_socket().

commit 4b72d3005246fb31ec038fc908729672df47364d
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 08:12:16 2013 +0100

    swrap: Add libc_setsockopt().

commit a6bbc3867e96fb30a53ffacda28ee4e8344f8542
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 08:08:19 2013 +0100

    swrap: Add libc_sendto().

commit 5b7e8960a325e7c3a9c08b24ce1079c0faa3c12d
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 07:57:26 2013 +0100

    swrap: Add libc_sendmsg().

commit ab6f0beb78d2c0b4af1c47f1d816829b9abac003
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 07:54:21 2013 +0100

    swrap: Add libc_send().

commit fb02405c73358d36e2cd08bd8d170bf2bbdb5b54
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 07:43:43 2013 +0100

    swrap: Add libc_recv().

commit c7b7039a4643a975697615d263c1e30e126b9c37
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Tue Dec 10 07:41:43 2013 +0100

    swrap: Add libc_recvfrom().

commit c1b2021ede8f3e2527ec0d5b28dd5bef259fca8a
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:46:00 2013 +0100

    swrap: Add libc_readv().

commit 430abbadb0fdbc49879ce5bf02066f0194384fdb
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:44:09 2013 +0100

    swrap: Add libc_read().

commit 89fcdfbf7bf162a950c52692e677f80c266971cf
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:42:03 2013 +0100

    swrap: Add libc_listen().

commit 6015f679bcb6fff32660b39bc42ac2b2362ab72e
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:39:52 2013 +0100

    swrap: Correctly load ioctl().

commit 5a34128deac0c456d973f851a728966c87964e6c
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:39:37 2013 +0100

    squash swrap_load_lib_handle

commit 7af4d587f80f4f981fdd45404a7e1ac725647c75
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:36:02 2013 +0100

    swrap: Add libc_getsockopt().

commit 9dd5276ce25f10278aca8342adfc5bcf332cbeb7
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:33:45 2013 +0100

    swrap: Add libc_getsockname().

commit 3c67ca0e9eedd2db2d5b6c052935fbe43d140703
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:31:46 2013 +0100

    swrap: Add libc_getpeername().

commit 999ace2a21cd6793d3502321ab0fd961e8c80f65
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:25:43 2013 +0100

    swrap: Add libc_dup2().

commit 84e6729c4946b7b154e90ea347fcdc5aa42dc4ee
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:24:30 2013 +0100

    swrap: Add libc_dup().

commit 2cfbea1bf2ff5f1edf1512cea5fbb12e87e0a800
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:22:42 2013 +0100

    swrap: Add libc_connect().

commit f3b03d777e9da4fb70360219bd0ef4535028971e
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:18:39 2013 +0100

    swrap: Add libc_close().

commit f7d9020866f64b266faf519d5175b01a6e178a50
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:16:43 2013 +0100

    swrap: Add libc_bind().

commit 5f0fa21e38ebefd884958365c3cdb1f3aeeb6149
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:14:45 2013 +0100

    swrap: Add libc_accept().

commit 2947b39e0c32c21e3f270efc449f4955ec85af8a
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:11:59 2013 +0100

    swrap: Add a swrap_load_lib_function macro.

commit e69f51d01375149d96e7634561d30267761a37a5
Author: Andreas Schneider <asn at cryptomilk.org>
Date:   Mon Dec 9 19:07:21 2013 +0100

    swrap: Add new function to load libraries.

-----------------------------------------------------------------------

Summary of changes:
 src/socket_wrapper.c |  521 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 320 insertions(+), 201 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 4f31311..4964ec1 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -341,148 +341,178 @@ static const char *socket_wrapper_dir(void);
 
 #define LIBC_NAME "libc.so"
 
-static void *swrap_libc_fn(void *handle, const char *fn_name)
+enum swrap_lib {
+    SWRAP_LIBC,
+    SWRAP_LIBNSL,
+    SWRAP_LIBSOCKET,
+};
+
+static void *swrap_load_lib_handle(enum swrap_lib lib)
 {
-	void *func;
+	int flags = RTLD_LAZY;
+	void *handle = NULL;
+	int i;
+
+#ifdef HAVE_APPLE
+	return RTLD_NEXT;
+#endif
+
+#ifdef RTLD_DEEPBIND
+	flags |= RTLD_DEEPBIND;
+#endif
+
+	switch (lib) {
+	case SWRAP_LIBNSL:
+		/* FALL TROUGH */
+	case SWRAP_LIBSOCKET:
+#ifdef HAVE_LIBSOCKET
+		if (handle == NULL) {
+			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+				char soname[256] = {0};
+
+				snprintf(soname, sizeof(soname), "libsocket.so.%d", i);
+				handle = dlopen(soname, flags);
+			}
+
+			swrap.libsocket_handle = handle;
+		} else {
+			handle = swrap.libsocket_handle;
+		}
+		break;
+#endif
+		/* FALL TROUGH */
+	case SWRAP_LIBC:
+		if (handle == NULL) {
+			for (handle = NULL, i = 10; handle == NULL && i >= 0; i--) {
+				char soname[256] = {0};
+
+				snprintf(soname, sizeof(soname), "libc.so.%d", i);
+				handle = dlopen(soname, flags);
+			}
+
+			swrap.libc_handle = handle;
+		} else {
+			handle = swrap.libc_handle;
+		}
+		break;
+	}
 
 	if (handle == NULL) {
-		return NULL;
+		SWRAP_LOG(SWRAP_LOG_ERROR,
+			  "Failed to dlopen library: %s\n",
+			  dlerror());
+		exit(-1);
 	}
 
+	return handle;
+}
+
+static void *_swrap_load_lib_function(enum swrap_lib lib, const char *fn_name)
+{
+	void *handle;
+	void *func;
+
+	handle = swrap_load_lib_handle(lib);
+
 	func = dlsym(handle, fn_name);
 	if (func == NULL) {
 		SWRAP_LOG(SWRAP_LOG_ERROR,
-			  "Failed to find %s: %s\n",
-			  fn_name, dlerror());
+				"Failed to find %s: %s\n",
+				fn_name, dlerror());
 		exit(-1);
 	}
 
 	return func;
 }
 
-static void swrap_libc_init(void)
+#define swrap_load_lib_function(lib, fn_name) \
+	if (swrap.fns.libc_##fn_name == NULL) { \
+		*(void **) (&swrap.fns.libc_##fn_name) = \
+			_swrap_load_lib_function(lib, #fn_name); \
+	}
+
+
+/*
+ * IMPORTANT
+ *
+ * Functions expeciall from libc need to be loaded individually, you can't load
+ * all at once or gdb will segfault at startup. The same applies to valgrind and
+ * has probably something todo with with the linker.
+ * So we need load each function at the point it is called the first time.
+ */
+static int libc_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 {
-	int i;
-	int flags = RTLD_LAZY;
-	void *handle;
+	swrap_load_lib_function(SWRAP_LIBSOCKET, accept);
 
-#ifdef HAVE_APPLE
-	handle = RTLD_NEXT;
-#else /* !HAVE_APPLE */
+	return swrap.fns.libc_accept(sockfd, addr, addrlen);
+}
 
-#ifdef RTLD_DEEPBIND
-	flags |= RTLD_DEEPBIND;
-#endif
+static int libc_bind(int sockfd,
+		     const struct sockaddr *addr,
+		     socklen_t addrlen)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, bind);
 
-	/* Load libc.so */
-	for (swrap.libc_handle = NULL, i = 10; swrap.libc_handle == NULL && i >= 0; i--) {
-		char soname[256] = {0};
+	return swrap.fns.libc_bind(sockfd, addr, addrlen);
+}
 
-		snprintf(soname, sizeof(soname), "%s.%d", LIBC_NAME, i);
-		swrap.libc_handle = dlopen(soname, flags);
-	}
+static int libc_close(int fd)
+{
+	swrap_load_lib_function(SWRAP_LIBC, close);
 
-	if (swrap.libc_handle == NULL) {
-		SWRAP_LOG(SWRAP_LOG_ERROR,
-			  "Failed to dlopen %s.%d: %s\n",
-			  LIBC_NAME, i, dlerror());
-		exit(-1);
-	}
+	return swrap.fns.libc_close(fd);
+}
 
-#ifdef HAVE_LIBSOCKET
-	for (swrap.libsocket_handle = NULL, i = 10; swrap.libsocket_handle == NULL && i >= 0; i--) {
-		char soname[256] = {0};
-                i = 1;
+static int libc_connect(int sockfd,
+			const struct sockaddr *addr,
+			socklen_t addrlen)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, connect);
 
-		snprintf(soname, sizeof(soname), "libsocket.so.%d", i);
-		swrap.libsocket_handle = dlopen(soname, flags);
-	}
+	return swrap.fns.libc_connect(sockfd, addr, addrlen);
+}
 
-	if (swrap.libsocket_handle == NULL) {
-		SWRAP_LOG(SWRAP_LOG_ERROR,
-			 "Failed to dlopen libsocket.so: %s",
-			 dlerror());
-		exit(-1);
-	}
-#endif /* HAVE_LIBSOCKET */
+static int libc_dup(int fd)
+{
+	swrap_load_lib_function(SWRAP_LIBC, dup);
 
-#endif /* !HAVE_APPLE */
+	return swrap.fns.libc_dup(fd);
+}
 
-	/* Load libc functions */
-#ifndef HAVE_APPLE
-	handle = swrap.libc_handle;
-#endif
-	*(void **) (&swrap.fns.libc_close) =
-		swrap_libc_fn(handle, "close");
-	*(void **) (&swrap.fns.libc_dup) =
-		swrap_libc_fn(handle, "dup");
-	*(void **) (&swrap.fns.libc_dup2) =
-		swrap_libc_fn(handle, "dup2");
-	*(void **) (&swrap.fns.libc_ioctl) =
-		swrap_libc_fn(handle, "ioctl");
-	*(void **) (&swrap.fns.libc_read) =
-		swrap_libc_fn(handle, "read");
-	*(void **) (&swrap.fns.libc_readv) =
-		swrap_libc_fn(handle, "readv");
-	*(void **) (&swrap.fns.libc_writev) =
-		swrap_libc_fn(handle, "writev");
-
-	/* Load libsocket funcitons */
-#if !defined(HAVE_APPLE) && defined(HAVE_LIBSOCKET)
-	handle = swrap.libsocket_handle;
-#endif
+static int libc_dup2(int oldfd, int newfd)
+{
+	swrap_load_lib_function(SWRAP_LIBC, dup2);
 
-	*(void **) (&swrap.fns.libc_accept) =
-		swrap_libc_fn(handle, "accept");
-	*(void **) (&swrap.fns.libc_bind) =
-		swrap_libc_fn(handle, "bind");
-	*(void **) (&swrap.fns.libc_connect) =
-		swrap_libc_fn(handle, "connect");
-	*(void **) (&swrap.fns.libc_getpeername) =
-		swrap_libc_fn(handle, "getpeername");
-	*(void **) (&swrap.fns.libc_getsockname) =
-		swrap_libc_fn(handle, "getsockname");
-	*(void **) (&swrap.fns.libc_getsockopt) =
-		swrap_libc_fn(handle, "getsockopt");
-	*(void **) (&swrap.fns.libc_listen) =
-		swrap_libc_fn(handle, "listen");
-	*(void **) (&swrap.fns.libc_recv) =
-		swrap_libc_fn(handle, "recv");
-	*(void **) (&swrap.fns.libc_recvfrom) =
-		swrap_libc_fn(handle, "recvfrom");
-	*(void **) (&swrap.fns.libc_send) =
-		swrap_libc_fn(handle, "send");
-	*(void **) (&swrap.fns.libc_sendmsg) =
-		swrap_libc_fn(handle, "sendmsg");
-	*(void **) (&swrap.fns.libc_sendto) =
-		swrap_libc_fn(handle, "sendto");
-	*(void **) (&swrap.fns.libc_setsockopt) =
-		swrap_libc_fn(handle, "setsockopt");
-	*(void **) (&swrap.fns.libc_socket) =
-		swrap_libc_fn(handle, "socket");
-}
-
-static void swrap_init(void)
-{
-	if (swrap.initialised) {
-		return;
-	}
+	return swrap.fns.libc_dup2(oldfd, newfd);
+}
 
-	swrap.socket_dir = strdup(socket_wrapper_dir());
-	if (swrap.socket_dir != NULL) {
-		swrap.enabled = true;
-	}
+static int libc_getpeername(int sockfd,
+			    struct sockaddr *addr,
+			    socklen_t *addrlen)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, getpeername);
 
-	swrap_libc_init();
+	return swrap.fns.libc_getpeername(sockfd, addr, addrlen);
+}
+
+static int libc_getsockname(int sockfd,
+			    struct sockaddr *addr,
+			    socklen_t *addrlen)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, getsockname);
 
-	swrap.initialised = true;
+	return swrap.fns.libc_getsockname(sockfd, addr, addrlen);
 }
 
-static int swrap_enabled(void)
+static int libc_getsockopt(int sockfd,
+			   int level,
+			   int optname,
+			   void *optval,
+			   socklen_t *optlen)
 {
-	swrap_init();
+	swrap_load_lib_function(SWRAP_LIBSOCKET, getsockopt);
 
-	return swrap.enabled ? 1 : 0;
+	return swrap.fns.libc_getsockopt(sockfd, level, optname, optval, optlen);
 }
 
 static int libc_vioctl(int d, unsigned long int request, va_list ap)
@@ -491,6 +521,8 @@ static int libc_vioctl(int d, unsigned long int request, va_list ap)
 	int rc;
 	int i;
 
+	swrap_load_lib_function(SWRAP_LIBC, ioctl);
+
 	for (i = 0; i < 4; i++) {
 		args[i] = va_arg(ap, long int);
 	}
@@ -505,6 +537,97 @@ static int libc_vioctl(int d, unsigned long int request, va_list ap)
 	return rc;
 }
 
+static int libc_listen(int sockfd, int backlog)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, listen);
+
+	return swrap.fns.libc_listen(sockfd, backlog);
+}
+
+static int libc_read(int fd, void *buf, size_t count)
+{
+	swrap_load_lib_function(SWRAP_LIBC, read);
+
+	return swrap.fns.libc_read(fd, buf, count);
+}
+
+static ssize_t libc_readv(int fd, const struct iovec *iov, int iovcnt)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, readv);
+
+	return swrap.fns.libc_readv(fd, iov, iovcnt);
+}
+
+static int libc_recv(int sockfd, void *buf, size_t len, int flags)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, recv);
+
+	return swrap.fns.libc_recv(sockfd, buf, len, flags);
+}
+
+static int libc_recvfrom(int sockfd,
+			 void *buf,
+			 size_t len,
+			 int flags,
+			 struct sockaddr *src_addr,
+			 socklen_t *addrlen)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, recvfrom);
+
+	return swrap.fns.libc_recvfrom(sockfd, buf, len, flags, src_addr, addrlen);
+}
+
+static int libc_send(int sockfd, const void *buf, size_t len, int flags)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, send);
+
+	return swrap.fns.libc_send(sockfd, buf, len, flags);
+}
+
+static int libc_sendmsg(int sockfd, const struct msghdr *msg, int flags)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, sendmsg);
+
+	return swrap.fns.libc_sendmsg(sockfd, msg, flags);
+}
+
+static int libc_sendto(int sockfd,
+		       const void *buf,
+		       size_t len,
+		       int flags,
+		       const  struct sockaddr *dst_addr,
+		       socklen_t addrlen)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, sendto);
+
+	return swrap.fns.libc_sendto(sockfd, buf, len, flags, dst_addr, addrlen);
+}
+
+static int libc_setsockopt(int sockfd,
+			   int level,
+			   int optname,
+			   const void *optval,
+			   socklen_t optlen)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, setsockopt);
+
+	return swrap.fns.libc_setsockopt(sockfd, level, optname, optval, optlen);
+}
+
+static int libc_socket(int domain, int type, int protocol)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, socket);
+
+	return swrap.fns.libc_socket(domain, type, protocol);
+}
+
+static ssize_t libc_writev(int fd, const struct iovec *iov, int iovcnt)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, writev);
+
+	return swrap.fns.libc_writev(fd, iov, iovcnt);
+}
+
 /*********************************************************
  * SWRAP HELPER FUNCTIONS
  *********************************************************/
@@ -907,10 +1030,6 @@ static struct socket_info *find_socket_info(int fd)
 {
 	struct socket_info *i;
 
-	if (!swrap_enabled()) {
-		return NULL;
-	}
-
 	for (i = sockets; i; i = i->next) {
 		struct socket_info_fd *f;
 		for (f = i->fds; f; f = f->next) {
@@ -1758,8 +1877,8 @@ static int swrap_socket(int family, int type, int protocol)
 	real_type &= ~SOCK_NONBLOCK;
 #endif
 
-	if (!swrap_enabled()) {
-		return swrap.fns.libc_socket(family, type, protocol);
+	if (socket_wrapper_dir() == NULL) {
+		return libc_socket(family, type, protocol);
 	}
 
 	switch (family) {
@@ -1769,7 +1888,7 @@ static int swrap_socket(int family, int type, int protocol)
 #endif
 		break;
 	case AF_UNIX:
-		return swrap.fns.libc_socket(family, type, protocol);
+		return libc_socket(family, type, protocol);
 	default:
 		errno = EAFNOSUPPORT;
 		return -1;
@@ -1807,7 +1926,7 @@ static int swrap_socket(int family, int type, int protocol)
 	 * We must call libc_socket with type, from the caller, not the version
 	 * we removed SOCK_CLOEXEC and SOCK_NONBLOCK from
 	 */
-	fd = swrap.fns.libc_socket(AF_UNIX, type, 0);
+	fd = libc_socket(AF_UNIX, type, 0);
 
 	if (fd == -1) return -1;
 
@@ -1864,7 +1983,7 @@ static int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 
 	parent_si = find_socket_info(s);
 	if (!parent_si) {
-		return swrap.fns.libc_accept(s, addr, addrlen);
+		return libc_accept(s, addr, addrlen);
 	}
 
 	/* 
@@ -1885,7 +2004,7 @@ static 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));
 
-	ret = swrap.fns.libc_accept(s, (struct sockaddr *)(void *)&un_addr, &un_addrlen);
+	ret = libc_accept(s, (struct sockaddr *)(void *)&un_addr, &un_addrlen);
 	if (ret == -1) {
 		free(my_addr);
 		return ret;
@@ -1936,9 +2055,9 @@ static int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 		*addrlen = len;
 	}
 
-	ret = swrap.fns.libc_getsockname(fd,
-					 (struct sockaddr *)(void *)&un_my_addr,
-					 &un_my_addrlen);
+	ret = libc_getsockname(fd,
+			       (struct sockaddr *)(void *)&un_my_addr,
+			       &un_my_addrlen);
 	if (ret == -1) {
 		free(child_fi);
 		free(child_si);
@@ -2084,7 +2203,7 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 			 type, socket_wrapper_default_iface(), port);
 		if (stat(un_addr.sun_path, &st) == 0) continue;
 
-		ret = swrap.fns.libc_bind(fd, (struct sockaddr *)(void *)&un_addr,
+		ret = libc_bind(fd, (struct sockaddr *)(void *)&un_addr,
 				sizeof(un_addr));
 		if (ret == -1) return ret;
 
@@ -2123,7 +2242,7 @@ static int swrap_connect(int s, const struct sockaddr *serv_addr,
 	int bcast = 0;
 
 	if (!si) {
-		return swrap.fns.libc_connect(s, serv_addr, addrlen);
+		return libc_connect(s, serv_addr, addrlen);
 	}
 
 	if (si->bound == 0) {
@@ -2151,9 +2270,9 @@ static int swrap_connect(int s, const struct sockaddr *serv_addr,
 	} else {
 		swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_SEND, NULL, 0);
 
-		ret = swrap.fns.libc_connect(s,
-					     (struct sockaddr *)(void *)&un_addr,
-					     sizeof(struct sockaddr_un));
+		ret = libc_connect(s,
+				   (struct sockaddr *)(void *)&un_addr,
+				   sizeof(struct sockaddr_un));
 	}
 


-- 
Socket Wrapper Repository


More information about the samba-cvs mailing list