aboutsummaryrefslogtreecommitdiffstats
path: root/tools/card-call-scd.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-04-03 08:27:08 +0000
committerWerner Koch <[email protected]>2019-04-03 08:27:08 +0000
commitbcca3acb87c36213fef9311236ea949d006f759c (patch)
tree56764c6a28d5fdd9c7730409dc0712848e90d46c /tools/card-call-scd.c
parentgpg: Print modern style key info for non-decryptable keys. (diff)
downloadgnupg-bcca3acb87c36213fef9311236ea949d006f759c.tar.gz
gnupg-bcca3acb87c36213fef9311236ea949d006f759c.zip
card: Allow card selection with LIST.
* tools/card-call-scd.c (start_agent): Request serialno only whean started. (scd_serialno): Allow NULL for r_serialno. * tools/gpg-card.c (cmd_factoryreset): Use changed scd_serialno. (cmd_list): New. (dispatch_command): Use cmd_list for cmdLIST. (interactive_loop): Ditto. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/card-call-scd.c')
-rw-r--r--tools/card-call-scd.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c
index 0a01bf5ca..c2580bf5c 100644
--- a/tools/card-call-scd.c
+++ b/tools/card-call-scd.c
@@ -310,11 +310,13 @@ static gpg_error_t
start_agent (unsigned int flags)
{
gpg_error_t err;
+ int started = 0;
if (agent_ctx)
err = 0;
else
{
+ started = 1;
err = start_new_gpg_agent (&agent_ctx,
GPG_ERR_SOURCE_DEFAULT,
opt.agent_program,
@@ -347,7 +349,7 @@ start_agent (unsigned int flags)
}
}
- if (!err && !(flags & START_AGENT_NO_STARTUP_CMDS))
+ if (started && !err && !(flags & START_AGENT_NO_STARTUP_CMDS))
{
/* Request the serial number of the card for an early test. */
struct card_info_s info;
@@ -990,7 +992,7 @@ learn_status_cb (void *opaque, const char *line)
/* Call the scdaemon to learn about a smartcard. This fills INFO
- * wioth data from the card. */
+ * with data from the card. */
gpg_error_t
scd_learn (card_info_t info)
{
@@ -1268,7 +1270,7 @@ scd_genkey (const char *keyref, int force, const char *algo, u32 *createtime)
/* Return the serial number of the card or an appropriate error. The
* serial number is returned as a hexstring. If DEMAND is not NULL
- * the reader with the a card of the serilanumber DEMAND is
+ * the reader with the a card of the serial number DEMAND is
* requested. */
gpg_error_t
scd_serialno (char **r_serialno, const char *demand)
@@ -1295,7 +1297,10 @@ scd_serialno (char **r_serialno, const char *demand)
return err;
}
- *r_serialno = serialno;
+ if (r_serialno)
+ *r_serialno = serialno;
+ else
+ xfree (serialno);
return 0;
}