summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-06 12:28:00 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-06-09 12:57:35 +0200
commit448c38bdcd72b52f11ec5f326f822cf57653f81c (patch)
tree98f26e9d477e720c3448773f398e6b13e0e431c7 /apt-pkg/deb
parent58702f8563a443a7c6e66253b259c2488b877290 (diff)
rework hashsum verification in the acquire system
Having every item having its own code to verify the file(s) it handles is an errorprune process and easy to break, especially if items move through various stages (download, uncompress, patching, …). With a giant rework we centralize (most of) the verification to have a better enforcement rate and (hopefully) less chance for bugs, but it breaks the ABI bigtime in exchange – and as we break it anyway, it is broken even harder. It shouldn't effect most frontends as they don't deal with the acquire system at all or implement their own items, but some do and will need to be patched (might be an opportunity to use apt on-board material). The theory is simple: Items implement methods to decide if hashes need to be checked (in this stage) and to return the expected hashes for this item (in this stage). The verification itself is done in worker message passing which has the benefit that a hashsum error is now a proper error for the acquire system rather than a Done() which is later revised to a Failed().
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc4
-rw-r--r--apt-pkg/deb/debmetaindex.cc78
2 files changed, 33 insertions, 49 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index d672b4fd8..185248619 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -742,13 +742,13 @@ bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
// and give it to the list parser
debDebFileParser Parser(DebControl, DebFile);
- if(Gen.SelectFile(DebFile, "local", *this) == false)
+ if(Gen.SelectFile(DebFile, "local", *this, pkgCache::Flag::LocalSource) == false)
return _error->Error("Problem with SelectFile %s", DebFile.c_str());
pkgCache::PkgFileIterator File = Gen.GetCurFile();
File->Size = DebControl->Size();
File->mtime = DebControl->ModificationTime();
-
+
if (Gen.MergeList(Parser) == false)
return _error->Error("Problem with MergeLister for %s", DebFile.c_str());
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index aa2db8149..eb5e78e3b 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -192,11 +192,13 @@ vector <IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
vector<debSectionEntry const*> const SectionEntries = src->second;
for (vector<debSectionEntry const*>::const_iterator I = SectionEntries.begin();
I != SectionEntries.end(); ++I) {
- IndexTarget * Target = new IndexTarget();
- Target->ShortDesc = "Sources";
- Target->MetaKey = SourceIndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section);
- Target->URI = SourceIndexURI(Target->ShortDesc.c_str(), (*I)->Section);
- Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section);
+ char const * const ShortDesc = "Sources";
+ IndexTarget * const Target = new IndexTarget(
+ SourceIndexURISuffix(ShortDesc, (*I)->Section),
+ ShortDesc,
+ Info(ShortDesc, (*I)->Section),
+ SourceIndexURI(ShortDesc, (*I)->Section)
+ );
IndexTargets->push_back (Target);
}
}
@@ -212,11 +214,13 @@ vector <IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
continue;
for (vector <const debSectionEntry *>::const_iterator I = a->second.begin();
I != a->second.end(); ++I) {
- IndexTarget * Target = new IndexTarget();
- Target->ShortDesc = "Packages";
- Target->MetaKey = IndexURISuffix(Target->ShortDesc.c_str(), (*I)->Section, a->first);
- Target->URI = IndexURI(Target->ShortDesc.c_str(), (*I)->Section, a->first);
- Target->Description = Info (Target->ShortDesc.c_str(), (*I)->Section, a->first);
+ char const * const ShortDesc = "Packages";
+ IndexTarget * const Target = new IndexTarget(
+ IndexURISuffix(ShortDesc, (*I)->Section, a->first),
+ ShortDesc,
+ Info (ShortDesc, (*I)->Section, a->first),
+ IndexURI(ShortDesc, (*I)->Section, a->first)
+ );
IndexTargets->push_back (Target);
sections.insert((*I)->Section);
}
@@ -235,11 +239,13 @@ vector <IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
s != sections.end(); ++s) {
for (std::vector<std::string>::const_iterator l = lang.begin();
l != lang.end(); ++l) {
- IndexTarget * Target = new OptionalIndexTarget();
- Target->ShortDesc = "Translation-" + *l;
- Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s);
- Target->URI = TranslationIndexURI(l->c_str(), *s);
- Target->Description = Info (Target->ShortDesc.c_str(), *s);
+ std::string const ShortDesc = "Translation-" + *l;
+ IndexTarget * const Target = new OptionalIndexTarget(
+ TranslationIndexURISuffix(l->c_str(), *s),
+ ShortDesc,
+ Info (ShortDesc.c_str(), *s),
+ TranslationIndexURI(l->c_str(), *s)
+ );
IndexTargets->push_back(Target);
}
}
@@ -249,8 +255,6 @@ vector <IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
/*}}}*/
bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
{
- bool const tryInRelease = _config->FindB("Acquire::TryInRelease", true);
-
indexRecords * const iR = new indexRecords(Dist);
if (Trusted == ALWAYS_TRUSTED)
iR->SetTrusted(true);
@@ -258,37 +262,17 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
iR->SetTrusted(false);
// special case for --print-uris
- if (GetAll) {
- vector <IndexTarget *> *targets = ComputeIndexTargets();
- for (vector <IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); ++Target) {
- new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description,
- (*Target)->ShortDesc, HashStringList());
- }
- delete targets;
-
- // this is normally created in pkgAcqMetaSig, but if we run
- // in --print-uris mode, we add it here
- if (tryInRelease == false)
- new pkgAcqMetaIndex(Owner, NULL,
- MetaIndexURI("Release"),
- MetaIndexInfo("Release"), "Release",
- MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
- ComputeIndexTargets(),
- iR);
+ vector <IndexTarget *> const * const targets = ComputeIndexTargets();
+#define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X))
+ pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
+ APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
+ targets, iR);
+#undef APT_TARGET
+ if (GetAll)
+ {
+ for (vector <IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); ++Target)
+ new pkgAcqIndex(Owner, TransactionManager, *Target);
}
- if (tryInRelease == true)
- new pkgAcqMetaClearSig(Owner,
- MetaIndexURI("InRelease"), MetaIndexInfo("InRelease"), "InRelease",
- MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
- MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
- ComputeIndexTargets(),
- iR);
- else
- new pkgAcqMetaIndex(Owner, NULL,
- MetaIndexURI("Release"), MetaIndexInfo("Release"), "Release",
- MetaIndexURI("Release.gpg"), MetaIndexInfo("Release.gpg"), "Release.gpg",
- ComputeIndexTargets(),
- iR);
return true;
}