void importKey( const Pathname &keyfile, bool trusted = false);
PublicKey readPublicKey( const Pathname &keyfile );
- std::string readSignatureKeyId( const Pathname &keyfile );
+ std::string readSignatureKeyId( const Pathname &data, const Pathname &keyfile );
void deleteKey( const std::string &id, bool trusted );
std::list<PublicKey> trustedPublicKeys();
MIL << "Going to verify signature for " << file << " with " << signature << std::endl;
// get the id of the signature
- std::string id = readSignatureKeyId(signature);
+ std::string id = readSignatureKeyId(file, signature);
// doeskey exists in trusted keyring
if ( publicKeyExists( id, _trusted_kr ) )
}
- std::string KeyRing::Impl::readSignatureKeyId( const Pathname &keyfile )
+ std::string KeyRing::Impl::readSignatureKeyId( const Pathname &data, const Pathname &keyfile )
{
// HACK create a tmp keyring with no keys
TmpDir dir;
"1",
"--homedir",
dir.path().asString().c_str(),
+ "--verify",
keyfile.asString().c_str(),
+ data.asString().c_str(),
NULL
};
return _pimpl->readPublicKey(keyfile);
}
- std::string KeyRing::readSignatureKeyId( const Pathname &keyfile )
+ std::string KeyRing::readSignatureKeyId( const Pathname &data, const Pathname &keyfile )
{
- return _pimpl->readSignatureKeyId(keyfile);
+ return _pimpl->readSignatureKeyId(data, keyfile);
}
void KeyRing::deleteKey( const std::string &id, bool trusted )
#include "zypp/base/GzStream.h"
#include "zypp/base/Gettext.h"
+#include "zypp/PathInfo.h"
#include <fstream>
YUMSourceImpl::YUMSourceImpl()
{}
+ bool YUMSourceImpl::cacheExists()
+ {
+ bool exists = PathInfo(_cache_dir + "/repodata/repomd.xml").isExist();
+ if (exists)
+ MIL << "YUM cache found at " << _cache_dir << std::endl;
+ else
+ MIL << "YUM cache not found" << std::endl;
+
+ return exists;
+ }
+
void YUMSourceImpl::factoryInit()
{
try {
try {
// first read list of all files in the repository
Pathname filename;
- if (_cache_dir.empty())
+ if (!cacheExists())
{
// now, the file exists, try to read it
filename = provideFile(_path + "/repodata/repomd.xml");
filesystem::TmpFile tmp;
filesystem::copy(filename, tmp.path());
filename = tmp.path();
- if (_cache_dir.empty())
+ if (!cacheExists())
{
MIL << "Trying to get the key" << endl;
Pathname key_local;
! repomd.atEnd();
++repomd)
{
- if (_cache_dir.empty())
+ if (!cacheExists())
{
if (! checkCheckSum(provideFile(_path + (*repomd)->location), (*repomd)->checksumType, (*repomd)->checksum))
{
}
if ((*repomd)->type == "patches")
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*repomd)->location)
- : _cache_dir + (*repomd)->location;
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*repomd)->location
+ : provideFile(_path + (*repomd)->location);
DBG << "reading file " << filename << endl;
ifgzstream st ( filename.asString().c_str() );
YUMPatchesParser patch(st, "");
++patch)
{
string filename = (*patch)->location;
- if (_cache_dir.empty())
+ if (!cacheExists())
{
if (! checkCheckSum(provideFile(_path + filename), (*patch)->checksumType, (*patch)->checksum))
{
try {
// first read list of all files in the repository
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + "/repodata/repomd.xml")
- : _cache_dir + "/repodata/repomd.xml";
+ Pathname filename = cacheExists()
+ ? _cache_dir + "/repodata/repomd.xml"
+ : provideFile(_path + "/repodata/repomd.xml");
_metadata_files.push_back("/repodata/repomd.xml");
// use tmpfile because of checking integrity - provideFile might release the medium
filesystem::TmpFile tmp;
filesystem::copy(filename, tmp.path());
filename = tmp.path();
- if (_cache_dir.empty())
+ if (!cacheExists())
{
MIL << "Checking repomd.xml integrity" << endl;
Pathname asc_local;
it != repo_files.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*it)->location)
- : _cache_dir + (*it)->location;
- if (_cache_dir.empty())
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*it)->location
+ : provideFile(_path + (*it)->location);
+ if (!cacheExists())
{
if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
it != repo_other.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*it)->location)
- : _cache_dir + (*it)->location;
- if (_cache_dir.empty())
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*it)->location
+ : provideFile(_path + (*it)->location);
+ if (!cacheExists())
{
if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
it != repo_primary.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*it)->location)
- : _cache_dir + (*it)->location;
- if (_cache_dir.empty())
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*it)->location
+ : provideFile(_path + (*it)->location);
+ if (!cacheExists())
{
if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
it != repo_group.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*it)->location)
- : _cache_dir + (*it)->location;
- if (_cache_dir.empty())
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*it)->location
+ : provideFile(_path + (*it)->location);
+ if (!cacheExists())
{
if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
it != repo_pattern.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*it)->location)
- : _cache_dir + (*it)->location;
- if (_cache_dir.empty())
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*it)->location
+ : provideFile(_path + (*it)->location);
+ if (!cacheExists())
{
if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
it != repo_product.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*it)->location)
- : _cache_dir + (*it)->location;
- if (_cache_dir.empty())
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*it)->location
+ : provideFile(_path + (*it)->location);
+ if (!cacheExists())
{
if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
it != repo_patches.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + (*it)->location)
- : _cache_dir + (*it)->location;
- if (_cache_dir.empty())
+ Pathname filename = cacheExists()
+ ? _cache_dir + (*it)->location
+ : provideFile(_path + (*it)->location);
+ if (!cacheExists())
{
if (! checkCheckSum(filename, (*it)->checksumType, (*it)->checksum))
{
++patch)
{
string filename = (*patch)->location;
- if (_cache_dir.empty())
+ if (!cacheExists())
{
if (! checkCheckSum(provideFile(_path + filename), (*patch)->checksumType, (*patch)->checksum))
{
it != patch_files.end();
it++)
{
- Pathname filename = _cache_dir.empty()
- ? provideFile(_path + *it)
- : _cache_dir + *it;
+ Pathname filename = cacheExists()
+ ? _cache_dir + *it
+ : provideFile(_path + *it);
_metadata_files.push_back(*it);
DBG << "Reading file " << filename << endl;
ifgzstream st ( filename.asString().c_str() );