mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
daemon: Do not use clone on the Hurd.
Checking for CLONE_NEWNS is only needed for using tha Linux specific clone(2), otherwise we can use fork(2). Using clone on the Hurd needs some work, only support LINUX for now. See https://lists.gnu.org/archive/html/guix-devel/2020-03/msg00190.html * nix/libstore/build.cc (CHROOT_ENABLED): Break into CHROOT_ENABLED and CLONE_ENABLED. (DerivationGoal::startBuilder): Replace CHROOT_ENABLED with __linux__. (DerivationGoal::runChild): Only define pivot_root() if SYS_pivot_root is defined. Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
This commit is contained in:
parent
496d607db3
commit
9c3b28b911
1 changed files with 7 additions and 4 deletions
|
@ -52,7 +52,12 @@
|
||||||
#endif
|
#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
|
#if CHROOT_ENABLED
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -2005,7 +2010,7 @@ void DerivationGoal::startBuilder()
|
||||||
- The UTS namespace ensures that builders see a hostname of
|
- The UTS namespace ensures that builders see a hostname of
|
||||||
localhost rather than the actual hostname.
|
localhost rather than the actual hostname.
|
||||||
*/
|
*/
|
||||||
#if CHROOT_ENABLED
|
#if __linux__
|
||||||
if (useChroot) {
|
if (useChroot) {
|
||||||
char stack[32 * 1024];
|
char stack[32 * 1024];
|
||||||
int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | SIGCHLD;
|
int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | SIGCHLD;
|
||||||
|
@ -2186,10 +2191,8 @@ void DerivationGoal::runChild()
|
||||||
if (mkdir("real-root", 0) == -1)
|
if (mkdir("real-root", 0) == -1)
|
||||||
throw SysError("cannot create real-root directory");
|
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)
|
if (pivot_root(".", "real-root") == -1)
|
||||||
throw SysError(format("cannot pivot old root directory onto '%1%'") % (chrootRootDir + "/real-root"));
|
throw SysError(format("cannot pivot old root directory onto '%1%'") % (chrootRootDir + "/real-root"));
|
||||||
#undef pivot_root
|
|
||||||
|
|
||||||
if (chroot(".") == -1)
|
if (chroot(".") == -1)
|
||||||
throw SysError(format("cannot change root directory to '%1%'") % chrootRootDir);
|
throw SysError(format("cannot change root directory to '%1%'") % chrootRootDir);
|
||||||
|
|
Loading…
Reference in a new issue