}
- 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()
{
}
}
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() ) );
}
* 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.
*/
void operator()( const Pathname &file ) const;
- private:
+ protected:
Pathname _signature;
+ std::string _description;
};
-
+
/**
* \short Checks for nothing
* Used as the default checker
{
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()) )
* ...
* };
* \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 */
shared_ptr<repo::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;
MediaSetAccess media(url);
shared_ptr<repo::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
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);
}
{
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 ) );
}
- this->enqueue( OnMediaLocation( _path + "/content", 1 ), sigchecker );
+ this->enqueue( OnMediaLocation( _info.path() + "/content", 1 ), sigchecker );
this->start( dest_dir, media );
this->reset();
// 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() )
{
}
}
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);
}
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);
}
#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"
{
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
*
void consumeIndex( const parser::susetags::RepoIndex_Ptr & data_r );
private:
- Pathname _path;
+ RepoInfo _info;
parser::susetags::RepoIndex_Ptr _repoindex;
};
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);
}
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;
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
{
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));
}
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);
_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());
}
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);
#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"
{
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 );
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;