Author: jkupec Date: Thu Sep 25 00:17:27 2008 New Revision: 11156 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11156&view=rev Log: - adapt to libzypp's keyring changes (bnc #366467) Modified: trunk/zypper/src/callbacks/keyring.h trunk/zypper/src/zypp-refresh.cc trunk/zypper/zypper.spec.cmake Modified: trunk/zypper/src/callbacks/keyring.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/callbacks/keyring.h?rev=11156&r1=11155&r2=11156&view=diff ============================================================================== --- trunk/zypper/src/callbacks/keyring.h (original) +++ trunk/zypper/src/callbacks/keyring.h Thu Sep 25 00:17:27 2008 @@ -31,7 +31,8 @@ { KeyRingReceive() : _gopts(Zypper::instance()->globalOpts()) {} - virtual bool askUserToAcceptUnsignedFile( const std::string &file ) + virtual bool askUserToAcceptUnsignedFile( + const std::string & file, const KeyContext & context) { if (_gopts.no_gpg_checks) { @@ -48,7 +49,8 @@ return read_bool_answer(PROMPT_YN_GPG_UNSIGNED_FILE_ACCEPT, question, false); } - virtual bool askUserToImportKey( const PublicKey &key ) +/* virtual bool askUserToImportKey( + const PublicKey &key, const KeyContext & context) { //this is because only root have access to rpm db where is keys stored if ( geteuid() != 0 && !_gopts.changedRoot) @@ -58,8 +60,11 @@ _("Import key %s to trusted keyring?")) % key.id()); return read_bool_answer(PROMPT_YN_GPG_KEY_IMPORT_TRUSTED, question, false); } - - virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id ) +*/ + virtual bool askUserToAcceptUnknownKey( + const std::string & file, + const std::string & id, + const zypp::KeyContext & context) { if (_gopts.no_gpg_checks) { @@ -76,28 +81,53 @@ return read_bool_answer(PROMPT_YN_GPG_UNKNOWN_KEY_ACCEPT, question, false); } - virtual bool askUserToTrustKey( const PublicKey &key ) + virtual KeyRingReport::KeyTrust askUserToAcceptKey( + const PublicKey &key, const zypp::KeyContext & context) { - const std::string& keyid = key.id(), keyname = key.name(), + Zypper & zypper = *Zypper::instance(); + + const std::string & keyid = key.id(), keyname = key.name(), fingerprint = key.fingerprint(); if (_gopts.no_gpg_checks) { MIL << boost::format("Automatically trusting key id %s, %s, fingerprint %s") % keyid % keyname % fingerprint << std::endl; - Zypper::instance()->out().info(boost::str(boost::format( + zypper.out().info(boost::str(boost::format( _("Automatically trusting key id %s, %s, fingerprint %s")) % keyid % keyname % fingerprint)); - return true; + return KeyRingReport::KEY_TRUST_TEMPORARILY; } std::string question = boost::str(boost::format( _("Do you want to trust key id %s, %s, fingerprint %s")) % keyid % keyname % fingerprint); - return read_bool_answer(PROMPT_YN_GPG_KEY_TRUST, question, false); + + PromptOptions popts; + popts.setOptions(_("t/i/n"), 2); + popts.setOptionHelp(0, _("Trust the key temporarily, do not import it.")); + popts.setOptionHelp(1, _("Trust the key and import it into RPM keyring.")); + popts.setOptionHelp(2, _("Don't trust the key.")); + + zypper.out().prompt(PROMPT_YN_GPG_KEY_TRUST, question, popts); + unsigned prep = + get_prompt_reply(zypper, PROMPT_YN_GPG_KEY_TRUST, popts); + switch (prep) + { + case 0: + return KeyRingReport::KEY_TRUST_TEMPORARILY; + case 1: + return KeyRingReport::KEY_TRUST_AND_IMPORT; + default: + return KeyRingReport::KEY_DONT_TRUST; + } + return KeyRingReport::KEY_DONT_TRUST; } - virtual bool askUserToAcceptVerificationFailed( const std::string &file,const PublicKey &key ) + virtual bool askUserToAcceptVerificationFailed( + const std::string & file, + const PublicKey & key, + const zypp::KeyContext & context ) { const std::string& keyid = key.id(), keyname = key.name(), fingerprint = key.fingerprint(); Modified: trunk/zypper/src/zypp-refresh.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypp-refresh.cc?rev=11156&r1=11155&r2=11156&view=diff ============================================================================== --- trunk/zypper/src/zypp-refresh.cc (original) +++ trunk/zypper/src/zypp-refresh.cc Thu Sep 25 00:17:27 2008 @@ -46,13 +46,13 @@ /////////////////////////////////////////////////////////////////// struct KeyRingReceive : public zypp::callback::ReceiveReportzypp::KeyRingReport { - virtual bool askUserToAcceptUnsignedFile( const std::string &file ) + virtual bool askUserToAcceptUnsignedFile( const std::string &file, const KeyContext & context ) { cerr << ". Error:" << endl << "refusing unsigned file " << file << endl; return readCallbackAnswer(); } - virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id ) + virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id, const KeyContext & context ) { cerr << ". Error:" << endl << "refusing unknown key, id: '" << id << "' from file '" << file << "'" << endl; return readCallbackAnswer(); } - virtual bool askUserToTrustKey( const PublicKey &key ) - { cerr << ". Error:" << endl << "not trusting key '" << key << "'" << endl;return readCallbackAnswer(); } - virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key ) + virtual KeyRingReport::KeyTrust askUserToAcceptKey( const PublicKey &key, const KeyContext & context ) + { cerr << ". Error:" << endl << "not trusting key '" << key << "'" << endl; return KeyRingReport::KEY_DONT_TRUST; } + virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key, const KeyContext & context ) { cerr << ". Error:" << endl << "verification of '" << file << "' with key '" << key << "' failed" << endl; return readCallbackAnswer(); } }; Modified: trunk/zypper/zypper.spec.cmake URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/zypper.spec.cmake?rev=11156&r1=11155&r2=11156&view=diff ============================================================================== --- trunk/zypper/zypper.spec.cmake (original) +++ trunk/zypper/zypper.spec.cmake Thu Sep 25 00:17:27 2008 @@ -11,7 +11,7 @@ # norootforbuild Name: @PACKAGE@ -BuildRequires: libzypp-devel >= 5.10.0 boost-devel >= 1.33.1 gettext-devel >= 0.15 readline-devel >= 5.1 +BuildRequires: libzypp-devel >= 5.12.0 boost-devel >= 1.33.1 gettext-devel >= 0.15 readline-devel >= 5.1 BuildRequires: gcc-c++ >= 4.1 cmake >= 2.4.6 Requires: procps Recommends: logrotate cron -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org