[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] daemon: Break CHROOT_ENABLED into CHROOT_ENABLED and CLONE_E
From: |
Manolis Ragkousis |
Subject: |
Re: [PATCH] daemon: Break CHROOT_ENABLED into CHROOT_ENABLED and CLONE_ENABLED. |
Date: |
Tue, 9 Aug 2016 20:37:23 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
Hello again,
I was looking at nix's git repo and Eelco's 8f67325 commit is a better
solution to the issue. I cherry picked it and modified it to apply to
our version of the daemon which I will send in another mail.
For this reason forget this patch.
Thank you,
Manolis
On 08/08/16 15:25, Manolis Ragkousis wrote:
> Hello everyone,
>
> This patch breaks CHROOT_ENABLED into CHROOT_ENABLED and CLONE_ENABLED.
>
> If you check the code below, you will see that in case clone() is not
> available it will use fork(), which is the case on Hurd.
>
> But because CHROOT_ENABLED checks for others things, like mount.h and
> pivot_root(), it never actually got to the second part of the code
> below. This is fixed with my patch.
>
> #if CHROOT_ENABLED
> if (useChroot) {
> char stack[32 * 1024];
> int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS |
> SIGCHLD;
> if (!fixedOutput) flags |= CLONE_NEWNET;
> pid = clone(childEntry, stack + sizeof(stack) - 8, flags, this);
> if (pid == -1)
> throw SysError("cloning builder process");
> } else
> #endif
> {
> pid = fork();
> if (pid == 0) runChild();
> }
>
> Thank you,
> Manolis
>