From 564720959e4ae47921b795fe6c5ce46e1e1bdc95 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 18 Jul 2014 23:21:46 +0200 Subject: WIP transaction based update --- apt-pkg/acquire-item.h | 302 +++++++++++++++++++++++++++---------------------- 1 file changed, 166 insertions(+), 136 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 0500a3627..6c9fec695 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -47,6 +47,7 @@ class indexRecords; class pkgRecords; class pkgSourceList; class IndexTarget; +class pkgAcqMetaIndex; /** \brief Represents the process by which a pkgAcquire object should {{{ * retrieve a file or a collection of files. @@ -116,7 +117,7 @@ class pkgAcquire::Item : public WeakPointable /** \brief The item was could not be downloaded because of * a transient network error (e.g. network down) */ - StatTransientNetworkError + StatTransientNetworkError, } Status; /** \brief Contains a textual description of the error encountered @@ -168,6 +169,9 @@ class pkgAcquire::Item : public WeakPointable */ unsigned int QueueCounter; + /** \brief TransactionID */ + unsigned long TransactionID; + /** \brief The number of additional fetch items that are expected * once this item is done. * @@ -183,6 +187,9 @@ class pkgAcquire::Item : public WeakPointable */ std::string DestFile; + /** \brief storge name until a transaction is finished */ + std::string PartialFile; + /** \brief Invoked by the acquire worker when the object couldn't * be fetched. * @@ -368,6 +375,137 @@ class pkgAcqSubIndex : public pkgAcquire::Item }; /*}}}*/ +/** \brief An item that is responsible for downloading the meta-index {{{ + * file (i.e., Release) itself and verifying its signature. + * + * Once the download and verification are complete, the downloads of + * the individual index files are queued up using pkgAcqDiffIndex. + * If the meta-index file had a valid signature, the expected hashsums + * of the index files will be the md5sums listed in the meta-index; + * otherwise, the expected hashsums will be "" (causing the + * authentication of the index files to be bypassed). + */ +class pkgAcqMetaIndex : public pkgAcquire::Item +{ + protected: + /** \brief The URI that is actually being downloaded; never + * modified by pkgAcqMetaIndex. + */ + std::string RealURI; + + /** \brief The file in which the signature for this index was stored. + * + * If empty, the signature and the md5sums of the individual + * indices will not be checked. + */ + std::string SigFile; + + /** \brief The index files to download. */ + const std::vector* IndexTargets; + + /** \brief The parser for the meta-index file. */ + indexRecords* MetaIndexParser; + + /** \brief If \b true, the index's signature is currently being verified. + */ + bool AuthPass; + // required to deal gracefully with problems caused by incorrect ims hits + bool IMSHit; + + /** \brief Check that the release file is a release file for the + * correct distribution. + * + * \return \b true if no fatal errors were encountered. + */ + bool VerifyVendor(std::string Message); + + /** \brief Called when a file is finished being retrieved. + * + * If the file was not downloaded to DestFile, a copy process is + * set up to copy it to DestFile; otherwise, Complete is set to \b + * true and the file is moved to its final location. + * + * \param Message The message block received from the fetch + * subprocess. + */ + void RetrievalDone(std::string Message); + + /** \brief Called when authentication succeeded. + * + * Sanity-checks the authenticated file, queues up the individual + * index files for download, and saves the signature in the lists + * directory next to the authenticated list file. + * + * \param Message The message block received from the fetch + * subprocess. + */ + void AuthDone(std::string Message); + + /** \brief Starts downloading the individual index files. + * + * \param verify If \b true, only indices whose expected hashsum + * can be determined from the meta-index will be downloaded, and + * the hashsums of indices will be checked (reporting + * #StatAuthError if there is a mismatch). If verify is \b false, + * no hashsum checking will be performed. + */ + void QueueIndexes(bool verify); + + public: + + // Specialized action members + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, + pkgAcquire::MethodConfig *Cnf); + virtual std::string Custom600Headers() const; + virtual std::string DescURI() const {return RealURI; }; + virtual void Finished(); + + /** \brief Create a new pkgAcqMetaIndex. */ + pkgAcqMetaIndex(pkgAcquire *Owner, + std::string URI,std::string URIDesc, std::string ShortDesc, + std::string SigFile, + const std::vector* IndexTargets, + indexRecords* MetaIndexParser); +}; + /*}}}*/ +/** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/ +class pkgAcqMetaClearSig : public pkgAcqMetaIndex +{ + /** \brief The URI of the meta-index file for the detached signature */ + std::string MetaIndexURI; + + /** \brief A "URI-style" description of the meta-index file */ + std::string MetaIndexURIDesc; + + /** \brief A brief description of the meta-index file */ + std::string MetaIndexShortDesc; + + /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */ + std::string MetaSigURI; + + /** \brief A "URI-style" description of the meta-signature file */ + std::string MetaSigURIDesc; + + /** \brief A brief description of the meta-signature file */ + std::string MetaSigShortDesc; + +public: + void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual std::string Custom600Headers() const; + + /** \brief Create a new pkgAcqMetaClearSig. */ + pkgAcqMetaClearSig(pkgAcquire *Owner, + std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc, + std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc, + std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc, + const std::vector* IndexTargets, + indexRecords* MetaIndexParser); + virtual ~pkgAcqMetaClearSig(); +}; + /*}}}*/ + + /** \brief Common base class for all classes that deal with fetching {{{ indexes */ @@ -378,13 +516,21 @@ class pkgAcqBaseIndex : public pkgAcquire::Item */ const struct IndexTarget * Target; indexRecords *MetaIndexParser; + pkgAcqMetaIndex *MetaOwner; + + pkgAcqBaseIndex(pkgAcqMetaIndex *MetaOwner, + struct IndexTarget const * const Target, + HashStringList const &ExpectedHashes, + indexRecords *MetaIndexParser) + : Item(MetaOwner->GetOwner(), ExpectedHashes), Target(Target), + MetaIndexParser(MetaIndexParser), MetaOwner(MetaOwner) {}; pkgAcqBaseIndex(pkgAcquire *Owner, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser) : Item(Owner, ExpectedHashes), Target(Target), - MetaIndexParser(MetaIndexParser) {}; + MetaIndexParser(MetaIndexParser), MetaOwner(0) {}; }; /*}}}*/ @@ -451,7 +597,7 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex * * \param ExpectedHashes The list file's hashsums which are expected. */ - pkgAcqDiffIndex(pkgAcquire *Owner, + pkgAcqDiffIndex(pkgAcqMetaIndex *MetaIndexOwner, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser); @@ -539,7 +685,7 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex * \param allPatches contains all related items so that each item can * check if it was the last one to complete the download step */ - pkgAcqIndexMergeDiffs(pkgAcquire *Owner, + pkgAcqIndexMergeDiffs(pkgAcqMetaIndex *MetaIndexOwner, struct IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser, @@ -667,7 +813,7 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex * should be ordered so that each diff appears before any diff * that depends on it. */ - pkgAcqIndexDiffs(pkgAcquire *Owner, + pkgAcqIndexDiffs(pkgAcqMetaIndex *MetaIndexOwner, struct IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser, @@ -710,6 +856,9 @@ class pkgAcqIndex : public pkgAcqBaseIndex /** \brief Do the changes needed to fetch via AptByHash (if needed) */ void InitByHashIfNeeded(const std::string MetaKey); + /** \brief Auto select the right compression to use */ + void AutoSelectCompression(); + public: // Specialized action members @@ -741,10 +890,17 @@ class pkgAcqIndex : public pkgAcqBaseIndex pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc, HashStringList const &ExpectedHashes, std::string compressExt=""); +#if 0 pkgAcqIndex(pkgAcquire *Owner, IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser); +#endif + pkgAcqIndex(pkgAcqMetaIndex *MetaIndexOwner, + IndexTarget const * const Target, + HashStringList const &ExpectedHash, + indexRecords *MetaIndexParser); + void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc); }; @@ -774,10 +930,12 @@ class pkgAcqIndexTrans : public pkgAcqIndex * * \param ShortDesc A brief description of this index file. */ - pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc, + pkgAcqIndexTrans(pkgAcquire *Owner, + std::string URI,std::string URIDesc, std::string ShortDesc); - pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const * const Target, - HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser); + pkgAcqIndexTrans(pkgAcqMetaIndex *Owner, IndexTarget const * const Target, + HashStringList const &ExpectedHashes, + indexRecords *MetaIndexParser); }; /*}}}*/ /** \brief Information about an index file. */ /*{{{*/ @@ -891,134 +1049,6 @@ class pkgAcqMetaSig : public pkgAcquire::Item virtual ~pkgAcqMetaSig(); }; /*}}}*/ -/** \brief An item that is responsible for downloading the meta-index {{{ - * file (i.e., Release) itself and verifying its signature. - * - * Once the download and verification are complete, the downloads of - * the individual index files are queued up using pkgAcqDiffIndex. - * If the meta-index file had a valid signature, the expected hashsums - * of the index files will be the md5sums listed in the meta-index; - * otherwise, the expected hashsums will be "" (causing the - * authentication of the index files to be bypassed). - */ -class pkgAcqMetaIndex : public pkgAcquire::Item -{ - protected: - /** \brief The URI that is actually being downloaded; never - * modified by pkgAcqMetaIndex. - */ - std::string RealURI; - - /** \brief The file in which the signature for this index was stored. - * - * If empty, the signature and the md5sums of the individual - * indices will not be checked. - */ - std::string SigFile; - - /** \brief The index files to download. */ - const std::vector* IndexTargets; - - /** \brief The parser for the meta-index file. */ - indexRecords* MetaIndexParser; - - /** \brief If \b true, the index's signature is currently being verified. - */ - bool AuthPass; - // required to deal gracefully with problems caused by incorrect ims hits - bool IMSHit; - - /** \brief Check that the release file is a release file for the - * correct distribution. - * - * \return \b true if no fatal errors were encountered. - */ - bool VerifyVendor(std::string Message); - - /** \brief Called when a file is finished being retrieved. - * - * If the file was not downloaded to DestFile, a copy process is - * set up to copy it to DestFile; otherwise, Complete is set to \b - * true and the file is moved to its final location. - * - * \param Message The message block received from the fetch - * subprocess. - */ - void RetrievalDone(std::string Message); - - /** \brief Called when authentication succeeded. - * - * Sanity-checks the authenticated file, queues up the individual - * index files for download, and saves the signature in the lists - * directory next to the authenticated list file. - * - * \param Message The message block received from the fetch - * subprocess. - */ - void AuthDone(std::string Message); - - /** \brief Starts downloading the individual index files. - * - * \param verify If \b true, only indices whose expected hashsum - * can be determined from the meta-index will be downloaded, and - * the hashsums of indices will be checked (reporting - * #StatAuthError if there is a mismatch). If verify is \b false, - * no hashsum checking will be performed. - */ - void QueueIndexes(bool verify); - - public: - - // Specialized action members - virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, - pkgAcquire::MethodConfig *Cnf); - virtual std::string Custom600Headers() const; - virtual std::string DescURI() const {return RealURI; }; - - /** \brief Create a new pkgAcqMetaIndex. */ - pkgAcqMetaIndex(pkgAcquire *Owner, - std::string URI,std::string URIDesc, std::string ShortDesc, - std::string SigFile, - const std::vector* IndexTargets, - indexRecords* MetaIndexParser); -}; - /*}}}*/ -/** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/ -class pkgAcqMetaClearSig : public pkgAcqMetaIndex -{ - /** \brief The URI of the meta-index file for the detached signature */ - std::string MetaIndexURI; - - /** \brief A "URI-style" description of the meta-index file */ - std::string MetaIndexURIDesc; - - /** \brief A brief description of the meta-index file */ - std::string MetaIndexShortDesc; - - /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */ - std::string MetaSigURI; - - /** \brief A "URI-style" description of the meta-signature file */ - std::string MetaSigURIDesc; - - /** \brief A brief description of the meta-signature file */ - std::string MetaSigShortDesc; - -public: - void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual std::string Custom600Headers() const; - - /** \brief Create a new pkgAcqMetaClearSig. */ - pkgAcqMetaClearSig(pkgAcquire *Owner, - std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc, - std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc, - std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc, - const std::vector* IndexTargets, - indexRecords* MetaIndexParser); - virtual ~pkgAcqMetaClearSig(); -}; - /*}}}*/ /** \brief An item that is responsible for fetching a package file. {{{ * * If the package file already exists in the cache, nothing will be -- cgit v1.2.3 From 2737f28a1cb2d03c66d2a7edd04215566903dbf1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 21 Jul 2014 11:19:37 +0200 Subject: Download Release first, then Release.gpg The old way of handling this was that pkgAcqMetaIndex was responsible to check/move both Release and Release.gpg in place. This breaks the assumption of the transaction that each pkgAcquire::Item has a single File that its responsible for. --- apt-pkg/acquire-item.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 6c9fec695..6235c353b 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -450,6 +450,15 @@ class pkgAcqMetaIndex : public pkgAcquire::Item * no hashsum checking will be performed. */ void QueueIndexes(bool verify); + + /** \brief The URI of the meta-index file for the detached signature */ + std::string MetaIndexSigURI; + + /** \brief A "URI-style" description of the meta-index file */ + std::string MetaIndexSigURIDesc; + + /** \brief A brief description of the meta-index file */ + std::string MetaIndexSigShortDesc; public: @@ -464,7 +473,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item /** \brief Create a new pkgAcqMetaIndex. */ pkgAcqMetaIndex(pkgAcquire *Owner, std::string URI,std::string URIDesc, std::string ShortDesc, - std::string SigFile, + std::string MetaIndexSigURI, std::string MetaIndexSigURIDesc, std::string MetaIndexSigShortDesc, const std::vector* IndexTargets, indexRecords* MetaIndexParser); }; @@ -1009,22 +1018,12 @@ class pkgAcqMetaSig : public pkgAcquire::Item */ std::string RealURI; - /** \brief The URI of the meta-index file to be fetched after the signature. */ - std::string MetaIndexURI; - - /** \brief A "URI-style" description of the meta-index file to be - * fetched after the signature. - */ - std::string MetaIndexURIDesc; - - /** \brief A brief description of the meta-index file to be fetched - * after the signature. - */ - std::string MetaIndexShortDesc; - /** \brief A package-system-specific parser for the meta-index file. */ indexRecords* MetaIndexParser; + /** \brief The file we need to verify */ + std::string MetaIndexFile; + /** \brief The index files which should be looked up in the meta-index * and then downloaded. * @@ -1032,6 +1031,9 @@ class pkgAcqMetaSig : public pkgAcquire::Item */ const std::vector* IndexTargets; + /** \brief if we are in fetching or download state */ + bool AuthPass; + public: // Specialized action members @@ -1042,8 +1044,9 @@ class pkgAcqMetaSig : public pkgAcquire::Item virtual std::string DescURI() const {return RealURI; }; /** \brief Create a new pkgAcqMetaSig. */ - pkgAcqMetaSig(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc, - std::string MetaIndexURI, std::string MetaIndexURIDesc, std::string MetaIndexShortDesc, + pkgAcqMetaSig(pkgAcqMetaIndex *MetaOwner, + std::string URI,std::string URIDesc, std::string ShortDesc, + std::string MetaIndexFile, const std::vector* IndexTargets, indexRecords* MetaIndexParser); virtual ~pkgAcqMetaSig(); -- cgit v1.2.3 From 1f4dd8fd8489fbfd62c4d1667f159433a5f532b2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 22 Jul 2014 11:35:30 +0200 Subject: WIP cleanup pkgAcqMetaSig --- apt-pkg/acquire-item.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 6235c353b..11a596ad5 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -1031,9 +1031,12 @@ class pkgAcqMetaSig : public pkgAcquire::Item */ const std::vector* IndexTargets; - /** \brief if we are in fetching or download state */ + /** \brief If we are in fetching or download state */ bool AuthPass; + /** \brief Was this file already on disk */ + bool IMSHit; + public: // Specialized action members -- cgit v1.2.3 From e05672e88678f520b2db59599e939345ad0b6e53 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2014 09:53:13 +0200 Subject: Rework TransactionID stuff --- apt-pkg/acquire-item.h | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 11a596ad5..3f7cca083 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -297,7 +297,8 @@ class pkgAcquire::Item : public WeakPointable * \param ExpectedHashes of the file represented by this item */ Item(pkgAcquire *Owner, - HashStringList const &ExpectedHashes=HashStringList()); + HashStringList const &ExpectedHashes=HashStringList(), + unsigned long TransactionID=0); /** \brief Remove this item from its owner's queue by invoking * pkgAcquire::Remove. @@ -370,7 +371,9 @@ class pkgAcqSubIndex : public pkgAcquire::Item * * \param ExpectedHashes The list file's hashsums which are expected. */ - pkgAcqSubIndex(pkgAcquire *Owner, std::string const &URI,std::string const &URIDesc, + pkgAcqSubIndex(pkgAcquire *Owner, + unsigned long TransactionID, + std::string const &URI,std::string const &URIDesc, std::string const &ShortDesc, HashStringList const &ExpectedHashes); }; /*}}}*/ @@ -459,6 +462,9 @@ class pkgAcqMetaIndex : public pkgAcquire::Item /** \brief A brief description of the meta-index file */ std::string MetaIndexSigShortDesc; + + /** \brief delayed constructor */ + void Init(std::string URIDesc, std::string ShortDesc); public: @@ -472,6 +478,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item /** \brief Create a new pkgAcqMetaIndex. */ pkgAcqMetaIndex(pkgAcquire *Owner, + unsigned long TransactionID, std::string URI,std::string URIDesc, std::string ShortDesc, std::string MetaIndexSigURI, std::string MetaIndexSigURIDesc, std::string MetaIndexSigShortDesc, const std::vector* IndexTargets, @@ -525,22 +532,14 @@ class pkgAcqBaseIndex : public pkgAcquire::Item */ const struct IndexTarget * Target; indexRecords *MetaIndexParser; - pkgAcqMetaIndex *MetaOwner; - - pkgAcqBaseIndex(pkgAcqMetaIndex *MetaOwner, - struct IndexTarget const * const Target, - HashStringList const &ExpectedHashes, - indexRecords *MetaIndexParser) - : Item(MetaOwner->GetOwner(), ExpectedHashes), Target(Target), - MetaIndexParser(MetaIndexParser), MetaOwner(MetaOwner) {}; pkgAcqBaseIndex(pkgAcquire *Owner, + unsigned long TransactionID, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser) : Item(Owner, ExpectedHashes), Target(Target), - MetaIndexParser(MetaIndexParser), MetaOwner(0) {}; - + MetaIndexParser(MetaIndexParser) {}; }; /*}}}*/ /** \brief An item that is responsible for fetching an index file of {{{ @@ -606,7 +605,8 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex * * \param ExpectedHashes The list file's hashsums which are expected. */ - pkgAcqDiffIndex(pkgAcqMetaIndex *MetaIndexOwner, + pkgAcqDiffIndex(pkgAcquire *Owner, + unsigned long TransactionID, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser); @@ -694,7 +694,8 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex * \param allPatches contains all related items so that each item can * check if it was the last one to complete the download step */ - pkgAcqIndexMergeDiffs(pkgAcqMetaIndex *MetaIndexOwner, + pkgAcqIndexMergeDiffs(pkgAcquire *Owner, + unsigned long TransactionID, struct IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser, @@ -822,7 +823,8 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex * should be ordered so that each diff appears before any diff * that depends on it. */ - pkgAcqIndexDiffs(pkgAcqMetaIndex *MetaIndexOwner, + pkgAcqIndexDiffs(pkgAcquire *Owner, + unsigned long TransactionID, struct IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser, @@ -899,13 +901,7 @@ class pkgAcqIndex : public pkgAcqBaseIndex pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc, HashStringList const &ExpectedHashes, std::string compressExt=""); -#if 0 - pkgAcqIndex(pkgAcquire *Owner, - IndexTarget const * const Target, - HashStringList const &ExpectedHash, - indexRecords *MetaIndexParser); -#endif - pkgAcqIndex(pkgAcqMetaIndex *MetaIndexOwner, + pkgAcqIndex(pkgAcquire *Owner, unsigned long TransactionID, IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser); @@ -942,7 +938,9 @@ class pkgAcqIndexTrans : public pkgAcqIndex pkgAcqIndexTrans(pkgAcquire *Owner, std::string URI,std::string URIDesc, std::string ShortDesc); - pkgAcqIndexTrans(pkgAcqMetaIndex *Owner, IndexTarget const * const Target, + pkgAcqIndexTrans(pkgAcquire *Owner, + unsigned long TransactionID, + IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser); }; @@ -1047,7 +1045,8 @@ class pkgAcqMetaSig : public pkgAcquire::Item virtual std::string DescURI() const {return RealURI; }; /** \brief Create a new pkgAcqMetaSig. */ - pkgAcqMetaSig(pkgAcqMetaIndex *MetaOwner, + pkgAcqMetaSig(pkgAcquire *Owner, + unsigned long TransactionID, std::string URI,std::string URIDesc, std::string ShortDesc, std::string MetaIndexFile, const std::vector* IndexTargets, -- cgit v1.2.3 From 80976dd5452a9cfbe0c4f6229c729711ba685a5f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 1 Aug 2014 11:06:47 +0200 Subject: mve MetaKey into pkgAcqBaseIndex --- apt-pkg/acquire-item.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 3f7cca083..f5a308c58 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -532,6 +532,8 @@ class pkgAcqBaseIndex : public pkgAcquire::Item */ const struct IndexTarget * Target; indexRecords *MetaIndexParser; + /** \brief The MetaIndex Key */ + std::string MetaKey; pkgAcqBaseIndex(pkgAcquire *Owner, unsigned long TransactionID, @@ -851,6 +853,7 @@ class pkgAcqIndex : public pkgAcqBaseIndex */ bool Erase; + // FIXME: // Unused, used to be used to verify that "Packages: " header was there bool __DELME_ON_NEXT_ABI_BREAK_Verify; -- cgit v1.2.3 From 81273628cc3022641756b05e78256d59b7bd7c51 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 1 Aug 2014 11:46:16 +0200 Subject: fix transactionid passing --- apt-pkg/acquire-item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index f5a308c58..e191e2554 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -540,7 +540,7 @@ class pkgAcqBaseIndex : public pkgAcquire::Item struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser) - : Item(Owner, ExpectedHashes), Target(Target), + : Item(Owner, ExpectedHashes, TransactionID), Target(Target), MetaIndexParser(MetaIndexParser) {}; }; /*}}}*/ -- cgit v1.2.3 From 63b7249e6930c1bcb69bac32f10108119eeacc2a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 2 Aug 2014 05:37:43 +0200 Subject: add ims check verify --- apt-pkg/acquire-item.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index e191e2554..31279f7df 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -873,6 +873,14 @@ class pkgAcqIndex : public pkgAcqBaseIndex /** \brief Auto select the right compression to use */ void AutoSelectCompression(); + /** \brief Get the full pathname of the final file for the given URI + */ + std::string GetFinalFilename(std::string const &URI, + std::string const &compExt); + + /** \brief Schedule file for verification after a IMS hit */ + void ReverifyAfterIMS(std::string const &FileName); + public: // Specialized action members -- cgit v1.2.3 From a9bb651a04d1eae42164a2fb2cdf92bf4392a532 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 2 Aug 2014 05:44:50 +0200 Subject: really move clearsign check into pkgAcqMetaClearSig::Done() --- apt-pkg/acquire-item.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 31279f7df..28577e9b8 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -507,8 +507,10 @@ class pkgAcqMetaClearSig : public pkgAcqMetaIndex std::string MetaSigShortDesc; public: - void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); virtual std::string Custom600Headers() const; + virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, + pkgAcquire::MethodConfig *Cnf); /** \brief Create a new pkgAcqMetaClearSig. */ pkgAcqMetaClearSig(pkgAcquire *Owner, -- cgit v1.2.3 From e6e893903869635ab7ee3200f654129b08717ded Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 25 Aug 2014 20:58:02 -0700 Subject: add shared code into pkgAcqMetaSigBase::GenerateAuthWarning() --- apt-pkg/acquire-item.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'apt-pkg/acquire-item.h') 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 */ -- cgit v1.2.3 From f456b60b7804c95810ccccdb87a76c4bc7f746d7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 16 Sep 2014 17:03:04 +0200 Subject: remove pkgAcqSubIndex --- apt-pkg/acquire-item.h | 57 -------------------------------------------------- 1 file changed, 57 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index ae93ea311..90eccdd16 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -338,44 +338,6 @@ struct DiffInfo { unsigned long size; }; /*}}}*/ -/** \brief An item that is responsible for fetching a SubIndex {{{ - * - * The MetaIndex file includes only records for important indexes - * and records for these SubIndex files so these can carry records - * for addition files like PDiffs and Translations - */ -class pkgAcqSubIndex : public pkgAcquire::Item -{ - protected: - /** \brief If \b true, debugging information will be written to std::clog. */ - bool Debug; - - public: - // Specialized action members - virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, - pkgAcquire::MethodConfig *Cnf); - virtual std::string DescURI() const {return Desc.URI;}; - virtual std::string Custom600Headers() const; - virtual bool ParseIndex(std::string const &IndexFile); - - /** \brief Create a new pkgAcqSubIndex. - * - * \param Owner The Acquire object that owns this item. - * - * \param URI The URI of the list file to download. - * - * \param URIDesc A long description of the list file to download. - * - * \param ShortDesc A short description of the list file to download. - * - * \param ExpectedHashes The list file's hashsums which are expected. - */ - pkgAcqSubIndex(pkgAcquire *Owner, - unsigned long TransactionID, - std::string const &URI,std::string const &URIDesc, - std::string const &ShortDesc, HashStringList const &ExpectedHashes); -}; /*}}}*/ class pkgAcqMetaSigBase : public pkgAcquire::Item @@ -991,9 +953,6 @@ class IndexTarget virtual bool IsOptional() const { return false; } - virtual bool IsSubIndex() const { - return false; - } }; /*}}}*/ /** \brief Information about an optional index file. */ /*{{{*/ @@ -1004,22 +963,6 @@ class OptionalIndexTarget : public IndexTarget } }; /*}}}*/ -/** \brief Information about an subindex index file. */ /*{{{*/ -class SubIndexTarget : public IndexTarget -{ - virtual bool IsSubIndex() const { - return true; - } -}; - /*}}}*/ -/** \brief Information about an subindex index file. */ /*{{{*/ -class OptionalSubIndexTarget : public OptionalIndexTarget -{ - virtual bool IsSubIndex() const { - return true; - } -}; - /*}}}*/ /** \brief An acquire item that downloads the detached signature {{{ * of a meta-index (Release) file, then queues up the release -- cgit v1.2.3 From 60323ed7fde01e8c013616e2d428bf9718f2fbc7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 16 Sep 2014 17:13:09 +0200 Subject: add a bunch of dpointers --- apt-pkg/acquire-item.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 90eccdd16..c6fd05d6d 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -63,6 +63,8 @@ class pkgAcqMetaIndex; */ class pkgAcquire::Item : public WeakPointable { + void *d; + protected: /** \brief The acquire object with which this item is associated. */ @@ -342,6 +344,8 @@ struct DiffInfo { class pkgAcqMetaSigBase : public pkgAcquire::Item { + void *d; + protected: bool GenerateAuthWarning(const std::string &RealURI, const std::string &Message); @@ -364,6 +368,8 @@ class pkgAcqMetaSigBase : public pkgAcquire::Item */ class pkgAcqMetaIndex : public pkgAcqMetaSigBase { + void *d; + protected: /** \brief The URI that is actually being downloaded; never * modified by pkgAcqMetaIndex. @@ -462,6 +468,8 @@ class pkgAcqMetaIndex : public pkgAcqMetaSigBase /** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/ class pkgAcqMetaClearSig : public pkgAcqMetaIndex { + void *d; + /** \brief The URI of the meta-index file for the detached signature */ std::string MetaIndexURI; @@ -503,6 +511,8 @@ public: */ class pkgAcqBaseIndex : public pkgAcquire::Item { + void *d; + protected: /** \brief Pointer to the IndexTarget data */ @@ -531,6 +541,8 @@ class pkgAcqBaseIndex : public pkgAcquire::Item */ class pkgAcqDiffIndex : public pkgAcqBaseIndex { + void *d; + protected: /** \brief If \b true, debugging information will be written to std::clog. */ bool Debug; @@ -603,6 +615,8 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex */ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex { + void *d; + protected: /** \brief If \b true, debugging output will be written to @@ -694,6 +708,8 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex */ class pkgAcqIndexDiffs : public pkgAcqBaseIndex { + void *d; + private: /** \brief Queue up the next diff download. @@ -819,6 +835,8 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex */ class pkgAcqIndex : public pkgAcqBaseIndex { + void *d; + protected: /** \brief If \b true, the index file has been decompressed. */ @@ -906,6 +924,8 @@ class pkgAcqIndex : public pkgAcqBaseIndex */ class pkgAcqIndexTrans : public pkgAcqIndex { + void *d; + public: virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); @@ -935,6 +955,8 @@ class pkgAcqIndexTrans : public pkgAcqIndex /** \brief Information about an index file. */ /*{{{*/ class IndexTarget { + void *d; + public: /** \brief A URI from which the index file can be downloaded. */ std::string URI; @@ -958,6 +980,8 @@ class IndexTarget /** \brief Information about an optional index file. */ /*{{{*/ class OptionalIndexTarget : public IndexTarget { + void *d; + virtual bool IsOptional() const { return true; } @@ -974,6 +998,8 @@ class OptionalIndexTarget : public IndexTarget */ class pkgAcqMetaSig : public pkgAcqMetaSigBase { + void *d; + protected: /** \brief The last good signature file */ std::string LastGoodSig; @@ -1029,6 +1055,8 @@ class pkgAcqMetaSig : public pkgAcqMetaSigBase */ class pkgAcqArchive : public pkgAcquire::Item { + void *d; + protected: /** \brief The package version being fetched. */ pkgCache::VerIterator Version; @@ -1107,6 +1135,8 @@ class pkgAcqArchive : public pkgAcquire::Item */ class pkgAcqFile : public pkgAcquire::Item { + void *d; + /** \brief How many times to retry the download, set from * Acquire::Retries. */ -- cgit v1.2.3 From 715c65de1f132aff9f040f0640e985018e4b564e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Sep 2014 09:17:49 +0200 Subject: use pkgAcqMetaBase as the transactionManager --- apt-pkg/acquire-item.h | 52 +++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index c6fd05d6d..622324347 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -47,7 +47,7 @@ class indexRecords; class pkgRecords; class pkgSourceList; class IndexTarget; -class pkgAcqMetaIndex; +class pkgAcqMetaBase; /** \brief Represents the process by which a pkgAcquire object should {{{ * retrieve a file or a collection of files. @@ -171,8 +171,8 @@ class pkgAcquire::Item : public WeakPointable */ unsigned int QueueCounter; - /** \brief TransactionID */ - unsigned long TransactionID; + /** \brief TransactionManager */ + pkgAcqMetaBase *TransactionManager; /** \brief The number of additional fetch items that are expected * once this item is done. @@ -300,7 +300,7 @@ class pkgAcquire::Item : public WeakPointable */ Item(pkgAcquire *Owner, HashStringList const &ExpectedHashes=HashStringList(), - unsigned long TransactionID=0); + pkgAcqMetaBase *TransactionManager=NULL); /** \brief Remove this item from its owner's queue by invoking * pkgAcquire::Remove. @@ -342,20 +342,32 @@ struct DiffInfo { /*}}}*/ /*}}}*/ -class pkgAcqMetaSigBase : public pkgAcquire::Item +class pkgAcqMetaBase : public pkgAcquire::Item { void *d; protected: + std::vector Transaction; + + public: + // transaction code + void Add(Item *I); + void AbortTransaction(); + bool TransactionHasError(); + void CommitTransaction(); + + // helper for the signature warning bool GenerateAuthWarning(const std::string &RealURI, const std::string &Message); - public: - pkgAcqMetaSigBase(pkgAcquire *Owner, - HashStringList const &ExpectedHashes=HashStringList(), - unsigned long TransactionID=0); + + pkgAcqMetaBase(pkgAcquire *Owner, + HashStringList const &ExpectedHashes=HashStringList(), + pkgAcqMetaBase *TransactionManager=NULL) + : Item(Owner, ExpectedHashes, TransactionManager) {}; }; + /** \brief An item that is responsible for downloading the meta-index {{{ * file (i.e., Release) itself and verifying its signature. * @@ -366,7 +378,7 @@ class pkgAcqMetaSigBase : public pkgAcquire::Item * otherwise, the expected hashsums will be "" (causing the * authentication of the index files to be bypassed). */ -class pkgAcqMetaIndex : public pkgAcqMetaSigBase +class pkgAcqMetaIndex : public pkgAcqMetaBase { void *d; @@ -458,7 +470,7 @@ class pkgAcqMetaIndex : public pkgAcqMetaSigBase /** \brief Create a new pkgAcqMetaIndex. */ pkgAcqMetaIndex(pkgAcquire *Owner, - unsigned long TransactionID, + pkgAcqMetaBase *TransactionManager, std::string URI,std::string URIDesc, std::string ShortDesc, std::string MetaIndexSigURI, std::string MetaIndexSigURIDesc, std::string MetaIndexSigShortDesc, const std::vector* IndexTargets, @@ -522,11 +534,11 @@ class pkgAcqBaseIndex : public pkgAcquire::Item std::string MetaKey; pkgAcqBaseIndex(pkgAcquire *Owner, - unsigned long TransactionID, + pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser) - : Item(Owner, ExpectedHashes, TransactionID), Target(Target), + : Item(Owner, ExpectedHashes, TransactionManager), Target(Target), MetaIndexParser(MetaIndexParser) {}; }; /*}}}*/ @@ -596,7 +608,7 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex * \param ExpectedHashes The list file's hashsums which are expected. */ pkgAcqDiffIndex(pkgAcquire *Owner, - unsigned long TransactionID, + pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser); @@ -687,7 +699,7 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex * check if it was the last one to complete the download step */ pkgAcqIndexMergeDiffs(pkgAcquire *Owner, - unsigned long TransactionID, + pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser, @@ -818,7 +830,7 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex * that depends on it. */ pkgAcqIndexDiffs(pkgAcquire *Owner, - unsigned long TransactionID, + pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser, @@ -906,7 +918,7 @@ class pkgAcqIndex : public pkgAcqBaseIndex pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc, HashStringList const &ExpectedHashes, std::string compressExt=""); - pkgAcqIndex(pkgAcquire *Owner, unsigned long TransactionID, + pkgAcqIndex(pkgAcquire *Owner, pkgAcqMetaBase *TransactionManager, IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser); @@ -946,7 +958,7 @@ class pkgAcqIndexTrans : public pkgAcqIndex std::string URI,std::string URIDesc, std::string ShortDesc); pkgAcqIndexTrans(pkgAcquire *Owner, - unsigned long TransactionID, + pkgAcqMetaBase *TransactionManager, IndexTarget const * const Target, HashStringList const &ExpectedHashes, indexRecords *MetaIndexParser); @@ -996,7 +1008,7 @@ class OptionalIndexTarget : public IndexTarget * * \sa pkgAcqMetaIndex */ -class pkgAcqMetaSig : public pkgAcqMetaSigBase +class pkgAcqMetaSig : public pkgAcqMetaBase { void *d; @@ -1040,7 +1052,7 @@ class pkgAcqMetaSig : public pkgAcqMetaSigBase /** \brief Create a new pkgAcqMetaSig. */ pkgAcqMetaSig(pkgAcquire *Owner, - unsigned long TransactionID, + pkgAcqMetaBase *TransactionManager, std::string URI,std::string URIDesc, std::string ShortDesc, std::string MetaIndexFile, const std::vector* IndexTargets, -- cgit v1.2.3 From 916b89109cd77728004819d4705778e3dc489b2e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Sep 2014 09:24:19 +0200 Subject: fix gcc warnings --- apt-pkg/acquire-item.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 622324347..0741ae60d 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -353,7 +353,7 @@ class pkgAcqMetaBase : public pkgAcquire::Item // transaction code void Add(Item *I); void AbortTransaction(); - bool TransactionHasError(); + bool TransactionHasError() APT_PURE; void CommitTransaction(); // helper for the signature warning @@ -885,7 +885,7 @@ class pkgAcqIndex : public pkgAcqBaseIndex std::string const &compExt); /** \brief Schedule file for verification after a IMS hit */ - void ReverifyAfterIMS(std::string const &FileName); + void ReverifyAfterIMS(); public: @@ -916,8 +916,7 @@ class pkgAcqIndex : public pkgAcqBaseIndex * fallback is ".gz" or none. */ pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc, - std::string ShortDesc, HashStringList const &ExpectedHashes, - std::string compressExt=""); + std::string ShortDesc, HashStringList const &ExpectedHashes); pkgAcqIndex(pkgAcquire *Owner, pkgAcqMetaBase *TransactionManager, IndexTarget const * const Target, HashStringList const &ExpectedHash, -- cgit v1.2.3 From 3f073d44c2d6cecb807f05a5f95c1c35ab23fb3c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Sep 2014 17:18:30 +0200 Subject: cleanup --- apt-pkg/acquire-item.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 3c522f66e..ae53fc6ac 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -880,10 +880,9 @@ class pkgAcqIndex : public pkgAcqBaseIndex /** \brief Auto select the right compression to use */ void AutoSelectCompression(); - /** \brief Get the full pathname of the final file for the given URI + /** \brief Get the full pathname of the final file for the current URI */ - std::string GetFinalFilename(std::string const &URI, - std::string const &compExt); + std::string GetFinalFilename() const; /** \brief Schedule file for verification after a IMS hit */ void ReverifyAfterIMS(); -- cgit v1.2.3 From c8aa88aa2c3139584cfabb1ce4619c773e9f2b99 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Sep 2014 18:08:53 +0200 Subject: cleanup, fix test-apt-update-unauth as the behavior of apt changed --- apt-pkg/acquire-item.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index ae53fc6ac..49f057b43 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -859,10 +859,6 @@ class pkgAcqIndex : public pkgAcqBaseIndex */ bool Erase; - // FIXME: - // Unused, used to be used to verify that "Packages: " header was there - bool __DELME_ON_NEXT_ABI_BREAK_Verify; - /** \brief The object that is actually being fetched (minus any * compression-related extensions). */ -- cgit v1.2.3 From 03bfbc965443393b92b2d6d82613472fa3a5067f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Sep 2014 23:48:19 +0200 Subject: make pdiff transactional (but at the cost of a CopyFile() --- apt-pkg/acquire-item.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 49f057b43..15b566069 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -90,7 +90,7 @@ class pkgAcquire::Item : public WeakPointable * \param To The new name of \a From. If \a To exists it will be * overwritten. */ - void Rename(std::string From,std::string To); + bool Rename(std::string From,std::string To); public: @@ -574,6 +574,10 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex */ std::string Description; + /** \brief If the copy step of the packages file is done + */ + bool PackagesFileReadyInPartial; + public: // Specialized action members virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); @@ -803,7 +807,7 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); - virtual std::string DescURI() const {return RealURI + "Index";}; + virtual std::string DescURI() const {return RealURI + "IndexDiffs";}; /** \brief Create an index diff item. * -- cgit v1.2.3 From 631a7dc7906a10ccd5f14dcfe42224e6107e11f6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Sep 2014 20:59:31 +0200 Subject: Do not allow going from authenticated to unauthenticated repo Also rework the way we load the Release file, so it only after Release.gpg verified the Release file. The rational is that we never want to load untrusted data into our parsers. Only stuff verified with gpg or by its hashes get loaded. To load untrusted data you now need to use apt-get update --allow-unauthenticated. --- apt-pkg/acquire-item.h | 148 +++++++++++++++++++++++++------------------------ 1 file changed, 77 insertions(+), 71 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 15b566069..cc156cf17 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -312,7 +312,9 @@ class pkgAcquire::Item : public WeakPointable enum RenameOnErrorState { HashSumMismatch, SizeMismatch, - InvalidFormat + InvalidFormat, + SignatureError, + NotClearsigned, }; /** \brief Rename failed file and set error @@ -367,6 +369,67 @@ class pkgAcqMetaBase : public pkgAcquire::Item : Item(Owner, ExpectedHashes, TransactionManager) {}; }; +/** \brief An acquire item that downloads the detached signature {{{ + * of a meta-index (Release) file, then queues up the release + * file itself. + * + * \todo Why protected members? + * + * \sa pkgAcqMetaIndex + */ +class pkgAcqMetaSig : public pkgAcqMetaBase +{ + void *d; + + protected: + + /** \brief The URI of the signature file. Unlike Desc.URI, this is + * never modified; it is used to determine the file that is being + * downloaded. + */ + std::string RealURI; + + std::string URIDesc; + std::string ShortDesc; + + /** \brief A package-system-specific parser for the meta-index file. */ + indexRecords* MetaIndexParser; + + /** \brief The file we need to verify */ + std::string MetaIndexFile; + + /** \brief The index files which should be looked up in the meta-index + * and then downloaded. + * + * \todo Why a list of pointers instead of a list of structs? + */ + const std::vector* IndexTargets; + + /** \brief If we are in fetching or download state */ + bool AuthPass; + + /** \brief Was this file already on disk */ + bool IMSHit; + + public: + + // Specialized action members + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, + pkgAcquire::MethodConfig *Cnf); + virtual std::string Custom600Headers() const; + virtual std::string DescURI() const {return RealURI; }; + + /** \brief Create a new pkgAcqMetaSig. */ + pkgAcqMetaSig(pkgAcquire *Owner, + pkgAcqMetaBase *TransactionManager, + std::string URI,std::string URIDesc, std::string ShortDesc, + std::string MetaIndexFile, + const std::vector* IndexTargets, + indexRecords* MetaIndexParser); + virtual ~pkgAcqMetaSig(); +}; + /*}}}*/ /** \brief An item that is responsible for downloading the meta-index {{{ * file (i.e., Release) itself and verifying its signature. @@ -436,15 +499,8 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase */ void AuthDone(std::string Message); - /** \brief Starts downloading the individual index files. - * - * \param verify If \b true, only indices whose expected hashsum - * can be determined from the meta-index will be downloaded, and - * the hashsums of indices will be checked (reporting - * #StatAuthError if there is a mismatch). If verify is \b false, - * no hashsum checking will be performed. - */ - void QueueIndexes(bool verify); + std::string URIDesc; + std::string ShortDesc; /** \brief The URI of the meta-index file for the detached signature */ std::string MetaIndexSigURI; @@ -459,7 +515,17 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase void Init(std::string URIDesc, std::string ShortDesc); public: - + + /** \brief Starts downloading the individual index files. + * + * \param verify If \b true, only indices whose expected hashsum + * can be determined from the meta-index will be downloaded, and + * the hashsums of indices will be checked (reporting + * #StatAuthError if there is a mismatch). If verify is \b false, + * no hashsum checking will be performed. + */ + void QueueIndexes(bool verify); + // Specialized action members virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, @@ -999,66 +1065,6 @@ class OptionalIndexTarget : public IndexTarget }; /*}}}*/ -/** \brief An acquire item that downloads the detached signature {{{ - * of a meta-index (Release) file, then queues up the release - * file itself. - * - * \todo Why protected members? - * - * \sa pkgAcqMetaIndex - */ -class pkgAcqMetaSig : public pkgAcqMetaBase -{ - void *d; - - protected: - /** \brief The last good signature file */ - std::string LastGoodSig; - - /** \brief The URI of the signature file. Unlike Desc.URI, this is - * never modified; it is used to determine the file that is being - * downloaded. - */ - std::string RealURI; - - /** \brief A package-system-specific parser for the meta-index file. */ - indexRecords* MetaIndexParser; - - /** \brief The file we need to verify */ - std::string MetaIndexFile; - - /** \brief The index files which should be looked up in the meta-index - * and then downloaded. - * - * \todo Why a list of pointers instead of a list of structs? - */ - const std::vector* IndexTargets; - - /** \brief If we are in fetching or download state */ - bool AuthPass; - - /** \brief Was this file already on disk */ - bool IMSHit; - - public: - - // Specialized action members - virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, - pkgAcquire::MethodConfig *Cnf); - virtual std::string Custom600Headers() const; - virtual std::string DescURI() const {return RealURI; }; - - /** \brief Create a new pkgAcqMetaSig. */ - pkgAcqMetaSig(pkgAcquire *Owner, - pkgAcqMetaBase *TransactionManager, - std::string URI,std::string URIDesc, std::string ShortDesc, - std::string MetaIndexFile, - const std::vector* IndexTargets, - indexRecords* MetaIndexParser); - virtual ~pkgAcqMetaSig(); -}; - /*}}}*/ /** \brief An item that is responsible for fetching a package file. {{{ * * If the package file already exists in the cache, nothing will be -- cgit v1.2.3 From c045cc0268d70eb3b7c41076ade7381f73e740f2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Sep 2014 10:43:00 +0200 Subject: refactor --- apt-pkg/acquire-item.h | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index e6a22ce7b..3c81f77a9 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -356,6 +356,24 @@ class pkgAcqMetaBase : public pkgAcquire::Item protected: std::vector Transaction; + /** \brief A package-system-specific parser for the meta-index file. */ + indexRecords *MetaIndexParser; + + /** \brief The index files which should be looked up in the meta-index + * and then downloaded. + */ + const std::vector* IndexTargets; + + /** \brief Starts downloading the individual index files. + * + * \param verify If \b true, only indices whose expected hashsum + * can be determined from the meta-index will be downloaded, and + * the hashsums of indices will be checked (reporting + * #StatAuthError if there is a mismatch). If verify is \b false, + * no hashsum checking will be performed. + */ + void QueueIndexes(bool verify); + public: // transaction code void Add(Item *I); @@ -369,9 +387,12 @@ class pkgAcqMetaBase : public pkgAcquire::Item pkgAcqMetaBase(pkgAcquire *Owner, + const std::vector* IndexTargets, + indexRecords* MetaIndexParser, HashStringList const &ExpectedHashes=HashStringList(), pkgAcqMetaBase *TransactionManager=NULL) - : Item(Owner, ExpectedHashes, TransactionManager) {}; + : Item(Owner, ExpectedHashes, TransactionManager), + MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) {}; }; /** \brief An acquire item that downloads the detached signature {{{ @@ -397,19 +418,9 @@ class pkgAcqMetaSig : public pkgAcqMetaBase std::string URIDesc; std::string ShortDesc; - /** \brief A package-system-specific parser for the meta-index file. */ - indexRecords* MetaIndexParser; - /** \brief The file we need to verify */ std::string MetaIndexFile; - /** \brief The index files which should be looked up in the meta-index - * and then downloaded. - * - * \todo Why a list of pointers instead of a list of structs? - */ - const std::vector* IndexTargets; - /** \brief If we are in fetching or download state */ bool AuthPass; @@ -463,12 +474,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase */ std::string SigFile; - /** \brief The index files to download. */ - const std::vector* IndexTargets; - - /** \brief The parser for the meta-index file. */ - indexRecords* MetaIndexParser; - /** \brief If \b true, the index's signature is currently being verified. */ bool AuthPass; @@ -521,16 +526,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase public: - /** \brief Starts downloading the individual index files. - * - * \param verify If \b true, only indices whose expected hashsum - * can be determined from the meta-index will be downloaded, and - * the hashsums of indices will be checked (reporting - * #StatAuthError if there is a mismatch). If verify is \b false, - * no hashsum checking will be performed. - */ - void QueueIndexes(bool verify); - // Specialized action members virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, -- cgit v1.2.3 From fa3a96a1051d65e5aa8cd9e9e0bb854ccc67a4b6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Sep 2014 17:38:23 +0200 Subject: cleanup --- apt-pkg/acquire-item.h | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 3c81f77a9..e560da956 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -364,6 +364,13 @@ class pkgAcqMetaBase : public pkgAcquire::Item */ const std::vector* IndexTargets; + /** \brief If \b true, the index's signature is currently being verified. + */ + bool AuthPass; + + // required to deal gracefully with problems caused by incorrect ims hits + bool IMSHit; + /** \brief Starts downloading the individual index files. * * \param verify If \b true, only indices whose expected hashsum @@ -381,6 +388,15 @@ class pkgAcqMetaBase : public pkgAcquire::Item bool TransactionHasError() APT_PURE; void CommitTransaction(); + /** \brief Stage (queue) a copy action when the transaction is commited + */ + void TransactionStageCopy(Item *I, + const std::string &From, + const std::string &To); + /** \brief Stage (queue) a removal action when the transaction is commited + */ + void TransactionStageRemoval(Item *I, const std::string &FinalFile); + // helper for the signature warning bool GenerateAuthWarning(const std::string &RealURI, const std::string &Message); @@ -392,7 +408,8 @@ class pkgAcqMetaBase : public pkgAcquire::Item HashStringList const &ExpectedHashes=HashStringList(), pkgAcqMetaBase *TransactionManager=NULL) : Item(Owner, ExpectedHashes, TransactionManager), - MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) {}; + MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets), + AuthPass(false), IMSHit(false) {}; }; /** \brief An acquire item that downloads the detached signature {{{ @@ -415,17 +432,14 @@ class pkgAcqMetaSig : public pkgAcqMetaBase */ std::string RealURI; - std::string URIDesc; - std::string ShortDesc; - /** \brief The file we need to verify */ std::string MetaIndexFile; - /** \brief If we are in fetching or download state */ - bool AuthPass; + /** \brief Long URI description used in the acquire system */ + std::string URIDesc; - /** \brief Was this file already on disk */ - bool IMSHit; + /** \brief Short URI description used in the acquire system */ + std::string ShortDesc; public: @@ -474,12 +488,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase */ std::string SigFile; - /** \brief If \b true, the index's signature is currently being verified. - */ - bool AuthPass; - // required to deal gracefully with problems caused by incorrect ims hits - bool IMSHit; - /** \brief Check that the release file is a release file for the * correct distribution. * -- cgit v1.2.3 From 899e4deda1d0b2e9ad405f7f0b44c5b9be05fce7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 1 Oct 2014 22:41:52 +0200 Subject: refactor and add pkgAcqIndex::ValidateFile() --- apt-pkg/acquire-item.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index e560da956..30a8850e4 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -283,7 +283,6 @@ class pkgAcquire::Item : public WeakPointable /** \return \b true if this object is being fetched from a trusted source. */ virtual bool IsTrusted() const {return false;}; - // report mirror problems /** \brief Report mirror problem * * This allows reporting mirror failures back to a centralized @@ -293,7 +292,6 @@ class pkgAcquire::Item : public WeakPointable */ void ReportMirrorFailure(std::string FailCode); - /** \brief Initialize an item. * * Adds the item to the list of items known to the acquire @@ -947,7 +945,6 @@ class pkgAcqIndex : public pkgAcqBaseIndex */ std::string CompressionExtension; - /** \brief Do the changes needed to fetch via AptByHash (if needed) */ void InitByHashIfNeeded(const std::string MetaKey); @@ -961,11 +958,15 @@ class pkgAcqIndex : public pkgAcqBaseIndex /** \brief Schedule file for verification after a IMS hit */ void ReverifyAfterIMS(); + /** \brief Validate the downloaded index file */ + bool ValidateFile(const std::string &FileName); + public: // Specialized action members virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, + virtual void Done(std::string Message,unsigned long long Size, + HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); virtual std::string Custom600Headers() const; virtual std::string DescURI() {return Desc.URI;}; -- cgit v1.2.3 From 651bddadd0558a3912833c7d51bb20625b318af9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Oct 2014 00:05:44 +0200 Subject: Cleanup pkgAcqIndex --- apt-pkg/acquire-item.h | 58 ++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 30a8850e4..6518c9a98 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -601,10 +601,20 @@ class pkgAcqBaseIndex : public pkgAcquire::Item /** \brief Pointer to the IndexTarget data */ const struct IndexTarget * Target; + + /** \brief Pointer to the indexRecords parser */ indexRecords *MetaIndexParser; + /** \brief The MetaIndex Key */ std::string MetaKey; + /** \brief The URI of the index file to recreate at our end (either + * by downloading it or by applying partial patches). + */ + std::string RealURI; + + bool VerifyHashByMetaKey(HashStringList const &Hashes); + pkgAcqBaseIndex(pkgAcquire *Owner, pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, @@ -631,11 +641,6 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex /** \brief If \b true, debugging information will be written to std::clog. */ bool Debug; - /** \brief The URI of the index file to recreate at our end (either - * by downloading it or by applying partial patches). - */ - std::string RealURI; - /** \brief The index file which will be patched to generate the new * file. */ @@ -712,11 +717,6 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex */ bool Debug; - /** \brief URI of the package index file that is being - * reconstructed. - */ - std::string RealURI; - /** \brief description of the file being downloaded. */ std::string Description; @@ -831,11 +831,6 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex */ bool Debug; - /** \brief The URI of the package index file that is being - * reconstructed. - */ - std::string RealURI; - /** A description of the file being downloaded. */ std::string Description; @@ -927,23 +922,36 @@ class pkgAcqIndex : public pkgAcqBaseIndex protected: - /** \brief If \b true, the index file has been decompressed. */ - bool Decompression; - - /** \brief If \b true, the partially downloaded file will be - * removed when the download completes. + /** \brief The stages the method goes through + * + * The method first downloads the indexfile, then its decompressed (or + * copied) and verified */ - bool Erase; + enum AllStages { + STAGE_DOWNLOAD, + STAGE_DECOMPRESS_AND_VERIFY, + }; + AllStages Stage; - /** \brief The object that is actually being fetched (minus any - * compression-related extensions). + /** \brief Handle what needs to be done when the download is done */ + void StageDownloadDone(std::string Message, + HashStringList const &Hashes, + pkgAcquire::MethodConfig *Cfg); + + /** \brief Handle what needs to be done when the decompression/copy is + * done */ - std::string RealURI; + void StageDecompressDone(std::string Message, + HashStringList const &Hashes, + pkgAcquire::MethodConfig *Cfg); /** \brief The compression-related file extensions that are being * added to the downloaded file one by one if first fails (e.g., "gz bz2"). */ - std::string CompressionExtension; + std::string CompressionExtensions; + + /** \brief The actual compression extension currently used */ + std::string ComprExt; /** \brief Do the changes needed to fetch via AptByHash (if needed) */ void InitByHashIfNeeded(const std::string MetaKey); -- cgit v1.2.3 From 1e8ba0d4087f72a930a588ce5fbf0c22dddb9403 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Oct 2014 00:38:35 +0200 Subject: donkults fixes --- apt-pkg/acquire-item.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 6518c9a98..5d5d6efb9 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -619,9 +619,10 @@ class pkgAcqBaseIndex : public pkgAcquire::Item pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, - indexRecords *MetaIndexParser) + indexRecords *MetaIndexParser, + std::string RealURI) : Item(Owner, ExpectedHashes, TransactionManager), Target(Target), - MetaIndexParser(MetaIndexParser) {}; + MetaIndexParser(MetaIndexParser), RealURI(RealURI) {}; }; /*}}}*/ /** \brief An item that is responsible for fetching an index file of {{{ @@ -945,13 +946,18 @@ class pkgAcqIndex : public pkgAcqBaseIndex HashStringList const &Hashes, pkgAcquire::MethodConfig *Cfg); + /** \brief If \b set, this partially downloaded file will be + * removed when the download completes. + */ + std::string EraseFileName; + /** \brief The compression-related file extensions that are being * added to the downloaded file one by one if first fails (e.g., "gz bz2"). */ std::string CompressionExtensions; /** \brief The actual compression extension currently used */ - std::string ComprExt; + std::string CurrentCompressionExtension; /** \brief Do the changes needed to fetch via AptByHash (if needed) */ void InitByHashIfNeeded(const std::string MetaKey); -- cgit v1.2.3 From a64bf0eb7a4e0a6fbb19d19efabecd709a19b917 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Oct 2014 00:47:33 +0200 Subject: fix crash --- apt-pkg/acquire-item.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 5d5d6efb9..fbbca8bf2 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -619,10 +619,9 @@ class pkgAcqBaseIndex : public pkgAcquire::Item pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, HashStringList const &ExpectedHashes, - indexRecords *MetaIndexParser, - std::string RealURI) + indexRecords *MetaIndexParser) : Item(Owner, ExpectedHashes, TransactionManager), Target(Target), - MetaIndexParser(MetaIndexParser), RealURI(RealURI) {}; + MetaIndexParser(MetaIndexParser) {}; }; /*}}}*/ /** \brief An item that is responsible for fetching an index file of {{{ -- cgit v1.2.3 From 61aea84df918a4257ea1233e48e5860529ecfc9b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Oct 2014 17:28:20 +0200 Subject: add a bunch of docstrings etc --- apt-pkg/acquire-item.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index fbbca8bf2..97236f90a 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -443,7 +443,8 @@ class pkgAcqMetaSig : public pkgAcqMetaBase // Specialized action members virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, + virtual void Done(std::string Message,unsigned long long Size, + HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); virtual std::string Custom600Headers() const; virtual std::string DescURI() {return RealURI; }; @@ -575,7 +576,8 @@ class pkgAcqMetaClearSig : public pkgAcqMetaIndex public: virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); virtual std::string Custom600Headers() const; - virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, + virtual void Done(std::string Message,unsigned long long Size, + HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); /** \brief Create a new pkgAcqMetaClearSig. */ -- cgit v1.2.3 From 1ce243188c2ba218f5dce8ec8b40556d58ed8ec2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Oct 2014 18:28:55 +0200 Subject: cleanup around pkgAcqMetaSig and improved tests --- apt-pkg/acquire-item.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 97236f90a..083a73197 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -433,6 +433,9 @@ class pkgAcqMetaSig : public pkgAcqMetaBase /** \brief The file we need to verify */ std::string MetaIndexFile; + /** \brief The file we use to verify the MetaIndexFile with */ + std::string MetaIndexFileSignature; + /** \brief Long URI description used in the acquire system */ std::string URIDesc; -- cgit v1.2.3 From eeac6897ebc6ecad6721ef9bd457fe51ef611755 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Oct 2014 09:42:12 +0200 Subject: add new "SetActiveSubprocess() --- apt-pkg/acquire-item.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 083a73197..bab2cc0d7 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -292,6 +292,12 @@ class pkgAcquire::Item : public WeakPointable */ void ReportMirrorFailure(std::string FailCode); + /** \brief Set the name of the current active subprocess + * + * See also #ActiveSubprocess + */ + void SetActiveSubprocess(const std::string &subprocess); + /** \brief Initialize an item. * * Adds the item to the list of items known to the acquire -- cgit v1.2.3 From f30976478e684fc19e48d71881805454ceb6ecae Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Oct 2014 11:45:42 +0200 Subject: Rework pkgAcqMeta{Index,Sig,ClearSig}::Done() for readability Move common code out but do not use subclassing for ::Done to make it easier to understand what each class is doing when its done --- apt-pkg/acquire-item.h | 64 +++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 29 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index bab2cc0d7..f12f57262 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -385,6 +385,41 @@ class pkgAcqMetaBase : public pkgAcquire::Item */ void QueueIndexes(bool verify); + + /** \brief Called when a file is finished being retrieved. + * + * If the file was not downloaded to DestFile, a copy process is + * set up to copy it to DestFile; otherwise, Complete is set to \b + * true and the file is moved to its final location. + * + * \param Message The message block received from the fetch + * subprocess. + */ + bool CheckDownloadDone(const std::string &Message, + const std::string &RealURI); + + /** \brief Queue the downloaded Signature for verification */ + void QueueForSignatureVerify(const std::string &MetaIndexFile, + const std::string &MetaIndexFileSignature); + + /** \brief Called when authentication succeeded. + * + * Sanity-checks the authenticated file, queues up the individual + * index files for download, and saves the signature in the lists + * directory next to the authenticated list file. + * + * \param Message The message block received from the fetch + * subprocess. + */ + bool AuthDone(std::string Message, const std::string &RealURI); + + /** \brief Check that the release file is a release file for the + * correct distribution. + * + * \return \b true if no fatal errors were encountered. + */ + bool VerifyVendor(std::string Message, const std::string &RealURI); + public: // transaction code void Add(Item *I); @@ -496,35 +531,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase */ std::string SigFile; - /** \brief Check that the release file is a release file for the - * correct distribution. - * - * \return \b true if no fatal errors were encountered. - */ - bool VerifyVendor(std::string Message); - - /** \brief Called when a file is finished being retrieved. - * - * If the file was not downloaded to DestFile, a copy process is - * set up to copy it to DestFile; otherwise, Complete is set to \b - * true and the file is moved to its final location. - * - * \param Message The message block received from the fetch - * subprocess. - */ - void RetrievalDone(std::string Message); - - /** \brief Called when authentication succeeded. - * - * Sanity-checks the authenticated file, queues up the individual - * index files for download, and saves the signature in the lists - * directory next to the authenticated list file. - * - * \param Message The message block received from the fetch - * subprocess. - */ - void AuthDone(std::string Message); - std::string URIDesc; std::string ShortDesc; -- cgit v1.2.3 From 673c9469abd656a92c7e8f1f91f919cad09f391e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Oct 2014 14:34:38 +0200 Subject: cleanup pkgAcq*::Failed() --- apt-pkg/acquire-item.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index f12f57262..e0739dcd2 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -436,9 +436,9 @@ class pkgAcqMetaBase : public pkgAcquire::Item */ void TransactionStageRemoval(Item *I, const std::string &FinalFile); - // helper for the signature warning - bool GenerateAuthWarning(const std::string &RealURI, - const std::string &Message); + /** Check if the current item should fail at this point */ + bool StopAuthentication(const std::string &RealURI, + const std::string &Message); pkgAcqMetaBase(pkgAcquire *Owner, @@ -524,13 +524,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase */ std::string RealURI; - /** \brief The file in which the signature for this index was stored. - * - * If empty, the signature and the md5sums of the individual - * indices will not be checked. - */ - std::string SigFile; - std::string URIDesc; std::string ShortDesc; -- cgit v1.2.3 From ba8a84216a84c5e1e02ad46f412a04728277cb36 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Oct 2014 14:39:16 +0200 Subject: rename AuthDone() -> CheckAuthDone() --- apt-pkg/acquire-item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index e0739dcd2..393f3a250 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -411,7 +411,7 @@ class pkgAcqMetaBase : public pkgAcquire::Item * \param Message The message block received from the fetch * subprocess. */ - bool AuthDone(std::string Message, const std::string &RealURI); + bool CheckAuthDone(std::string Message, const std::string &RealURI); /** \brief Check that the release file is a release file for the * correct distribution. -- cgit v1.2.3 From 2d0a7bb434ebef179ab4955dfb09262452213190 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 6 Oct 2014 14:54:53 +0200 Subject: rename StopAuthentication -> CheckStopAuthentication and make it protected --- apt-pkg/acquire-item.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 393f3a250..02b8c13e8 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -413,6 +413,10 @@ class pkgAcqMetaBase : public pkgAcquire::Item */ bool CheckAuthDone(std::string Message, const std::string &RealURI); + /** Check if the current item should fail at this point */ + bool CheckStopAuthentication(const std::string &RealURI, + const std::string &Message); + /** \brief Check that the release file is a release file for the * correct distribution. * @@ -436,11 +440,6 @@ class pkgAcqMetaBase : public pkgAcquire::Item */ void TransactionStageRemoval(Item *I, const std::string &FinalFile); - /** Check if the current item should fail at this point */ - bool StopAuthentication(const std::string &RealURI, - const std::string &Message); - - pkgAcqMetaBase(pkgAcquire *Owner, const std::vector* IndexTargets, indexRecords* MetaIndexParser, -- cgit v1.2.3 From 5684f71fa0f6c1b765aa53e22ca3b024c578b9c9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 6 Oct 2014 14:29:53 +0200 Subject: use _apt:root only for partial directories Using a different user for calling methods is intended to protect us from methods running amok (via remotely exploited bugs) by limiting what can be done by them. By using root:root for the final directories and just have the files in partial writeable by the methods we enhance this in sofar as a method can't modify already verified data in its parent directory anymore. As a side effect, this also clears most of the problems you could have if the final directories are shared without user-sharing or if these directories disappear as they are now again root owned and only the partial directories contain _apt owned files (usually none if apt isn't running) and the directory itself is autocreated with the right permissions. --- apt-pkg/acquire-item.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'apt-pkg/acquire-item.h') diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 02b8c13e8..a3388ca3e 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -75,12 +75,11 @@ class pkgAcquire::Item : public WeakPointable * \param Item Metadata about this item (its URI and * description). */ - inline void QueueURI(ItemDesc &Item) - {Owner->Enqueue(Item);}; + void QueueURI(ItemDesc &Item); /** \brief Remove this item from its owner's queue. */ - inline void Dequeue() {Owner->Dequeue(this);}; - + void Dequeue(); + /** \brief Rename a file without modifying its timestamp. * * Many item methods call this as their final action. -- cgit v1.2.3