]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add mail_user.dict_op_set and mail_user_get_dict_op_settings()
authorSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Wed, 2 Jun 2021 23:06:44 +0000 (00:06 +0100)
committerSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Thu, 1 Jul 2021 19:14:30 +0000 (20:14 +0100)
Used to initialize or obtain dict_op_settings for the user.

src/lib-storage/mail-user.c
src/lib-storage/mail-user.h

index b9408706851033a992beb47bb2125bd3e3c9f13a..02c39655192346bb0463e542dd39e98fbf6d05ef 100644 (file)
@@ -781,6 +781,18 @@ int mail_user_home_mkdir(struct mail_user *user)
        return 0;
 }
 
+const struct dict_op_settings *
+mail_user_get_dict_op_settings(struct mail_user *user)
+{
+       if (user->dict_op_set == NULL) {
+               user->dict_op_set = p_new(user->pool, struct dict_op_settings, 1);
+               user->dict_op_set->username = p_strdup(user->pool, user->username);
+               if (mail_user_get_home(user, &user->dict_op_set->home_dir) <= 0)
+                       user->dict_op_set->home_dir = NULL;
+       }
+       return user->dict_op_set;
+}
+
 static const struct var_expand_func_table mail_user_var_expand_func_table_arr[] = {
        { "userdb", mail_user_var_expand_func_userdb },
        { NULL, NULL }
index 1b4d16918e3ed2c69db8f334ed38d4e6ab357791..8943f60b4d89fba16e8e8c103a5e7fa34ab5eece 100644 (file)
@@ -10,6 +10,7 @@ struct stats;
 struct fs_settings;
 struct ssl_iostream_settings;
 struct mail_user;
+struct dict_op_settings;
 
 struct mail_user_vfuncs {
        void (*deinit)(struct mail_user *user);
@@ -62,6 +63,7 @@ struct mail_user {
        struct mail_user_settings *set;
        struct mail_namespace *namespaces;
        struct mail_storage *storages;
+       struct dict_op_settings *dict_op_set;
        ARRAY(const struct mail_storage_hooks *) hooks;
 
        normalizer_func_t *default_normalizer;
@@ -218,6 +220,12 @@ void mail_user_stats_fill(struct mail_user *user, struct stats *stats);
    with ENOENT. This way it avoids unnecessary disk IO to the home. */
 int mail_user_home_mkdir(struct mail_user *user);
 
+/* Return dict_op_settings for the user. The returned settings are valid until
+   the user is freed. */
+const struct dict_op_settings *
+mail_user_get_dict_op_settings(struct mail_user *user);
+
+
 /* Obtain the postmaster address to be used for this user as an RFC 5322 (IMF)
    address. Returns false if the configured postmaster address is invalid in
    which case error_r contains the error message. */