From: Timo Sirainen Date: Wed, 15 Apr 2020 14:50:42 +0000 (+0300) Subject: doveconf: Don't show hidden settings unless they've been explicitly set X-Git-Tag: 2.3.15~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4c710dd0afbd10eeb5950c10f3ee7edd28304ae;p=thirdparty%2Fdovecot%2Fcore.git doveconf: Don't show hidden settings unless they've been explicitly set --- diff --git a/src/config/config-request.c b/src/config/config-request.c index 5b62e64f3c..9709615c94 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -232,9 +232,17 @@ settings_export(struct config_export_context *ctx, CONST_PTR_OFFSET(info->defaults, def->offset); change_value = CONST_PTR_OFFSET(change_set, def->offset); switch (ctx->scope) { - case CONFIG_DUMP_SCOPE_ALL: + case CONFIG_DUMP_SCOPE_ALL_WITH_HIDDEN: dump_default = TRUE; break; + case CONFIG_DUMP_SCOPE_ALL_WITHOUT_HIDDEN: + if ((def->flags & SET_FLAG_HIDDEN) == 0) { + /* not hidden - dump it */ + dump_default = TRUE; + break; + } + /* hidden - dump default only if it's explicitly set */ + /* fall through */ case CONFIG_DUMP_SCOPE_SET: dump_default = *((const char *)change_value) != 0; break; diff --git a/src/config/config-request.h b/src/config/config-request.h index f5baba7f35..c8a3fa24a8 100644 --- a/src/config/config-request.h +++ b/src/config/config-request.h @@ -7,8 +7,10 @@ struct master_service_settings_output; enum config_dump_scope { - /* Dump all settings */ - CONFIG_DUMP_SCOPE_ALL, + /* Dump all settings, including hidden settings */ + CONFIG_DUMP_SCOPE_ALL_WITH_HIDDEN, + /* Dump all non-hidden settings */ + CONFIG_DUMP_SCOPE_ALL_WITHOUT_HIDDEN, /* Dump all that have explicitly been set */ CONFIG_DUMP_SCOPE_SET, /* Dump only settings that differ from defaults */ diff --git a/src/config/doveconf.c b/src/config/doveconf.c index ea2b97dbbe..02762dff77 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -866,7 +866,7 @@ int main(int argc, char *argv[]) MASTER_SERVICE_FLAG_DONT_SEND_STATS | MASTER_SERVICE_FLAG_STANDALONE | MASTER_SERVICE_FLAG_NO_INIT_DATASTACK_FRAME; - enum config_dump_scope scope = CONFIG_DUMP_SCOPE_ALL; + enum config_dump_scope scope = CONFIG_DUMP_SCOPE_ALL_WITHOUT_HIDDEN; const char *orig_config_path, *config_path, *module; ARRAY(const char *) module_names; struct config_filter filter; @@ -956,6 +956,8 @@ int main(int argc, char *argv[]) } else if (argv[optind] != NULL) { /* print only a single config setting */ setting_name_filters = argv+optind; + if (scope == CONFIG_DUMP_SCOPE_ALL_WITHOUT_HIDDEN) + scope = CONFIG_DUMP_SCOPE_ALL_WITH_HIDDEN; } else if (!simple_output) { /* print the config file path before parsing it, so in case of errors it's still shown */ @@ -1019,7 +1021,7 @@ int main(int argc, char *argv[]) printf("# Hostname: %s\n", my_hostdomain()); if (!config_path_specified) check_wrong_config(config_path); - if (scope == CONFIG_DUMP_SCOPE_ALL) + if (scope == CONFIG_DUMP_SCOPE_ALL_WITHOUT_HIDDEN) printf("# NOTE: Send doveconf -n output instead when asking for help.\n"); fflush(stdout); ret2 = config_dump_human(&filter, wanted_modules, scope, NULL, hide_passwords);