aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-08-21 08:19:16 +0000
committerWerner Koch <[email protected]>2019-08-21 12:13:51 +0000
commitc97c2e578dd173ef5e7916a3aa539b3a65a7d86d (patch)
tree23e93484755c055249ad110cd9b15a9fddd8d5cf
parentscd: Fix check_application_conflict. (diff)
downloadgnupg-c97c2e578dd173ef5e7916a3aa539b3a65a7d86d.tar.gz
gnupg-c97c2e578dd173ef5e7916a3aa539b3a65a7d86d.zip
gpg: New option --use-only-openpgp-card
* g10/gpg.c (opts): Add option. (main): Set flag. * g10/options.h: Add flags.use_only_openpgp_card. * g10/call-agent.c (start_agent): Implement option. -- With the previous patch we switch to autoselect an application instead of requesting an openpgp card. This option allows to revert this in case of use use cases which expected the former behaviour. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit c185f6dfbd1bfd809369da789239a371e9d1610e) This was first added to the 2.2 branch.
-rw-r--r--doc/gpg.texi7
-rw-r--r--g10/call-agent.c4
-rw-r--r--g10/gpg.c9
-rw-r--r--g10/options.h3
4 files changed, 22 insertions, 1 deletions
diff --git a/doc/gpg.texi b/doc/gpg.texi
index b01fe246b..212defe0c 100644
--- a/doc/gpg.texi
+++ b/doc/gpg.texi
@@ -3516,6 +3516,13 @@ file and returns with failure if the configuration file would prevent
@command{@gpgname} from startup. Thus it may be used to run a syntax check
on the configuration file.
+@c @item --use-only-openpgp-card
+@c @opindex use-only-openpgp-card
+@c Only access OpenPGP card's and no other cards. This is a hidden
+@c option which could be used in case an old use case required the
+@c OpenPGP card while several cards are avaiable. This option might be
+@c removed if it turns out that nobody requires it.
+
@end table
@c *******************************
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 62568fc76..9e510ae98 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -367,7 +367,9 @@ start_agent (ctrl_t ctrl, int flag_for_card)
if (!(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
rc = warn_version_mismatch (agent_ctx, SCDAEMON_NAME, 2);
if (!rc)
- rc = assuan_transact (agent_ctx, "SCD SERIALNO",
+ rc = assuan_transact (agent_ctx,
+ opt.flags.use_only_openpgp_card?
+ "SCD SERIALNO openpgp" : "SCD SERIALNO",
NULL, NULL, NULL, NULL,
learn_status_cb, &info);
if (rc && !(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
diff --git a/g10/gpg.c b/g10/gpg.c
index 4a94bffc8..8d3898d4e 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -426,6 +426,7 @@ enum cmd_and_opt_values
oKeyOrigin,
oRequestOrigin,
oNoSymkeyCache,
+ oUseOnlyOpenPGPCard,
oNoop
};
@@ -896,6 +897,10 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
ARGPARSE_s_n (oNoSymkeyCache, "no-symkey-cache", "@"),
+ /* Options which can be used in special circumstances. They are not
+ * published and we hope they are never required. */
+ ARGPARSE_s_n (oUseOnlyOpenPGPCard, "use-only-openpgp-card", "@"),
+
/* Dummy options with warnings. */
ARGPARSE_s_n (oUseAgent, "use-agent", "@"),
ARGPARSE_s_n (oNoUseAgent, "no-use-agent", "@"),
@@ -3642,6 +3647,10 @@ main (int argc, char **argv)
opt.def_new_key_algo = pargs.r.ret_str;
break;
+ case oUseOnlyOpenPGPCard:
+ opt.flags.use_only_openpgp_card = 1;
+ break;
+
case oNoop: break;
default:
diff --git a/g10/options.h b/g10/options.h
index 234929b15..5530be4ce 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -251,6 +251,9 @@ struct
unsigned int rfc4880bis:1;
/* Hack: --output is not given but OUTFILE was temporary set to "-". */
unsigned int dummy_outfile:1;
+ /* Force the use of the OpenPGP card and do not allow the use of
+ * another card. */
+ unsigned int use_only_openpgp_card:1;
} flags;
/* Linked list of ways to find a key if the key isn't on the local