aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2005-07-19 12:14:39 +0000
committerWerner Koch <[email protected]>2005-07-19 12:14:39 +0000
commita0b4f403018fc1fb54286174467f52fdf0426bf1 (patch)
tree691b98eaf69d9e2e56045711cdae199d2a369094
parent* configure.ac [W32]: Always set DISABLE_KEYSERVER_PATH. (diff)
downloadgnupg-a0b4f403018fc1fb54286174467f52fdf0426bf1.tar.gz
gnupg-a0b4f403018fc1fb54286174467f52fdf0426bf1.zip
* g10.c, options.h: New option --limit-card-insert-tries.
* cardglue.c (open_card): Use it.
Diffstat (limited to '')
-rw-r--r--g10/ChangeLog3
-rw-r--r--g10/cardglue.c6
-rw-r--r--g10/g10.c9
-rw-r--r--g10/options.h2
4 files changed, 18 insertions, 2 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 241a04115..f2275364d 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,5 +1,8 @@
2005-07-19 Werner Koch <[email protected]>
+ * g10.c, options.h: New option --limit-card-insert-tries.
+ * cardglue.c (open_card): Use it.
+
* export.c (parse_export_options): New option
export-reset-subkey-passwd.
(do_export_stream): Implement it.
diff --git a/g10/cardglue.c b/g10/cardglue.c
index f9fba6806..0e2da279c 100644
--- a/g10/cardglue.c
+++ b/g10/cardglue.c
@@ -385,6 +385,7 @@ open_card (void)
int rc;
app_t app;
int did_shutdown = 0;
+ int retry_count = 0;
/* First check whether we can contact a gpg-agent and divert all
operation to it. This is required because gpg as well as the
@@ -421,7 +422,10 @@ open_card (void)
app = xcalloc (1, sizeof *app);
app->slot = slot;
rc = app_select_openpgp (app);
- if (rc && !opt.batch)
+ if (opt.limit_card_insert_tries
+ && ++retry_count >= opt.limit_card_insert_tries)
+ ;
+ else if (rc && !opt.batch)
{
write_status_text (STATUS_CARDCTRL, "1");
diff --git a/g10/g10.c b/g10/g10.c
index 626ee8786..a0e698c53 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -347,6 +347,7 @@ enum cmd_and_opt_values
oMultifile,
oKeyidFormat,
oNoInteractiveSelection,
+ oLimitCardInsertTries,
oReaderPort,
octapiDriver,
@@ -677,6 +678,7 @@ static ARGPARSE_OPTS opts[] = {
{ oMultifile, "multifile", 0, "@" },
{ oKeyidFormat, "keyid-format", 2, "@" },
{ oNoInteractiveSelection, "no-interactive-selection", 0, "@" },
+ { oLimitCardInsertTries, "limit-card-insert-tries", 1, "@"},
{ oReaderPort, "reader-port", 2, "@"},
{ octapiDriver, "ctapi-driver", 2, "@"},
@@ -1583,7 +1585,7 @@ parse_trust_model(const char *model)
}
int
-main( int argc, char **argv )
+main (int argc, char **argv )
{
ARGPARSE_ARGS pargs;
IOBUF a;
@@ -2546,6 +2548,11 @@ main( int argc, char **argv )
case oNoInteractiveSelection:
opt.no_interactive_selection = 1;
break;
+
+ case oLimitCardInsertTries:
+ opt.limit_card_insert_tries = pargs.r.ret_int;
+ break;
+
case oNoop: break;
diff --git a/g10/options.h b/g10/options.h
index 05741a937..45744e57b 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -195,6 +195,8 @@ struct
byte *show_subpackets;
int rfc2440_text;
+ int limit_card_insert_tries; /* If > 0, limit the number of card
+ insertion prompts to this value. */
#ifdef ENABLE_CARD_SUPPORT
const char *ctapi_driver; /* Library to access the ctAPI. */
const char *pcsc_driver; /* Library to access the PC/SC system. */