about summary refs log tree commit diff
path: root/src/libstore/gc.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-04T23·29+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-04T23·29+0000
commit74033a844fe57e3e91c71ae37f9a65f6b2f22aa9 (patch)
treeb7bc47382b27fc8ca916ca1cbbcc8fe9aa427aaa /src/libstore/gc.cc
parent0d40f6d7bb226e69f65f8ca8e6d0597baf3eec9a (diff)
* Add indirect root registration to the protocol so that unprivileged
  processes can register indirect roots.  Of course, there is still
  the problem that the garbage collector can only read the targets of
  the indirect roots when it's running as root...

Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r--src/libstore/gc.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index 56e64369a741..ba59083cad74 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -82,6 +82,15 @@ void LocalStore::syncWithGC()
 }
 
 
+void LocalStore::addIndirectRoot(const Path & path)
+{
+    string hash = printHash32(hashString(htSHA1, path));
+    Path realRoot = canonPath((format("%1%/%2%/auto/%3%")
+        % nixStateDir % gcRootsDir % hash).str());
+    createSymlink(realRoot, path, false);
+}
+
+
 Path addPermRoot(const Path & _storePath, const Path & _gcRoot,
     bool indirect, bool allowOutsideRootsDir)
 {
@@ -90,12 +99,8 @@ Path addPermRoot(const Path & _storePath, const Path & _gcRoot,
     assertStorePath(storePath);
 
     if (indirect) {
-        string hash = printHash32(hashString(htSHA1, gcRoot));
-        Path realRoot = canonPath((format("%1%/%2%/auto/%3%")
-            % nixStateDir % gcRootsDir % hash).str());
-        
         createSymlink(gcRoot, storePath, true);
-        createSymlink(realRoot, gcRoot, false);
+        store->addIndirectRoot(gcRoot);
     }
 
     else {