[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08/09: daemon: Raise an error if substituter doesn't send the expected h
From: |
guix-commits |
Subject: |
08/09: daemon: Raise an error if substituter doesn't send the expected hash. |
Date: |
Tue, 8 Dec 2020 17:00:15 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit bfe4cdf88ee3e88910d22291a4c745462f2d6417
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Dec 3 09:44:22 2020 +0100
daemon: Raise an error if substituter doesn't send the expected hash.
It was already impossible in practice for 'expectedHashStr' to be empty
if 'status' == "success".
* nix/libstore/build.cc (SubstitutionGoal::finished): Throw 'SubstError'
when 'expectedHashStr' is empty.
---
nix/libstore/build.cc | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 6cfe7ab..b5551b8 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -3040,27 +3040,28 @@ void SubstitutionGoal::finished()
if (!pathExists(destPath))
throw SubstError(format("substitute did not produce path `%1%'") %
destPath);
+ if (expectedHashStr == "")
+ throw SubstError(format("substituter did not communicate hash for
`%1'") % storePath);
+
hash = hashPath(htSHA256, destPath);
/* Verify the expected hash we got from the substituer. */
- if (expectedHashStr != "") {
- size_t n = expectedHashStr.find(':');
- if (n == string::npos)
- throw Error(format("bad hash from substituter: %1%") %
expectedHashStr);
- HashType hashType = parseHashType(string(expectedHashStr, 0, n));
- if (hashType == htUnknown)
- throw Error(format("unknown hash algorithm in `%1%'") %
expectedHashStr);
- Hash expectedHash = parseHash16or32(hashType,
string(expectedHashStr, n + 1));
- Hash actualHash = hashType == htSHA256 ? hash.first :
hashPath(hashType, destPath).first;
- if (expectedHash != actualHash) {
- if (settings.printBuildTrace)
- printMsg(lvlError, format("@ hash-mismatch %1% %2% %3% %4%")
- % storePath % "sha256"
- % printHash16or32(expectedHash)
- % printHash16or32(actualHash));
- throw SubstError(format("hash mismatch for substituted item
`%1%'") % storePath);
- }
- }
+ size_t n = expectedHashStr.find(':');
+ if (n == string::npos)
+ throw Error(format("bad hash from substituter: %1%") %
expectedHashStr);
+ HashType hashType = parseHashType(string(expectedHashStr, 0, n));
+ if (hashType == htUnknown)
+ throw Error(format("unknown hash algorithm in `%1%'") %
expectedHashStr);
+ Hash expectedHash = parseHash16or32(hashType, string(expectedHashStr, n
+ 1));
+ Hash actualHash = hashType == htSHA256 ? hash.first :
hashPath(hashType, destPath).first;
+ if (expectedHash != actualHash) {
+ if (settings.printBuildTrace)
+ printMsg(lvlError, format("@ hash-mismatch %1% %2% %3% %4%")
+ % storePath % "sha256"
+ % printHash16or32(expectedHash)
+ % printHash16or32(actualHash));
+ throw SubstError(format("hash mismatch for substituted item `%1%'")
% storePath);
+ }
} catch (SubstError & e) {
- branch master updated (20e5658 -> 799f066), guix-commits, 2020/12/08
- 06/09: daemon: Run 'guix substitute --substitute' as an agent., guix-commits, 2020/12/08
- 09/09: import: opam: Adjust test to latest 'opam->guix-package' changes., guix-commits, 2020/12/08
- 04/09: daemon: Use 'Agent' to spawn 'guix substitute --query'., guix-commits, 2020/12/08
- 05/09: daemon: Factorize substituter agent spawning., guix-commits, 2020/12/08
- 01/09: database: Remove unnecessary module imports., guix-commits, 2020/12/08
- 08/09: daemon: Raise an error if substituter doesn't send the expected hash.,
guix-commits <=
- 07/09: substitute: Cache and reuse connections while substituting., guix-commits, 2020/12/08
- 03/09: daemon: 'Agent' constructor takes a list of environment variables., guix-commits, 2020/12/08
- 02/09: gnu: autotools: Add version 2.70., guix-commits, 2020/12/08