ref: refs/heads/master commit 6b20f2642424416724c474ea6586122109f3f2d2 Author: Ján Kupec <jkupec@suse.cz> Date: Tue Nov 10 18:52:59 2009 +0100 --gpg-auto-import-keys global option added (fate #307087) --- src/Zypper.cc | 16 ++++++++++++++++ src/Zypper.h | 2 ++ src/callbacks/keyring.h | 25 ++++++++++++++++++------- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Zypper.cc b/src/Zypper.cc index f32bc8a..9504025 100644 --- a/src/Zypper.cc +++ b/src/Zypper.cc @@ -176,8 +176,14 @@ void print_main_help(Zypper & zypper) "\t--no-refresh\t\tDo not refresh the repositories.\n" )) + string(_( // translators: these belong to Repository Options main help text + // \todo merge into the main string for 11.3 "\t--no-cd\t\t\tIgnore CD/DVD repositories.\n" "\t--no-remote\t\tIgnore remote repositories.\n" + )) + string(_( + // translators: these belong to Repository Options main help text + // \todo merge into the main string for 11.3 + "\t--gpg-auto-import-keys\tAutomatically trust and import new repository\n" + "\t\t\t\tsigning keys.\n" )); static string help_global_target_options = _(" Target Options:\n" @@ -324,6 +330,7 @@ void Zypper::processGlobalOptions() {"rug-compatible", no_argument, 0, 'r'}, {"non-interactive", no_argument, 0, 'n'}, {"no-gpg-checks", no_argument, 0, 0 }, + {"gpg-auto-import-keys", no_argument, 0, 0 }, {"root", required_argument, 0, 'R'}, {"reposd-dir", required_argument, 0, 'D'}, {"cache-dir", required_argument, 0, 'C'}, @@ -462,6 +469,15 @@ void Zypper::processGlobalOptions() MIL << "Entering no-gpg-checks mode" << endl; } + if (gopts.count("gpg-auto-import-keys")) { + _gopts.gpg_auto_import_keys = true; + string warn = str::form( + _("Turning on '%s'. New repository signing keys will be automatically imported!"), + "--gpg-auto-import-keys"); + out().warning(warn, Out::HIGH); + MIL << "gpg-auto-import-keys is on" << endl; + } + if ((it = gopts.find("root")) != gopts.end()) { _gopts.root_dir = it->second.front(); _gopts.changedRoot = true; diff --git a/src/Zypper.h b/src/Zypper.h index c6b7d36..39d361d 100644 --- a/src/Zypper.h +++ b/src/Zypper.h @@ -45,6 +45,7 @@ struct GlobalOptions is_rug_compatible(false), non_interactive(false), no_gpg_checks(false), + gpg_auto_import_keys(false), machine_readable(false), no_refresh(false), no_cd(false), @@ -73,6 +74,7 @@ struct GlobalOptions bool is_rug_compatible; bool non_interactive; bool no_gpg_checks; + bool gpg_auto_import_keys; bool machine_readable; /** Whether to disable autorefresh. */ bool no_refresh; diff --git a/src/callbacks/keyring.h b/src/callbacks/keyring.h index e67567c..fb2118d 100644 --- a/src/callbacks/keyring.h +++ b/src/callbacks/keyring.h @@ -121,7 +121,9 @@ namespace zypp const std::string & keyid = key.id(), keyname = key.name(), fingerprint = key.fingerprint(); - if (_gopts.no_gpg_checks) + if (_gopts.gpg_auto_import_keys) + s << _("Automatically importing the following key:") << std::endl; + else if (_gopts.no_gpg_checks) s << _("Automatically trusting the following key:") << std::endl; else s << _("New repository or package signing key received:") << std::endl; @@ -135,13 +137,22 @@ namespace zypp s << str::form(_("Repository: %s"), context.repoInfo().name().c_str()) << std::endl; - // print info and dont ask + // print info and don't ask if (_gopts.no_gpg_checks) { - MIL << boost::format("Automatically trusting key id '%s', '%s', fingerprint '%s'") - % keyid % keyname % fingerprint << std::endl; zypper.out().info(s.str()); - return KeyRingReport::KEY_TRUST_TEMPORARILY; + if (_gopts.gpg_auto_import_keys) + { + MIL << boost::format("Automatically importing key id '%s', '%s', fingerprint '%s'") + % keyid % keyname % fingerprint << std::endl; + return KeyRingReport::KEY_TRUST_AND_IMPORT; + } + else + { + MIL << boost::format("Automatically trusting key id '%s', '%s', fingerprint '%s'") + % keyid % keyname % fingerprint << std::endl; + return KeyRingReport::KEY_TRUST_TEMPORARILY; + } } // ask the user @@ -159,10 +170,10 @@ namespace zypp // The anserws must be separated by slash characters '/' and must // correspond to reject/trusttemporarily/trustalways in that order. // The answers should be lower case letters. - popts.setOptions(_("r/t/a/"), 0); + popts.setOptions(_("r/t/a/"), _gopts.gpg_auto_import_keys ? 2 : 0); else // translators: the same as r/t/a, but without 'a' - popts.setOptions(_("r/t"), 0); + popts.setOptions(_("r/t"), _gopts.gpg_auto_import_keys ? 1 : 0); // translators: help text for the 'r' option in the 'r/t/a' prompt popts.setOptionHelp(0, _("Don't trust the key.")); // translators: help text for the 't' option in the 'r/t/a' prompt -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org