Author: mlandres
Date: Thu Jun 26 15:32:36 2008
New Revision: 10473
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10473&view=rev
Log:
- Import newer gpg keys if a trusted key is updated
(bnc#393160)
Added:
branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/GpgKeyz.cc
Modified:
branches/SuSE-Linux-10_3-Branch/libzypp/VERSION.cmake
branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/CMakeLists.txt
branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/Tools.h
branches/SuSE-Linux-10_3-Branch/libzypp/package/libzypp.changes
branches/SuSE-Linux-10_3-Branch/libzypp/zypp/KeyRing.cc
branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.cc
branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.h
branches/SuSE-Linux-10_3-Branch/libzypp/zypp/base/String.h
branches/SuSE-Linux-10_3-Branch/libzypp/zypp/target/rpm/RpmDb.cc
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/VERSION.cmake
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/VERSION.cmake?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/VERSION.cmake (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/VERSION.cmake Thu Jun 26 15:32:36 2008
@@ -45,6 +45,6 @@
#
SET(LIBZYPP_MAJOR "3")
-SET(LIBZYPP_MINOR "26")
+SET(LIBZYPP_MINOR "27")
SET(LIBZYPP_COMPATMINOR "24")
-SET(LIBZYPP_PATCH "8")
+SET(LIBZYPP_PATCH "0")
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/CMakeLists.txt?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/CMakeLists.txt (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/CMakeLists.txt Thu Jun 26 15:32:36 2008
@@ -29,7 +29,7 @@
## ############################################################
-FOREACH( loop_var ScanSource Iorder Xml Ex Main FakePool AOUT Parse Test Basic)
+FOREACH( loop_var ScanSource Iorder Xml Ex Main FakePool AOUT Parse Test Basic GpgKeyz)
ADD_EXECUTABLE( ${loop_var}
${loop_var}.cc
)
Added: branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/GpgKeyz.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/GpgKeyz.cc?rev=10473&view=auto
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/GpgKeyz.cc (added)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/GpgKeyz.cc Thu Jun 26 15:32:36 2008
@@ -0,0 +1,155 @@
+#include "Tools.h"
+#include <iostream>
+#include <fstream>
+#include <list>
+#include <map>
+#include <set>
+
+#include
+#include
+#include
+#include "zypp/base/Exception.h"
+#include "zypp/base/InputStream.h"
+#include "zypp/base/DefaultIntegral.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+using namespace zypp;
+
+///////////////////////////////////////////////////////////////////
+
+static const Pathname sysRoot( "/Local/ma/GPG" );
+
+///////////////////////////////////////////////////////////////////
+
+struct KeyRingSignalsReceive : public callback::ReceiveReport<KeyRingSignals>
+{
+ KeyRingSignalsReceive()
+ {
+ connect();
+ }
+ virtual void trustedKeyAdded( const KeyRing &/*keyring*/, const PublicKey &/*key*/ )
+ {
+ USR << endl;
+ }
+ virtual void trustedKeyRemoved( const KeyRing &/*keyring*/, const PublicKey &/*key*/ )
+ {
+ USR << endl;
+ }
+};
+
+///////////////////////////////////////////////////////////////////
+
+void ltrusted()
+{
+ list<PublicKey> trustedPublicKeys;
+ {
+ //zypp::base::LogControl::TmpLineWriter shutUp;
+ KeyRing_Ptr p( getZYpp()->keyRing() );
+ trustedPublicKeys = p->trustedPublicKeys();
+ }
+ USR << "Trusted Keys " << trustedPublicKeys.size() << endl;
+ for_( it, trustedPublicKeys.begin(), trustedPublicKeys.end() )
+ {
+ USR << *it << endl;
+ USR << " Creat: " << (*it).created() << endl;
+ USR << " Expir: " << (*it).expires() << endl;
+ }
+}
+
+///////////////////////////////////////////////////////////////////
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+ INT << "===[START]==========================================" << endl;
+ --argc;
+ ++argv;
+ KeyRingSignalsReceive r;
+
+ filesystem::unlink("/Local/ma/GPG/repos.d/newgpgkey.repo");
+
+ if ( true )
+ {
+ RepoManager repoManager( makeRepoManager( sysRoot ) );
+ RepoInfo nrepo;
+ nrepo
+ .setAlias( "newgpgkey" )
+ .setName( "Test Repo with new gpg key" )
+ .setEnabled( true )
+ .setAutorefresh( false )
+ .addBaseUrl( Url("dir:///schnell/CD-ARCHIVE/11.0/GM/DVD/i386/DVD1") );
+
+ repoManager.addRepository( nrepo );
+ SEC << "refreshMetadat" << endl;
+ repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
+ SEC << "buildCache" << endl;
+ repoManager.buildCache( nrepo );
+ SEC << "------" << endl;
+ }
+
+ ltrusted();
+
+ if ( 1 )
+ {
+ //zypp::base::LogControl::TmpLineWriter shutUp;
+ getZYpp()->initTarget( sysRoot );
+ }
+
+ ltrusted();
+
+ INT << "===[DONE]===========================================" << endl;
+ zypp::base::LogControl::TmpLineWriter shutUp;
+ return 0;
+}
+
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main2( int argc, char * argv[] )
+{
+ INT << "===[START]==========================================" << endl;
+ --argc;
+ ++argv;
+ KeyRingSignalsReceive r;
+
+
+ KeyRing_Ptr p( getZYpp()->keyRing() );
+
+ //PublicKey ka("/Local/ma/GPG/all-keys/build-9c800aca-40d8063e.asc");
+ PublicKey kb("/Local/ma/GPG/all-keys/build-9c800aca-481f343a.asc");
+
+ SEC << "============================================" << endl;
+ ltrusted();
+ //p->importKey( ka, true );
+ //ltrusted();
+ p->importKey( kb, true );
+ ltrusted();
+
+ SEC << "============================================" << endl;
+
+ if ( 1 )
+ {
+ zypp::base::LogControl::TmpLineWriter shutUp;
+ getZYpp()->initTarget( sysRoot );
+ }
+
+
+
+ INT << "===[DONE]===========================================" << endl;
+ zypp::base::LogControl::TmpLineWriter shutUp;
+ return 0;
+}
+
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/Tools.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/Tools.h?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/Tools.h (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/devel/devel.ma/Tools.h Thu Jun 26 15:32:36 2008
@@ -109,7 +109,7 @@
RepoManagerOptions mgropt;
mgropt.repoCachePath = mgrdir_r/"cache";
mgropt.repoRawCachePath = mgrdir_r/"raw_cache";
- mgropt.knownReposPath = mgrdir_r;
+ mgropt.knownReposPath = mgrdir_r/"repos.d";
return RepoManager( mgropt );
}
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/package/libzypp.changes?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/package/libzypp.changes (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/package/libzypp.changes Thu Jun 26 15:32:36 2008
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Thu Jun 26 15:31:24 CEST 2008 - ma@suse.de
+
+- Import newer gpg keys if a trusted key is updated
+ (bnc#393160)
+- version 3.27.0
+- revision 10473
+
+-------------------------------------------------------------------
Wed Feb 20 18:15:11 CET 2008 - dmacvicar@suse.de
- Fetcher::reset() should not reset cache directories.
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/zypp/KeyRing.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/zypp/KeyRing.cc?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/zypp/KeyRing.cc (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/zypp/KeyRing.cc Thu Jun 26 15:32:36 2008
@@ -316,6 +316,19 @@
{
PublicKey key = exportKey( id, trustedKeyRing() );
+ // lets look if there is an updated key in the
+ // general keyring
+ if ( publicKeyExists( id, generalKeyRing() ) )
+ {
+ PublicKey untkey = exportKey( id, generalKeyRing() );
+ if ( untkey.created() > key.created() )
+ {
+ MIL << "Key " << key << " was updated. Saving new version into trusted keyring." << endl;
+ importKey( untkey, true );
+ key = untkey;
+ }
+ }
+
MIL << "Key " << id << " " << key.name() << " is trusted" << endl;
// it exists, is trusted, does it validates?
if ( verifyFile( file, signature, trustedKeyRing() ) )
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.cc?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.cc (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.cc Thu Jun 26 15:32:36 2008
@@ -10,22 +10,25 @@
*
*/
#include <iostream>
-//#include "zypp/base/Logger.h"
+#include <vector>
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
#include "zypp/base/String.h"
-#include "zypp/base/Regex.h"
-#include "zypp/PublicKey.h"
+
#include "zypp/ExternalProgram.h"
+#include "zypp/PublicKey.h"
#include "zypp/TmpPath.h"
#include "zypp/PathInfo.h"
-#include "zypp/base/Exception.h"
-#include "zypp/base/Logger.h"
+#include "zypp/Date.h"
+
+//#include <ctime>
using std::endl;
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
+{ /////////////////////////////////////////////////////////////////
//
// CLASS NAME : PublicKey::Impl
//
@@ -40,7 +43,7 @@
readFromFile(file);
MIL << "Done reading key" << std::endl;
}
-
+
public:
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
@@ -49,53 +52,54 @@
return _nullimpl;
}
-
std::string asString() const
{
- return "[" + id() + "] [" + name() + "] [" + fingerprint() + "]";
+ return "[" + id() + "-" + str::hexstring(created(),8).substr(2) + "] [" + name() + "] [" + fingerprint() + "]";
}
-
+
std::string armoredData() const
{ return _data; }
-
+
std::string id() const
{ return _id; }
-
+
std::string name() const
{ return _name; }
-
+
std::string fingerprint() const
{ return _fingerprint; }
-
+
+ Date created() const
+ { return _created; }
+
+ Date expires() const
+ { return _expires; }
+
Pathname path() const
- {
+ {
return _data_file.path();
//return _data_file;
}
-
+
protected:
-
+
void readFromFile( const Pathname &keyfile)
{
- static str::regex rxColons("^([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):\n$");
-
+
PathInfo info(keyfile);
- MIL << "Reading pubkey from " << keyfile << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyfile, "sha1")<< endl;
+ MIL << "Reading pubkey from " << keyfile << " of size " << info.size() << " and sha1 " << filesystem::checksum(keyfile, "sha1")<< endl;
if ( !info.isExist() )
ZYPP_THROW(Exception("Can't read public key from " + keyfile.asString() + ", file not found"));
-
+
if ( copy( keyfile, _data_file.path() ) != 0 )
ZYPP_THROW(Exception("Can't copy public key data from " + keyfile.asString() + " to " + _data_file.path().asString() ));
-
- filesystem::TmpDir dir;
-
const char* argv[] =
{
"gpg",
+ "-v",
"--no-default-keyring",
- "--homedir",
- dir.path().asString().c_str(),
+ "--fixed-list-mode",
"--with-fingerprint",
"--with-colons",
"--quiet",
@@ -107,45 +111,85 @@
_data_file.path().asString().c_str(),
NULL
};
-
+
ExternalProgram prog(argv,ExternalProgram::Discard_Stderr, false, -1, true);
-
+
std::string line;
- int count = 0;
-
- // pub:-:1024:17:A84EDAE89C800ACA:2000-10-19:2008-06-21::-:SuSE Package Signing Key :
-
- for(line = prog.receiveLine(), count=0; !line.empty(); line = prog.receiveLine(), count++ )
+ bool sawpub = false;
+ bool sawsig = false;
+
+ // pub:-:1024:17:A84EDAE89C800ACA:971961473:1214043198::-:SuSE Package Signing Key :
+ // fpr:::::::::79C179B2E1C820C1890F9994A84EDAE89C800ACA:
+ // sig:::17:A84EDAE89C800ACA:1087899198:::::[selfsig]::13x:
+ // sig:::17:9E40E310000AABA4:980442706::::[User ID not found]:10x:
+ // sig:::1:77B2E6003D25D3D9:980443247::::[User ID not found]:10x:
+ // sub:-:2048:16:197448E88495160C:971961490:1214043258::: [expires: 2008-06-21]
+ // sig:::17:A84EDAE89C800ACA:1087899258:::::[keybind]::18x:
+
+ for ( line = prog.receiveLine(); !line.empty(); line = prog.receiveLine() )
{
- //MIL << "[" << line << "]" << std::endl;
- str::smatch what;
- if(str::regex_match(line, what, rxColons))
+ // trim trailing NL.
+ if ( line.empty() )
+ continue;
+ if ( line[line.size()-1] == '\n' )
+ line.erase( line.size()-1 );
+
+ // split at ':'
+ std::vectorstd::string words;
+ str::splitFields( line, std::back_inserter(words), ":" );
+ if( words.empty() )
+ continue;
+
+ if ( words[0] == "pub" )
{
- if ( what[1] == "pub" )
- {
- _id = what[5];
- _name = what[10];
- //return key;
- }
- else if ( what[1] == "fpr" )
- {
- _fingerprint = what[10];
- }
- //dumpRegexpResults(what);
+ if ( sawpub )
+ continue;
+ sawpub = true;
+ // take default from pub
+ _id = words[4];
+ _name = words[9];
+ _created = Date(str::strtonumDate::ValueType(words[5]));
+ _expires = Date(str::strtonumDate::ValueType(words[6]));
+
+ }
+ else if ( words[0] == "sig" )
+ {
+ if ( sawsig || words[words.size()-2] != "13x" )
+ continue;
+ sawsig = true;
+ // update creation and expire dates from 1st signature type "13x"
+ if ( ! words[5].empty() )
+ _created = Date(str::strtonumDate::ValueType(words[5]));
+ if ( ! words[6].empty() )
+ _expires = Date(str::strtonumDate::ValueType(words[6]));
+ }
+ else if ( words[0] == "fpr" )
+ {
+ _fingerprint = words[9];
+ }
+ else if ( words[0] == "uid" )
+ {
+ if ( ! words[9].empty() )
+ _name = words[9];
}
}
prog.close();
-
- if (_id.size() == 0 )
- ZYPP_THROW(BadKeyException("File " + keyfile.asString() + " doesn't contain public key data" , keyfile));
+
+ if ( _id.size() == 0 )
+ ZYPP_THROW( BadKeyException( "File " + keyfile.asString() + " doesn't contain public key data" , keyfile ) );
+
+ //replace all escaped semicolon with real ':'
+ str::replace_all( _name, "\\x3a", ":" );
}
-
+
private:
std::string _id;
std::string _name;
std::string _fingerprint;
std::string _data;
filesystem::TmpFile _data_file;
+ Date _created;
+ Date _expires;
//Pathname _data_file;
private:
friend Impl * rwcowClone<Impl>( const Impl * rhs );
@@ -166,7 +210,9 @@
PublicKey::PublicKey( const Pathname &file )
: _pimpl( new Impl(file) )
- {}
+ {
+ MIL << *this << endl;
+ }
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : PublicKey::~PublicKey
@@ -185,32 +231,51 @@
{
return _pimpl->asString();
}
-
+
std::string PublicKey::armoredData() const
{ return _pimpl->armoredData(); }
-
+
std::string PublicKey::id() const
{ return _pimpl->id(); }
-
+
std::string PublicKey::name() const
{ return _pimpl->name(); }
-
+
std::string PublicKey::fingerprint() const
{ return _pimpl->fingerprint(); }
-
+
+ Date PublicKey::created() const
+ { return _pimpl->created(); }
+
+ Date PublicKey::expires() const
+ { return _pimpl->expires(); }
+
Pathname PublicKey::path() const
{ return _pimpl->path(); }
bool PublicKey::operator==( PublicKey b ) const
{
- return (b.id() == id()) && (b.fingerprint() == fingerprint() );
+ return( b.id() == id()
+ && b.fingerprint() == fingerprint()
+ && b.created() == created() );
}
-
+
bool PublicKey::operator==( std::string sid ) const
{
return sid == id();
}
-
+
+ std::ostream & dumpOn( std::ostream & str, const PublicKey & obj )
+ {
+ str << "[" << obj.name() << "]" << endl;
+ str << " fpr " << obj.fingerprint() << endl;
+ str << " id " << obj.id() << endl;
+ str << " cre " << obj.created() << endl;
+ str << " exp " << obj.expires() << endl;
+ str << "]";
+ return str;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.h?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.h (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/zypp/PublicKey.h Thu Jun 26 15:32:36 2008
@@ -25,7 +25,7 @@
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
-
+
/**
* Exception thrown when the supplied key is
* not a valid gpg key
@@ -39,10 +39,10 @@
BadKeyException()
: Exception( "Bad Key Exception" )
{}
-
+
Pathname keyFile() const
{ return _keyfile; }
-
+
/** Ctor taking message.
* Use \ref ZYPP_THROW to throw exceptions.
*/
@@ -54,13 +54,16 @@
private:
Pathname _keyfile;
};
-
-
+
+
+ // forward declaration of class Date
+ class Date;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PublicKey
//
- /**
+ /**
* Class that represent a GPG Public Key
*/
class PublicKey
@@ -73,26 +76,38 @@
public:
PublicKey();
- /** Ctor
+ /** Ctor
* \throws when data does not make a key
*/
PublicKey(const Pathname &file);
-
+
~PublicKey();
-
+
bool isValid() const
{ return ( ! id().empty() && ! fingerprint().empty() && !path().empty() ); }
-
+
std::string asString() const;
std::string armoredData() const;
std::string id() const;
std::string name() const;
std::string fingerprint() const;
- Pathname path() const;
-
+
+ /**
+ * Date when the key was created (time is 00:00:00)
+ */
+ Date created() const;
+
+ /**
+ * Date when the key expires (time is 00:00:00)
+ * If the key never expires the date is Date() (i.e. 0 seconds since the epoch (1.1.1970))
+ */
+ Date expires() const;
+
+ Pathname path() const;
+
bool operator==( PublicKey b ) const;
bool operator==( std::string sid ) const;
-
+
private:
/** Pointer to implementation */
RWCOW_pointer<Impl> _pimpl;
@@ -103,7 +118,10 @@
inline std::ostream & operator<<( std::ostream & str, const PublicKey & obj )
{ return str << obj.asString(); }
- /////////////////////////////////////////////////////////////////
+ /** \relates PublicKey Detailed stream output */
+ std::ostream & dumpOn( std::ostream & str, const PublicKey & obj );
+
+ /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_PUBLICKEY_H
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/zypp/base/String.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/zypp/base/String.h?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/zypp/base/String.h (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/zypp/base/String.h Thu Jun 26 15:32:36 2008
@@ -229,6 +229,23 @@
inline bool strToBool( const std::string & str, bool default_r )
{ return( default_r ? strToFalse( str ) : strToTrue( str ) ); }
//@}
+ ///////////////////////////////////////////////////////////////////
+
+ /**
+ * Looks for text in string and replaces it in place
+ *
+ * \note It only performs substtution in one pass
+ */
+ inline std::string & replace_all( std::string & str, const std::string & from, const std::string & to )
+ {
+ std::string::size_type pos = 0;
+ while( pos < str.length() && (pos = str.find( from, pos )) != std::string::npos )
+ {
+ str.replace( pos, from.size(), to );
+ pos += to.size();
+ }
+ return str;
+ }
///////////////////////////////////////////////////////////////////
/** \name Split. */
@@ -266,6 +283,57 @@
}
return ret;
}
+
+ /** Split \a line_r into fields.
+ * Any single character in \a sepchars_r is treated as a
+ * field separator. The words are passed to OutputIterator
+ * \a result_r.
+ * \code
+ * "" -> words 0
+ * ":" -> words 2 |||
+ * "a" -> words 1 |a|
+ * ":a" -> words 2 ||a|
+ * "a:" -> words 2 |a||
+ * ":a:" -> words 3 ||a||
+ *
+ * \endcode
+ *
+ * \code
+ * std::vectorstd::string words;
+ * str::split( "some line", std::back_inserter(words) )
+ * \endcode
+ *
+ */
+ template<class _OutputIterator>
+ unsigned splitFields( const std::string & line_r,
+ _OutputIterator result_r,
+ const std::string & sepchars_r = ":" )
+ {
+ const char * beg = line_r.c_str();
+ const char * cur = beg;
+ unsigned ret = 0;
+ for ( beg = cur; *beg; beg = cur, ++result_r )
+ {
+ // skip non sepchars
+ while( *cur && !::strchr( sepchars_r.c_str(), *cur ) )
+ ++cur;
+ // build string
+ *result_r = std::string( beg, cur-beg );
+ ++ret;
+ // skip sepchar
+ if ( *cur )
+ {
+ ++cur;
+ if ( ! *cur ) // ending with sepchar
+ {
+ *result_r = std::string(); // add final empty field
+ ++ret;
+ break;
+ }
+ }
+ }
+ return ret;
+ }
//@}
///////////////////////////////////////////////////////////////////
Modified: branches/SuSE-Linux-10_3-Branch/libzypp/zypp/target/rpm/RpmDb.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-10_3-Branch/libzypp/zypp/target/rpm/RpmDb.cc?rev=10473&r1=10472&r2=10473&view=diff
==============================================================================
--- branches/SuSE-Linux-10_3-Branch/libzypp/zypp/target/rpm/RpmDb.cc (original)
+++ branches/SuSE-Linux-10_3-Branch/libzypp/zypp/target/rpm/RpmDb.cc Thu Jun 26 15:32:36 2008
@@ -909,7 +909,7 @@
// now import the key in rpm
try
{
- importPubkey((*it).path());
+ importPubkey(*it);
MIL << "Trusted key " << (*it).id() << " (" << (*it).name() << ") imported in rpm database." << std::endl;
}
catch (RpmException &e)
@@ -989,20 +989,33 @@
// check if the key is already in the rpm database and just
// return if it does.
set<Edition> rpm_keys = pubkeyEditions();
+ string keyshortid = pubkey_r.id().substr(8,8);
+ MIL << "Comparing '" << keyshortid << "' to: ";
for ( set<Edition>::const_iterator it = rpm_keys.begin(); it != rpm_keys.end(); ++it)
{
string id = str::toUpper( (*it).version() );
- string keyshortid = pubkey_r.id().substr(8,8);
- MIL << "Comparing '" << id << "' to '" << keyshortid << "'" << endl;
+ MIL << ", '" << id << "'";
if ( id == keyshortid )
{
// they match id
- // FIXME id is not sufficient?
- MIL << "Key " << pubkey_r << " is already in the rpm trusted keyring." << endl;
- return;
+ // now check if timestamp is different
+ Date date = Date(str::strtonumDate::ValueType("0x" + (*it).release()));
+ if ( date == pubkey_r.created() )
+ {
+
+ MIL << endl << "Key " << pubkey_r << " is already in the rpm trusted keyring." << endl;
+ return;
+ }
+ else
+ {
+ MIL << endl << "Key " << pubkey_r << " has another version in keyring. ( " << date << " & " << pubkey_r.created() << ")" << endl;
+
+ }
+
}
}
- // key does not exists, lets import it
+ // key does not exists, lets import it
+ MIL << endl;
RpmArgVec opts;
opts.push_back ( "--import" );
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org