Skip to content

Commit

Permalink
Only register drv outputs when it's safe to do so if ca-drvs aren't e…
Browse files Browse the repository at this point in the history
…nabled

Unless ca drvs are enabled, only allow registering derivation outputs when we
know it's safe to do so, meaning when we can check that the mapping matches
what's defined in the drv file itself
  • Loading branch information
thufschmitt committed Nov 12, 2020
1 parent 58ea93c commit 3be2780
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/libstore/local-store.cc
Expand Up @@ -623,6 +623,29 @@ void LocalStore::registerDrvOutput(const DrvOutputId& id, const DrvOutputInfo &

void LocalStore::registerDrvOutput_(State & state, const StorePath & deriver, const string & outputName, const StorePath & output)
{
bool requireCADrvs = false;
// Ensure that we don't register a boguous derivation output.
if (isValidPath_(state, deriver)) {
debug("Checking the validiy of the drv output '%s!%s'", printStorePath(deriver), outputName);
// Can't use `readDerivation` here as we already hold the lock on the db
auto matchingDrv = parseDerivation(
*this,
readFile(Store::toRealPath(deriver)),
Derivation::nameFromPath(deriver)
);
auto outputsFromDrv = matchingDrv.outputsAndOptPaths(*this);
auto currentOutputFromDrv = outputsFromDrv.find(outputName);
assert (currentOutputFromDrv != outputsFromDrv.end());
if (!currentOutputFromDrv->second.second.has_value()) {
// Floating-ca or dependent thereof
settings.requireExperimentalFeature("ca-derivations");
} else {
assert (*currentOutputFromDrv->second.second == output);
}
} else {
requireCADrvs = true;
}

retrySQLite<void>([&]() {
state.stmtAddDerivationOutput.use()
(printStorePath(deriver))
Expand Down

0 comments on commit 3be2780

Please sign in to comment.