about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-06-11T11·36+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-06-11T11·36+0000
commit9bff7ad7287dafff1e06f3c3db6a5ec295d7c152 (patch)
treeb535975cb1bbcf0ab3fbc005dfce5060dba22dbd /src
parentf3ebd03bb17533806d38fe871200b1dc4688acdc (diff)
* Check against creation of GC roots in the store. Those roots don't
  work, because findRoots() stops when it encounters a symlink to the
  store.  And of course the store is supposed to be read-only.

Diffstat (limited to 'src')
-rw-r--r--src/libstore/gc.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index e04e9c1071cb..2ad52d8bf4ea 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -97,6 +97,11 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot,
     Path gcRoot(canonPath(_gcRoot));
     assertStorePath(storePath);
 
+    if (isInStore(gcRoot))
+        throw Error(format(
+                "creating a garbage collector root (%1%) in the Nix store is forbidden "
+                "(are you running nix-build inside the store?)") % gcRoot);
+
     if (indirect) {
         createSymlink(gcRoot, storePath, true);
         store->addIndirectRoot(gcRoot);
@@ -114,7 +119,6 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot,
         }
             
         createSymlink(gcRoot, storePath, false);
-
     }
 
     /* Check that the root can be found by the garbage collector. */