summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2016-04-16 13:10:31 +0000
committerbapt <bapt@FreeBSD.org>2016-04-16 13:10:31 +0000
commit881983d98c30c4b633b31d9e3b3a70acdbafcb21 (patch)
tree704a5456e1728db89fd9f160521adb8ee9f3ce2c /usr.sbin
parent13b4b9515d5084f66ba00a12d7498918969d1694 (diff)
downloadFreeBSD-src-881983d98c30c4b633b31d9e3b3a70acdbafcb21.zip
FreeBSD-src-881983d98c30c4b633b31d9e3b3a70acdbafcb21.tar.gz
Use the SOCK_CLOEXEC flags in the socket(2) 'type' attribute instead of
calling fcntl(2) MFC after: 1 week
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/inetd/inetd.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index f2d504f..752a7a4 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -1251,7 +1251,9 @@ setup(struct servtab *sep)
{
int on = 1;
- if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) < 0) {
+ /* Set all listening sockets to close-on-exec. */
+ if ((sep->se_fd = socket(sep->se_family,
+ sep->se_socktype | SOCK_CLOEXEC, 0)) < 0) {
if (debug)
warn("socket failed on %s/%s",
sep->se_service, sep->se_proto);
@@ -1259,13 +1261,6 @@ setup(struct servtab *sep)
sep->se_service, sep->se_proto);
return;
}
- /* Set all listening sockets to close-on-exec. */
- if (fcntl(sep->se_fd, F_SETFD, FD_CLOEXEC) < 0) {
- syslog(LOG_ERR, "%s/%s: fcntl (F_SETFD, FD_CLOEXEC): %m",
- sep->se_service, sep->se_proto);
- close(sep->se_fd);
- return;
- }
#define turnon(fd, opt) \
setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
if (strcmp(sep->se_proto, "tcp") == 0 && (options & SO_DEBUG) &&
OpenPOWER on IntegriCloud