mirror of
git://git.gnupg.org/gnupg.git
synced 2024-06-03 22:48:03 +02:00
scd: Enhance PASSWD command to accept KEYGRIP optionally.
* scd/command.c (cmd_passwd): Handle KEYGRIP optionally. -- GnuPG-bug-id: 5862 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
d577ed2956
commit
934864d399
|
@ -1620,7 +1620,7 @@ cmd_random (assuan_context_t ctx, char *line)
|
||||||
|
|
||||||
|
|
||||||
static const char hlp_passwd[] =
|
static const char hlp_passwd[] =
|
||||||
"PASSWD [--reset] [--nullpin] [--clear] <chvno>\n"
|
"PASSWD [--reset] [--nullpin] [--clear] <chvno> [<keygrip>]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Change the PIN or, if --reset is given, reset the retry counter of\n"
|
"Change the PIN or, if --reset is given, reset the retry counter of\n"
|
||||||
"the card holder verification vector CHVNO. The option --nullpin is\n"
|
"the card holder verification vector CHVNO. The option --nullpin is\n"
|
||||||
|
@ -1635,6 +1635,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
|
||||||
char *chvnostr;
|
char *chvnostr;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
card_t card;
|
card_t card;
|
||||||
|
const char *keygrip = NULL;
|
||||||
|
|
||||||
if (has_option (line, "--reset"))
|
if (has_option (line, "--reset"))
|
||||||
flags |= APP_CHANGE_FLAG_RESET;
|
flags |= APP_CHANGE_FLAG_RESET;
|
||||||
|
@ -1650,7 +1651,11 @@ cmd_passwd (assuan_context_t ctx, char *line)
|
||||||
chvnostr = line;
|
chvnostr = line;
|
||||||
while (*line && !spacep (line))
|
while (*line && !spacep (line))
|
||||||
line++;
|
line++;
|
||||||
*line = 0;
|
if (*line)
|
||||||
|
*line++ = 0;
|
||||||
|
|
||||||
|
if (strlen (line) == 40)
|
||||||
|
keygrip = line;
|
||||||
|
|
||||||
/* Do not allow other flags aside of --clear. */
|
/* Do not allow other flags aside of --clear. */
|
||||||
if ((flags & APP_CHANGE_FLAG_CLEAR) && (flags & ~APP_CHANGE_FLAG_CLEAR))
|
if ((flags & APP_CHANGE_FLAG_CLEAR) && (flags & ~APP_CHANGE_FLAG_CLEAR))
|
||||||
|
@ -1660,7 +1665,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
|
||||||
if ((rc = open_card (ctrl)))
|
if ((rc = open_card (ctrl)))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
card = card_get (ctrl, NULL);
|
card = card_get (ctrl, keygrip);
|
||||||
if (!card)
|
if (!card)
|
||||||
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
|
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user