X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/61aea84df918a4257ea1233e48e5860529ecfc9b..02e20767719873fa8f1919bd0e7a75f63e00c484:/apt-pkg/acquire-item.h?ds=sidebyside diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 97236f90a..1af737e00 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -63,6 +63,8 @@ class pkgAcqMetaBase; */ class pkgAcquire::Item : public WeakPointable { + friend class pkgAcqMetaBase; + void *d; protected: @@ -75,12 +77,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. @@ -253,7 +254,11 @@ class pkgAcquire::Item : public WeakPointable * line, so they should (if nonempty) have a leading newline and * no trailing newline. */ +#if APT_PKG_ABI >= 413 virtual std::string Custom600Headers() const {return std::string();}; +#else + virtual std::string Custom600Headers() {return std::string();}; +#endif /** \brief A "descriptive" URI-like string. * @@ -279,9 +284,16 @@ class pkgAcquire::Item : public WeakPointable /** \return the acquire process with which this item is associated. */ pkgAcquire *GetOwner() const {return Owner;}; +#if APT_PKG_ABI < 413 + pkgAcquire *GetOwner() {return Owner;}; +#endif /** \return \b true if this object is being fetched from a trusted source. */ +#if APT_PKG_ABI >= 413 virtual bool IsTrusted() const {return false;}; +#else + virtual bool IsTrusted() {return false;}; +#endif /** \brief Report mirror problem * @@ -292,6 +304,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 @@ -318,6 +336,7 @@ class pkgAcquire::Item : public WeakPointable InvalidFormat, SignatureError, NotClearsigned, + MaximumSizeExceeded }; /** \brief Rename failed file and set error @@ -334,20 +353,24 @@ class pkgAcquire::Item : public WeakPointable }; /*}}}*/ /** \brief Information about an index patch (aka diff). */ /*{{{*/ -struct DiffInfo { +struct APT_HIDDEN DiffInfo { /** The filename of the diff. */ std::string file; - /** The sha1 hash of the diff. */ - std::string sha1; + /** The hashes of the diff */ + HashStringList result_hashes; + + /** The hashes of the file after the diff is applied */ + HashStringList patch_hashes; - /** The size of the diff. */ - unsigned long size; + /** The size of the file after the diff is applied */ + unsigned long long result_size; + + /** The size of the diff itself */ + unsigned long long patch_size; }; /*}}}*/ - /*}}}*/ - -class pkgAcqMetaBase : public pkgAcquire::Item +class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/ { void *d; @@ -379,6 +402,47 @@ 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 get the custom600 header for all pkgAcqMeta */ + std::string GetCustom600Headers(const std::string &RealURI) const; + + /** \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 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. + * + * \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); @@ -386,20 +450,15 @@ class pkgAcqMetaBase : public pkgAcquire::Item bool TransactionHasError() APT_PURE; void CommitTransaction(); - /** \brief Stage (queue) a copy action when the transaction is commited + /** \brief Stage (queue) a copy action when the transaction is committed */ void TransactionStageCopy(Item *I, const std::string &From, const std::string &To); - /** \brief Stage (queue) a removal action when the transaction is commited + /** \brief Stage (queue) a removal action when the transaction is committed */ void TransactionStageRemoval(Item *I, const std::string &FinalFile); - // helper for the signature warning - bool GenerateAuthWarning(const std::string &RealURI, - const std::string &Message); - - pkgAcqMetaBase(pkgAcquire *Owner, const std::vector* IndexTargets, indexRecords* MetaIndexParser, @@ -409,7 +468,7 @@ class pkgAcqMetaBase : public pkgAcquire::Item MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets), AuthPass(false), IMSHit(false) {}; }; - + /*}}}*/ /** \brief An acquire item that downloads the detached signature {{{ * of a meta-index (Release) file, then queues up the release * file itself. @@ -418,7 +477,7 @@ class pkgAcqMetaBase : public pkgAcquire::Item * * \sa pkgAcqMetaIndex */ -class pkgAcqMetaSig : public pkgAcqMetaBase +class APT_HIDDEN pkgAcqMetaSig : public pkgAcqMetaBase { void *d; @@ -433,6 +492,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; @@ -446,7 +508,11 @@ class pkgAcqMetaSig : public pkgAcqMetaBase virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); +#if APT_PKG_ABI >= 413 virtual std::string Custom600Headers() const; +#else + virtual std::string Custom600Headers(); +#endif virtual std::string DescURI() {return RealURI; }; /** \brief Create a new pkgAcqMetaSig. */ @@ -459,7 +525,6 @@ class pkgAcqMetaSig : public pkgAcqMetaBase virtual ~pkgAcqMetaSig(); }; /*}}}*/ - /** \brief An item that is responsible for downloading the meta-index {{{ * file (i.e., Release) itself and verifying its signature. * @@ -470,7 +535,7 @@ class pkgAcqMetaSig : public pkgAcqMetaBase * otherwise, the expected hashsums will be "" (causing the * authentication of the index files to be bypassed). */ -class pkgAcqMetaIndex : public pkgAcqMetaBase +class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase { void *d; @@ -480,42 +545,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; - - /** \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; @@ -537,7 +566,11 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase 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); +#if APT_PKG_ABI >= 413 virtual std::string Custom600Headers() const; +#else + virtual std::string Custom600Headers(); +#endif virtual std::string DescURI() {return RealURI; }; virtual void Finished(); @@ -551,7 +584,7 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase }; /*}}}*/ /** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/ -class pkgAcqMetaClearSig : public pkgAcqMetaIndex +class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex { void *d; @@ -575,7 +608,11 @@ class pkgAcqMetaClearSig : public pkgAcqMetaIndex public: virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); +#if APT_PKG_ABI >= 413 virtual std::string Custom600Headers() const; +#else + virtual std::string Custom600Headers(); +#endif virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); @@ -590,8 +627,6 @@ public: virtual ~pkgAcqMetaClearSig(); }; /*}}}*/ - - /** \brief Common base class for all classes that deal with fetching {{{ indexes */ @@ -635,7 +670,7 @@ class pkgAcqBaseIndex : public pkgAcquire::Item * * \sa pkgAcqIndexDiffs, pkgAcqIndex */ -class pkgAcqDiffIndex : public pkgAcqBaseIndex +class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex { void *d; @@ -663,7 +698,11 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); virtual std::string DescURI() {return RealURI + "Index";}; +#if APT_PKG_ABI >= 413 virtual std::string Custom600Headers() const; +#else + virtual std::string Custom600Headers(); +#endif /** \brief Parse the Index file for a set of Packages diffs. * @@ -708,7 +747,7 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex * * \sa pkgAcqDiffIndex, pkgAcqIndex */ -class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex +class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex { void *d; @@ -796,7 +835,7 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex * * \sa pkgAcqDiffIndex, pkgAcqIndex */ -class pkgAcqIndexDiffs : public pkgAcqBaseIndex +class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex { void *d; @@ -811,7 +850,7 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex * \return \b true if an applicable diff was found, \b false * otherwise. */ - bool QueueNextDiff(); + APT_HIDDEN bool QueueNextDiff(); /** \brief Handle tasks that must be performed after the item * finishes downloading. @@ -824,7 +863,7 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex * \param allDone If \b true, the file was entirely reconstructed, * and its md5sum is verified. */ - void Finish(bool allDone=false); + APT_HIDDEN void Finish(bool allDone=false); protected: @@ -846,9 +885,6 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex */ std::vector available_patches; - /** Stop applying patches when reaching that sha1 */ - std::string ServerSha1; - /** The current status of this patch. */ enum DiffState { @@ -892,12 +928,10 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex * * \param ShortDesc A brief description of this item. * - * \param ExpectedHashes The expected md5sum of the completely + * \param ExpectedHashes The expected hashsums of the completely * reconstructed package index file; the index file will be tested * against this value when it is entirely reconstructed. * - * \param ServerSha1 is the sha1sum of the current file on the server - * * \param diffs The remaining diffs from the index of diffs. They * should be ordered so that each diff appears before any diff * that depends on it. @@ -907,7 +941,6 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex struct IndexTarget const * const Target, HashStringList const &ExpectedHash, indexRecords *MetaIndexParser, - std::string ServerSha1, std::vector diffs=std::vector()); }; /*}}}*/ @@ -918,7 +951,7 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex * * \todo Why does pkgAcqIndex have protected members? */ -class pkgAcqIndex : public pkgAcqBaseIndex +class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex { void *d; @@ -983,7 +1016,11 @@ class pkgAcqIndex : public pkgAcqBaseIndex virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); +#if APT_PKG_ABI >= 413 virtual std::string Custom600Headers() const; +#else + virtual std::string Custom600Headers(); +#endif virtual std::string DescURI() {return Desc.URI;}; /** \brief Create a pkgAcqIndex. @@ -1016,45 +1053,8 @@ class pkgAcqIndex : public pkgAcqBaseIndex std::string const &ShortDesc); }; /*}}}*/ -/** \brief An acquire item that is responsible for fetching a {{{ - * translated index file. - * - * The only difference from pkgAcqIndex is that transient failures - * are suppressed: no error occurs if the translated index file is - * missing. - */ -class pkgAcqIndexTrans : public pkgAcqIndex -{ - void *d; - - public: - - virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual std::string Custom600Headers() const; - - /** \brief Create a pkgAcqIndexTrans. - * - * \param Owner The pkgAcquire object with which this item is - * associated. - * - * \param URI The URI of the index file that is to be downloaded. - * - * \param URIDesc A "URI-style" description of this index file. - * - * \param ShortDesc A brief description of this index file. - */ - pkgAcqIndexTrans(pkgAcquire *Owner, - std::string URI,std::string URIDesc, - std::string ShortDesc); - pkgAcqIndexTrans(pkgAcquire *Owner, - pkgAcqMetaBase *TransactionManager, - IndexTarget const * const Target, - HashStringList const &ExpectedHashes, - indexRecords *MetaIndexParser); -}; - /*}}}*/ /** \brief Information about an index file. */ /*{{{*/ -class IndexTarget +class APT_HIDDEN IndexTarget { void *d; @@ -1079,7 +1079,7 @@ class IndexTarget }; /*}}}*/ /** \brief Information about an optional index file. */ /*{{{*/ -class OptionalIndexTarget : public IndexTarget +class APT_HIDDEN OptionalIndexTarget : public IndexTarget { void *d; @@ -1142,8 +1142,12 @@ class pkgAcqArchive : public pkgAcquire::Item virtual std::string DescURI() {return Desc.URI;}; virtual std::string ShortDesc() {return Desc.ShortDesc;}; virtual void Finished(); +#if APT_PKG_ABI >= 413 virtual bool IsTrusted() const; - +#else + virtual bool IsTrusted(); +#endif + /** \brief Create a new pkgAcqArchive. * * \param Owner The pkgAcquire object with which this item is @@ -1192,7 +1196,11 @@ class pkgAcqFile : public pkgAcquire::Item virtual void Done(std::string Message,unsigned long long Size, HashStringList const &CalcHashes, pkgAcquire::MethodConfig *Cnf); virtual std::string DescURI() {return Desc.URI;}; +#if APT_PKG_ABI >= 413 virtual std::string Custom600Headers() const; +#else + virtual std::string Custom600Headers(); +#endif /** \brief Create a new pkgAcqFile object. *