summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config-daemon.ac2
-rw-r--r--nix/libstore/build.cc9
2 files changed, 10 insertions, 1 deletions
diff --git a/config-daemon.ac b/config-daemon.ac
index 4e949bc88a3..35d9c8cd56b 100644
--- a/config-daemon.ac
+++ b/config-daemon.ac
@@ -79,7 +79,7 @@ if test "x$guix_build_daemon" = "xyes"; then
79 dnl Chroot support. 79 dnl Chroot support.
80 AC_CHECK_FUNCS([chroot unshare]) 80 AC_CHECK_FUNCS([chroot unshare])
81 AC_CHECK_HEADERS([sched.h sys/param.h sys/mount.h sys/syscall.h \ 81 AC_CHECK_HEADERS([sched.h sys/param.h sys/mount.h sys/syscall.h \
82 linux/close_range.h]) 82 linux/close_range.h sys/prctl.h])
83 83
84 if test "x$ac_cv_func_chroot" != "xyes"; then 84 if test "x$ac_cv_func_chroot" != "xyes"; then
85 AC_MSG_ERROR(['chroot' function missing, bailing out]) 85 AC_MSG_ERROR(['chroot' function missing, bailing out])
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 2261ef3c2a0..e6a139eb0d7 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -50,6 +50,9 @@
50#if HAVE_SCHED_H 50#if HAVE_SCHED_H
51#include <sched.h> 51#include <sched.h>
52#endif 52#endif
53#if HAVE_SYS_PRCTL_H
54#include <sys/prctl.h>
55#endif
53 56
54 57
55#define CHROOT_ENABLED HAVE_CHROOT && HAVE_SYS_MOUNT_H && defined(MS_BIND) && defined(MS_PRIVATE) 58#define CHROOT_ENABLED HAVE_CHROOT && HAVE_SYS_MOUNT_H && defined(MS_BIND) && defined(MS_PRIVATE)
@@ -2075,6 +2078,12 @@ void DerivationGoal::runChild()
2075 2078
2076#if CHROOT_ENABLED 2079#if CHROOT_ENABLED
2077 if (useChroot) { 2080 if (useChroot) {
2081# if HAVE_SYS_PRCTL_H
2082 /* Drop ambient capabilities such as CAP_CHOWN that might have
2083 been granted when starting guix-daemon. */
2084 prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0);
2085# endif
2086
2078 if (!fixedOutput) { 2087 if (!fixedOutput) {
2079 /* Initialise the loopback interface. */ 2088 /* Initialise the loopback interface. */
2080 AutoCloseFD fd(socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)); 2089 AutoCloseFD fd(socket(PF_INET, SOCK_DGRAM, IPPROTO_IP));