summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/acquire-item.cc103
-rw-r--r--apt-pkg/acquire-item.h16
2 files changed, 65 insertions, 54 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index c3b6f0e6a..0ec151050 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1367,13 +1367,56 @@ void pkgAcqIndexTrans::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
Item::Failed(Message,Cnf);
}
/*}}}*/
+
+pkgAcqMetaSigBase::pkgAcqMetaSigBase(pkgAcquire *Owner,
+ HashStringList const &ExpectedHashes,
+ unsigned long TransactionID)
+ : Item(Owner, ExpectedHashes, TransactionID)
+{
+}
+ /*{{{*/
+bool pkgAcqMetaSigBase::GenerateAuthWarning(const std::string &RealURI,
+ const std::string &Message)
+{
+ string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
+
+ if(FileExists(Final))
+ {
+ Status = StatTransientNetworkError;
+ _error->Warning(_("An error occurred during the signature "
+ "verification. The repository is not updated "
+ "and the previous index files will be used. "
+ "GPG error: %s: %s\n"),
+ Desc.Description.c_str(),
+ LookupTag(Message,"Message").c_str());
+ RunScripts("APT::Update::Auth-Failure");
+ return true;
+ } else if (LookupTag(Message,"Message").find("NODATA") != string::npos) {
+ /* Invalid signature file, reject (LP: #346386) (Closes: #627642) */
+ _error->Error(_("GPG error: %s: %s"),
+ Desc.Description.c_str(),
+ LookupTag(Message,"Message").c_str());
+ Status = StatError;
+ return true;
+ } else {
+ _error->Warning(_("GPG error: %s: %s"),
+ Desc.Description.c_str(),
+ LookupTag(Message,"Message").c_str());
+ }
+ // gpgv method failed
+ ReportMirrorFailure("GPGFailure");
+ return false;
+}
+ /*}}}*/
+
+
pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, /*{{{*/
unsigned long TransactionID,
string URI,string URIDesc,string ShortDesc,
string MetaIndexFile,
const vector<IndexTarget*>* IndexTargets,
indexRecords* MetaIndexParser) :
- Item(Owner, HashStringList(), TransactionID), RealURI(URI),
+ pkgAcqMetaSigBase(Owner, HashStringList(), TransactionID), RealURI(URI),
MetaIndexParser(MetaIndexParser), MetaIndexFile(MetaIndexFile),
IndexTargets(IndexTargets), AuthPass(false), IMSHit(false)
{
@@ -1490,31 +1533,9 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
// FIXME: duplicated code from pkgAcqMetaIndex
if (AuthPass == true)
{
- if(FileExists(Final))
- {
- Status = StatTransientNetworkError;
- _error->Warning(_("An error occurred during the signature "
- "verification. The repository is not updated "
- "and the previous index files will be used. "
- "GPG error: %s: %s\n"),
- Desc.Description.c_str(),
- LookupTag(Message,"Message").c_str());
- RunScripts("APT::Update::Auth-Failure");
- return;
- } else if (LookupTag(Message,"Message").find("NODATA") != string::npos) {
- /* Invalid signature file, reject (LP: #346386) (Closes: #627642) */
- _error->Error(_("GPG error: %s: %s"),
- Desc.Description.c_str(),
- LookupTag(Message,"Message").c_str());
- Status = StatError;
- return;
- } else {
- _error->Warning(_("GPG error: %s: %s"),
- Desc.Description.c_str(),
- LookupTag(Message,"Message").c_str());
- }
- // gpgv method failed
- ReportMirrorFailure("GPGFailure");
+ bool Stop = GenerateAuthWarning(RealURI, Message);
+ if(Stop)
+ return;
}
// FIXME: this is used often (e.g. in pkgAcqIndexTrans) so refactor
@@ -1536,7 +1557,7 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner, /*{{{*/
string MetaIndexSigURI,string MetaIndexSigURIDesc, string MetaIndexSigShortDesc,
const vector<IndexTarget*>* IndexTargets,
indexRecords* MetaIndexParser) :
- Item(Owner, HashStringList(), TransactionID), RealURI(URI), IndexTargets(IndexTargets),
+ pkgAcqMetaSigBase(Owner, HashStringList(), TransactionID), RealURI(URI), IndexTargets(IndexTargets),
MetaIndexParser(MetaIndexParser), AuthPass(false), IMSHit(false),
MetaIndexSigURI(MetaIndexSigURI), MetaIndexSigURIDesc(MetaIndexSigURIDesc),
MetaIndexSigShortDesc(MetaIndexSigShortDesc)
@@ -1905,31 +1926,9 @@ void pkgAcqMetaIndex::Failed(string Message,
if (AuthPass == true)
{
- if(FileExists(Final))
- {
- Status = StatTransientNetworkError;
- _error->Warning(_("An error occurred during the signature "
- "verification. The repository is not updated "
- "and the previous index files will be used. "
- "GPG error: %s: %s\n"),
- Desc.Description.c_str(),
- LookupTag(Message,"Message").c_str());
- RunScripts("APT::Update::Auth-Failure");
- return;
- } else if (LookupTag(Message,"Message").find("NODATA") != string::npos) {
- /* Invalid signature file, reject (LP: #346386) (Closes: #627642) */
- _error->Error(_("GPG error: %s: %s"),
- Desc.Description.c_str(),
- LookupTag(Message,"Message").c_str());
- Status = StatError;
- return;
- } else {
- _error->Warning(_("GPG error: %s: %s"),
- Desc.Description.c_str(),
- LookupTag(Message,"Message").c_str());
- }
- // gpgv method failed
- ReportMirrorFailure("GPGFailure");
+ bool Stop = GenerateAuthWarning(RealURI, Message);
+ if(Stop)
+ return;
}
/* Always move the meta index, even if gpgv failed. This ensures
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 28577e9b8..ae93ea311 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -378,6 +378,18 @@ class pkgAcqSubIndex : public pkgAcquire::Item
};
/*}}}*/
+class pkgAcqMetaSigBase : public pkgAcquire::Item
+{
+ protected:
+ bool GenerateAuthWarning(const std::string &RealURI,
+ const std::string &Message);
+
+ public:
+ pkgAcqMetaSigBase(pkgAcquire *Owner,
+ HashStringList const &ExpectedHashes=HashStringList(),
+ unsigned long TransactionID=0);
+};
+
/** \brief An item that is responsible for downloading the meta-index {{{
* file (i.e., Release) itself and verifying its signature.
*
@@ -388,7 +400,7 @@ class pkgAcqSubIndex : public pkgAcquire::Item
* otherwise, the expected hashsums will be "" (causing the
* authentication of the index files to be bypassed).
*/
-class pkgAcqMetaIndex : public pkgAcquire::Item
+class pkgAcqMetaIndex : public pkgAcqMetaSigBase
{
protected:
/** \brief The URI that is actually being downloaded; never
@@ -1017,7 +1029,7 @@ class OptionalSubIndexTarget : public OptionalIndexTarget
*
* \sa pkgAcqMetaIndex
*/
-class pkgAcqMetaSig : public pkgAcquire::Item
+class pkgAcqMetaSig : public pkgAcqMetaSigBase
{
protected:
/** \brief The last good signature file */