mirror of
https://github.com/NixOS/nix
synced 2025-06-27 04:21:16 +02:00
* computeStorePathForText: take the references into account when
computing the store path (NIX-77). This is an important security property in multi-user Nix stores. Note that this changes the store paths of derivations (since the derivation aterms are added using addTextToStore), but not most outputs (unless they use builtins.toFile).
This commit is contained in:
parent
c558b1583c
commit
b618fa6eb6
5 changed files with 18 additions and 6 deletions
|
@ -73,6 +73,8 @@ Path makeStorePath(const string & type,
|
|||
string s = type + ":sha256:" + printHash(hash) + ":"
|
||||
+ nixStore + ":" + suffix;
|
||||
|
||||
printMsg(lvlError, s);
|
||||
|
||||
checkStoreName(suffix);
|
||||
|
||||
return nixStore + "/"
|
||||
|
@ -114,10 +116,19 @@ std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
|
|||
}
|
||||
|
||||
|
||||
Path computeStorePathForText(const string & suffix, const string & s)
|
||||
Path computeStorePathForText(const string & suffix, const string & s,
|
||||
const PathSet & references)
|
||||
{
|
||||
Hash hash = hashString(htSHA256, s);
|
||||
return makeStorePath("text", hash, suffix);
|
||||
/* Stuff the references (if any) into the type. This is a bit
|
||||
hacky, but we can't put them in `s' since that would be
|
||||
ambiguous. */
|
||||
string type = "text";
|
||||
for (PathSet::const_iterator i = references.begin(); i != references.end(); ++i) {
|
||||
type += ":";
|
||||
type += *i;
|
||||
}
|
||||
return makeStorePath(type, hash, suffix);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue