summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2015-12-24 06:15:58 +0100
committerNIIBE Yutaka <gniibe@fsij.org>2015-12-24 06:15:58 +0100
commit5ca57f1a697e875bae5a5c73f1a580c42ca75343 (patch)
tree2640f8cfb96b8f500d0eae7438c03ffcb0f05178
parentg10: Remove subcommand checkbkupkey for --key-edit. (diff)
downloadgnupg2-5ca57f1a697e875bae5a5c73f1a580c42ca75343.tar.xz
gnupg2-5ca57f1a697e875bae5a5c73f1a580c42ca75343.zip
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.
Diffstat (limited to '')
-rw-r--r--g10/call-agent.c5
-rw-r--r--g10/call-agent.h4
-rw-r--r--g10/import.c8
-rw-r--r--g10/keyedit.c2
-rw-r--r--g10/main.h2
5 files changed, 11 insertions, 10 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 8eb16e411..26de72e31 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 fa1b88a29..208b75b2d 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 27bfece34..d35b5d590 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 0553208c3..a30305870 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 06f2577ec..06821722a 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 );