Allow relative paths anywhere into the parent's store path

This commit is contained in:
Eelco Dolstra 2021-09-21 13:45:11 +02:00
parent 5cbb9c5406
commit 06557299b3

View file

@ -95,8 +95,11 @@ struct PathInputScheme : InputScheme
absPath = nix::absPath(path, parent); absPath = nix::absPath(path, parent);
// for security, ensure that if the parent is a store path, it's inside it // for security, ensure that if the parent is a store path, it's inside it
if (store->isInStore(parent) && !isInDir(absPath, parent)) if (store->isInStore(parent)) {
throw BadStorePath("relative path '%s' [%s] points outside of its parent's store path '%s'", path, absPath, parent); auto storePath = store->printStorePath(store->toStorePath(parent).first);
if (!isInDir(absPath, storePath))
throw BadStorePath("relative path '%s' points outside of its parent's store path '%s'", path, storePath);
}
} else } else
absPath = path; absPath = path;