summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2026-05-30 15:07:15 +0200
committerLudovic Courtès <ludo@gnu.org>2026-08-17 16:47:36 +0200
commitd04d7d9be525aaf2d55792b172b051ec5a539eed (patch)
treec56c7446d92d7befc9b9546c5d18b2d8c0255c55
parent6fbe87f2c890e10c6b24f838b73ad3683b5c97b0 (diff)
daemon: Remove ‘requireSignature’ argument to ‘importPath’.
In ‘guix-daemon’ the value of ‘requireSignature’ has always been true. * nix/libstore/local-store.hh (LocalStore)[importPath]: Remove ‘requireSignature’ argument. * nix/libstore/local-store.cc (LocalStore::importPath): Adjust accordingly. Change-Id: I4e2d781c85107770cb64ab71d2e7fb711859e0c7 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--nix/libstore/local-store.cc29
-rw-r--r--nix/libstore/local-store.hh2
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
1326Path LocalStore::importPath(bool requireSignature, Source & source) 1326Path 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