unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Manolis Ragkousis <manolis837@gmail.com>
To: Guix-devel <Guix-devel@gnu.org>
Subject: [PATCH] daemon: Split CHROOT_ENABLED into CHROOT_ENABLED and CONTAINER_ENABLED.
Date: Thu, 20 Aug 2015 14:16:29 +0300	[thread overview]
Message-ID: <CAFtzXzO9oCaNUsRfyR1sdbfEd4oDekhWwCxOsybAdmPVwvZg3A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 580 bytes --]

With this patch, the daemon can perform chrooted builds on Hurd, without
creating problems to other parts of the daemon that can't be supported.

So as Mark said, the cases are:

1. CONTAINER_ENABLED and CHROOT_ENABLED are both true.
In this case, the daemon works as expected, which is what happens in Linux now.

2. CONTAINER_ENABLED is false and CHROOT_ENABLED is true.
Here, things like namespaces cannot be supported, but we can still
perform chrooted builds.

3. CONTAINER_ENABLED and CHROOT_ENABLED are both false.
Here, the daemon is unusable on the system, as it should.

[-- Attachment #2: 0001-daemon-Split-CHROOT_ENABLED-into-CHROOT_ENABLED-and-.patch --]
[-- Type: text/x-patch, Size: 1948 bytes --]

From 9faae6784c63a47f3cc8faa160c208f60dad1e9c Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
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 <linux/fs.h>
 #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 <sys/mount.h> 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 <sys/socket.h>
@@ -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


             reply	other threads:[~2015-08-20 11:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 11:16 Manolis Ragkousis [this message]
2015-08-22  2:28 ` [PATCH] daemon: Split CHROOT_ENABLED into CHROOT_ENABLED and CONTAINER_ENABLED Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFtzXzO9oCaNUsRfyR1sdbfEd4oDekhWwCxOsybAdmPVwvZg3A@mail.gmail.com \
    --to=manolis837@gmail.com \
    --cc=Guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).