]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Remove plugin settings and related functions
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 20 Nov 2024 13:43:14 +0000 (15:43 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:01 +0000 (10:40 +0200)
src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h
src/lib-storage/mail-user-lua.c
src/lib-storage/mail-user.c
src/lib-storage/mail-user.h

index d568aca8bd14ed329d9a55b00336a9598e9c5b4e..bcd2694e8768801b7f647b03ca42e2c8ea52192f 100644 (file)
@@ -112,8 +112,6 @@ static const struct setting_define mail_storage_setting_defines[] = {
        { .type = SET_FILTER_ARRAY, .key = "namespace",
           .offset = offsetof(struct mail_storage_settings, namespaces),
           .filter_array_field_name = "namespace_name" },
-       { .type = SET_STRLIST, .key = "plugin",
-         .offset = offsetof(struct mail_storage_settings, plugin_envs) },
 
        SETTING_DEFINE_LIST_END
 };
@@ -190,7 +188,6 @@ const struct mail_storage_settings mail_storage_default_settings = {
        .recipient_delimiter = "+",
 
        .namespaces = ARRAY_INIT,
-       .plugin_envs = ARRAY_INIT,
 };
 
 static const struct setting_keyvalue mail_storage_default_settings_keyvalue[] = {
index 8ad2960f2f1a106bddda58ba062928f13f73709c..a233a599b078ccf957760f1db8d86713153ff20a 100644 (file)
@@ -92,7 +92,6 @@ struct mail_storage_settings {
        ARRAY_TYPE(const_string) mail_attachment_detection_options;
 
        ARRAY_TYPE(const_string) namespaces;
-       ARRAY(const char *) plugin_envs;
 
        enum file_lock_method parsed_lock_method;
        enum fsync_mode parsed_fsync_mode;
index dcb9ed88815a49f4b1898211b54230f9ac88c685..a6af81a92d830e7f495ec38ed8f3a52bf7658d0b 100644 (file)
@@ -141,16 +141,6 @@ static int lua_storage_mail_user_var_expand(lua_State *L)
        return 1;
 }
 
-static int lua_storage_mail_user_plugin_getenv(lua_State *L)
-{
-       DLUA_REQUIRE_ARGS(L, 2);
-       struct mail_user *user = lua_check_storage_mail_user(L, 1);
-       const char *set = lua_tostring(L, 2);
-       const char *val = mail_user_plugin_getenv(user, set);
-       lua_pushstring(L, val);
-       return 1;
-}
-
 static int lua_storage_mail_user_mailbox_alloc(lua_State *L)
 {
        DLUA_REQUIRE_ARGS_IN(L, 2, 3);
@@ -386,7 +376,6 @@ static luaL_Reg lua_storage_mail_user_methods[] = {
        { "__eq", lua_storage_mail_user_eq },
        { "__lt", lua_storage_mail_user_lt },
        { "__le", lua_storage_mail_user_le },
-       { "plugin_getenv", lua_storage_mail_user_plugin_getenv },
        { "var_expand", lua_storage_mail_user_var_expand },
        { "mailbox", lua_storage_mail_user_mailbox_alloc },
        { "metadata_get", lua_storage_mail_user_metadata_get },
index 430573117fe9273a6bc34a6e84b746319c3fd14e..6c24c843754c6c675f6a7959adb10dbae202f31e 100644 (file)
@@ -105,35 +105,6 @@ mail_user_alloc(struct mail_storage_service_user *service_user)
        return user;
 }
 
-static void
-mail_user_expand_plugins_envs(struct mail_user *user,
-                             struct mail_storage_settings *set)
-{
-       const char **envs, *error;
-       string_t *str;
-       unsigned int i, count;
-
-       if (!array_is_created(&set->plugin_envs))
-               return;
-
-       str = t_str_new(256);
-       envs = array_get_modifiable(&set->plugin_envs, &count);
-       i_assert((count % 2) == 0);
-
-       const struct var_expand_params *params = mail_user_var_expand_params(user);
-
-       for (i = 0; i < count; i += 2) {
-               str_truncate(str, 0);
-               if (var_expand(str, envs[i+1], params, &error) < 0) {
-                       user->error = p_strdup_printf(user->pool,
-                               "Failed to expand plugin setting %s = '%s': %s",
-                               envs[i], envs[i+1], error);
-                       return;
-               }
-               envs[i+1] = p_strdup(user->pool, str_c(str));
-       }
-}
-
 int mail_user_init(struct mail_user *user, const char **error_r)
 {
        const char *error;
@@ -147,8 +118,6 @@ int mail_user_init(struct mail_user *user, const char **error_r)
                         &user->_mail_set, &error) < 0 ||
            !mail_user_settings_update_special_use(user, user->_mail_set, &error))
                user->error = p_strdup(user->pool, error);
-       else
-               mail_user_expand_plugins_envs(user, user->_mail_set);
 
        if (user->error == NULL) {
                user->initialized = TRUE;
@@ -482,57 +451,6 @@ bool mail_user_is_plugin_loaded(struct mail_user *user, struct module *module)
        return ret;
 }
 
-bool mail_user_plugin_getenv_bool(struct mail_user *user, const char *name)
-{
-       const struct mail_storage_settings *mail_set =
-               mail_user_set_get_storage_set(user);
-       return mail_user_set_plugin_getenv_bool(mail_set, name);
-}
-
-bool mail_user_set_plugin_getenv_bool(const struct mail_storage_settings *set,
-                                     const char *name)
-{
-       const char *env = mail_user_set_plugin_getenv(set, name);
-
-       if (env == NULL)
-               return FALSE;
-       switch (env[0]) {
-               case 'n':
-               case 'N':
-               case '0':
-               case 'f':
-               case 'F':
-               return FALSE;
-       }
-
-       //any other value including empty string will be treated as TRUE.
-       return TRUE;
-}
-
-const char *mail_user_plugin_getenv(struct mail_user *user, const char *name)
-{
-       const struct mail_storage_settings *mail_set =
-               mail_user_set_get_storage_set(user);
-       return mail_user_set_plugin_getenv(mail_set, name);
-}
-
-const char *mail_user_set_plugin_getenv(const struct mail_storage_settings *set,
-                                       const char *name)
-{
-       const char *const *envs;
-       unsigned int i, count;
-
-       if (!array_is_created(&set->plugin_envs))
-               return NULL;
-
-       envs = array_get(&set->plugin_envs, &count);
-       for (i = 0; i < count; i += 2) {
-               if (strcmp(envs[i], name) == 0)
-                       return envs[i+1];
-       }
-       return NULL;
-}
-
 int mail_user_try_home_expand(struct mail_user *user, const char **pathp)
 {
        const char *home, *path = *pathp;
index 0085ed5a27b6bda503ea92128514ea7992d89cb3..13955076c397c6c00da08d0016402e8ed106432d 100644 (file)
@@ -172,13 +172,6 @@ int mail_user_lock_file_create(struct mail_user *user, const char *lock_fname,
 
 /* Returns TRUE if plugin is loaded for the user. */
 bool mail_user_is_plugin_loaded(struct mail_user *user, struct module *module);
-/* If name exists in plugin_envs, return its value. */
-const char *mail_user_plugin_getenv(struct mail_user *user, const char *name);
-bool mail_user_plugin_getenv_bool(struct mail_user *user, const char *name);
-const char *mail_user_set_plugin_getenv(const struct mail_storage_settings *set,
-                                       const char *name);
-bool mail_user_set_plugin_getenv_bool(const struct mail_storage_settings *set,
-                                     const char *name);
 
 /* Add more namespaces to user's namespaces. The ->next pointers may be
    changed, so the namespaces pointer will be updated to user->namespaces. */