changeset 5493:41d06921177b draft

privsep: We need getsockopt as well as setsockopt on the link socket So we can report receive buffer size. Important for route(4) overflow so we can try and set a bigger buffer.
author Roy Marples <roy@marples.name>
date Sat, 03 Oct 2020 17:00:56 +0100
parents 9fe902232341
children 0fbde4769bbe
files src/if-bsd.c src/privsep.c src/privsep.h
diffstat 3 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/if-bsd.c	Fri Oct 02 15:57:01 2020 +0100
+++ b/src/if-bsd.c	Sat Oct 03 17:00:56 2020 +0100
@@ -216,8 +216,10 @@
 #endif
 
 #ifdef PRIVSEP_RIGHTS
+	/* We need to getsockopt for SO_RCVBUF and
+	 * setsockopt for RO_MISSFILTER. */
 	if (IN_PRIVSEP(ctx))
-		ps_rights_limit_fd_setsockopt(ctx->link_fd);
+		ps_rights_limit_fd_sockopt(ctx->link_fd);
 #endif
 
 	return 0;
--- a/src/privsep.c	Fri Oct 02 15:57:01 2020 +0100
+++ b/src/privsep.c	Sat Oct 03 17:00:56 2020 +0100
@@ -260,11 +260,12 @@
 }
 
 int
-ps_rights_limit_fd_setsockopt(int fd)
+ps_rights_limit_fd_sockopt(int fd)
 {
 	cap_rights_t rights;
 
-	cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_EVENT, CAP_SETSOCKOPT);
+	cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_EVENT,
+	    CAP_GETSOCKOPT, CAP_SETSOCKOPT);
 	if (cap_rights_limit(fd, &rights) == -1 && errno != ENOSYS)
 		return -1;
 	return 0;
--- a/src/privsep.h	Fri Oct 02 15:57:01 2020 +0100
+++ b/src/privsep.h	Sat Oct 03 17:00:56 2020 +0100
@@ -197,7 +197,7 @@
 int ps_rights_limit_ioctl(int);
 int ps_rights_limit_fd_fctnl(int);
 int ps_rights_limit_fd_rdonly(int);
-int ps_rights_limit_fd_setsockopt(int);
+int ps_rights_limit_fd_sockopt(int);
 int ps_rights_limit_fd(int);
 int ps_rights_limit_fdpair(int []);
 #endif