diff options
author | NIIBE Yutaka <[email protected]> | 2022-03-10 02:11:38 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2022-03-10 02:11:38 +0000 |
commit | 934864d399bb6091d55a15811eee7ed6e5391fb6 (patch) | |
tree | 0f87d6b94c8c09717ab598f029396b0cd956f839 /scd/command.c | |
parent | scd: Use same idiom for same work. (diff) | |
download | gnupg-934864d399bb6091d55a15811eee7ed6e5391fb6.tar.gz gnupg-934864d399bb6091d55a15811eee7ed6e5391fb6.zip |
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 <[email protected]>
Diffstat (limited to 'scd/command.c')
-rw-r--r-- | scd/command.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/scd/command.c b/scd/command.c index b4f662924..5c0a06b93 100644 --- a/scd/command.c +++ b/scd/command.c @@ -1620,7 +1620,7 @@ cmd_random (assuan_context_t ctx, char *line) static const char hlp_passwd[] = - "PASSWD [--reset] [--nullpin] [--clear] <chvno>\n" + "PASSWD [--reset] [--nullpin] [--clear] <chvno> [<keygrip>]\n" "\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" @@ -1635,6 +1635,7 @@ cmd_passwd (assuan_context_t ctx, char *line) char *chvnostr; unsigned int flags = 0; card_t card; + const char *keygrip = NULL; if (has_option (line, "--reset")) flags |= APP_CHANGE_FLAG_RESET; @@ -1650,7 +1651,11 @@ cmd_passwd (assuan_context_t ctx, char *line) chvnostr = line; while (*line && !spacep (line)) line++; - *line = 0; + if (*line) + *line++ = 0; + + if (strlen (line) == 40) + keygrip = line; /* Do not allow other flags aside of --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))) return rc; - card = card_get (ctrl, NULL); + card = card_get (ctrl, keygrip); if (!card) return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION); |