mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-19 09:02:22 +02:00
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.
This commit is contained in:
parent
44aee35e69
commit
5ca57f1a69
@ -2216,7 +2216,7 @@ inq_import_key_parms (void *opaque, const char *line)
|
|||||||
/* Call the agent to import a key into the agent. */
|
/* Call the agent to import a key into the agent. */
|
||||||
gpg_error_t
|
gpg_error_t
|
||||||
agent_import_key (ctrl_t ctrl, const char *desc, char **cache_nonce_addr,
|
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;
|
gpg_error_t err;
|
||||||
struct import_key_parm_s parm;
|
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.key = key;
|
||||||
parm.keylen = keylen;
|
parm.keylen = keylen;
|
||||||
|
|
||||||
snprintf (line, sizeof line, "IMPORT_KEY%s%s%s",
|
snprintf (line, sizeof line, "IMPORT_KEY%s%s%s%s",
|
||||||
unattended? " --unattended":"",
|
unattended? " --unattended":"",
|
||||||
|
force? " --force":"",
|
||||||
cache_nonce_addr && *cache_nonce_addr? " ":"",
|
cache_nonce_addr && *cache_nonce_addr? " ":"",
|
||||||
cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"");
|
cache_nonce_addr && *cache_nonce_addr? *cache_nonce_addr:"");
|
||||||
cn_parm.cache_nonce_addr = cache_nonce_addr;
|
cn_parm.cache_nonce_addr = cache_nonce_addr;
|
||||||
|
@ -186,8 +186,8 @@ gpg_error_t agent_keywrap_key (ctrl_t ctrl, int forexport,
|
|||||||
|
|
||||||
/* Send a key to the agent. */
|
/* Send a key to the agent. */
|
||||||
gpg_error_t agent_import_key (ctrl_t ctrl, const char *desc,
|
gpg_error_t agent_import_key (ctrl_t ctrl, const char *desc,
|
||||||
char **cache_nonce_addr,
|
char **cache_nonce_addr, const void *key,
|
||||||
const void *key, size_t keylen, int unattended);
|
size_t keylen, int unattended, int force);
|
||||||
|
|
||||||
/* Receive a key from the agent. */
|
/* Receive a key from the agent. */
|
||||||
gpg_error_t agent_export_key (ctrl_t ctrl, const char *keygrip,
|
gpg_error_t agent_export_key (ctrl_t ctrl, const char *keygrip,
|
||||||
|
@ -1319,8 +1319,8 @@ import_one (ctrl_t ctrl,
|
|||||||
true the secret keys are stored by gpg-agent in the transfer format
|
true the secret keys are stored by gpg-agent in the transfer format
|
||||||
(i.e. no re-protection and aksing for passphrases). */
|
(i.e. no re-protection and aksing for passphrases). */
|
||||||
gpg_error_t
|
gpg_error_t
|
||||||
transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats, kbnode_t sec_keyblock,
|
transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats,
|
||||||
int batch)
|
kbnode_t sec_keyblock, int batch, int force)
|
||||||
{
|
{
|
||||||
gpg_error_t err = 0;
|
gpg_error_t err = 0;
|
||||||
void *kek = NULL;
|
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);
|
char *desc = gpg_format_keydesc (pk, FORMAT_KEYDESC_IMPORT, 1);
|
||||||
err = agent_import_key (ctrl, desc, &cache_nonce,
|
err = agent_import_key (ctrl, desc, &cache_nonce,
|
||||||
wrappedkey, wrappedkeylen, batch);
|
wrappedkey, wrappedkeylen, batch, force);
|
||||||
xfree (desc);
|
xfree (desc);
|
||||||
}
|
}
|
||||||
if (!err)
|
if (!err)
|
||||||
@ -1783,7 +1783,7 @@ import_secret_one (ctrl_t ctrl, const char *fname, kbnode_t keyblock,
|
|||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
|
|
||||||
nr_prev = stats->secret_imported;
|
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)
|
if (gpg_err_code (err) == GPG_ERR_NOT_PROCESSED)
|
||||||
{
|
{
|
||||||
/* TRANSLATORS: For smartcard, each private key on
|
/* TRANSLATORS: For smartcard, each private key on
|
||||||
|
@ -1981,7 +1981,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
|
|||||||
node = new_kbnode (pkt);
|
node = new_kbnode (pkt);
|
||||||
|
|
||||||
/* Transfer it to gpg-agent which handles secret keys. */
|
/* 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. */
|
/* Treat the pkt as a public key. */
|
||||||
pkt->pkttype = PKT_PUBLIC_KEY;
|
pkt->pkttype = PKT_PUBLIC_KEY;
|
||||||
|
@ -338,7 +338,7 @@ import_stats_t import_new_stats_handle (void);
|
|||||||
void import_release_stats_handle (import_stats_t hd);
|
void import_release_stats_handle (import_stats_t hd);
|
||||||
void import_print_stats (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,
|
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 );
|
int collapse_uids( KBNODE *keyblock );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user