diff options
author | Neal H. Walfield <[email protected]> | 2015-05-19 13:00:16 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2015-05-19 13:01:01 +0000 |
commit | 3a9305439b75ccd4446378d4fd87da087fd9c892 (patch) | |
tree | 6d34efaf2d68216fbe4e34a7f9a2894dc23e4403 | |
parent | agent: Modify agent_clear_passphrase to support an ext. password cache. (diff) | |
download | gnupg-3a9305439b75ccd4446378d4fd87da087fd9c892.tar.gz gnupg-3a9305439b75ccd4446378d4fd87da087fd9c892.zip |
agent: When the password cache is cleared, also clear the ext. cache.
* agent/agent.h (agent_clear_passphrase): New declaration.
* agent/call-pinentry.c (agent_clear_passphrase): New function.
* agent/command.c (cmd_clear_passphrase): Call agent_clear_passphrase.
--
Signed-off-by: Neal H. Walfield <[email protected]>
-rw-r--r-- | agent/agent.h | 3 | ||||
-rw-r--r-- | agent/call-pinentry.c | 26 | ||||
-rw-r--r-- | agent/command.c | 4 |
3 files changed, 32 insertions, 1 deletions
diff --git a/agent/agent.h b/agent/agent.h index d5d6392a2..dbbf68922 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -374,7 +374,8 @@ int agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn); int agent_popup_message_start (ctrl_t ctrl, const char *desc, const char *ok_btn); void agent_popup_message_stop (ctrl_t ctrl); - +int agent_clear_passphrase (ctrl_t ctrl, + const char *keyinfo, cache_mode_t cache_mode); /*-- cache.c --*/ void initialize_module_cache (void); diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c index abfea93e0..018a609a3 100644 --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -1416,3 +1416,29 @@ agent_popup_message_stop (ctrl_t ctrl) /* Now we can close the connection. */ unlock_pinentry (0); } + +int +agent_clear_passphrase (ctrl_t ctrl, + const char *keyinfo, cache_mode_t cache_mode) +{ + int rc; + char line[ASSUAN_LINELENGTH]; + + if (! (keyinfo && (cache_mode == CACHE_MODE_NORMAL + || cache_mode == CACHE_MODE_USER + || cache_mode == CACHE_MODE_SSH))) + return gpg_error (GPG_ERR_NOT_SUPPORTED); + + rc = start_pinentry (ctrl); + if (rc) + return rc; + + snprintf (line, DIM(line)-1, "CLEARPASSPHRASE %c/%s", + cache_mode == CACHE_MODE_USER? 'u' : + cache_mode == CACHE_MODE_SSH? 's' : 'n', + keyinfo); + rc = assuan_transact (entry_ctx, line, + NULL, NULL, NULL, NULL, NULL, NULL); + + return unlock_pinentry (rc); +} diff --git a/agent/command.c b/agent/command.c index 8ed9a0f76..a5dce44be 100644 --- a/agent/command.c +++ b/agent/command.c @@ -1602,6 +1602,10 @@ cmd_clear_passphrase (assuan_context_t ctx, char *line) agent_put_cache (cacheid, opt_normal ? CACHE_MODE_NORMAL : CACHE_MODE_USER, NULL, 0); + + agent_clear_passphrase (ctrl, cacheid, + opt_normal ? CACHE_MODE_NORMAL : CACHE_MODE_USER); + return 0; } |