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.
This commit is contained in:
Eelco Dolstra 2013-06-13 17:12:06 +02:00
parent 6cc2a8f8ed
commit 1e2c7c04b1

View file

@ -789,6 +789,9 @@ private:
/* Outputs that are corrupt or not valid. */ /* Outputs that are corrupt or not valid. */
PathSet missingPaths; PathSet missingPaths;
/* Paths that have been subject to hash rewriting. */
PathSet rewrittenPaths;
/* User selected for running the builder. */ /* User selected for running the builder. */
UserLock buildUser; UserLock buildUser;
@ -1493,6 +1496,8 @@ void DerivationGoal::buildDone()
sink.s = rewriteHashes(sink.s, rewritesFromTmp); sink.s = rewriteHashes(sink.s, rewritesFromTmp);
StringSource source(sink.s); StringSource source(sink.s);
restorePath(path, source); restorePath(path, source);
rewrittenPaths.insert(path);
} }
/* Gain ownership of the build result using the setuid /* Gain ownership of the build result using the setuid
@ -2293,8 +2298,10 @@ void DerivationGoal::computeClosure()
% path % i->second.hashAlgo % printHash16or32(h) % printHash16or32(h2)); % path % i->second.hashAlgo % printHash16or32(h) % printHash16or32(h2));
} }
/* Get rid of all weird permissions. */ /* Get rid of all weird permissions. This also checks that
canonicalisePathMetaData(path, buildUser.enabled() ? buildUser.getUID() : -1); 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 /* For this output path, find the references to other paths
contained in it. Compute the SHA-256 NAR hash at the same contained in it. Compute the SHA-256 NAR hash at the same