From 5489086456ca13b2e884edecf7505235d214a594 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 25 Jun 2012 14:12:17 -0400 Subject: Use a private UTS namespace to provide a deterministic host/domain name to builders In chroot builds, set the host name to "localhost" and the domain name to "(none)" (the latter being the kernel's default). This improves determinism a bit further. P.S. I have to idea what UTS stands for. --- src/libstore/build.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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. */ -- cgit 1.4.1