Skip to contentSkip to conversation

close more file descriptors on exec

PATCH New Heiko Hund 1 participant 1 message Feb 1, 2013

lore
Share & tools
lore

Heiko Hund

author
#0 lore raw

PATCH 1/1 close more file descriptors on exec

Don't inherit the --status and --ifconfig-pool-persist, and on Linux the epoll(7), file descriptors to scripts and other processes that may be forked by plugins.

---
 src/openvpn/event.c  |    3 +++
 src/openvpn/status.c |    2 ++
 2 files changed, 5 insertions(+)
src/openvpn/event.c +3 -0
index 2a13e1c..34a3c45 100644
@@ -34,6 +34,7 @@
 #include "error.h"
 #include "integer.h"
 #include "event.h"
+#include "fdmisc.h"
 
 #include "memdbg.h"
 
@@ -582,6 +583,8 @@ ep_init (int *maxevents, unsigned int flags)
   if (fd < 0)
     return NULL;
 
+  set_cloexec (fd);
+
   ALLOC_OBJ_CLEAR (eps, struct ep_set);
 
   /* set dispatch functions */
src/openvpn/status.c +2 -0
index 5f9ab9e..8773f3d 100644
@@ -33,6 +33,7 @@
 #include "status.h"
 #include "perf.h"
 #include "misc.h"
+#include "fdmisc.h"
 
 #include "memdbg.h"
 
@@ -98,6 +99,7 @@ status_open (const char *filename,
 	  if (so->fd >= 0)
 	    {
 	      so->filename = string_alloc (filename, NULL);
+              set_cloexec (so->fd);
 
 	      /* allocate read buffer */
 	      if (so->flags & STATUS_OUTPUT_READ)
Signature · 1 line
1.7.9.5