From: Roy Marples Date: Thu, 30 Apr 2020 20:26:16 +0000 (+0100) Subject: privsep: allow --chrootdir= to configure a default chroot directory X-Git-Tag: v9.1.0~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c72190790162cf2afe51feacf76be4154b215d3d;p=thirdparty%2Fdhcpcd.git privsep: allow --chrootdir= to configure a default chroot directory --- diff --git a/configure b/configure index 3e2e20fd..a7ae9241 100755 --- a/configure +++ b/configure @@ -13,6 +13,7 @@ IPV4LL= INET6= PRIVSEP= PRIVSEP_USER= +PRIVSEP_CHROOT= ARC4RANDOM= CLOSEFROM= RBTREE= @@ -71,6 +72,7 @@ for x do --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 @@ if [ "$PRIVSEP" = yes ]; then 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 diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 67ae0b2e..839209f9 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1826,6 +1826,9 @@ main(int argc, char **argv) #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);