[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Tue May 3 13:37:45 UTC 2016


The branch, master has been updated
       via  d731d16 swrap: Add support for accept4()
       via  09f3be7 swrap: Add support for running on OpenBSD
      from  feb9ee0 Bump version to 1.1.6

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


- Log -----------------------------------------------------------------
commit d731d16ac6b8f8c1edaf51794ed458cfe19c0040
Author: Andreas Schneider <asn at samba.org>
Date:   Tue May 3 14:59:34 2016 +0200

    swrap: Add support for accept4()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>

commit 09f3be725259c8ea9f51c84a96c4c03459ba72aa
Author: Andreas Schneider <asn at samba.org>
Date:   Tue May 3 14:43:21 2016 +0200

    swrap: Add support for running on OpenBSD
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>

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

Summary of changes:
 ConfigureChecks.cmake |  3 +++
 config.h.cmake        |  2 ++
 src/socket_wrapper.c  | 53 +++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 56 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 71e5056..48455ef 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -62,6 +62,9 @@ check_function_exists(signalfd HAVE_SIGNALFD)
 check_function_exists(eventfd HAVE_EVENTFD)
 check_function_exists(timerfd_create HAVE_TIMERFD_CREATE)
 check_function_exists(bindresvport HAVE_BINDRESVPORT)
+check_function_exists(accept4 HAVE_ACCEPT4)
+
+check_function_exists(pledge HAVE_PLEDGE)
 
 
 if (UNIX)
diff --git a/config.h.cmake b/config.h.cmake
index 91e1206..a9b8ce8 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -39,6 +39,8 @@
 #cmakedefine HAVE_EVENTFD 1
 #cmakedefine HAVE_TIMERFD_CREATE 1
 #cmakedefine HAVE_BINDRESVPORT 1
+#cmakedefine HAVE_ACCEPT4 1
+#cmakedefine HAVE_PLEDGE 1
 
 #cmakedefine HAVE_ACCEPT_PSOCKLEN_T 1
 #cmakedefine HAVE_IOCTL_INT 1
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 3b0499d..6e65a7e 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -335,9 +335,16 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl,
 #include <dlfcn.h>
 
 struct swrap_libc_fns {
+#ifdef HAVE_ACCEPT4
+	int (*libc_accept4)(int sockfd,
+			   struct sockaddr *addr,
+			   socklen_t *addrlen,
+			   int flags);
+#else
 	int (*libc_accept)(int sockfd,
 			   struct sockaddr *addr,
 			   socklen_t *addrlen);
+#endif
 	int (*libc_bind)(int sockfd,
 			 const struct sockaddr *addr,
 			 socklen_t addrlen);
@@ -552,12 +559,26 @@ static void *_swrap_load_lib_function(enum swrap_lib lib, const char *fn_name)
  * has probably something todo with with the linker.
  * So we need load each function at the point it is called the first time.
  */
+#ifdef HAVE_ACCEPT4
+static int libc_accept4(int sockfd,
+			struct sockaddr *addr,
+			socklen_t *addrlen,
+			int flags)
+{
+	swrap_load_lib_function(SWRAP_LIBSOCKET, accept4);
+
+	return swrap.fns.libc_accept4(sockfd, addr, addrlen, flags);
+}
+
+#else /* HAVE_ACCEPT4 */
+
 static int libc_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 {
 	swrap_load_lib_function(SWRAP_LIBSOCKET, accept);
 
 	return swrap.fns.libc_accept(sockfd, addr, addrlen);
 }
+#endif /* HAVE_ACCEPT4 */
 
 static int libc_bind(int sockfd,
 		     const struct sockaddr *addr,
@@ -2575,7 +2596,10 @@ int pipe(int pipefd[2])
  *   ACCEPT
  ***************************************************************************/
 
-static int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
+static int swrap_accept(int s,
+			struct sockaddr *addr,
+			socklen_t *addrlen,
+			int flags)
 {
 	struct socket_info *parent_si, *child_si;
 	struct socket_info_fd *child_fi;
@@ -2596,7 +2620,11 @@ static int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 
 	parent_si = find_socket_info(s);
 	if (!parent_si) {
+#ifdef HAVE_ACCEPT4
+		return libc_accept4(s, addr, addrlen, flags);
+#else
 		return libc_accept(s, addr, addrlen);
+#endif
 	}
 
 	/*
@@ -2609,7 +2637,11 @@ static int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 		return -1;
 	}
 
+#ifdef HAVE_ACCEPT4
+	ret = libc_accept4(s, &un_addr.sa.s, &un_addr.sa_socklen, flags);
+#else
 	ret = libc_accept(s, &un_addr.sa.s, &un_addr.sa_socklen);
+#endif
 	if (ret == -1) {
 		if (errno == ENOTSOCK) {
 			/* Remove stale fds */
@@ -2713,13 +2745,20 @@ static int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 	return fd;
 }
 
+#ifdef HAVE_ACCEPT4
+int accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
+{
+	return swrap_accept(s, addr, (socklen_t *)addrlen, flags);
+}
+#endif
+
 #ifdef HAVE_ACCEPT_PSOCKLEN_T
 int accept(int s, struct sockaddr *addr, Psocklen_t addrlen)
 #else
 int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 #endif
 {
-	return swrap_accept(s, addr, (socklen_t *)addrlen);
+	return swrap_accept(s, addr, (socklen_t *)addrlen, 0);
 }
 
 static int autobind_start_init;
@@ -5248,6 +5287,16 @@ int eventfd(int count, int flags)
 }
 #endif
 
+#ifdef HAVE_PLEDGE
+int pledge(const char *promises, const char *paths[])
+{
+	(void)promises; /* unused */
+	(void)paths; /* unused */
+
+	return 0;
+}
+#endif /* HAVE_PLEDGE */
+
 /****************************
  * DESTRUCTOR
  ***************************/


-- 
Socket Wrapper Repository



More information about the samba-cvs mailing list