about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libstore/build.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 6efb294e8389..281bfb495540 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1793,7 +1793,7 @@ void DerivationGoal::startBuilder()
                      IPC mechanisms (shared memory, message queues,
                      semaphores).  It also ensures that all IPC
                      objects are destroyed when the builder exits. */
-                if (unshare(CLONE_NEWNS | CLONE_NEWNET | CLONE_NEWIPC) == -1)
+                if (unshare(CLONE_NEWNS | CLONE_NEWNET | CLONE_NEWIPC | CLONE_NEWUTS) == -1)
                     throw SysError("cannot set up private namespaces");
 
                 /* Initialise the loopback interface. */
@@ -1808,6 +1808,12 @@ void DerivationGoal::startBuilder()
 
                 fd.close();
 
+                /* Set the hostname etc. to fixed values. */
+                char hostname[] = "localhost";
+                sethostname(hostname, sizeof(hostname));
+                char domainname[] = "(none)"; // kernel default
+                setdomainname(domainname, sizeof(domainname));
+
                 /* Bind-mount all the directories from the "host"
                    filesystem that we want in the chroot
                    environment. */