about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libstore/build.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index ab3a46aa8319..466e3326d5f8 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1673,6 +1673,17 @@ void DerivationGoal::startBuilder()
         if (chmod(chrootTmpDir.c_str(), 01777) == -1)
             throw SysError("creating /tmp in the chroot");
 
+        /* Create a /etc/passwd with entries for the build user and
+           the nobody account.  The latter is kind of a hack to
+           support Samba-in-QEMU. */
+        createDirs(chrootRootDir + "/etc");
+
+        writeStringToFile(chrootRootDir + "/etc/passwd",
+            (format(
+                "nixbld:x:%1%:65534:Nix build user:/:/noshell\n"
+                "nobody:x:65534:65534:Nobody:/:/noshell\n")
+                % (buildUser.enabled() ? buildUser.getUID() : getuid())).str());
+
         /* Bind-mount a user-configurable set of directories from the
            host file system.  The `/dev/pts' directory must be mounted
            separately so that newly-created pseudo-terminals show
@@ -1770,7 +1781,7 @@ void DerivationGoal::startBuilder()
                safe.  Also note that setuid() when run as root sets
                the real, effective and saved UIDs. */
             if (buildUser.enabled()) {
-                printMsg(lvlChatty, format("switching to user `%1%'") % buildUser.getUser());
+                debug(format("switching to user `%1%'") % buildUser.getUser());
 
                 if (amPrivileged()) {