about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@higgsboson.tk>2016-11-24T23·08+0100
committerJörg Thalheim <joerg@higgsboson.tk>2016-11-24T23·15+0100
commit855abd85d8ec27411aa4ad3be2b7f90d17b5693d (patch)
treed6cbbbef951084f7d03709da665f1b027c1b49b7 /src
parent7ee43df8622cc0589d54248fb44cebe1c1d991d2 (diff)
Simplify remouting with MS_PRIVATE in sandbox build
also fix race condition if mounts are added after mountinfo is read.
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index ba51f85917f3..ee266b7d3704 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2283,12 +2283,8 @@ void DerivationGoal::runChild()
                outside of the namespace.  Making a subtree private is
                local to the namespace, though, so setting MS_PRIVATE
                does not affect the outside world. */
-            Strings mounts = tokenizeString<Strings>(readFile("/proc/self/mountinfo", true), "\n");
-            for (auto & i : mounts) {
-                vector<string> fields = tokenizeString<vector<string> >(i, " ");
-                string fs = decodeOctalEscaped(fields.at(4));
-                if (mount(0, fs.c_str(), 0, MS_PRIVATE, 0) == -1)
-                    throw SysError(format("unable to make filesystem ‘%1%’ private") % fs);
+            if (mount(0, "/", 0, MS_REC|MS_PRIVATE, 0) == -1) {
+                throw SysError("unable to make ‘/’ private mount");
             }
 
             /* Bind-mount chroot directory to itself, to treat it as a