aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-12-30 09:18:23 +0000
committerWerner Koch <[email protected]>2021-12-30 09:19:55 +0000
commit42785d7c8a524129d9fe1a5afae553ff73f8e25b (patch)
treef90ab6067298e7565da0497d03abd0b2b8461b2d
parentbuild: Remove unused old m4 files. (diff)
downloadgnupg-42785d7c8a524129d9fe1a5afae553ff73f8e25b.tar.gz
gnupg-42785d7c8a524129d9fe1a5afae553ff73f8e25b.zip
gpgconf: Do not list ignored options and mark forced options as r/o.
* tools/gpgconf-comp.c (list_one_option): Skip ignored options and set the no_change flag for forced options. (retrieve_options_from_program): Put the attributes into the option table. --
-rw-r--r--tools/gpgconf-comp.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index b316d83d6..fa4ca015f 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1468,6 +1468,10 @@ list_one_option (gc_component_id_t component,
unsigned long flags;
const char *desc_domain = gc_component[component].desc_domain;
+ /* Don't show options with the ignore attribute. */
+ if (option->attr_ignore && !option->attr_force)
+ return;
+
if (option->desc)
{
desc = my_dgettext (desc_domain, option->desc);
@@ -1504,6 +1508,7 @@ list_one_option (gc_component_id_t component,
if (option->def_in_desc) flags |= GC_OPT_FLAG_DEF_DESC;
if (option->no_arg_desc) flags |= GC_OPT_FLAG_NO_ARG_DESC;
if (option->no_change) flags |= GC_OPT_FLAG_NO_CHANGE;
+ if (option->attr_force) flags |= GC_OPT_FLAG_NO_CHANGE;
es_fprintf (out, ":%lu", flags);
if (opt.verbose)
{
@@ -2058,11 +2063,6 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
{
char *opt_value;
- if (pargs.r_type & ARGPARSE_OPT_IGNORE)
- {
- /* log_debug ("ignored\n"); */
- continue;
- }
if (pargs.r_opt == ARGPARSE_CONFFILE)
{
/* log_debug ("current conffile='%s'\n", */
@@ -2084,8 +2084,18 @@ retrieve_options_from_program (gc_component_id_t component, int only_installed)
if (!option)
continue; /* We don't want to handle this option. */
- option->attr_ignore = !!(pargs.r_type & ARGPARSE_ATTR_IGNORE);
- option->attr_force = !!(pargs.r_type & ARGPARSE_ATTR_FORCE);
+ /* Set the force and ignore attributes. The idea is that there
+ * is no way to clear them again, thus we set them when first
+ * encountered. */
+ if ((pargs.r_type & ARGPARSE_ATTR_FORCE))
+ option->attr_force = 1;
+ if ((pargs.r_type & ARGPARSE_ATTR_IGNORE))
+ option->attr_ignore = 1;
+
+ /* If an option has been ignored, there is no need to return
+ * that option with gpgconf --list-options. */
+ if (option->attr_ignore)
+ continue;
switch ((pargs.r_type & ARGPARSE_TYPE_MASK))
{