diff options
author | NIIBE Yutaka <[email protected]> | 2015-04-03 08:39:59 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2015-04-03 08:39:59 +0000 |
commit | f82c4a6d0d76e716b6a7b22ca964fa2da1f962a0 (patch) | |
tree | 4a2ff1ab9e04bc630126719fce01d097308028e3 /g10/keyedit.c | |
parent | agent: Add --force option for LEARN. (diff) | |
download | gnupg-f82c4a6d0d76e716b6a7b22ca964fa2da1f962a0.tar.gz gnupg-f82c4a6d0d76e716b6a7b22ca964fa2da1f962a0.zip |
g10: Fix keytocard.
g10/call-agent.h (agent_scd_learn): Add FORCE option.
g10/call-agent.c (agent_scd_learn): Implement FORCE option.
g10/keygen.c (gen_card_key): Follow the change of option.
g10/card-util.c (change_pin, card_status, factory_reset): Likewise.
g10/keyedit.c (keyedit_menu): Update private key storage by
agent_scd_learn.
--
This is not a perfect solution since there is a possibility user
unplug card before quitting 'gpg --keyedit' session. Usually,
it works well.
GnuPG-bug-id: 1846
Diffstat (limited to 'g10/keyedit.c')
-rw-r--r-- | g10/keyedit.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/g10/keyedit.c b/g10/keyedit.c index 91f5dae56..2f9469f17 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -1450,6 +1450,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, char *answer = NULL; int redisplay = 1; int modified = 0; + int sec_shadowing = 0; int run_subkey_warnings = 0; int toggle; int have_commands = !!commands; @@ -1836,8 +1837,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, if (card_store_subkey (node, xxpk ? xxpk->pubkey_usage : 0)) { redisplay = 1; - /* Only the secret key has been modified; thus - there is no need to set the modified flag. */ + sec_shadowing = 1; } } } @@ -1923,7 +1923,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, if (card_store_subkey (node, 0)) { redisplay = 1; - /* FIXME:sec_modified = 1;*/ + sec_shadowing = 1; } } release_kbnode (node); @@ -2182,7 +2182,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, case cmdQUIT: if (have_commands) goto leave; - if (!modified) + if (!modified && !sec_shadowing) goto leave; if (!cpr_get_answer_is_yes ("keyedit.save.okay", _("Save changes? (y/N) "))) @@ -2204,7 +2204,18 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, break; } } - else + + if (sec_shadowing) + { + err = agent_scd_learn (NULL, 1); + if (err) + { + log_error (_("update failed: %s\n"), gpg_strerror (err)); + break; + } + } + + if (!modified && !sec_shadowing) tty_printf (_("Key not changed so no update needed.\n")); if (update_trust) |