]> 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>
Thu, 15 Mar 2012 13:03:22 +0000 (09:03 -0400)
Just to be safe.

src/main/listen.c

index b19c8bc56ceae2d5682510f2ce33bcf5363d197d..e079f70eda1ad1f951e341c59152b8da2cb8a037 100644 (file)
@@ -1524,6 +1524,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.