summaryrefslogtreecommitdiffstats
path: root/tools/gpgconf-comp.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-03-14 18:53:43 +0100
committerWerner Koch <wk@gnupg.org>2020-03-14 19:12:41 +0100
commit451cd1b3928172b312ca2597c3318e6e9e8be97d (patch)
tree3f8b8aa7052753d26a585e71a5861a35786e5ebc /tools/gpgconf-comp.c
parentgpg: New option --auto-key-import (diff)
downloadgnupg2-451cd1b3928172b312ca2597c3318e6e9e8be97d.tar.xz
gnupg2-451cd1b3928172b312ca2597c3318e6e9e8be97d.zip
gpgconf: Further simplify the gpgconf option processing.
* common/gc-opt-flags.h (GC_OPT_FLAG_RUNTIME): Move to ... * tools/gpgconf-comp.c: here. (known_options_scdaemon): Remove "options". (known_options_dirmngr): Remove "options". (known_options_gpgsm): Remove "options". (known_options_gpg): Remove "options" and "keyserver". (struct gc_option_s): Rename active t gpgconf_list. (gc_component_list_options): Do not act upon active. (option_check_validity): Ditto. (is_known_option): Make it work correctly for unknown options. (retrieve_options_from_program): Use renamed flag gpgconf_list only to detect duplicated items from --gpgconf-list. Do not set runtime. Only e set the options if set by --gpgconf-list; never clear them. * agent/gpg-agent.c: Simplify the --gpgconf-list output. * dirmngr/dirmngr.c: Ditto. * g10/gpg.c: Ditto. * kbx/keyboxd.c: Ditto. * scd/scdaemon.c: Ditto. * sm/gpgsm.c: Ditto. * tests/openpgp/gpgconf.scm: Use "compliance" instead of "keyserver" for the string arg test. -- There is no need to read the list of options from the components unless they convey a default value. It is better to consult only the list we have in gpgconf-comp.c to decide on whether an option should be displayed. Right, this might mess up thing if a newer gpgconf version is used with an older component, but we already print warnings in this case and in general we do not want to support this anymore - the times of gpg 1.4. and 2.0 are long over now. GnuPG-bug-id: 4788 Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tools/gpgconf-comp.c')
-rw-r--r--tools/gpgconf-comp.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 0700bcf1b..1643eb94c 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -278,6 +278,9 @@ static const struct
several times. A comma separated list of arguments is used as the
argument value. */
#define GC_OPT_FLAG_LIST (1UL << 2)
+/* The RUNTIME flag for an option indicates that the option can be
+ changed at runtime. */
+#define GC_OPT_FLAG_RUNTIME (1UL << 3)
/* A human-readable description for each flag. */
@@ -366,8 +369,6 @@ static known_option_t known_options_scdaemon[] =
{ "verbose", GC_OPT_FLAG_LIST|GC_OPT_FLAG_RUNTIME, GC_LEVEL_BASIC },
{ "quiet", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC },
{ "no-greeting", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE },
- { "options", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT,
- GC_ARG_TYPE_FILENAME },
{ "reader-port", GC_OPT_FLAG_RUNTIME, GC_LEVEL_BASIC },
{ "ctapi-driver", GC_OPT_FLAG_RUNTIME, GC_LEVEL_ADVANCED },
{ "pcsc-driver", GC_OPT_FLAG_RUNTIME, GC_LEVEL_ADVANCED },
@@ -395,8 +396,6 @@ static known_option_t known_options_gpg[] =
{ "encrypt-to", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC },
{ "group", GC_OPT_FLAG_LIST, GC_LEVEL_ADVANCED,
GC_ARG_TYPE_ALIAS_LIST},
- { "options", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE,
- GC_ARG_TYPE_FILENAME },
{ "compliance", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT },
{ "default-new-key-algo", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE },
{ "trust-model", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE },
@@ -428,8 +427,6 @@ static known_option_t known_options_gpgsm[] =
{ "no-greeting", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE },
{ "default-key", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC },
{ "encrypt-to", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC },
- { "options", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT,
- GC_ARG_TYPE_FILENAME },
{ "disable-dirmngr", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT },
{ "p12-charset", GC_OPT_FLAG_NONE, GC_LEVEL_ADVANCED },
{ "keyserver", GC_OPT_FLAG_LIST, GC_LEVEL_BASIC,
@@ -462,8 +459,6 @@ static known_option_t known_options_dirmngr[] =
{ "verbose", GC_OPT_FLAG_LIST, GC_LEVEL_BASIC },
{ "quiet", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC },
{ "no-greeting", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE },
- { "options", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT,
- GC_ARG_TYPE_FILENAME },
{ "resolver-timeout", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE },
{ "nameserver", GC_OPT_FLAG_NONE, GC_LEVEL_INVISIBLE },
{ "debug-level", GC_OPT_FLAG_ARG_OPT, GC_LEVEL_ADVANCED },
@@ -516,7 +511,7 @@ struct gc_option_s
unsigned int opt_arg:1; /* The option's argument is optional. */
unsigned int runtime:1; /* The option is runtime changeable. */
- unsigned int active:1; /* Has been announced in gpgconf-list. */
+ unsigned int gpgconf_list:1; /* Mentioned by --gpgconf-list. */
unsigned int has_default:1; /* The option has a default value. */
unsigned int def_in_desc:1; /* The default is in the descrition. */
@@ -1426,7 +1421,7 @@ gc_component_list_options (int component, estream_t out)
{
/* Do not output unknown or internal options. */
if (!option->is_header
- && (!option->active || option->level == GC_LEVEL_INTERNAL))
+ && option->level == GC_LEVEL_INTERNAL)
continue;
if (option->is_header)
@@ -1477,7 +1472,7 @@ is_known_option (gc_component_id_t component, const char *name)
if (!strcmp (option->name, name))
break;
}
- return option;
+ return (option && option->name)? option : NULL;
}
@@ -1669,7 +1664,7 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
* We need to check the code whether both specifications match. */
if ((known_option->flags & GC_OPT_FLAG_ARG_OPT))
opt_info[opt_info_used].opt_arg = 1;
- /* Same here. */
+
if ((known_option->flags & GC_OPT_FLAG_RUNTIME))
opt_info[opt_info_used].runtime = 1;
@@ -1766,18 +1761,20 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
option = find_option (component, line);
if (option)
{
- if (option->active)
+ if (option->gpgconf_list)
gc_error (1, errno,
"option %s returned twice from \"%s --gpgconf-list\"",
line, pgmname);
- option->active = 1;
+ option->gpgconf_list = 1;
- /* Runtime is duplicated - see above. */
- option->runtime = !!(flags & GC_OPT_FLAG_RUNTIME);
- option->has_default = !!(flags & GC_OPT_FLAG_DEFAULT);
- option->def_in_desc = !!(flags & GC_OPT_FLAG_DEF_DESC);
- option->no_arg_desc = !!(flags & GC_OPT_FLAG_NO_ARG_DESC);
- option->no_change = !!(flags & GC_OPT_FLAG_NO_CHANGE);
+ if ((flags & GC_OPT_FLAG_DEFAULT))
+ option->has_default = 1;
+ if ((flags & GC_OPT_FLAG_DEF_DESC))
+ option->def_in_desc = 1;
+ if ((flags & GC_OPT_FLAG_NO_ARG_DESC))
+ option->no_arg_desc = 1;
+ if ((flags & GC_OPT_FLAG_NO_CHANGE))
+ option->no_change = 1;
if (default_value && *default_value)
option->default_value = xstrdup (default_value);
@@ -1923,9 +1920,7 @@ option_check_validity (gc_component_id_t component,
{
char *arg;
- if (!option->active)
- gc_error (1, 0, "option %s not supported by component %s",
- option->name, gc_component[component].name);
+ (void)component;
if (option->new_flags || option->new_value)
gc_error (1, 0, "option %s already changed", option->name);