]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: doveconf - Fix asking for settings which have named filter as prefix
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 20 Mar 2025 12:01:52 +0000 (14:01 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Mar 2025 07:23:34 +0000 (07:23 +0000)
For example "doveconf imapc_master_user" wouldn't output the setting,
although "doveconf imapc/master_user" would.

src/config/doveconf.c

index 0f0fcad7c88e53be045333fded0e4c3d2a59c5cf..0131a09f490da0621b121d542e5793ed61f28771 100644 (file)
@@ -1198,9 +1198,33 @@ int main(int argc, char *argv[])
                setting_name_filters = argv+optind;
                if (scope == CONFIG_DUMP_SCOPE_ALL_WITHOUT_HIDDEN)
                        scope = CONFIG_DUMP_SCOPE_ALL_WITH_HIDDEN;
-               flags |= CONFIG_PARSE_FLAG_PREFIXES_IN_FILTERS |
-                       CONFIG_PARSE_FLAG_MERGE_GROUP_FILTERS |
+               flags |= CONFIG_PARSE_FLAG_MERGE_GROUP_FILTERS |
                        CONFIG_PARSE_FLAG_MERGE_DEFAULT_FILTERS;
+               /* Named filters are a bit troublesome here. For example we
+                  can have imapc { ... } named filter, and imapc_master_user
+                  setting, which is normally written by doveconf as
+                  imapc { master_user }. However, we need to support also:
+
+                  doveconf imapc/master_user
+                  doveconf imapc_master_user
+                  doveconf imapc # output named filter's all settings
+
+                  Change the behavior based on whether the parameter contains
+                  '/'. This makes the first two cases work. The last is a bit
+                  of an issue though. We don't know at this point whether
+                  "imapc" is a named filter or a setting. So the current
+                  behavior is:
+
+                  # Output named filter settings only, no settings prefixed
+                  # with imapc_.
+                  doveconf imapc
+
+                  # Output both named filter settings and settings prefixed
+                  # with imapc_.
+                  doveconf imapc/
+               */
+               if (strchr(argv[optind], '/') != NULL)
+                       flags |= CONFIG_PARSE_FLAG_PREFIXES_IN_FILTERS;
        } else if (!simple_output) {
                /* print the config file path before parsing it, so in case
                   of errors it's still shown */