From: Hallvard Furuseth Date: Thu, 15 May 2008 20:56:41 +0000 (+0000) Subject: ITS#5507: Set FD_CLOEXEC (close on exec) flag on LDAP file descriptors X-Git-Tag: LOCKER_IDS~166 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1fc3f1c1301f20ad090b62757d8af2ead3658ebe;p=openldap ITS#5507: Set FD_CLOEXEC (close on exec) flag on LDAP file descriptors --- diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index e854535432..b70d60dda2 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -36,6 +36,9 @@ #ifdef HAVE_IO_H #include #endif /* HAVE_IO_H */ +#ifdef HAVE_FCNTL_H +#include +#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 ); } diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index 70f948de19..0f3c1ee34d 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -47,6 +47,9 @@ #ifdef HAVE_IO_H #include #endif /* HAVE_IO_H */ +#ifdef HAVE_FCNTL_H +#include +#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 ); }