diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-06-25T18·12-0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-06-25T18·12-0400 |
commit | 5489086456ca13b2e884edecf7505235d214a594 (patch) | |
tree | dae47c508e616e6e603d17bd4963b0785ff0db0a /src/libstore/build.cc | |
parent | 8da6772ed48e2ee7082071b31c7afeb800195cdb (diff) |
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.
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r-- | src/libstore/build.cc | 8 |
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. */ |