]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Set "close on exec" flag
authorAlan T. DeKok <aland@freeradius.org>
Thu, 15 Mar 2012 13:03:22 +0000 (09:03 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 16 Mar 2012 15:50:27 +0000 (11:50 -0400)
Just to be safe.

src/main/listen.c

index eb13b67a8e3658ac7148243959f32ac594f5b543..f51cafe523f6ed0665cb22fa9297cf5355ed8df5 100644 (file)
@@ -2072,6 +2072,21 @@ static int listen_bind(rad_listen_t *this)
                radlog(L_ERR, "Failed opening %s: %s", buffer, strerror(errno));
                return -1;
        }
+
+#ifdef FD_CLOEXEC
+       /*
+        *      We don't want child processes inheriting these
+        *      file descriptors.
+        */
+       rcode = fcntl(this->fd, F_GETFD);
+       if (rcode >= 0) {
+               if (fcntl(this->fd, F_SETFD, rcode | FD_CLOEXEC) < 0) {
+                       close(this->fd);
+                       radlog(L_ERR, "Failed setting close on exec: %s", strerror(errno));
+                       return -1;
+               }
+       }
+#endif
                
        /*
         *      Bind to a device BEFORE touching IP addresses.