From: Ted Lemon Date: Wed, 5 Jan 2000 18:01:41 +0000 (+0000) Subject: Set close-on-exec if possible. X-Git-Tag: V3-BETA-2-PATCH-1~477 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7c83eb431fe5c3600e9af336da50f1aea92353a;p=thirdparty%2Fdhcp.git Set close-on-exec if possible. --- diff --git a/common/dns.c b/common/dns.c index 7b8df0a1f..97e9af47b 100644 --- a/common/dns.c +++ b/common/dns.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: dns.c,v 1.12 1999/10/07 06:35:41 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dns.c,v 1.13 2000/01/05 18:00:51 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -65,6 +65,11 @@ void dns_startup () if (dns_protocol_fd < 0) log_fatal ("unable to create dns socket: %m"); +#if defined (HAVE_SETFD) + if (fcntl (dns_protocol_fd, F_SETFD, 1) < 0) + log_fatal ("unable to set close-on-exec on dns fd: %m"); +#endif + first_name_server (); add_protocol ("dns", dns_protocol_fd, dns_packet, 0); diff --git a/common/icmp.c b/common/icmp.c index 62c83b375..8265460bb 100644 --- a/common/icmp.c +++ b/common/icmp.c @@ -23,7 +23,7 @@ #ifndef lint static char copyright[] = -"$Id: icmp.c,v 1.15 1999/09/09 23:26:12 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: icmp.c,v 1.16 2000/01/05 18:01:41 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -83,6 +83,11 @@ void icmp_startup (routep, handler) if (new -> socket < 0) log_fatal ("unable to create icmp socket: %m"); +#if defined (HAVE_SETFD) + if (fcntl (new -> socket, F_SETFD, 1) < 0) + log_error ("Can't set close-on-exec on icmp socket: %m"); +#endif + /* Make sure it does routing... */ state = 0; if (setsockopt (new -> socket, SOL_SOCKET, SO_DONTROUTE,