]> git.sur5r.net Git - openldap/commitdiff
ITS#5507: Set FD_CLOEXEC (close on exec) flag on LDAP file descriptors
authorHallvard Furuseth <hallvard@openldap.org>
Thu, 15 May 2008 20:56:41 +0000 (20:56 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Thu, 15 May 2008 20:56:41 +0000 (20:56 +0000)
libraries/libldap/os-ip.c
libraries/libldap/os-local.c

index e8545354323e74dc5ae2fa5b9d5e2e966835d049..b70d60dda2908693d06464b6ead819b836e93e14 100644 (file)
@@ -36,6 +36,9 @@
 #ifdef HAVE_IO_H
 #include <io.h>
 #endif /* HAVE_IO_H */
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
 
 #include "ldap-int.h"
 
@@ -110,6 +113,9 @@ ldap_int_socket(LDAP *ld, int family, int type )
 {
        ber_socket_t s = socket(family, type, 0);
        osip_debug(ld, "ldap_new_socket: %d\n",s,0,0);
+#ifdef FD_CLOEXEC
+       fcntl(s, F_SETFD, FD_CLOEXEC);
+#endif
        return ( s );
 }
 
index 70f948de19713af0f4d614d5f013fe80c1411544..0f3c1ee34d548387c03b9b734687a50b60437268 100644 (file)
@@ -47,6 +47,9 @@
 #ifdef HAVE_IO_H
 #include <io.h>
 #endif /* HAVE_IO_H */
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
 
 #include "ldap-int.h"
 #include "ldap_defaults.h"
@@ -89,6 +92,9 @@ ldap_pvt_socket(LDAP *ld)
 {
        ber_socket_t s = socket(PF_LOCAL, SOCK_STREAM, 0);
        oslocal_debug(ld, "ldap_new_socket: %d\n",s,0,0);
+#ifdef FD_CLOEXEC
+       fcntl(s, F_SETFD, FD_CLOEXEC);
+#endif
        return ( s );
 }