From 6776a52bb380bb2567847c6e50e1d7880ad7847a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 12 Dec 2008 11:49:42 +0000 Subject: [PATCH] * Use a PathSet for the chroot directories so that we don't accidentally bind-mount a directory twice. --- src/libstore/build.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 53828d5ce..d4c5b81d3 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1665,7 +1665,7 @@ void DerivationGoal::startBuilder() work properly. Purity checking for fixed-output derivations is somewhat pointless anyway. */ useChroot = queryBoolSetting("build-use-chroot", false); - Paths dirsInChroot; + PathSet dirsInChroot; if (fixedOutput) useChroot = false; @@ -1706,10 +1706,11 @@ void DerivationGoal::startBuilder() defaultDirs.push_back("/dev"); defaultDirs.push_back("/dev/pts"); defaultDirs.push_back("/proc"); - - dirsInChroot = querySetting("build-chroot-dirs", defaultDirs); - dirsInChroot.push_front(tmpDir); + Paths dirsInChroot_ = querySetting("build-chroot-dirs", defaultDirs); + dirsInChroot.insert(dirsInChroot_.begin(), dirsInChroot_.end()); + + dirsInChroot.insert(tmpDir); /* Make the closure of the inputs available in the chroot, rather than the whole Nix store. This prevents any access @@ -1726,7 +1727,7 @@ void DerivationGoal::startBuilder() if (lstat(i->c_str(), &st)) throw SysError(format("getting attributes of path `%1%'") % *i); if (S_ISDIR(st.st_mode)) - dirsInChroot.push_back(*i); + dirsInChroot.insert(*i); else { Path p = chrootRootDir + *i; if (link(i->c_str(), p.c_str()) == -1) @@ -1776,7 +1777,7 @@ void DerivationGoal::startBuilder() /* Bind-mount all the directories from the "host" filesystem that we want in the chroot environment. */ - foreach (Paths::iterator, i, dirsInChroot) { + foreach (PathSet::iterator, i, dirsInChroot) { Path source = *i; Path target = chrootRootDir + source; debug(format("bind mounting `%1%' to `%2%'") % source % target);