[Pkg-gnupg-commit] [gnupg2] 72/159: g10: Use --force when importing key for bkuptocard.

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 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.
---
 g10/call-agent.c | 5 +++--
 g10/call-agent.h | 4 ++--
 g10/import.c     | 8 ++++----
 g10/keyedit.c    | 2 +-
 g10/main.h       | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)

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

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