From: Timo Sirainen Date: Tue, 15 Nov 2022 23:20:38 +0000 (+0200) Subject: lib-storage, dsync: Use a copy of unexpanded location settings X-Git-Tag: 2.4.0~3341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=910c5c080f3b42002c433d263a5efa9df23f8ade;p=thirdparty%2Fdovecot%2Fcore.git lib-storage, dsync: Use a copy of unexpanded location settings 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. --- diff --git a/src/doveadm/dsync/dsync-brain.c b/src/doveadm/dsync/dsync-brain.c index fcf208feb6..e6b974e963 100644 --- a/src/doveadm/dsync/dsync-brain.c +++ b/src/doveadm/dsync/dsync-brain.c @@ -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; } } diff --git a/src/lib-storage/index/shared/shared-storage.c b/src/lib-storage/index/shared/shared-storage.c index b805569fcf..b8c1398831 100644 --- a/src/lib-storage/index/shared/shared-storage.c +++ b/src/lib-storage/index/shared/shared-storage.c @@ -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 && diff --git a/src/lib-storage/mail-namespace.c b/src/lib-storage/mail-namespace.c index a4a3bdcdc8..ad5870479c 100644 --- a/src/lib-storage/mail-namespace.c +++ b/src/lib-storage/mail-namespace.c @@ -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, diff --git a/src/lib-storage/mail-storage-settings.c b/src/lib-storage/mail-storage-settings.c index acb879db30..131c5adaf4 100644 --- a/src/lib-storage/mail-storage-settings.c +++ b/src/lib-storage/mail-storage-settings.c @@ -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", diff --git a/src/lib-storage/mail-storage-settings.h b/src/lib-storage/mail-storage-settings.h index a056d0d9b3..cd0f7ccd46 100644 --- a/src/lib-storage/mail-storage-settings.h +++ b/src/lib-storage/mail-storage-settings.h @@ -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; }; /* */ diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index 90f0d3fc24..3492a45862 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -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]);