Author: dmacvicar Date: Tue Sep 9 17:43:37 2008 New Revision: 10977 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10977&view=rev Log: - provide context about the repository (name/alias) if available when checking signatures (bnc#370223) Modified: trunk/libzypp/zypp/FileChecker.cc trunk/libzypp/zypp/FileChecker.h trunk/libzypp/zypp/KeyRing.cc trunk/libzypp/zypp/KeyRing.h trunk/libzypp/zypp/RepoManager.cc trunk/libzypp/zypp/repo/susetags/Downloader.cc trunk/libzypp/zypp/repo/susetags/Downloader.h trunk/libzypp/zypp/repo/yum/Downloader.cc trunk/libzypp/zypp/repo/yum/Downloader.h Modified: trunk/libzypp/zypp/FileChecker.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/FileChecker.cc?rev=1... ============================================================================== --- trunk/libzypp/zypp/FileChecker.cc (original) +++ trunk/libzypp/zypp/FileChecker.cc Tue Sep 9 17:43:37 2008 @@ -94,11 +94,20 @@ } - SignatureFileChecker::SignatureFileChecker( const Pathname &signature ) - : _signature(signature) + SignatureFileChecker::SignatureFileChecker( const Pathname &signature, + const std::string &description ) + : _signature(signature) + , _description(description) + { + + } + + SignatureFileChecker::SignatureFileChecker( const std::string &description ) + : _description(description) { } + SignatureFileChecker::SignatureFileChecker() { } @@ -119,7 +128,8 @@ } MIL << "checking " << file << " file validity using digital signature.." << endl; - bool valid = z->keyRing()->verifyFileSignatureWorkflow( file, file.basename(), _signature); + bool valid = z->keyRing()->verifyFileSignatureWorkflow( file, _description.empty() ? file.basename() : _description, _signature); + if (!valid) ZYPP_THROW( FileCheckException( "Signature verification failed for " + file.basename() ) ); } Modified: trunk/libzypp/zypp/FileChecker.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/FileChecker.h?rev=10... ============================================================================== --- trunk/libzypp/zypp/FileChecker.h (original) +++ trunk/libzypp/zypp/FileChecker.h Tue Sep 9 17:43:37 2008 @@ -86,7 +86,14 @@ * Constructor. * \param signature Signature that validates the file */ - SignatureFileChecker( const Pathname &signature ); + SignatureFileChecker( const Pathname &signature, + const std::string &description = std::string() ); + + /** + * Constructor for files not containing a signature + * \param description Description of the checker + */ + SignatureFileChecker( const std::string &description ); /** * Default Constructor. @@ -109,10 +116,11 @@ */ void operator()( const Pathname &file ) const; - private: + protected: Pathname _signature; + std::string _description; }; - + /** * \short Checks for nothing * Used as the default checker Modified: trunk/libzypp/zypp/KeyRing.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/KeyRing.cc?rev=10977... ============================================================================== --- trunk/libzypp/zypp/KeyRing.cc (original) +++ trunk/libzypp/zypp/KeyRing.cc Tue Sep 9 17:43:37 2008 @@ -335,7 +335,7 @@ { callback::SendReport<KeyRingReport> report; //callback::SendReport<KeyRingSignals> emitSignal; - MIL << "Going to verify signature for " << file << " with " << signature << endl; + MIL << "Going to verify signature for " << filedesc << " ( " << file << " ) with " << signature << endl; // if signature does not exists, ask user if he wants to accept unsigned file. if( signature.empty() || (!PathInfo(signature).isExist()) ) Modified: trunk/libzypp/zypp/KeyRing.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/KeyRing.h?rev=10977&... ============================================================================== --- trunk/libzypp/zypp/KeyRing.h (original) +++ trunk/libzypp/zypp/KeyRing.h Tue Sep 9 17:43:37 2008 @@ -209,10 +209,23 @@ * ... * }; * \endcode + * + * \param file Path of the file to be verified + * \param filedesc Description of the file (to give the user some context) + * \param signature Signature to verify the file against + * * \see \ref KeyRingReport */ bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature); + + /** + * Verifies a file against a signature, with no user interaction + * + * \param file Path of the file to be verified + * \param signature Signature to verify the file against + */ bool verifyFileSignature( const Pathname &file, const Pathname &signature); + bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature); /** Dtor */ Modified: trunk/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=1... ============================================================================== --- trunk/libzypp/zypp/RepoManager.cc (original) +++ trunk/libzypp/zypp/RepoManager.cc Tue Sep 9 17:43:37 2008 @@ -547,9 +547,9 @@ shared_ptrrepo::Downloader downloader_ptr; if ( repokind.toEnum() == RepoType::RPMMD_e ) - downloader_ptr.reset(new yum::Downloader(info.path())); + downloader_ptr.reset(new yum::Downloader(info)); else - downloader_ptr.reset( new susetags::Downloader(info.path())); + downloader_ptr.reset( new susetags::Downloader(info)); RepoStatus newstatus = downloader_ptr->status(media); bool refresh = false; @@ -677,10 +677,12 @@ MediaSetAccess media(url); shared_ptrrepo::Downloader downloader_ptr; + MIL << "Creating downloader for [ " << info.name() << " ]" << endl; + if ( repokind.toEnum() == RepoType::RPMMD_e ) - downloader_ptr.reset(new yum::Downloader(info.path())); + downloader_ptr.reset(new yum::Downloader(info)); else - downloader_ptr.reset( new susetags::Downloader(info.path())); + downloader_ptr.reset( new susetags::Downloader(info) ); /** * Given a downloader, sets the other repos raw metadata Modified: trunk/libzypp/zypp/repo/susetags/Downloader.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/susetags/Downlo... ============================================================================== --- trunk/libzypp/zypp/repo/susetags/Downloader.cc (original) +++ trunk/libzypp/zypp/repo/susetags/Downloader.cc Tue Sep 9 17:43:37 2008 @@ -26,16 +26,23 @@ namespace susetags { -Downloader::Downloader(const Pathname &path ) - : _path(path) +Downloader::Downloader(const RepoInfo &info ) + : _info(info) { } +Downloader::Downloader(const Pathname &path ) +{ + RepoInfo info; + info.setPath(path); + _info = info; +} + RepoStatus Downloader::status( MediaSetAccess &media ) { - Pathname content = media.provideFile( _path + "/content"); - Pathname mediafile = media.provideFile( _path + "/media.1/media" ); + Pathname content = media.provideFile( _info.path() + "/content"); + Pathname mediafile = media.provideFile( _info.path() + "/media.1/media" ); return RepoStatus(content) && RepoStatus(mediafile); } @@ -46,19 +53,19 @@ { downloadMediaInfo( dest_dir, media ); - SignatureFileChecker sigchecker; + SignatureFileChecker sigchecker(_info.name()); - Pathname sig = _path + "/content.asc"; + Pathname sig = _info.path() + "/content.asc"; if ( media.doesFileExist(sig) ) { this->enqueue( OnMediaLocation( sig, 1 ) ); this->start( dest_dir, media ); this->reset(); - sigchecker = SignatureFileChecker( dest_dir + sig ); + sigchecker = SignatureFileChecker( dest_dir + sig, _info.name() ); } - Pathname key = _path + "/content.key"; + Pathname key = _info.path() + "/content.key"; if ( media.doesFileExist(key) ) { this->enqueue( OnMediaLocation( key, 1 ) ); @@ -68,7 +75,7 @@ } - this->enqueue( OnMediaLocation( _path + "/content", 1 ), sigchecker ); + this->enqueue( OnMediaLocation( _info.path() + "/content", 1 ), sigchecker ); this->start( dest_dir, media ); this->reset(); @@ -76,19 +83,19 @@ // Content file first to get the repoindex { - Pathname inputfile( dest_dir + _path + "/content" ); + Pathname inputfile( dest_dir + _info.path() + "/content" ); ContentFileReader content; content.setRepoIndexConsumer( bind( &Downloader::consumeIndex, this, _1 ) ); content.parse( inputfile ); } if ( ! _repoindex ) { - ZYPP_THROW( ParseException( (dest_dir+_path).asString() + ": " + "No repository index in content file." ) ); + ZYPP_THROW( ParseException( (dest_dir+_info.path()).asString() + ": " + "No repository index in content file." ) ); } MIL << "RepoIndex: " << _repoindex << endl; if ( _repoindex->metaFileChecksums.empty() ) { - ZYPP_THROW( ParseException( (dest_dir+_path).asString() + ": " + "No metadata checksums in content file." ) ); + ZYPP_THROW( ParseException( (dest_dir+_info.path()).asString() + ": " + "No metadata checksums in content file." ) ); } if ( _repoindex->signingKeys.empty() ) { @@ -172,7 +179,7 @@ } } MIL << "adding job " << it->first << endl; - OnMediaLocation location( _path + descr_dir + it->first, 1 ); + OnMediaLocation location( _info.path() + descr_dir + it->first, 1 ); location.setChecksum( it->second ); this->enqueueDigested(location); } @@ -181,7 +188,7 @@ it != _repoindex->signingKeys.end(); ++it ) { - OnMediaLocation location( _path + it->first, 1 ); + OnMediaLocation location( _info.path() + it->first, 1 ); location.setChecksum( it->second ); this->enqueueDigested(location); } Modified: trunk/libzypp/zypp/repo/susetags/Downloader.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/susetags/Downlo... ============================================================================== --- trunk/libzypp/zypp/repo/susetags/Downloader.h (original) +++ trunk/libzypp/zypp/repo/susetags/Downloader.h Tue Sep 9 17:43:37 2008 @@ -13,6 +13,7 @@ #include "zypp/Url.h" #include "zypp/Pathname.h" #include "zypp/ProgressData.h" +#include "zypp/RepoInfo.h" #include "zypp/RepoStatus.h" #include "zypp/MediaSetAccess.h" #include "zypp/repo/Downloader.h" @@ -34,12 +35,23 @@ { public: /** - * \short Constructor + * \short Constructor from the repository information * + * The repository information allows more context to be given + * to the user when something fails. + * + * \param info Repository information + */ + Downloader( const RepoInfo &info ); + + /** + * \short Constructor from the pathname relative to the + * repository url + * * \param path Path to the repostory from the media */ Downloader( const Pathname &path ); - + /** * \short Download metadata to a local directory * @@ -61,7 +73,7 @@ void consumeIndex( const parser::susetags::RepoIndex_Ptr & data_r ); private: - Pathname _path; + RepoInfo _info; parser::susetags::RepoIndex_Ptr _repoindex; }; Modified: trunk/libzypp/zypp/repo/yum/Downloader.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/yum/Downloader.... ============================================================================== --- trunk/libzypp/zypp/repo/yum/Downloader.cc (original) +++ trunk/libzypp/zypp/repo/yum/Downloader.cc Tue Sep 9 17:43:37 2008 @@ -32,14 +32,21 @@ namespace yum { -Downloader::Downloader( const Pathname &path ) - : _path(path), _media_ptr(0L) +Downloader::Downloader( const RepoInfo &info ) + : _info(info), _media_ptr(0L) { } +Downloader::Downloader(const Pathname &path ) +{ + RepoInfo info; + info.setPath(path); + _info = info; +} + RepoStatus Downloader::status( MediaSetAccess &media ) { - Pathname repomd = media.provideFile( _path + "/repodata/repomd.xml"); + Pathname repomd = media.provideFile( _info.path() + "/repodata/repomd.xml"); return RepoStatus(repomd); } @@ -59,7 +66,7 @@ bool Downloader::patches_Callback( const OnMediaLocation &loc, const string &id ) { - OnMediaLocation loc_with_path(loc_with_path_prefix(loc, _path)); + OnMediaLocation loc_with_path(loc_with_path_prefix(loc, _info.path())); MIL << id << " : " << loc_with_path << endl; this->enqueueDigested(loc_with_path); return true; @@ -69,7 +76,7 @@ bool Downloader::repomd_Callback( const OnMediaLocation &loc, const ResourceType &dtype ) { - OnMediaLocation loc_with_path(loc_with_path_prefix(loc, _path)); + OnMediaLocation loc_with_path(loc_with_path_prefix(loc, _info.path())); MIL << dtype << " : " << loc_with_path << endl; //! \todo do this through a ZConfig call so that it is always in sync with parser @@ -95,7 +102,7 @@ { this->start( _dest_dir, *_media_ptr ); // now the patches.xml file must exists - PatchesFileReader( _dest_dir + _path + loc.filename(), + PatchesFileReader( _dest_dir + _info.path() + loc.filename(), bind( &Downloader::patches_Callback, this, _1, _2)); } @@ -106,9 +113,9 @@ const Pathname &dest_dir, const ProgressData::ReceiverFnc & progressrcv ) { - Pathname repomdpath = _path + "/repodata/repomd.xml"; - Pathname keypath = _path + "/repodata/repomd.xml.key"; - Pathname sigpath = _path + "/repodata/repomd.xml.asc"; + Pathname repomdpath = _info.path() + "/repodata/repomd.xml"; + Pathname keypath = _info.path() + "/repodata/repomd.xml.key"; + Pathname sigpath = _info.path() + "/repodata/repomd.xml.asc"; _media_ptr = (&media); @@ -120,14 +127,14 @@ _dest_dir = dest_dir; - SignatureFileChecker sigchecker; + SignatureFileChecker sigchecker(_info.name()); if ( _media_ptr->doesFileExist(sigpath) ) { this->enqueue( OnMediaLocation(sigpath,1).setOptional(true) ); this->start( dest_dir, *_media_ptr); this->reset(); - sigchecker = SignatureFileChecker(dest_dir + sigpath); + sigchecker = SignatureFileChecker(dest_dir + sigpath, _info.name()); } @@ -153,8 +160,8 @@ this->reset(); - Reader reader( dest_dir + _path + "/repodata/repomd.xml" ); - RepomdFileReader( dest_dir + _path + "/repodata/repomd.xml", bind( &Downloader::repomd_Callback, this, _1, _2)); + Reader reader( dest_dir + _info.path() + "/repodata/repomd.xml" ); + RepomdFileReader( dest_dir + _info.path() + "/repodata/repomd.xml", bind( &Downloader::repomd_Callback, this, _1, _2)); // ready, go! this->start( dest_dir, *_media_ptr); Modified: trunk/libzypp/zypp/repo/yum/Downloader.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/yum/Downloader.... ============================================================================== --- trunk/libzypp/zypp/repo/yum/Downloader.h (original) +++ trunk/libzypp/zypp/repo/yum/Downloader.h Tue Sep 9 17:43:37 2008 @@ -16,6 +16,7 @@ #include "zypp/OnMediaLocation.h" #include "zypp/MediaSetAccess.h" #include "zypp/ProgressData.h" +#include "zypp/RepoInfo.h" #include "zypp/RepoStatus.h" #include "zypp/repo/Downloader.h" #include "zypp/repo/yum/ResourceType.h" @@ -41,9 +42,20 @@ { public: - /** - * \short Constructor + /** + * \short Constructor from the repository information + * + * The repository information allows more context to be given + * to the user when something fails. * + * \param info Repository information + */ + Downloader( const RepoInfo &info ); + + /** + * \short Constructor from the pathname relative to the + * repository url + * * \param path Path to the repostory from the media */ Downloader( const Pathname &path ); @@ -68,7 +80,7 @@ bool repomd_Callback( const OnMediaLocation &loc, const ResourceType &dtype ); bool patches_Callback( const OnMediaLocation &loc, const std::string &id ); private: - Pathname _path; + RepoInfo _info; Pathname _dest_dir; std::list<OnMediaLocation> _patches_files; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org