Skip to content

Commit db8439c

Browse files
L-asEricson2314
authored andcommitted
Remove signRealisation from drv goal
We can move this method from `LocalStore` to `Store` --- even if we only want the actual builder to sign things in many cases, there is no reason to try to enforce this policy by spurious moving the method to a subclass. Now, we might technically sign class, but CA derivations is experimental, and @Ericson2314 is going to revisit all this stuff with issue #11896 anyways.
1 parent 0e7e1f5 commit db8439c

File tree

8 files changed

+17
-28
lines changed

8 files changed

+17
-28
lines changed

src/libstore/build/derivation-goal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ Goal::Co DerivationGoal::resolvedFinished()
10471047
: worker.store;
10481048
newRealisation.dependentRealisations = drvOutputReferences(worker.store, *drv, realisation.outPath, &drvStore);
10491049
}
1050-
signRealisation(newRealisation);
1050+
worker.store.signRealisation(newRealisation);
10511051
worker.store.registerDrvOutput(newRealisation);
10521052
}
10531053
outputPaths.insert(realisation.outPath);

src/libstore/build/derivation-goal.hh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,6 @@ struct DerivationGoal : public Goal
267267
*/
268268
Path openLogFile();
269269

270-
/**
271-
* Sign the newly built realisation if the store allows it
272-
*/
273-
virtual void signRealisation(Realisation&) {}
274-
275270
/**
276271
* Close the log file.
277272
*/

src/libstore/local-store.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,19 +1585,6 @@ void LocalStore::addSignatures(const StorePath & storePath, const StringSet & si
15851585
}
15861586

15871587

1588-
void LocalStore::signRealisation(Realisation & realisation)
1589-
{
1590-
// FIXME: keep secret keys in memory.
1591-
1592-
auto secretKeyFiles = settings.secretKeyFiles;
1593-
1594-
for (auto & secretKeyFile : secretKeyFiles.get()) {
1595-
SecretKey secretKey(readFile(secretKeyFile));
1596-
LocalSigner signer(std::move(secretKey));
1597-
realisation.sign(signer);
1598-
}
1599-
}
1600-
16011588
void LocalStore::signPathInfo(ValidPathInfo & info)
16021589
{
16031590
// FIXME: keep secret keys in memory.

src/libstore/local-store.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ private:
401401
* specified by the ‘secret-key-files’ option.
402402
*/
403403
void signPathInfo(ValidPathInfo & info);
404-
void signRealisation(Realisation &);
405404

406405
void addBuildLog(const StorePath & drvPath, std::string_view log) override;
407406

src/libstore/store-api.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,19 @@ Derivation Store::readDerivation(const StorePath & drvPath)
12741274
Derivation Store::readInvalidDerivation(const StorePath & drvPath)
12751275
{ return readDerivationCommon(*this, drvPath, false); }
12761276

1277+
void Store::signRealisation(Realisation & realisation)
1278+
{
1279+
// FIXME: keep secret keys in memory.
1280+
1281+
auto secretKeyFiles = settings.secretKeyFiles;
1282+
1283+
for (auto & secretKeyFile : secretKeyFiles.get()) {
1284+
SecretKey secretKey(readFile(secretKeyFile));
1285+
LocalSigner signer(std::move(secretKey));
1286+
realisation.sign(signer);
1287+
}
1288+
}
1289+
12771290
}
12781291

12791292

src/libstore/store-api.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ public:
622622
virtual void addSignatures(const StorePath & storePath, const StringSet & sigs)
623623
{ unsupported("addSignatures"); }
624624

625+
void signRealisation(Realisation &);
626+
625627
/* Utility functions. */
626628

627629
/**

src/libstore/unix/build/local-derivation-goal.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
28722872
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)
28732873
&& !drv->type().isImpure())
28742874
{
2875-
signRealisation(thisRealisation);
2875+
worker.store.signRealisation(thisRealisation);
28762876
worker.store.registerDrvOutput(thisRealisation);
28772877
}
28782878
builtOutputs.emplace(outputName, thisRealisation);
@@ -2881,11 +2881,6 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
28812881
return builtOutputs;
28822882
}
28832883

2884-
void LocalDerivationGoal::signRealisation(Realisation & realisation)
2885-
{
2886-
getLocalStore().signRealisation(realisation);
2887-
}
2888-
28892884

28902885
void LocalDerivationGoal::checkOutputs(const std::map<std::string, ValidPathInfo> & outputs)
28912886
{

src/libstore/unix/build/local-derivation-goal.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ struct LocalDerivationGoal : public DerivationGoal
241241
*/
242242
SingleDrvOutputs registerOutputs();
243243

244-
void signRealisation(Realisation &) override;
245-
246244
/**
247245
* Check that an output meets the requirements specified by the
248246
* 'outputChecks' attribute (or the legacy

0 commit comments

Comments
 (0)