From: Alan T. DeKok Date: Thu, 15 Mar 2012 13:03:22 +0000 (-0400) Subject: Set "close on exec" flag X-Git-Tag: release_2_2_0~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7d135a8dec9a7b074312a646df6eb7d68eb52b9;p=thirdparty%2Ffreeradius-server.git Set "close on exec" flag Just to be safe. --- diff --git a/src/main/listen.c b/src/main/listen.c index b19c8bc56ce..e079f70eda1 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -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.