Require linux 3.13 or later for chroot

Fixes #453
This commit is contained in:
Shea Levy 2015-02-04 11:46:38 -05:00 committed by Eelco Dolstra
parent f3a5930488
commit d66d9e8425
2 changed files with 8 additions and 2 deletions

View file

@ -243,7 +243,8 @@ flag, e.g. <literal>--option gc-keep-outputs false</literal>.</para>
users” feature</link> to perform the actual builds under different users” feature</link> to perform the actual builds under different
users than root). Currently, chroot builds only work on Linux users than root). Currently, chroot builds only work on Linux
because Nix uses “bind mounts” to make the Nix store and other because Nix uses “bind mounts” to make the Nix store and other
directories available inside the chroot.</para> directories available inside the chroot. Kernel version 3.13 or later
is needed due to a PID namespace fix nix depends on.</para>
</listitem> </listitem>

View file

@ -1970,7 +1970,12 @@ void DerivationGoal::startBuilder()
char stack[32 * 1024]; char stack[32 * 1024];
pid_t child = clone(childEntry, stack + sizeof(stack) - 8, pid_t child = clone(childEntry, stack + sizeof(stack) - 8,
CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWNET | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_PARENT | SIGCHLD, this); CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWNET | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_PARENT | SIGCHLD, this);
if (child == -1) throw SysError("cloning builder process"); if (child == -1) {
if (errno == EINVAL)
throw SysError("cloning builder process (Linux chroot builds require 3.13 or later)");
else
throw SysError("cloning builder process");
}
writeFull(builderOut.writeSide, int2String(child) + "\n"); writeFull(builderOut.writeSide, int2String(child) + "\n");
_exit(0); _exit(0);
}); });