aboutsummaryrefslogtreecommitdiffstats
path: root/agent/call-pinentry.c
diff options
context:
space:
mode:
authorNeal H. Walfield <[email protected]>2015-05-19 12:58:04 +0000
committerNeal H. Walfield <[email protected]>2015-05-19 13:01:00 +0000
commite201c20f25e7bed29088186c5f717d43047a0f4b (patch)
tree97b72a92dd749593c311dadbb896d9310261a9eb /agent/call-pinentry.c
parentg10: detects public key encryption packet error properly. (diff)
downloadgnupg-e201c20f25e7bed29088186c5f717d43047a0f4b.tar.gz
gnupg-e201c20f25e7bed29088186c5f717d43047a0f4b.zip
agent: Modify agent_clear_passphrase to support an ext. password cache.
* agent/agent.h (agent_get_passphrase): Add arguments keyinfo and cache_mode. Update callers. * agent/call-pinentry.c (agent_get_passphrase): Add arguments keyinfo and cache_mode. If KEYINFO and CACHE_MODE describe a cachable key, then send SETKEYINFO to the pinentry. -- Signed-off-by: Neal H. Walfield <[email protected]>
Diffstat (limited to 'agent/call-pinentry.c')
-rw-r--r--agent/call-pinentry.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
index 5c3743aa4..abfea93e0 100644
--- a/agent/call-pinentry.c
+++ b/agent/call-pinentry.c
@@ -1015,7 +1015,8 @@ agent_askpin (ctrl_t ctrl,
int
agent_get_passphrase (ctrl_t ctrl,
char **retpass, const char *desc, const char *prompt,
- const char *errtext, int with_qualitybar)
+ const char *errtext, int with_qualitybar,
+ const char *keyinfo, cache_mode_t cache_mode)
{
int rc;
@@ -1060,6 +1061,26 @@ agent_get_passphrase (ctrl_t ctrl,
prompt = desc && strstr (desc, "PIN")? "PIN": _("Passphrase");
+ /* If we have a KEYINFO string and are normal, user, or ssh cache
+ mode, we tell that the Pinentry so it may use it for own caching
+ purposes. Most pinentries won't have this implemented and thus
+ we do not error out in this case. */
+ if (keyinfo && (cache_mode == CACHE_MODE_NORMAL
+ || cache_mode == CACHE_MODE_USER
+ || cache_mode == CACHE_MODE_SSH))
+ snprintf (line, DIM(line)-1, "SETKEYINFO %c/%s",
+ cache_mode == CACHE_MODE_USER? 'u' :
+ cache_mode == CACHE_MODE_SSH? 's' : 'n',
+ keyinfo);
+ else
+ snprintf (line, DIM(line)-1, "SETKEYINFO --clear");
+
+ rc = assuan_transact (entry_ctx, line,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ if (rc && gpg_err_code (rc) != GPG_ERR_ASS_UNKNOWN_CMD)
+ return unlock_pinentry (rc);
+
+
if (desc)
snprintf (line, DIM(line)-1, "SETDESC %s", desc);
else