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
1 changed files with 9 additions and 2 deletions

View File

@ -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