[PATCH] Set close on exec in socket accept calls.

Gary Lockyer gary at catalyst.net.nz
Sun Nov 5 18:44:50 UTC 2017


Set SOCK_CLOEXEC on accept calls, this patch assumes that the samba
accepts are all handled by the socket wrapper code.

As always comments and reviews appreciated

Gary.

-------------- next part --------------
From 4f26aaa2a0fe95a875ffede2ab3342a689fb3463 Mon Sep 17 00:00:00 2001
From: Gary Lockyer <gary at catalyst.net.nz>
Date: Fri, 3 Nov 2017 14:21:48 +1300
Subject: [PATCH] lib socket_wrapper: Set close on exec in accept

Set SOCK_CLOEXEC on all socket accept calls.  This patch assumes that
all the accept calls are handled by the socket wrapper code.

Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
---
 lib/socket_wrapper/socket_wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index ba289e6..a8f5fdc 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -2761,7 +2761,7 @@ int accept(int s, struct sockaddr *addr, Psocklen_t addrlen)
 int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 #endif
 {
-	return swrap_accept(s, addr, (socklen_t *)addrlen, 0);
+	return swrap_accept(s, addr, (socklen_t *)addrlen, SOCK_CLOEXEC);
 }
 
 static int autobind_start_init;
-- 
2.7.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20171106/8f554747/signature.sig>


More information about the samba-technical mailing list