]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
trash: Read settings after namespaces are loaded
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 1 Mar 2017 07:15:29 +0000 (09:15 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 16 Mar 2017 17:51:02 +0000 (19:51 +0200)
Fixes Panic: file mail-namespace.c: line 709 (mail_namespace_find): assertion failed: (ns != NULL)

src/plugins/trash/trash-plugin.c

index 6687920796405728710e879df5104563ca2a91c4..e967615080207fb5f151d9bf5fc6df5a8edb4b78 100644 (file)
@@ -348,17 +348,27 @@ trash_mail_user_created(struct mail_user *user)
        } else {
                tuser = p_new(user->pool, struct trash_user, 1);
                MODULE_CONTEXT_SET(user, trash_user_module, tuser);
+       }
+}
 
-               if (read_configuration(user, env) == 0) {
-                       trash_next_quota_test_alloc =
-                               quser->quota->set->test_alloc;
-                       quser->quota->set->test_alloc = trash_quota_test_alloc;
-               }
+static void
+trash_mail_namespaces_created(struct mail_namespace *namespaces)
+{
+       struct mail_user *user = namespaces->user;
+       struct trash_user *tuser = TRASH_USER_CONTEXT(user);
+       struct quota_user *quser = QUOTA_USER_CONTEXT(user);
+       const char *env = mail_user_plugin_getenv(user, "trash");
+
+       if (tuser != NULL && read_configuration(user, env) == 0) {
+               trash_next_quota_test_alloc =
+                       quser->quota->set->test_alloc;
+               quser->quota->set->test_alloc = trash_quota_test_alloc;
        }
 }
 
 static struct mail_storage_hooks trash_mail_storage_hooks = {
-       .mail_user_created = trash_mail_user_created
+       .mail_user_created = trash_mail_user_created,
+       .mail_namespaces_created = trash_mail_namespaces_created,
 };
 
 void trash_plugin_init(struct module *module)