mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
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 <neal@g10code.com>
This commit is contained in:
parent
c771963140
commit
e201c20f25
@ -366,7 +366,8 @@ int agent_askpin (ctrl_t ctrl,
|
||||
const char *keyinfo, cache_mode_t cache_mode);
|
||||
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 agent_get_confirmation (ctrl_t ctrl, const char *desc, const char *ok,
|
||||
const char *notokay, int with_cancel);
|
||||
int agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn);
|
||||
|
@ -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
|
||||
|
@ -1519,7 +1519,7 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
|
||||
next_try:
|
||||
rc = agent_get_passphrase (ctrl, &response, desc, prompt,
|
||||
repeat_errtext? repeat_errtext:errtext,
|
||||
opt_qualbar);
|
||||
opt_qualbar, cacheid, CACHE_MODE_USER);
|
||||
xfree (repeat_errtext);
|
||||
repeat_errtext = NULL;
|
||||
if (!rc)
|
||||
@ -1536,7 +1536,8 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
|
||||
char *response2;
|
||||
|
||||
rc = agent_get_passphrase (ctrl, &response2, desc2, prompt,
|
||||
errtext, 0);
|
||||
errtext, 0,
|
||||
cacheid, CACHE_MODE_USER);
|
||||
if (rc)
|
||||
break;
|
||||
if (strcmp (response2, response))
|
||||
|
Loading…
x
Reference in New Issue
Block a user