]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Replaced dict_init() with dict_init_full() in various places.
authorTimo Sirainen <tss@iki.fi>
Thu, 28 Aug 2014 13:10:25 +0000 (22:10 +0900)
committerTimo Sirainen <tss@iki.fi>
Thu, 28 Aug 2014 13:10:25 +0000 (22:10 +0900)
src/lib-storage/index/index-attribute.c
src/plugins/last-login/last-login-plugin.c
src/plugins/quota/quota-dict.c
src/plugins/quota/quota.c

index 3ed4fb824840665b5fb1f1b08d113a02537d76b1..899fa30692471320c0d41e923f12bf4c8d364f17 100644 (file)
@@ -82,6 +82,7 @@ index_storage_get_dict(struct mailbox *box, enum mail_attribute_type type,
        struct mail_storage *storage = box->storage;
        struct mail_namespace *ns;
        struct mailbox_metadata metadata;
+       struct dict_settings set;
        const char *error;
 
        if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0)
@@ -118,11 +119,13 @@ index_storage_get_dict(struct mailbox *box, enum mail_attribute_type type,
                return -1;
        }
 
-       if (dict_init(storage->set->mail_attribute_dict,
-                     DICT_DATA_TYPE_STRING,
-                     storage->user->username,
-                     storage->user->set->base_dir,
-                     &storage->_shared_attr_dict, &error) < 0) {
+       memset(&set, 0, sizeof(set));
+       set.username = storage->user->username;
+       set.base_dir = storage->user->set->base_dir;
+       if (mail_user_get_home(storage->user, &set.home_dir) <= 0)
+               set.home_dir = NULL;
+       if (dict_init_full(storage->set->mail_attribute_dict, &set,
+                          &storage->_shared_attr_dict, &error) < 0) {
                mail_storage_set_critical(storage,
                        "mail_attribute_dict: dict_init(%s) failed: %s",
                        storage->set->mail_attribute_dict, error);
index f8752fd1875e5cad7da5b91262032ea3dcb8d1df..d1e4f7e60faa8bd12f95c1adf23b27704a123ae4 100644 (file)
@@ -61,6 +61,7 @@ static void last_login_mail_user_created(struct mail_user *user)
        struct mail_user_vfuncs *v = user->vlast;
        struct last_login_user *luser;
        struct dict *dict;
+       struct dict_settings set;
        struct dict_transaction_context *trans;
        const char *dict_value, *key_name, *error;
 
@@ -74,8 +75,12 @@ static void last_login_mail_user_created(struct mail_user *user)
        if (dict_value == NULL)
                return;
 
-       if (dict_init(dict_value, DICT_DATA_TYPE_STRING, user->username,
-                     user->set->base_dir, &dict, &error) < 0) {
+       memset(&set, 0, sizeof(set));
+       set.username = user->username;
+       set.base_dir = user->set->base_dir;
+       if (mail_user_get_home(user, &set.home_dir) <= 0)
+               set.home_dir = NULL;
+       if (dict_init_full(dict_value, &set, &dict, &error) < 0) {
                i_error("last_login_dict: dict_init(%s) failed: %s",
                        dict_value, error);
                return;
index 907c6e04ddd3c807f669dd16f9c3ba72f155c28b..5ec65e9eeb49fff5fcc7da3e8de791cebcaa2fd4 100644 (file)
@@ -32,6 +32,7 @@ static int dict_quota_init(struct quota_root *_root, const char *args,
                           const char **error_r)
 {
        struct dict_quota_root *root = (struct dict_quota_root *)_root;
+       struct dict_settings set;
        const char *username, *p, *error;
 
        p = args == NULL ? NULL : strchr(args, ':');
@@ -78,9 +79,12 @@ static int dict_quota_init(struct quota_root *_root, const char *args,
 
        /* FIXME: we should use 64bit integer as datatype instead but before
           it can actually be used don't bother */
-       if (dict_init(args, DICT_DATA_TYPE_STRING, username,
-                     _root->quota->user->set->base_dir, &root->dict,
-                     &error) < 0) {
+       memset(&set, 0, sizeof(set));
+       set.username = username;
+       set.base_dir = _root->quota->user->set->base_dir;
+       if (mail_user_get_home(_root->quota->user, &set.home_dir) <= 0)
+               set.home_dir = NULL;
+       if (dict_init_full(args, &set, &root->dict, &error) < 0) {
                *error_r = t_strdup_printf("dict_init(%s) failed: %s", args, error);
                return -1;
        }
index 02575752a8825a0e87ef62ebf4502744ac8e9196..d44b1f31fa381264a851d0aa114f138bcdce81fd 100644 (file)
@@ -664,10 +664,15 @@ int quota_set_resource(struct quota_root *root, const char *name,
        }
 
        if (root->limit_set_dict == NULL) {
-               if (dict_init(root->set->limit_set, DICT_DATA_TYPE_STRING,
-                             root->quota->user->username,
-                             root->quota->user->set->base_dir,
-                             &root->limit_set_dict, error_r) < 0)
+               struct dict_settings set;
+
+               memset(&set, 0, sizeof(set));
+               set.username = root->quota->user->username;
+               set.base_dir = root->quota->user->set->base_dir;
+               if (mail_user_get_home(root->quota->user, &set.home_dir) <= 0)
+                       set.home_dir = NULL;
+               if (dict_init_full(root->set->limit_set, &set,
+                                  &root->limit_set_dict, error_r) < 0)
                        return -1;
        }