changeset 5408:2de2190e16a8 draft

privsep: shutdown read end of the write only sockets Clearly shows our intent and hopefully is an optimisation within the kernel.
author Roy Marples <roy@marples.name>
date Sat, 18 Jul 2020 12:40:30 +0100
parents 30603cb789ea
children 571dbb02e7c5
files src/privsep-root.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/privsep-root.c	Wed Jul 08 12:36:36 2020 +0100
+++ b/src/privsep-root.c	Sat Jul 18 12:40:30 2020 +0100
@@ -635,7 +635,7 @@
 	ctx->ps_root_pid = getpid();
 	ctx->options |= DHCPCD_PRIVSEPROOT;
 
-	/* Open network sockets for sending.
+	/* Open network sockets for sending only.
 	 * This is a small bit wasteful for non sandboxed OS's
 	 * but makes life very easy for unicasting DHCPv6 in non master
 	 * mode as we no longer care about address selection. */
@@ -645,6 +645,8 @@
 		    SOCK_RAW | SOCK_CXNB, IPPROTO_UDP);
 		if (ctx->udp_wfd == -1)
 			logerr("%s: dhcp_openraw", __func__);
+		else if (shutdown(ctx->udp_wfd, SHUT_RD) == -1)
+			logerr("%s: shutdown dhcp", __func__);
 	}
 #endif
 #ifdef INET6
@@ -652,6 +654,8 @@
 		ctx->nd_fd = ipv6nd_open(false);
 		if (ctx->nd_fd == -1)
 			logerr("%s: ipv6nd_open", __func__);
+		else if (shutdown(ctx->nd_fd, SHUT_RD) == -1)
+			logerr("%s: shutdown nd", __func__);
 	}
 #endif
 #ifdef DHCP6
@@ -659,6 +663,8 @@
 		ctx->dhcp6_wfd = dhcp6_openraw();
 		if (ctx->dhcp6_wfd == -1)
 			logerr("%s: dhcp6_openraw", __func__);
+		else if (shutdown(ctx->dhcp6_wfd, SHUT_RD) == -1)
+			logerr("%s: shutdown dhcp6", __func__);
 	}
 #endif