diff options
| -rw-r--r-- | nix/libstore/local-store.cc | 29 | ||||
| -rw-r--r-- | nix/libstore/local-store.hh | 2 |
2 files changed, 13 insertions, 18 deletions
diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc index 3bb96e32601..46ce649fb0b 100644 --- a/nix/libstore/local-store.cc +++ b/nix/libstore/local-store.cc | |||
| @@ -1323,7 +1323,7 @@ Path LocalStore::createTempDirInStore() | |||
| 1323 | } | 1323 | } |
| 1324 | 1324 | ||
| 1325 | 1325 | ||
| 1326 | Path LocalStore::importPath(bool requireSignature, Source & source) | 1326 | Path LocalStore::importPath(Source & source) |
| 1327 | { | 1327 | { |
| 1328 | HashAndReadSource hashAndReadSource(source); | 1328 | HashAndReadSource hashAndReadSource(source); |
| 1329 | 1329 | ||
| @@ -1356,25 +1356,20 @@ Path LocalStore::importPath(bool requireSignature, Source & source) | |||
| 1356 | 1356 | ||
| 1357 | bool haveSignature = readInt(hashAndReadSource) == 1; | 1357 | bool haveSignature = readInt(hashAndReadSource) == 1; |
| 1358 | 1358 | ||
| 1359 | if (requireSignature && !haveSignature) | 1359 | if (!haveSignature) |
| 1360 | throw Error(std::format("imported archive of `{}' lacks a signature", dstPath)); | 1360 | throw Error(std::format("imported archive of `{}' lacks a signature", dstPath)); |
| 1361 | 1361 | ||
| 1362 | if (haveSignature) { | 1362 | string signature = readString(hashAndReadSource); |
| 1363 | string signature = readString(hashAndReadSource); | 1363 | string hash2 = verifySignature(signature); |
| 1364 | 1364 | ||
| 1365 | if (requireSignature) { | 1365 | /* Note: runProgram() throws an exception if the signature |
| 1366 | string hash2 = verifySignature(signature); | 1366 | is invalid. */ |
| 1367 | 1367 | ||
| 1368 | /* Note: runProgram() throws an exception if the signature | 1368 | if (printHash(hash) != hash2) |
| 1369 | is invalid. */ | 1369 | throw Error( |
| 1370 | 1370 | "signed hash doesn't match actual contents of imported " | |
| 1371 | if (printHash(hash) != hash2) | 1371 | "archive; archive could be corrupt, or someone is trying " |
| 1372 | throw Error( | 1372 | "to import a Trojan horse"); |
| 1373 | "signed hash doesn't match actual contents of imported " | ||
| 1374 | "archive; archive could be corrupt, or someone is trying " | ||
| 1375 | "to import a Trojan horse"); | ||
| 1376 | } | ||
| 1377 | } | ||
| 1378 | 1373 | ||
| 1379 | /* Do the actual import. */ | 1374 | /* Do the actual import. */ |
| 1380 | 1375 | ||
| @@ -1431,7 +1426,7 @@ Paths LocalStore::importPaths(Source & source) | |||
| 1431 | unsigned long long n = readLongLong(source); | 1426 | unsigned long long n = readLongLong(source); |
| 1432 | if (n == 0) break; | 1427 | if (n == 0) break; |
| 1433 | if (n != 1) throw Error("input doesn't look like something created by `nix-store --export'"); | 1428 | if (n != 1) throw Error("input doesn't look like something created by `nix-store --export'"); |
| 1434 | res.push_back(importPath(true, source)); | 1429 | res.push_back(importPath(source)); |
| 1435 | } | 1430 | } |
| 1436 | return res; | 1431 | return res; |
| 1437 | } | 1432 | } |
diff --git a/nix/libstore/local-store.hh b/nix/libstore/local-store.hh index 754cdf5ad31..6a0def7412e 100644 --- a/nix/libstore/local-store.hh +++ b/nix/libstore/local-store.hh | |||
| @@ -257,7 +257,7 @@ private: | |||
| 257 | 257 | ||
| 258 | Path createTempDirInStore(); | 258 | Path createTempDirInStore(); |
| 259 | 259 | ||
| 260 | Path importPath(bool requireSignature, Source & source); | 260 | Path importPath(Source & source); |
| 261 | 261 | ||
| 262 | void checkDerivationOutputs(const Path & drvPath, const Derivation & drv); | 262 | void checkDerivationOutputs(const Path & drvPath, const Derivation & drv); |
| 263 | 263 | ||
