changeset 5184:88d5345f56ce draft

privsep: allow --chrootdir= to configure a default chroot directory
author Roy Marples <roy@marples.name>
date Thu, 30 Apr 2020 21:26:16 +0100
parents 09e3f731e43e
children 532e88420b25
files configure src/dhcpcd.c
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Thu Apr 30 21:13:45 2020 +0100
+++ b/configure	Thu Apr 30 21:26:16 2020 +0100
@@ -13,6 +13,7 @@
 INET6=
 PRIVSEP=
 PRIVSEP_USER=
+PRIVSEP_CHROOT=
 ARC4RANDOM=
 CLOSEFROM=
 RBTREE=
@@ -71,6 +72,7 @@
 	--disable-privsep) PRIVSEP=no;;
 	--enable-privsep) PRIVSEP=yes;;
 	--privsepuser) PRIVSEP_USER=$var;;
+	--chrootdir) PRIVSEP_CHROOT=$var;;
 	--prefix) PREFIX=$var;;
 	--sysconfdir) SYSCONFDIR=$var;;
 	--bindir|--sbindir) SBINDIR=$var;;
@@ -579,9 +581,17 @@
 
 	echo "CPPFLAGS+=	-DPRIVSEP" >>$CONFIG_MK
 	echo "PRIVSEP_USER?=	$PRIVSEP_USER" >>$CONFIG_MK
+	if [ -n "$PRIVSEP_CHROOT" ]; then
+		echo "PRIVSEP_CHROOT=	$PRIVSEP_CHROOT" >>$CONFIG_MK
+	fi
 	echo "#ifndef PRIVSEP_USER" >>$CONFIG_H
 	echo "#define PRIVSEP_USER		 \"$PRIVSEP_USER\"" >>$CONFIG_H
 	echo "#endif" >>$CONFIG_H
+	if [ -n "$PRIVSEP_CHROOT" ]; then
+		echo "#ifndef PRIVSEP_CHROOT" >>$CONFIG_H
+		echo "#define PRIVSEP_CHROOT	\"$PRIVSEP_CHROOT\"" >>$CONFIG_H
+		echo "#endif" >>$CONFIG_H
+	fi
 	echo "DHCPCD_SRCS+=	privsep.c privsep-root.c privsep-inet.c" \
 		>>$CONFIG_MK
 	if [ -z "$INET" ] || [ "$INET" = yes ]; then
--- a/src/dhcpcd.c	Thu Apr 30 21:13:45 2020 +0100
+++ b/src/dhcpcd.c	Thu Apr 30 21:26:16 2020 +0100
@@ -1826,6 +1826,9 @@
 #endif
 #ifdef PRIVSEP
 	ctx.ps_root_fd = ctx.ps_data_fd = -1;
+#ifdef PRIVSEP_CHROOT
+	ctx.ps_chroot = PRIVSEP_CHROOT;
+#endif
 	TAILQ_INIT(&ctx.ps_processes);
 #endif
 	rt_init(&ctx);