From 9a27004822e826243e3792b5c68396f03f11631e Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Wed, 19 Apr 2006 14:32:58 +0000 Subject: [PATCH] add fingerprint to callbacks --- zypp/KeyRing.cc | 23 ++++++++++++++--------- zypp/KeyRing.h | 10 +++++----- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/zypp/KeyRing.cc b/zypp/KeyRing.cc index 05ab874..2a46e2c 100644 --- a/zypp/KeyRing.cc +++ b/zypp/KeyRing.cc @@ -21,6 +21,7 @@ #include "zypp/base/Logger.h" #include "zypp/base/IOStream.h" #include "zypp/base/String.h" +#include "zypp/Pathname.h" #include "zypp/KeyRing.h" #include "zypp/ExternalProgram.h" #include "zypp/TmpPath.h" @@ -65,13 +66,13 @@ namespace zypp bool KeyRingReport::askUserToAcceptUnsignedFile( const Pathname &file ) { return _keyRingDefaultAccept; } - bool KeyRingReport::askUserToAcceptUnknownKey( const Pathname &file, const std::string &keyid, const std::string &keyname ) + bool KeyRingReport::askUserToAcceptUnknownKey( const Pathname &file, const std::string &keyid, const std::string &keyname, const std::string &fingerprint ) { return _keyRingDefaultAccept; } - bool KeyRingReport::askUserToTrustKey( const std::string &keyid, const std::string &keyname, const std::string &keydetails ) + bool KeyRingReport::askUserToTrustKey( const std::string &keyid, const std::string &keyname, const std::string &fingerprint ) { return _keyRingDefaultAccept; } - bool KeyRingReport::askUserToAcceptVerificationFailed( const Pathname &file, const std::string &keyid, const std::string &keyname ) + bool KeyRingReport::askUserToAcceptVerificationFailed( const Pathname &file, const std::string &keyid, const std::string &keyname, const std::string &fingerprint ) { return _keyRingDefaultAccept; } /////////////////////////////////////////////////////////////////// @@ -262,7 +263,7 @@ namespace zypp if ( verifyFile( file, signature, _trusted_kr ) ) return true; else - return report->askUserToAcceptVerificationFailed( file, key.id, key.name ); + return report->askUserToAcceptVerificationFailed( file, key.id, key.name, key.fingerprint ); } else { @@ -276,13 +277,13 @@ namespace zypp MIL << "Key " << id << " " << key.name << " is not trusted" << std::endl; // ok the key is not trusted, ask the user to trust it or not #warning We need the key details passed to the callback - if ( report->askUserToTrustKey(key.id, key.name, "") ) + if ( report->askUserToTrustKey(key.id, key.name, key.fingerprint) ) { MIL << "User wants to trust key " << id << " " << key.name << std::endl; //dumpFile(unKey.path()); importKey( unKey.path(), _trusted_kr ); - emitSignal->trustedKeyAdded( (const KeyRing &)(*this), id, key.name ); + emitSignal->trustedKeyAdded( (const KeyRing &)(*this), id, key.name, key.fingerprint ); // emit key added if ( verifyFile( file, signature, _trusted_kr ) ) @@ -293,7 +294,7 @@ namespace zypp else { MIL << "File signature check fails" << std::endl; - if ( report->askUserToAcceptVerificationFailed( file, key.id, key.name ) ) + if ( report->askUserToAcceptVerificationFailed( file, key.id, key.name, key.fingerprint ) ) { MIL << "User continues anyway." << std::endl; return true; @@ -314,7 +315,7 @@ namespace zypp else { // unknown key... - if ( report->askUserToAcceptUnknownKey( file, id, "Unknown Key" ) ) + if ( report->askUserToAcceptUnknownKey( file, id, "Unknown Key", "No fingerprint" ) ) { MIL << "User wants to accept unknown key " << id << std::endl; return true; @@ -367,7 +368,11 @@ namespace zypp { key.id = what[5]; key.name = what[10]; - return key; + //return key; + } + else if ( what[1] == "fpr" ) + { + key.fingerprint = what[10]; } //dumpRegexpResults(what); } diff --git a/zypp/KeyRing.h b/zypp/KeyRing.h index d56893f..fec11ac 100644 --- a/zypp/KeyRing.h +++ b/zypp/KeyRing.h @@ -32,16 +32,16 @@ namespace zypp struct KeyRingReport : public callback::ReportBase { virtual bool askUserToAcceptUnsignedFile( const Pathname &file ); - virtual bool askUserToAcceptUnknownKey( const Pathname &file, const std::string &keyid, const std::string &keyname ); - virtual bool askUserToTrustKey( const std::string &keyid, const std::string &keyname, const std::string &keydetails ); - virtual bool askUserToAcceptVerificationFailed( const Pathname &file, const std::string &keyid, const std::string &keyname ); + virtual bool askUserToAcceptUnknownKey( const Pathname &file, const std::string &keyid, const std::string &keyname, const std::string &fingerprint ); + virtual bool askUserToTrustKey( const std::string &keyid, const std::string &keyname, const std::string &fingerprint); + virtual bool askUserToAcceptVerificationFailed( const Pathname &file, const std::string &keyid, const std::string &keyname, const std::string &fingerprint ); }; struct KeyRingSignals : public callback::ReportBase { - virtual void trustedKeyAdded( const KeyRing &keyring, const std::string &keyid, const std::string &keyname ) + virtual void trustedKeyAdded( const KeyRing &keyring, const std::string &keyid, const std::string &keyname, const std::string &fingerprint ) {} - virtual void trustedKeyRemoved( const KeyRing &keyring, const std::string &keyid, const std::string &keyname ) + virtual void trustedKeyRemoved( const KeyRing &keyring, const std::string &keyid, const std::string &keyname, const std::string &fingerprint ) {} }; -- 2.7.4