Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8457:f5554ae61732 HEAD
Don't drop useless namespaces automatically while creating a new one.
It may free namespaces that are still being used elsewhere. Rather do it
explicitly at the beginning of each mailbox sync.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 20 Nov 2008 19:32:58 +0200 |
parents | 529034798b6b |
children | ed4d6f6e4da7 |
files | src/imap/imap-sync.c src/lib-storage/index/shared/shared-storage.c src/lib-storage/mail-user.c src/lib-storage/mail-user.h |
diffstat | 4 files changed, 20 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-sync.c Wed Nov 19 20:09:34 2008 +0200 +++ b/src/imap/imap-sync.c Thu Nov 20 19:32:58 2008 +0200 @@ -4,6 +4,7 @@ #include "str.h" #include "ostream.h" #include "mail-storage.h" +#include "mail-user.h" #include "imap-quote.h" #include "imap-util.h" #include "imap-sync.h" @@ -138,6 +139,10 @@ ctx->box = box; ctx->imap_flags = imap_flags; + /* make sure user can't DoS the system by causing Dovecot to create + tons of useless namespaces. */ + mail_user_drop_useless_namespaces(client->user); + ctx->sync_ctx = mailbox_sync_init(box, flags); ctx->t = mailbox_transaction_begin(box, 0); ctx->mail = mail_alloc(ctx->t, MAIL_FETCH_FLAGS, 0);
--- a/src/lib-storage/index/shared/shared-storage.c Wed Nov 19 20:09:34 2008 +0200 +++ b/src/lib-storage/index/shared/shared-storage.c Thu Nov 20 19:32:58 2008 +0200 @@ -163,20 +163,6 @@ str_append(location, PKG_RUNDIR"/user-not-found"); } -static void drop_unusable_shared_namespaces(struct mail_user *user) -{ -#define NS_UNUSABLE_FLAGS (NAMESPACE_FLAG_AUTOCREATED | ) - struct mail_namespace *ns, *next; - - for (ns = user->namespaces; ns != NULL; ns = next) { - next = ns->next; - - if ((ns->flags & NAMESPACE_FLAG_USABLE) == 0 && - (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0) - mail_namespace_destroy(ns); - } -} - int shared_storage_get_namespace(struct mail_storage *_storage, const char **_name, struct mail_namespace **ns_r) @@ -298,7 +284,6 @@ ns->prefix, error); return -1; } - drop_unusable_shared_namespaces(user); mail_user_add_namespace(user, ns); *_name = mail_namespace_fix_sep(ns, name);
--- a/src/lib-storage/mail-user.c Wed Nov 19 20:09:34 2008 +0200 +++ b/src/lib-storage/mail-user.c Thu Nov 20 19:32:58 2008 +0200 @@ -59,6 +59,19 @@ } } +void mail_user_drop_useless_namespaces(struct mail_user *user) +{ + struct mail_namespace *ns, *next; + + for (ns = user->namespaces; ns != NULL; ns = next) { + next = ns->next; + + if ((ns->flags & NAMESPACE_FLAG_USABLE) == 0 && + (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0) + mail_namespace_destroy(ns); + } +} + const char *mail_user_home_expand(struct mail_user *user, const char *path) { (void)mail_user_try_home_expand(user, &path);
--- a/src/lib-storage/mail-user.h Wed Nov 19 20:09:34 2008 +0200 +++ b/src/lib-storage/mail-user.h Thu Nov 20 19:32:58 2008 +0200 @@ -38,6 +38,8 @@ /* Add a new namespace to user's namespaces. */ void mail_user_add_namespace(struct mail_user *user, struct mail_namespace *ns); +/* Drop autocreated shared namespaces that don't have any "usable" mailboxes. */ +void mail_user_drop_useless_namespaces(struct mail_user *user); /* Replace ~/ at the beginning of the path with the user's home directory. */ const char *mail_user_home_expand(struct mail_user *user, const char *path);