]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Replace ALT with mail_alt_path setting
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 27 Oct 2023 12:52:53 +0000 (15:52 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:10 +0000 (12:34 +0200)
src/lib-storage/index/dbox-common/dbox-storage.c
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/list/mailbox-list-delete.c
src/lib-storage/list/mailbox-list-delete.h
src/lib-storage/list/mailbox-list-fs.c
src/lib-storage/list/mailbox-list-maildir.c
src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list.c
src/lib-storage/mailbox-list.h

index 691a9f61ad67fe6db01c94691b719b4f95d95f1f..dda7a59a51d6d094ce481ed4d93c1613aa204f79 100644 (file)
@@ -41,8 +41,8 @@ dbox_alt_path_has_changed(const char *root_dir, const char *alt_path,
        }
 
        if (alt_path == NULL) {
-               e_warning(event,
-                         "%s: Original ALT=%s, but currently no ALT path set",
+               e_warning(event, "%s: Original mail_alt_path=%s, "
+                         "but currently mail_alt_path is empty",
                          root_dir, linkpath);
                return TRUE;
        } else if (strcmp(linkpath, alt_path) != 0) {
@@ -53,7 +53,8 @@ dbox_alt_path_has_changed(const char *root_dir, const char *alt_path,
                           mdbox. we'll silently replace the symlink. */
                        return TRUE;
                }
-               e_warning(event, "%s: Original ALT=%s, but currently ALT=%s",
+               e_warning(event, "%s: Original mail_alt_path=%s, "
+                         "but currently mail_alt_path=%s",
                          root_dir, linkpath, alt_path);
                return TRUE;
        }
index 6541b463edaec83de662cd48f0c7b98fc360b5da..b3b6640e6fe8fdc96ad6f55b9a3bb6c05b253775 100644 (file)
@@ -62,10 +62,10 @@ int mdbox_storage_create(struct mail_storage *_storage,
        dir = mailbox_list_get_root_forced(ns->list, MAILBOX_LIST_PATH_TYPE_DIR);
        storage->storage_dir = p_strconcat(_storage->pool, dir,
                                           "/"MDBOX_GLOBAL_DIR_NAME, NULL);
-       if (ns->list->set.alt_dir != NULL) {
+       if (ns->list->mail_set->mail_alt_path[0] != '\0') {
                storage->alt_storage_dir = p_strconcat(_storage->pool,
-                                                       ns->list->set.alt_dir,
-                                                       "/"MDBOX_GLOBAL_DIR_NAME, NULL);
+                       ns->list->mail_set->mail_alt_path,
+                       "/"MDBOX_GLOBAL_DIR_NAME, NULL);
        }
 
        event_set_append_log_prefix(_storage->event, t_strdup_printf(
index b092a0ac74bdffc8cbe24d17e0edf03a1a3965e5..35d4f95d949307ac6a326d8bacf4a248029331ba 100644 (file)
@@ -366,7 +366,7 @@ static int mailbox_list_try_delete(struct mailbox_list *list, const char *name,
                return 0;
        }
 
-       /* Note that only ALT currently uses maildir_name in paths.
+       /* Note that only mail_alt_path currently uses maildir_name in paths.
           INDEX and CONTROL don't. */
        if (type != MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX ||
            *list->set.maildir_name == '\0') {
index 1033ea72ca884f491063e0008448e2497ec12515..da8d17039a9315aae80d90f38e2ec7032161b2d0 100644 (file)
@@ -47,7 +47,8 @@ int mailbox_list_delete_mailbox_file(struct mailbox_list *list,
 int mailbox_list_delete_mailbox_nonrecursive(struct mailbox_list *list,
                                             const char *name, const char *path,
                                             bool rmdir_path);
-/* Lookup INDEX, CONTROL and ALT directories for the mailbox and delete them.
+/* Lookup INDEX, CONTROL and mail_alt_path directories for the mailbox and
+   delete them.
    Returns 1 if anything was unlink()ed or rmdir()ed, 0 if not.
    Returns -1 and sets the list error on any errors. */
 int mailbox_list_delete_finish(struct mailbox_list *list, const char *name);
index 27ae8b91cb86a12a38acabac3cd2cf7eb6815fba..9dd38fd5909007b5e04354deae8c46e180d34647 100644 (file)
@@ -98,24 +98,25 @@ fs_list_get_path(struct mailbox_list *_list, const char *name,
                }
                break;
        case MAILBOX_LIST_PATH_TYPE_ALT_DIR:
-               if (set->alt_dir == NULL)
+               if (mail_set->mail_alt_path[0] == '\0')
                        return 0;
                if (*set->maildir_name != '\0') {
                        /* maildir_name is for the mailbox, caller is asking
                           for the directory name */
-                       *path_r = t_strdup_printf("%s/%s%s", set->alt_dir,
+                       *path_r = t_strdup_printf("%s/%s%s",
+                               mail_set->mail_alt_path,
                                mail_set->parsed_mailbox_root_directory_prefix,
                                name);
                        return 1;
                }
-               root_dir = set->alt_dir;
+               root_dir = mail_set->mail_alt_path;
                break;
        case MAILBOX_LIST_PATH_TYPE_MAILBOX:
                break;
        case MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX:
-               if (set->alt_dir == NULL)
+               if (mail_set->mail_alt_path[0] == '\0')
                        return 0;
-               root_dir = set->alt_dir;
+               root_dir = mail_set->mail_alt_path;
                break;
        case MAILBOX_LIST_PATH_TYPE_CONTROL:
                if (set->control_dir != NULL) {
index 465ae59269ea29aa73f8853143105fe2068c271a..5c0f860a29403bc5c8fe8d0151e686c20d81044d 100644 (file)
@@ -125,9 +125,9 @@ maildir_list_get_path(struct mailbox_list *_list, const char *name,
                break;
        case MAILBOX_LIST_PATH_TYPE_ALT_DIR:
        case MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX:
-               if (_list->set.alt_dir == NULL)
+               if (_list->mail_set->mail_alt_path[0] == '\0')
                        return 0;
-               root_dir = _list->set.alt_dir;
+               root_dir = _list->mail_set->mail_alt_path;
                break;
        case MAILBOX_LIST_PATH_TYPE_CONTROL:
                if (_list->set.control_dir != NULL) {
index 2cbe2eddb75c232088b43fee37234fc360201c0c..6785e9ba2f18da261f55a062cc8e35c4889c28ca 100644 (file)
@@ -84,6 +84,7 @@ static const struct setting_define mail_storage_setting_defines[] = {
        DEF(STR_HIDDEN, mailbox_root_directory_name),
        DEF(STR_HIDDEN, mailbox_subscriptions_filename),
        DEF(STR, mail_volatile_path),
+       DEF(STR, mail_alt_path),
        DEF(BOOL_HIDDEN, mail_alt_check),
        DEF(BOOL_HIDDEN, mail_full_filesystem_access),
        DEF(BOOL, maildir_stat_dirs),
@@ -153,6 +154,7 @@ const struct mail_storage_settings mail_storage_default_settings = {
        .mailbox_root_directory_name = "",
        .mailbox_subscriptions_filename = "subscriptions",
        .mail_volatile_path = "",
+       .mail_alt_path = "",
        .mail_alt_check = TRUE,
        .mail_full_filesystem_access = FALSE,
        .maildir_stat_dirs = FALSE,
@@ -504,6 +506,18 @@ mailbox_list_get_path_setting(const char *key, const char **value,
                *type_r = MAILBOX_LIST_PATH_TYPE_LIST_INDEX;
                return TRUE;
        }
+       struct {
+               const char *set_name;
+               enum mailbox_list_path_type type;
+       } set_types[] = {
+               { "mail_alt_path", MAILBOX_LIST_PATH_TYPE_ALT_DIR },
+       };
+       for (unsigned int i = 0; i < N_ELEMENTS(set_types); i++) {
+               if (strcmp(set_types[i].set_name, key) == 0) {
+                       *type_r = set_types[i].type;
+                       return TRUE;
+               }
+       }
        return FALSE;
 }
 
@@ -995,6 +1009,7 @@ static const size_t mail_storage_2nd_reset_offsets[] = {
        OFFSET(mailbox_root_directory_name),
        OFFSET(mailbox_subscriptions_filename),
        OFFSET(mail_volatile_path),
+       OFFSET(mail_alt_path),
        OFFSET(mail_alt_check),
 };
 
index ddbb635eeb28469eb2319d8bb7ca11b4c2172dd4..be3245daa69913fb84ccbb763d537e1033cc2ffc 100644 (file)
@@ -64,6 +64,7 @@ struct mail_storage_settings {
        const char *mailbox_root_directory_name;
        const char *mailbox_subscriptions_filename;
        const char *mail_volatile_path;
+       const char *mail_alt_path;
        bool mail_alt_check;
        bool mail_full_filesystem_access;
        bool maildir_stat_dirs;
index 1af781a46cabc94599cf83ab3561802384c48da9..21477ff1b515085956881ac00f9acf2441019080 100644 (file)
@@ -2159,8 +2159,10 @@ mailbox_lists_rename_compatible(struct mailbox_list *list1,
                                struct mailbox_list *list2,
                                const char **error_r)
 {
-       if (!nullequals(list1->set.alt_dir, list2->set.alt_dir)) {
-               *error_r = t_strdup_printf("Namespace %s has alt dir, %s doesn't",
+       if (!nullequals(list1->mail_set->mail_alt_path,
+                       list2->mail_set->mail_alt_path)) {
+               *error_r = t_strdup_printf(
+                       "Namespace %s has mail_alt_path, %s doesn't",
                        list1->ns->set->name, list2->ns->set->name);
                return FALSE;
        }
index 6da026b9281bee59fa10188af332b881e79b85e9..5372143f50e11d873873284335eda8fd411b7145 100644 (file)
@@ -126,8 +126,8 @@ int mailbox_list_create(struct event *event, struct mail_namespace *ns,
                return -1;
        }
        if ((class->props & MAILBOX_LIST_PROP_NO_ALT_DIR) != 0 &&
-           set->alt_dir != NULL) {
-               *error_r = "alt_dir not supported by this driver";
+           mail_set->mail_alt_path[0] != '\0') {
+               *error_r = "mail_alt_path not supported by this driver";
                return -1;
        }
 
@@ -168,7 +168,6 @@ int mailbox_list_create(struct event *event, struct mail_namespace *ns,
        list->set.inbox_path = p_strdup(list->pool, set->inbox_path);
        list->set.maildir_name =
                p_strdup(list->pool, set->maildir_name);
-       list->set.alt_dir = p_strdup(list->pool, set->alt_dir);
        list->set.index_control_use_maildir_name =
                set->index_control_use_maildir_name;
 
@@ -199,7 +198,7 @@ int mailbox_list_create(struct event *event, struct mail_namespace *ns,
                "" : list->set.control_dir,
                list->set.inbox_path == NULL ?
                "" : list->set.inbox_path,
-               list->set.alt_dir == NULL ? "" : list->set.alt_dir);
+               mail_set->mail_alt_path);
        if ((flags & MAILBOX_LIST_FLAG_SECONDARY) == 0)
                mail_namespace_finish_list_init(ns, list);
 
@@ -308,8 +307,6 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data,
                        dest = &set_r->index_cache_dir;
                else if (strcmp(key, "CONTROL") == 0)
                        dest = &set_r->control_dir;
-               else if (strcmp(key, "ALT") == 0)
-                       dest = &set_r->alt_dir;
                else if (strcmp(key, "DIRNAME") == 0)
                        dest = &set_r->maildir_name;
                else if (strcmp(key, "FULLDIRNAME") == 0) {
@@ -1397,7 +1394,6 @@ mailbox_list_set_get_root_path(const struct mailbox_list_settings *set,
                path = set->root_dir;
                break;
        case MAILBOX_LIST_PATH_TYPE_ALT_DIR:
-               path = set->alt_dir;
                break;
        case MAILBOX_LIST_PATH_TYPE_MAILBOX:
                if (*parsed_mailbox_root_directory_prefix == '\0')
@@ -1409,13 +1405,6 @@ mailbox_list_set_get_root_path(const struct mailbox_list_settings *set,
                }
                break;
        case MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX:
-               if (*parsed_mailbox_root_directory_prefix == '\0')
-                       path = set->alt_dir;
-               else if (set->alt_dir != NULL) {
-                       path = t_strconcat(set->alt_dir, "/",
-                               parsed_mailbox_root_directory_prefix, NULL);
-                       path = t_strndup(path, strlen(path)-1);
-               }
                break;
        case MAILBOX_LIST_PATH_TYPE_CONTROL:
                path = set->control_dir != NULL ?
@@ -1459,6 +1448,17 @@ bool mailbox_list_default_get_root_path(struct mailbox_list *list,
        const char *path = NULL;
 
        switch (type) {
+       case MAILBOX_LIST_PATH_TYPE_ALT_DIR:
+               path = mail_set->mail_alt_path;
+               break;
+       case MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX:
+               if (mail_set->mailbox_root_directory_name[0] == '\0')
+                       path = mail_set->mail_alt_path;
+               else if (mail_set->mail_alt_path[0] != '\0') {
+                       path = t_strconcat(mail_set->mail_alt_path, "/",
+                               mail_set->mailbox_root_directory_name, NULL);
+               }
+               break;
        case MAILBOX_LIST_PATH_TYPE_LIST_INDEX:
                if (mail_set->parsed_list_index_dir != NULL) {
                        if (mail_set->parsed_list_index_dir[0] == '/') {
@@ -1482,6 +1482,8 @@ bool mailbox_list_default_get_root_path(struct mailbox_list *list,
                        list->mail_set->parsed_mailbox_root_directory_prefix,
                        type, path_r);
        }
+       if (path != NULL && path[0] == '\0')
+               path = NULL;
        *path_r = path;
        return path != NULL;
 }
index 72f43866218253fb085d2f8afb45bf1d1ace0472..a5176a6060806f22c01e058212d5e6c30d1fd867 100644 (file)
@@ -119,7 +119,6 @@ struct mailbox_list_settings {
        const char *index_pvt_dir;
        const char *index_cache_dir;
        const char *control_dir;
-       const char *alt_dir; /* FIXME: dbox-specific.. */
 
        const char *inbox_path;
        /* If non-empty, it means that mails exist in a maildir_name