[Pkg-gnupg-commit] [gnupg2] 73/159: agent: IMPORT_KEY with --force option fix.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Jan 27 13:23:55 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 79b51bb8727bd3485229ac8ff5987558156d5d83
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Thu Dec 24 14:19:53 2015 +0900

    agent: IMPORT_KEY with --force option fix.
    
    * agent/cvt-openpgp.c (convert_from_openpgp_main): Add an option not
    to check existing key.
    (convert_from_openpgp): Ditto.
    (convert_from_openpgp_native): Call convert_from_openpgp_main with
    dontcare_exist=0.
    * agent/command.c (cmd_import_key): Call with dontcare_exist=force.
---
 agent/command.c     |  2 +-
 agent/cvt-openpgp.c | 10 +++++-----
 agent/cvt-openpgp.h |  1 +
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/agent/command.c b/agent/command.c
index 446cf24..718a5e6 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -2151,7 +2151,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
 
       xfree (key);
       key = NULL;
-      err = convert_from_openpgp (ctrl, openpgp_sexp, grip,
+      err = convert_from_openpgp (ctrl, openpgp_sexp, force, grip,
                                   ctrl->server_local->keydesc, cache_nonce,
                                   &key, opt_unattended? NULL : &passphrase);
       if (err)
diff --git a/agent/cvt-openpgp.c b/agent/cvt-openpgp.c
index 0b9ecf0..8df6b8e 100644
--- a/agent/cvt-openpgp.c
+++ b/agent/cvt-openpgp.c
@@ -685,7 +685,7 @@ try_do_unprotect_cb (struct pin_entry_info_s *pi)
    silently decrypt the key; CACHE_NONCE and R_PASSPHRASE must both be
    NULL in this mode.  */
 static gpg_error_t
-convert_from_openpgp_main (ctrl_t ctrl, gcry_sexp_t s_pgp,
+convert_from_openpgp_main (ctrl_t ctrl, gcry_sexp_t s_pgp, int dontcare_exist,
                            unsigned char *grip, const char *prompt,
                            const char *cache_nonce, const char *passphrase,
                            unsigned char **r_key, char **r_passphrase)
@@ -894,7 +894,7 @@ convert_from_openpgp_main (ctrl_t ctrl, gcry_sexp_t s_pgp,
   if (err)
     goto leave;
 
-  if (!from_native && !agent_key_available (grip))
+  if (!dontcare_exist && !from_native && !agent_key_available (grip))
     {
       err = gpg_error (GPG_ERR_EEXIST);
       goto leave;
@@ -1028,12 +1028,12 @@ convert_from_openpgp_main (ctrl_t ctrl, gcry_sexp_t s_pgp,
    the key.  The keygrip will be stored at the 20 byte buffer pointed
    to by GRIP.  On error NULL is stored at all return arguments.  */
 gpg_error_t
-convert_from_openpgp (ctrl_t ctrl, gcry_sexp_t s_pgp,
+convert_from_openpgp (ctrl_t ctrl, gcry_sexp_t s_pgp, int dontcare_exist,
                       unsigned char *grip, const char *prompt,
                       const char *cache_nonce,
                       unsigned char **r_key, char **r_passphrase)
 {
-  return convert_from_openpgp_main (ctrl, s_pgp, grip, prompt,
+  return convert_from_openpgp_main (ctrl, s_pgp, dontcare_exist, grip, prompt,
                                     cache_nonce, NULL,
                                     r_key, r_passphrase);
 }
@@ -1052,7 +1052,7 @@ convert_from_openpgp_native (ctrl_t ctrl,
   if (!passphrase)
     return gpg_error (GPG_ERR_INTERNAL);
 
-  err = convert_from_openpgp_main (ctrl, s_pgp, grip, NULL,
+  err = convert_from_openpgp_main (ctrl, s_pgp, 0, grip, NULL,
                                    NULL, passphrase,
                                    r_key, NULL);
 
diff --git a/agent/cvt-openpgp.h b/agent/cvt-openpgp.h
index d27a776..9a4fc3d 100644
--- a/agent/cvt-openpgp.h
+++ b/agent/cvt-openpgp.h
@@ -20,6 +20,7 @@
 #define GNUPG_AGENT_CVT_OPENPGP_H
 
 gpg_error_t convert_from_openpgp (ctrl_t ctrl, gcry_sexp_t s_pgp,
+                                  int dontcare_exist,
                                   unsigned char *grip, const char *prompt,
                                   const char *cache_nonce,
                                   unsigned char **r_key, char **r_passphrase);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list