]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage, dsync: Use a copy of unexpanded location settings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 15 Nov 2022 23:20:38 +0000 (01:20 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 30 Nov 2022 12:46:45 +0000 (14:46 +0200)
The unexpanded settings structs are used in only a few places. Replace
this usage by explicitly copying the few variables that are actually
needed. This allows getting rid of the full unexpanded settings structs,
which simplifies the settings handling code.

src/doveadm/dsync/dsync-brain.c
src/lib-storage/index/shared/shared-storage.c
src/lib-storage/mail-namespace.c
src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h
src/lib-storage/mailbox-list.c

index fcf208feb64eb40992086c34578e8d4dcc6e6776..e6b974e963a5604215e29702d0ae5e46f6a02f06 100644 (file)
@@ -882,7 +882,7 @@ bool dsync_brain_want_namespace(struct dsync_brain *brain,
                        return TRUE;
                return FALSE;
        } else {
-               return strcmp(ns->unexpanded_set->location,
+               return strcmp(ns->set->unexpanded_location,
                              SETTING_STRVAR_UNEXPANDED) == 0;
        }
 }
index b805569fcf96cee3e7386cd54e4fa2ca1ff07609..b8c139883134de4cdae6a9f81a1a758569a655f6 100644 (file)
@@ -45,7 +45,7 @@ shared_storage_create(struct mail_storage *_storage, struct mail_namespace *ns,
        driver = t_strdup_until(ns->set->location, p);
        storage->location = p_strdup(_storage->pool, ns->set->location);
        storage->unexpanded_location =
-               p_strdup(_storage->pool, ns->unexpanded_set->location);
+               p_strdup(_storage->pool, ns->set->unexpanded_location);
        storage->storage_class_name = p_strdup(_storage->pool, driver);
 
        if (mail_user_get_storage_class(_storage->user, driver) == NULL &&
index a4a3bdcdc8601a30723494da0c803382f8919763..ad5870479cd37e072dbb986c748be5c736bf2d04 100644 (file)
@@ -15,8 +15,9 @@ static struct mail_namespace_settings prefixless_ns_unexpanded_set = {
        .name = "",
        .type = "private",
        .separator = "",
-       .prefix = "0",
-       .location = "0fail::LAYOUT=none",
+       .prefix = "",
+       .location = "fail::LAYOUT=none",
+       .unexpanded_location = "0fail::LAYOUT=none",
        .alias_for = NULL,
 
        .inbox = FALSE,
index acb879db30a3da4ea40734a2a435f465efa99b5b..131c5adaf46c4c9842d7d23d87203383a387a039 100644 (file)
@@ -440,6 +440,12 @@ static bool mail_storage_settings_check(void *_set, pool_t pool,
        bool uidl_format_ok;
        char c;
 
+#ifndef CONFIG_BINARY
+       i_assert(set->mail_location[0] == SETTING_STRVAR_UNEXPANDED[0] ||
+                set->mail_location[0] == SETTING_STRVAR_EXPANDED[0]);
+       set->unexpanded_mail_location = set->mail_location;
+#endif
+
        if (set->mailbox_idle_check_interval == 0) {
                *error_r = "mailbox_idle_check_interval must not be 0";
                return FALSE;
@@ -590,6 +596,12 @@ static bool namespace_settings_check(void *_set, pool_t pool ATTR_UNUSED,
 
        name = ns->prefix != NULL ? ns->prefix : "";
 
+#ifndef CONFIG_BINARY
+       i_assert(ns->location[0] == SETTING_STRVAR_UNEXPANDED[0] ||
+                ns->location[0] == SETTING_STRVAR_EXPANDED[0]);
+       ns->unexpanded_location = ns->location;
+#endif
+
        if (ns->separator[0] != '\0' && ns->separator[1] != '\0') {
                *error_r = t_strdup_printf("Namespace '%s': "
                        "Hierarchy separator must be only one character long",
index a056d0d9b3629dc0dbe5a5888fc5ef4ec9747aa9..cd0f7ccd469243744ad82e56bd08ff9bf49f0fcb 100644 (file)
@@ -69,6 +69,7 @@ struct mail_storage_settings {
 
        enum file_lock_method parsed_lock_method;
        enum fsync_mode parsed_fsync_mode;
+       const char *unexpanded_mail_location;
 
        const char *const *parsed_mail_attachment_content_type_filter;
        bool parsed_mail_attachment_exclude_inlined;
@@ -94,6 +95,7 @@ struct mail_namespace_settings {
 
        ARRAY(struct mailbox_settings *) mailboxes;
        struct mail_user_settings *user_set;
+       const char *unexpanded_location;
 };
 
 /* <settings checks> */
index 90f0d3fc2486a37c95240156a48623eee5edc430..3492a458620146bae6905cef39936d01e8c2022c 100644 (file)
@@ -423,7 +423,7 @@ const char *mailbox_list_get_unexpanded_path(struct mailbox_list *list,
                                             enum mailbox_list_path_type type)
 {
        const struct mail_storage_settings *mail_set;
-       const char *location = list->ns->unexpanded_set->location;
+       const char *location = list->ns->set->unexpanded_location;
        struct mail_user *user = list->ns->user;
        struct mailbox_list_settings set;
        const char *p, *path, *error;
@@ -437,11 +437,8 @@ const char *mailbox_list_get_unexpanded_path(struct mailbox_list *list,
        location++;
 
        if (*location == '\0') {
-               mail_set = mail_user_set_get_driver_settings(user->set_parser,
-                       user->set_info, user->unexpanded_set,
-                       &mail_storage_setting_parser_info);
-               i_assert(mail_set != NULL);
-               location = mail_set->mail_location;
+               mail_set = mail_user_set_get_storage_set(user);
+               location = mail_set->unexpanded_mail_location;
                if (*location == SETTING_STRVAR_EXPANDED[0])
                        return "";
                i_assert(*location == SETTING_STRVAR_UNEXPANDED[0]);