From: David Kalnischkies Date: Wed, 15 Oct 2014 16:32:14 +0000 (+0200) Subject: Merge branch 'debian/sid' into debian/experimental X-Git-Tag: 1.1.exp7~2 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/0977f81757f42889a9edb761061529041afe0a06 Merge branch 'debian/sid' into debian/experimental The acquire code changed completely, so this is more an import of the testcase and a new fix than the merge of an existent fix. Conflicts: apt-pkg/acquire-item.cc --- 0977f81757f42889a9edb761061529041afe0a06 diff --cc apt-pkg/acquire-item.cc index c63253447,253cbdaf7..5187738e9 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@@ -1282,20 -1036,16 +1282,25 @@@ std::string pkgAcqIndex::GetFinalFilena } /*}}}*/ // AcqIndex::ReverifyAfterIMS - Reverify index after an ims-hit /*{{{*/ -void pkgAcqIndex::ReverifyAfterIMS(std::string const &FileName) +void pkgAcqIndex::ReverifyAfterIMS() { - std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' ')); + // update destfile to *not* include the compression extension when doing + // a reverify (as its uncompressed on disk already) + DestFile = GetPartialFileNameFromURI(RealURI); + ++ // do not reverify cdrom sources as apt-cdrom may rewrite the Packages ++ // file when its doing the indexcopy ++ if (RealURI.substr(0,6) == "cdrom:") ++ return; ++ + // adjust DestFile if its compressed on disk if (_config->FindB("Acquire::GzipIndexes",false) == true) - DestFile += compExt; + DestFile += '.' + CurrentCompressionExtension; - string FinalFile = GetFinalFilename(RealURI, compExt); - Rename(FinalFile, FileName); - Decompression = true; - Desc.URI = "copy:" + FileName; + // copy FinalFile into partial/ so that we check the hash again + string FinalFile = GetFinalFilename(); + Stage = STAGE_DECOMPRESS_AND_VERIFY; + Desc.URI = "copy:" + FinalFile; QueueURI(Desc); } /*}}}*/ @@@ -1387,37 -1139,43 +1392,32 @@@ void pkgAcqIndex::StageDownloadDone(str ErrorText = "Method gave a blank filename"; } - if (FileName == DestFile) - Erase = true; - else + // Methods like e.g. "file:" will give us a (compressed) FileName that is + // not the "DestFile" we set, in this case we uncompress from the local file + if (FileName != DestFile) Local = true; + else + EraseFileName = FileName; - // The files timestamp matches, for non-local URLs reverify the local - // file, for local file, uncompress again to ensure the hashsum is still - // matching the Release file - bool const IsCDROM = RealURI.substr(0,6) == "cdrom:"; - if ((Local == false || IsCDROM == true) && - StringToBool(LookupTag(Message,"IMS-Hit"),false) == true) + // we need to verify the file against the current Release file again + // on if-modfied-since hit to avoid a stale attack against us + if(StringToBool(LookupTag(Message,"IMS-Hit"),false) == true) { - // set destfile to the final destfile - if(_config->FindB("Acquire::GzipIndexes",false) == false) - { - DestFile = _config->FindDir("Dir::State::lists") + "partial/"; - DestFile += URItoFileName(RealURI); - } - -- // do not reverify cdrom sources as apt-cdrom may rewrite the Packages -- // file when its doing the indexcopy - if (RealURI.substr(0,6) == "cdrom:") - return; - - if (IsCDROM == false) - ReverifyAfterIMS(FileName); + // The files timestamp matches, reverify by copy into partial/ + EraseFileName = ""; + ReverifyAfterIMS(); return; } - string decompProg; - // If we enable compressed indexes, queue for hash verification + // If we have compressed indexes enabled, queue for hash verification if (_config->FindB("Acquire::GzipIndexes",false)) { - DestFile = _config->FindDir("Dir::State::lists"); - DestFile += URItoFileName(RealURI) + '.' + compExt; - - Decompression = true; + DestFile = GetPartialFileNameFromURI(RealURI + '.' + CurrentCompressionExtension); + EraseFileName = ""; + Stage = STAGE_DECOMPRESS_AND_VERIFY; Desc.URI = "copy:" + FileName; QueueURI(Desc); - + SetActiveSubprocess("copy"); return; }