[git] GnuPG - branch, master, updated. gnupg-2.1.10-73-g79b51bb

by NIIBE Yutaka cvs at cvs.gnupg.org
Thu Dec 24 06:23:43 CET 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  79b51bb8727bd3485229ac8ff5987558156d5d83 (commit)
       via  5ca57f1a697e875bae5a5c73f1a580c42ca75343 (commit)
      from  44aee35e69540510617aea4b886ef845590960fe (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
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.

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);

commit 5ca57f1a697e875bae5a5c73f1a580c42ca75343
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Thu Dec 24 14:15:58 2015 +0900

    g10: Use --force when importing key for bkuptocard.
    
    * g10/call-agent.c (agent_import_key): Add an argument FORCE.
    * g10/import.c (transfer_secret_keys): Likewise.
    (import_secret_one): Call transfer_secret_keys with FORCE=0.
    * g10/keyedit.c (keyedit_menu): Call with FORCE=1.

diff --git a/g10/call-agent.c b/g10/call-agent.c
index 8eb16e4..26de72e 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -2216,7 +2216,7 @@ inq_import_key_parms (void *opaque, const char *line)
 /* Call the agent to import a key into the agent.  */
 gpg_error_t
 agent_import_key (ctrl_t ctrl, const char *desc, char **cache_nonce_addr,
-                  const void *key, size_t keylen, int unattended)
+                  const void *key, size_t keylen, int unattended, int force)
 {
   gpg_error_t err;
   struct import_key_parm_s parm;
@@ -2246,8 +2246,9 @@ agent_import_key (ctrl_t ctrl, const char *desc, char **cache_nonce_addr,
   parm.key    = key;
   parm.keylen = keylen;
 
-  snprintf (line, sizeof line, "IMPORT_KEY%s%s%s",
+  snprintf (line, sizeof line, "IMPORT_KEY%s%s%s%s",
             unattended? " --unattended":"",
+            force? " --force":"",
             cache_nonce_addr && *cache_nonce_addr? " ":"",
             cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"");
   cn_parm.cache_nonce_addr = cache_nonce_addr;
diff --git a/g10/call-agent.h b/g10/call-agent.h
index fa1b88a..208b75b 100644
--- a/g10/call-agent.h
+++ b/g10/call-agent.h
@@ -186,8 +186,8 @@ gpg_error_t agent_keywrap_key (ctrl_t ctrl, int forexport,
 
 /* Send a key to the agent.  */
 gpg_error_t agent_import_key (ctrl_t ctrl, const char *desc,
-                              char **cache_nonce_addr,
-                              const void *key, size_t keylen, int unattended);
+                              char **cache_nonce_addr, const void *key,
+                              size_t keylen, int unattended, int force);
 
 /* Receive a key from the agent.  */
 gpg_error_t agent_export_key (ctrl_t ctrl, const char *keygrip,
diff --git a/g10/import.c b/g10/import.c
index 27bfece..d35b5d5 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -1319,8 +1319,8 @@ import_one (ctrl_t ctrl,
    true the secret keys are stored by gpg-agent in the transfer format
    (i.e. no re-protection and aksing for passphrases). */
 gpg_error_t
-transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats, kbnode_t sec_keyblock,
-                      int batch)
+transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats,
+                      kbnode_t sec_keyblock, int batch, int force)
 {
   gpg_error_t err = 0;
   void *kek = NULL;
@@ -1556,7 +1556,7 @@ transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats, kbnode_t sec_ke
       {
         char *desc = gpg_format_keydesc (pk, FORMAT_KEYDESC_IMPORT, 1);
         err = agent_import_key (ctrl, desc, &cache_nonce,
-                                wrappedkey, wrappedkeylen, batch);
+                                wrappedkey, wrappedkeylen, batch, force);
         xfree (desc);
       }
       if (!err)
@@ -1783,7 +1783,7 @@ import_secret_one (ctrl_t ctrl, const char *fname, kbnode_t keyblock,
               gpg_error_t err;
 
 	      nr_prev = stats->secret_imported;
-              err = transfer_secret_keys (ctrl, stats, keyblock, batch);
+              err = transfer_secret_keys (ctrl, stats, keyblock, batch, 0);
               if (gpg_err_code (err) == GPG_ERR_NOT_PROCESSED)
                 {
                   /* TRANSLATORS: For smartcard, each private key on
diff --git a/g10/keyedit.c b/g10/keyedit.c
index 0553208..a303058 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -1981,7 +1981,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
 	    node = new_kbnode (pkt);
 
             /* Transfer it to gpg-agent which handles secret keys.  */
-            err = transfer_secret_keys (ctrl, NULL, node, 1);
+            err = transfer_secret_keys (ctrl, NULL, node, 1, 1);
 
             /* Treat the pkt as a public key.  */
             pkt->pkttype = PKT_PUBLIC_KEY;
diff --git a/g10/main.h b/g10/main.h
index 06f2577..0682172 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -338,7 +338,7 @@ import_stats_t import_new_stats_handle (void);
 void import_release_stats_handle (import_stats_t hd);
 void import_print_stats (import_stats_t hd);
 gpg_error_t transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats,
-                                  kbnode_t sec_keyblock, int batch);
+                                  kbnode_t sec_keyblock, int batch, int force);
 
 int collapse_uids( KBNODE *keyblock );
 

-----------------------------------------------------------------------

Summary of changes:
 agent/command.c     |  2 +-
 agent/cvt-openpgp.c | 10 +++++-----
 agent/cvt-openpgp.h |  1 +
 g10/call-agent.c    |  5 +++--
 g10/call-agent.h    |  4 ++--
 g10/import.c        |  8 ++++----
 g10/keyedit.c       |  2 +-
 g10/main.h          |  2 +-
 8 files changed, 18 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list