1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-22 15:11:41 +02:00

agent: Add --verify to the PASSWD command.

* agent/command.c (cmd_passwd): Add option --verify.
--

GnuPG-bug-id: 1951
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-06-29 12:50:16 +02:00
parent 7a38733164
commit 9bca96dbc5
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -1691,10 +1691,13 @@ cmd_learn (assuan_context_t ctx, char *line)
static const char hlp_passwd[] =
"PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset] <hexkeygrip>\n"
"PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset]\n"
" [--verify] <hexkeygrip>\n"
"\n"
"Change the passphrase/PIN for the key identified by keygrip in LINE. When\n"
"--preset is used then the new passphrase will be added to the cache.\n";
"Change the passphrase/PIN for the key identified by keygrip in LINE. If\n"
"--preset is used then the new passphrase will be added to the cache.\n"
"If --verify is used the command asks for the passphrase and verifies\n"
"that the passphrase valid.\n";
static gpg_error_t
cmd_passwd (assuan_context_t ctx, char *line)
{
@ -1708,13 +1711,14 @@ cmd_passwd (assuan_context_t ctx, char *line)
unsigned char *shadow_info = NULL;
char *passphrase = NULL;
char *pend;
int opt_preset;
int opt_preset, opt_verify;
if (ctrl->restricted)
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
opt_preset = has_option (line, "--preset");
cache_nonce = option_value (line, "--cache-nonce");
opt_verify = has_option (line, "--verify");
if (cache_nonce)
{
for (pend = cache_nonce; *pend && !spacep (pend); pend++)
@ -1753,7 +1757,9 @@ cmd_passwd (assuan_context_t ctx, char *line)
goto leave;
ctrl->in_passwd++;
err = agent_key_from_file (ctrl, cache_nonce, ctrl->server_local->keydesc,
err = agent_key_from_file (ctrl,
opt_verify? NULL : cache_nonce,
ctrl->server_local->keydesc,
grip, &shadow_info, CACHE_MODE_IGNORE, NULL,
&s_skey, &passphrase);
if (err)
@ -1763,6 +1769,10 @@ cmd_passwd (assuan_context_t ctx, char *line)
log_error ("changing a smartcard PIN is not yet supported\n");
err = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
}
else if (opt_verify)
{
/* All done. */
}
else
{
char *newpass = NULL;