1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-03 12:11:33 +01:00

agent: For SSH, robustly handling scdaemon's errors.

* agent/command-ssh.c (card_key_list): Return 0 when
agent_card_serialno returns an error.
(ssh_handler_request_identities): Handle errors for card listing
and proceed to other cases.
--

GnuPG-bug-id: 2980

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2017-03-06 10:26:11 +09:00
parent 67c203b6bf
commit 4ce4f2f683

View File

@ -2393,13 +2393,12 @@ card_key_list (ctrl_t ctrl, char **r_serialno, strlist_t *result)
err = agent_card_serialno (ctrl, r_serialno, NULL); err = agent_card_serialno (ctrl, r_serialno, NULL);
if (err) if (err)
{ {
if (gpg_err_code (err) == GPG_ERR_ENODEV) if (gpg_err_code (err) != GPG_ERR_ENODEV && opt.verbose)
return 0; /* Nothing available. */
if (opt.verbose)
log_info (_("error getting serial number of card: %s\n"), log_info (_("error getting serial number of card: %s\n"),
gpg_strerror (err)); gpg_strerror (err));
return err;
/* Nothing available. */
return 0;
} }
err = agent_card_cardlist (ctrl, result); err = agent_card_cardlist (ctrl, result);
@ -2568,7 +2567,6 @@ ssh_handler_request_identities (ctrl_t ctrl,
gpg_error_t err; gpg_error_t err;
int ret; int ret;
ssh_control_file_t cf = NULL; ssh_control_file_t cf = NULL;
char *cardsn;
gpg_error_t ret_err; gpg_error_t ret_err;
(void)request; (void)request;
@ -2601,21 +2599,21 @@ ssh_handler_request_identities (ctrl_t ctrl,
if (opt.verbose) if (opt.verbose)
log_info (_("error getting list of cards: %s\n"), log_info (_("error getting list of cards: %s\n"),
gpg_strerror (err)); gpg_strerror (err));
goto out; goto scd_out;
} }
for (sl = card_list; sl; sl = sl->next) for (sl = card_list; sl; sl = sl->next)
{ {
char *serialno0; char *serialno0;
char *cardsn;
err = agent_card_serialno (ctrl, &serialno0, sl->d); err = agent_card_serialno (ctrl, &serialno0, sl->d);
if (err) if (err)
{ {
if (opt.verbose) if (opt.verbose)
log_info (_("error getting serial number of card: %s\n"), log_info (_("error getting serial number of card: %s\n"),
gpg_strerror (err)); gpg_strerror (err));
xfree (serialno); continue;
free_strlist (card_list);
goto out;
} }
xfree (serialno0); xfree (serialno0);
@ -2640,6 +2638,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
free_strlist (card_list); free_strlist (card_list);
} }
scd_out:
/* Then look at all the registered and non-disabled keys. */ /* Then look at all the registered and non-disabled keys. */
err = open_control_file (&cf, 0); err = open_control_file (&cf, 0);
if (err) if (err)