]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: Fix using empty fts_driver setting
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 18 Mar 2024 21:22:53 +0000 (23:22 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:39:58 +0000 (10:39 +0200)
src/plugins/fts/fts-storage.c
src/plugins/fts/fts-user.c
src/plugins/fts/fts-user.h

index 6b06d7678e60ae2e2756bdee433280a1012d06cb..a3f98c733650f0ca19c262c6fd6c7e4c9afc8db7 100644 (file)
@@ -816,7 +816,7 @@ void fts_mailbox_allocated(struct mailbox *box)
        struct mailbox_vfuncs *v = box->vlast;
        struct fts_mailbox *fbox;
 
-       if (flist == NULL || flist->failed)
+       if (flist == NULL || flist->failed || flist->backend == NULL)
                return;
 
        const struct fts_settings *set;
@@ -863,12 +863,14 @@ fts_init_namespace(struct fts_mailbox_list *flist, struct mail_namespace *ns)
        struct fts_backend *backend;
        const char *error;
 
-       const struct fts_settings *set;
-       if (fts_user_try_get_settings(ns->user, &set) < 0) {
+       const struct fts_settings *set = NULL;
+       if (settings_get(ns->list->event, &fts_setting_parser_info, 0,
+                        &set, &error) < 0) {
                flist->failed = TRUE;
-               e_error(ns->list->event,
-                       "fts: Failed to initialize backend, "
-                       "could not retrieve settings.");
+               e_error(ns->list->event, "fts: %s", error);
+       } else if (set->driver[0] == '\0') {
+               e_debug(ns->list->event,
+                       "fts: No fts_driver setting - plugin disabled");
        } else if (fts_backend_init(set->driver, ns, &error, &backend) < 0) {
                flist->failed = TRUE;
                e_error(ns->list->event,
@@ -879,6 +881,7 @@ fts_init_namespace(struct fts_mailbox_list *flist, struct mail_namespace *ns)
                if ((flist->backend->flags & FTS_BACKEND_FLAG_FUZZY_SEARCH) != 0)
                        ns->user->fuzzy_search = TRUE;
        }
+       settings_free(set);
 }
 
 void fts_mail_namespaces_added(struct mail_namespace *ns)
@@ -893,16 +896,6 @@ void fts_mail_namespaces_added(struct mail_namespace *ns)
 void
 fts_mailbox_list_created(struct mailbox_list *list)
 {
-       const struct fts_settings *set;
-       /* This specific check is only a quick bypass. The actual validity
-          of the settings will be checked later in fts_init_namespace() */
-       if (fts_user_try_get_settings(list->ns->user, &set) == 0 &&
-           *set->driver == '\0') {
-               e_debug(list->event,
-                       "fts: No fts_driver setting - plugin disabled");
-               return;
-       }
-
        const char *path;
        if (!mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_INDEX, &path)) {
                e_debug(list->event,
index 756bc74b30f614bf92f3186e26649c59941c09fb..1f687d6e0b95b6e3eeafde33b39d0665c8892e29 100644 (file)
@@ -33,15 +33,6 @@ const struct fts_settings *fts_user_get_settings(struct mail_user *user)
        return fuser->set;
 }
 
-int fts_user_try_get_settings(struct mail_user *user,
-                             const struct fts_settings **set_r)
-{
-       struct fts_user *fuser = FTS_USER_CONTEXT(user);
-       if (fuser == NULL) return -1;
-       *set_r = fuser->set;
-       return 0;
-}
-
 size_t fts_mail_user_message_max_size(struct mail_user *user)
 {
        struct fts_user *fuser = FTS_USER_CONTEXT_REQUIRE(user);
index 98cf8972395d5d20cb3cf09fd836d53e5f42be58..2bede4369dc951b65cc639d0a3aff861c6d6c0c2 100644 (file)
@@ -4,8 +4,6 @@
 #include "fts-settings.h"
 
 const struct fts_settings *fts_user_get_settings(struct mail_user *user);
-int fts_user_try_get_settings(struct mail_user *user,
-                             const struct fts_settings **set_r);
 
 size_t fts_mail_user_message_max_size(struct mail_user *user);