1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-04-17 15:44:34 +02:00

gpg: Allow "help" as value for --tofu-policy.

* g10/gpg.c (parse_tofu_policy): Add keyword "help".
(parse_tofu_db_format): Ditto.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-12-03 16:19:35 +01:00
parent 218a52787a
commit 59f6192cb7
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -1968,26 +1968,37 @@ parse_trust_model(const char *model)
} }
#endif /*NO_TRUST_MODELS*/ #endif /*NO_TRUST_MODELS*/
static int static int
parse_tofu_policy (const char *policy) parse_tofu_policy (const char *policystr)
{ {
#ifdef USE_TOFU #ifdef USE_TOFU
if (ascii_strcasecmp (policy, "auto") == 0) struct { const char *keyword; int policy; } list[] = {
return TOFU_POLICY_AUTO; { "auto", TOFU_POLICY_AUTO },
else if (ascii_strcasecmp (policy, "good") == 0) { "good", TOFU_POLICY_GOOD },
return TOFU_POLICY_GOOD; { "unknown", TOFU_POLICY_UNKNOWN },
else if (ascii_strcasecmp (policy, "unknown") == 0) { "bad", TOFU_POLICY_BAD },
return TOFU_POLICY_UNKNOWN; { "ask", TOFU_POLICY_ASK }
else if (ascii_strcasecmp (policy, "bad") == 0) };
return TOFU_POLICY_BAD; int i;
else if (ascii_strcasecmp (policy, "ask") == 0)
return TOFU_POLICY_ASK; if (!ascii_strcasecmp (policystr, "help"))
else
#endif /*USE_TOFU*/
{ {
log_error (_("unknown TOFU policy '%s'\n"), policy); log_info (_("available TOFU policies:\n"));
for (i=0; i < DIM (list); i++)
log_info (" %s\n", list[i].keyword);
g10_exit (1); g10_exit (1);
} }
for (i=0; i < DIM (list); i++)
if (!ascii_strcasecmp (policystr, list[i].keyword))
return list[i].policy;
#endif /*USE_TOFU*/
log_error (_("unknown TOFU policy '%s'\n"), policystr);
if (!opt.quiet)
log_info (_("(use \"help\" to list choices)\n"));
g10_exit (1);
} }
static int static int
@ -2000,10 +2011,17 @@ parse_tofu_db_format (const char *db_format)
return TOFU_DB_SPLIT; return TOFU_DB_SPLIT;
else if (ascii_strcasecmp (db_format, "flat") == 0) else if (ascii_strcasecmp (db_format, "flat") == 0)
return TOFU_DB_FLAT; return TOFU_DB_FLAT;
else if (ascii_strcasecmp (db_format, "help") == 0)
{
log_info ("available TOFU DB fomats: auto, split, flat\n");
g10_exit (1);
}
else else
#endif /*USE_TOFU*/ #endif /*USE_TOFU*/
{ {
log_error (_("unknown TOFU DB format '%s'\n"), db_format); log_error (_("unknown TOFU DB format '%s'\n"), db_format);
if (!opt.quiet)
log_info (_("(use \"help\" to list choices)\n"));
g10_exit (1); g10_exit (1);
} }
} }
@ -4727,7 +4745,7 @@ main (int argc, char **argv)
KEYDB_HANDLE hd; KEYDB_HANDLE hd;
if (argc < 2) if (argc < 2)
wrong_args("--tofu-policy POLICY KEYID [KEYID...]"); wrong_args ("--tofu-policy POLICY KEYID [KEYID...]");
policy = parse_tofu_policy (argv[0]); policy = parse_tofu_policy (argv[0]);