diff options
Diffstat (limited to 'nix')
-rw-r--r-- | nix/libstore/build.cc | 11 | ||||
-rw-r--r-- | nix/libutil/util.cc | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index 17e92c68a7..29266f1dd6 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -52,7 +52,12 @@ #endif -#define CHROOT_ENABLED HAVE_CHROOT && HAVE_SYS_MOUNT_H && defined(MS_BIND) && defined(MS_PRIVATE) && defined(CLONE_NEWNS) && defined(SYS_pivot_root) +#define CHROOT_ENABLED HAVE_CHROOT && HAVE_SYS_MOUNT_H && defined(MS_BIND) && defined(MS_PRIVATE) +#define CLONE_ENABLED defined(CLONE_NEWNS) + +#if defined(SYS_pivot_root) +#define pivot_root(new_root, put_old) (syscall(SYS_pivot_root, new_root,put_old)) +#endif #if CHROOT_ENABLED #include <sys/socket.h> @@ -2005,7 +2010,7 @@ void DerivationGoal::startBuilder() - The UTS namespace ensures that builders see a hostname of localhost rather than the actual hostname. */ -#if CHROOT_ENABLED +#if __linux__ if (useChroot) { char stack[32 * 1024]; int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | SIGCHLD; @@ -2186,10 +2191,8 @@ void DerivationGoal::runChild() if (mkdir("real-root", 0) == -1) throw SysError("cannot create real-root directory"); -#define pivot_root(new_root, put_old) (syscall(SYS_pivot_root, new_root, put_old)) if (pivot_root(".", "real-root") == -1) throw SysError(format("cannot pivot old root directory onto '%1%'") % (chrootRootDir + "/real-root")); -#undef pivot_root if (chroot(".") == -1) throw SysError(format("cannot change root directory to '%1%'") % chrootRootDir); diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index fb2dfad1f7..17d145b4c6 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -861,6 +861,10 @@ void killUser(uid_t uid) which means "follow POSIX", which we don't want here */ if (syscall(SYS_kill, -1, SIGKILL, false) == 0) break; +#elif __GNU__ + /* Killing all a user's processes using PID=-1 does currently + not work on the Hurd. */ + if (kill(getpid(), SIGKILL) == 0) break; #else if (kill(-1, SIGKILL) == 0) break; #endif @@ -873,6 +877,10 @@ void killUser(uid_t uid) }); int status = pid.wait(true); +#if __GNU__ + /* When the child killed itself, status = SIGKILL. */ + if (status == SIGKILL) return; +#endif if (status != 0) throw Error(format("cannot kill processes for uid `%1%': %2%") % uid % statusToString(status)); |