about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-06-13T15·12+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-06-13T15·12+0200
commit1e2c7c04b1125fb63fae733fc27abb86743b8224 (patch)
treef47f355ae5e6d8b9706bbdfbc838176916e7213e /src
parent6cc2a8f8ed7cb53e49bfbd08f462af062da18ce7 (diff)
Fix assertion failure in canonicalisePathMetaData() after hash rewriting
The assertion in canonicalisePathMetaData() failed because the
ownership of the path already changed due to the hash rewriting.  The
solution is not to check the ownership of rewritten paths.

Issue #122.
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index cef0c2c96db1..2d33719573d0 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -789,6 +789,9 @@ private:
     /* Outputs that are corrupt or not valid. */
     PathSet missingPaths;
 
+    /* Paths that have been subject to hash rewriting. */
+    PathSet rewrittenPaths;
+
     /* User selected for running the builder. */
     UserLock buildUser;
 
@@ -1493,6 +1496,8 @@ void DerivationGoal::buildDone()
                 sink.s = rewriteHashes(sink.s, rewritesFromTmp);
                 StringSource source(sink.s);
                 restorePath(path, source);
+
+                rewrittenPaths.insert(path);
             }
 
             /* Gain ownership of the build result using the setuid
@@ -2293,8 +2298,10 @@ void DerivationGoal::computeClosure()
                     % path % i->second.hashAlgo % printHash16or32(h) % printHash16or32(h2));
         }
 
-        /* Get rid of all weird permissions. */
-        canonicalisePathMetaData(path, buildUser.enabled() ? buildUser.getUID() : -1);
+        /* Get rid of all weird permissions.  This also checks that
+           all files are owned by the build user, if applicable. */
+        canonicalisePathMetaData(path,
+            buildUser.enabled() && rewrittenPaths.find(path) == rewrittenPaths.end() ? buildUser.getUID() : -1);
 
         /* For this output path, find the references to other paths
            contained in it.  Compute the SHA-256 NAR hash at the same