From 9faae6784c63a47f3cc8faa160c208f60dad1e9c Mon Sep 17 00:00:00 2001 From: Manolis Ragkousis Date: Thu, 20 Aug 2015 13:50:04 +0300 Subject: [PATCH] daemon: Split CHROOT_ENABLED into CHROOT_ENABLED and CONTAINER_ENABLED. * nix/libstore/build.cc (CHROOT_ENABLED): Split. (DerivationGoal::startBuilder): Replace CHROOT_ENABLED with CONTAINER_ENABLED. (DerivationGoal::runChild): Same. --- nix/libstore/build.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index a9eedce..7cde735 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -51,7 +51,15 @@ #include #endif -#define CHROOT_ENABLED HAVE_CHROOT && HAVE_UNSHARE && HAVE_SYS_MOUNT_H && defined(MS_BIND) && defined(MS_PRIVATE) && defined(CLONE_NEWNS) && defined(SYS_pivot_root) +/* In non Linux systems we can still support chroot builds, even + though doesn't exist.*/ +#if __linux__ +#define CHROOT_ENABLED HAVE_CHROOT && HAVE_SYS_MOUNT_H +#else +#define CHROOT_ENABLED HAVE_CHROOT +#endif + +#define CONTAINER_ENABLED CHROOT_ENABLED && defined(MS_BIND) && defined(MS_PRIVATE) && defined(CLONE_NEWNS) && defined(SYS_pivot_root) #if CHROOT_ENABLED #include @@ -1946,7 +1954,7 @@ void DerivationGoal::startBuilder() - The UTS namespace ensures that builders see a hostname of localhost rather than the actual hostname. */ -#if CHROOT_ENABLED +#if CONTAINER_ENABLED if (useChroot) { char stack[32 * 1024]; int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | SIGCHLD; @@ -1994,7 +2002,7 @@ void DerivationGoal::runChild() commonChildInit(builderOut); -#if CHROOT_ENABLED +#if CONTAINER_ENABLED if (useChroot) { /* Initialise the loopback interface. */ AutoCloseFD fd(socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)); -- 2.5.0