Set FD_CLOEXEC flag on all sockets.
[oweals/tinc.git] / src / bsd / device.c
index f1d3f9f470311137cb3de6059511ca4b6037cca5..45c2d5f656b5b90338e7cce3de62a526c34d26dd 100644 (file)
@@ -1,7 +1,7 @@
 /*
     device.c -- Interaction BSD tun/tap device
     Copyright (C) 2001-2005 Ivo Timmermans,
-                  2001-2011 Guus Sliepen <guus@tinc-vpn.org>
+                  2001-2012 Guus Sliepen <guus@tinc-vpn.org>
                   2009      Grzegorz Dymarek <gregd72002@googlemail.com>
 
     This program is free software; you can redistribute it and/or modify
@@ -106,6 +106,10 @@ static bool setup_device(void) {
                return false;
        }
 
+#ifdef FD_CLOEXEC
+       fcntl(device_fd, F_SETFD, FD_CLOEXEC);
+#endif
+
        switch(device_type) {
                default:
                        device_type = DEVICE_TYPE_TUN;