From 8a8feb29265b3dfc27f82072563a641a7976752a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 30 Jul 2007 17:47:05 +0200 Subject: * apt-pkg/acquire-item.{cc,h}: - rename "hash" into ExpectedHash in pkgAcqFile, pkgAcqIndex - add missing HashSum() call to class pkgAcqIndex - use the data provided by acquire-method (and send via the {SHA256,SHA1,MD5Sum}-Hash tag when comparing the hash, this avoids calculating the hash twice (just like old libapt) * apt-pkg/acquire-method.cc: - send MD5Sum-Hash tag to libapt to be consistant with HashString::SupportedHashes() * apt-pkg/acquire-worker.cc: - check with "Owner->HashSum().HashType()" what hash the frontend is expecting and pass it to pkgAcquireItem::Done() in the new HashString format - add some debugging output * apt-pkg/contrib/hashes.cc: - fix off-by-one error when constructing a HashString from a single input string * apt-pkg/contrib/hashes.h: - add "HashType()" method * apt-pkg/init.h, apt-pkg/makefile, methods/makefile: - break ABI --- apt-pkg/acquire-worker.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'apt-pkg/acquire-worker.cc') diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 25d40ef54..460f59961 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -267,8 +267,23 @@ bool pkgAcquire::Worker::RunMessages() _error->Warning("Bizarre Error - File size is not what the server reported %s %lu", LookupTag(Message,"Size","0").c_str(),TotalSize); + // see if there is a hash to verify + string RecivedHash; + HashString expectedHash(Owner->HashSum()); + if(!expectedHash.empty()) + { + string hashTag = expectedHash.HashType()+"-Hash"; + RecivedHash = expectedHash.HashType() + ":" + LookupTag(Message, hashTag.c_str()); + if(_config->FindB("Debug::pkgAcquire::Auth", false) == true) + { + clog << "201 URI Done: " << Owner->DescURI() << endl + << "RecivedHash: " << RecivedHash << endl + << "ExpectedHash: " << expectedHash.toStr() + << endl << endl; + } + } Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()), - LookupTag(Message,"MD5-Hash"),Config); + RecivedHash.c_str(), Config); ItemDone(); // Log that we are done -- cgit v1.2.3