From 5a569509b491d43bfcb5c72e85a6d7374a583228 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 11 Dec 2008 17:44:02 +0000 Subject: [PATCH] * Provide a minimal /etc/passwd in the chroot to keep some builders happy. --- src/libstore/build.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index ab3a46aa83..466e3326d5 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()) {