about summary refs log tree commit diff
path: root/src/libstore/store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-03-10T22·27+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-03-10T22·27+0000
commitfdea084c365083a65eb363973400416107b5e32b (patch)
tree82584bb341b821205fd73122276ae38dd9320f2f /src/libstore/store.cc
parent37d1b1cafd17a18dc7dbef3b4ba7fb204158d58b (diff)
* Allow `make check' to work in directories that have symlink
  components.

Diffstat (limited to 'src/libstore/store.cc')
-rw-r--r--src/libstore/store.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index e792fd28cedc..556ba8e62166 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -76,10 +76,30 @@ static void upgradeStore07();
 static void upgradeStore09();
 
 
+void checkStoreNotSymlink()
+{
+    if (getEnv("NIX_IGNORE_SYMLINK_STORE") == "1") return;
+    Path path = nixStore;
+    struct stat st;
+    while (path != "/") {
+        if (lstat(path.c_str(), &st))
+            throw SysError(format("getting status of `%1%'") % path);
+        if (S_ISLNK(st.st_mode))
+            throw Error(format(
+                "the path `%1%' is a symlink; "
+                "this is not allowed for the Nix store and its parent directories")
+                % path);
+        path = dirOf(path);
+    }
+}
+
+
 void openDB(bool reserveSpace)
 {
     if (readOnlyMode) return;
 
+    checkStoreNotSymlink();
+
     try {
         Path reservedPath = nixDBPath + "/reserved";
         string s = querySetting("gc-reserved-space", "");