diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2013-08-18 23:27:24 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-05-09 13:06:27 +0200 |
commit | 1262d35895c930f3fa49d7b4182cdd7a4a841f74 (patch) | |
tree | 3d9874d4d7768273af4ee0907eb36d79295ab257 /cmdline | |
parent | f4c3850ea335545e297504941dc8c7a8f1c83358 (diff) |
use 'best' hash for source authentication
Collect all hashes we can get from the source record and put them into a
HashStringList so that 'apt-get source' can use it instead of using
always the MD5sum.
We therefore also deprecate the MD5 struct member in favor of the list.
While at it, the parsing of the Files is enhanced so that records which
miss "Files" (aka MD5 checksums) are still searched for other checksums
as they include just as much data, just not with a nice and catchy name.
LP: 1098738
Diffstat (limited to 'cmdline')
-rw-r--r-- | cmdline/apt-get.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1148dbbf3..fc6223989 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -828,19 +828,26 @@ static bool DoSource(CommandLine &CmdL) queued.insert(Last->Index().ArchiveURI(I->Path)); // check if we have a file with that md5 sum already localy - if(!I->Hash.empty() && FileExists(flNotDir(I->Path))) - { - HashString hash_string = HashString(I->Hash); - if(hash_string.VerifyFile(flNotDir(I->Path))) + std::string localFile = flNotDir(I->Path); + if (FileExists(localFile) == true) + if(I->Hashes.VerifyFile(localFile) == true) { ioprintf(c1out,_("Skipping already downloaded file '%s'\n"), - flNotDir(I->Path).c_str()); + localFile.c_str()); continue; } + + // see if we have a hash (Acquire::ForceHash is the only way to have none) + HashString const * const hs = I->Hashes.find(NULL); + if (hs == NULL && _config->FindB("APT::Get::AllowUnauthenticated",false) == false) + { + ioprintf(c1out, "Skipping download of file '%s' as requested hashsum is not available for authentication\n", + localFile.c_str()); + continue; } new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path), - I->Hash,I->Size, + hs != NULL ? hs->toStr() : "", I->Size, Last->Index().SourceInfo(*Last,*I),Src); } } |