dovecot-2.0: Fixes to INBOX sharing.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jul 6 18:55:32 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/07353259bb41
changeset: 11740:07353259bb41
user: Timo Sirainen <tss at iki.fi>
date: Tue Jul 06 16:55:23 2010 +0100
description:
Fixes to INBOX sharing.
NAMESPACE_FLAG_INBOX was split to two flags: _FLAG_INBOX_USER (this namespace
has the user's own INBOX) and _FLAG_INBOX_ANY (namespace has INBOX, either
user's own or another user's).
diffstat:
src/imap/cmd-list.c | 10 ++--
src/lib-lda/mail-deliver.c | 2 +-
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 2 +-
src/lib-storage/index/index-storage.c | 6 ++-
src/lib-storage/index/maildir/maildir-storage.c | 4 +-
src/lib-storage/index/mbox/mbox-lock.c | 2 +-
src/lib-storage/index/mbox/mbox-storage.c | 4 +-
src/lib-storage/index/shared/shared-storage.c | 2 +-
src/lib-storage/list/mailbox-list-delete.c | 2 +-
src/lib-storage/list/mailbox-list-fs-iter.c | 25 ++++++++++--
src/lib-storage/list/mailbox-list-fs.c | 2 +-
src/lib-storage/list/mailbox-list-maildir-iter.c | 20 ++++++----
src/lib-storage/list/mailbox-list-maildir.c | 2 +-
src/lib-storage/mail-namespace.c | 22 ++++++-----
src/lib-storage/mail-namespace.h | 16 +++++---
src/lib-storage/mail-storage-private.h | 6 ++-
src/lib-storage/mail-storage.c | 6 +-
src/lib-storage/mailbox-list.c | 4 +-
src/plugins/acl/acl-mailbox-list.c | 4 +-
src/plugins/fts/fts-storage.c | 2 +-
src/plugins/listescape/listescape-plugin.c | 2 +-
src/plugins/quota/quota-maildir.c | 2 +-
22 files changed, 89 insertions(+), 58 deletions(-)
diffs (truncated from 538 to 300 lines):
diff -r c52acd672735 -r 07353259bb41 src/imap/cmd-list.c
--- a/src/imap/cmd-list.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/imap/cmd-list.c Tue Jul 06 16:55:23 2010 +0100
@@ -177,7 +177,7 @@
enum mailbox_info_flags flags = MAILBOX_UNMARKED;
if (ctx->seen_inbox_namespace &&
- (ctx->ns->flags & NAMESPACE_FLAG_INBOX) == 0) {
+ (ctx->ns->flags & NAMESPACE_FLAG_INBOX_USER) == 0) {
/* INBOX doesn't exist. use the default INBOX flags */
return flags;
}
@@ -381,7 +381,7 @@
of handling INBOX/ namespace */
continue;
}
- if ((ctx->ns->flags & NAMESPACE_FLAG_INBOX) == 0) {
+ if ((ctx->ns->flags & NAMESPACE_FLAG_INBOX_USER) == 0) {
/* INBOX is in non-empty prefix namespace,
and we're now listing prefixless namespace
that contains INBOX. There's no way we can
@@ -554,7 +554,7 @@
enum imap_match_result match, ret;
if (*ctx->ns->prefix != '\0' &&
- (ctx->ns->flags & NAMESPACE_FLAG_INBOX) == 0)
+ (ctx->ns->flags & NAMESPACE_FLAG_INBOX_USER) == 0)
return IMAP_MATCH_NO;
/* if the original reference and pattern combined produces something
@@ -706,7 +706,7 @@
ctx->cur_ns_skip_trailing_sep = FALSE;
- if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0)
+ if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0)
ctx->seen_inbox_namespace = TRUE;
if (*cur_ns_prefix != '\0') {
@@ -758,7 +758,7 @@
/* INBOX always exists */
if (!ctx->inbox_found && ctx->cur_ns_match_inbox &&
- (ctx->ns->flags & NAMESPACE_FLAG_INBOX) != 0 &&
+ (ctx->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 &&
(ctx->list_flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0) {
str = t_strdup_printf("* LIST (\\Unmarked) \"%s\" \"INBOX\"",
ctx->ns->sep_str);
diff -r c52acd672735 -r 07353259bb41 src/lib-lda/mail-deliver.c
--- a/src/lib-lda/mail-deliver.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-lda/mail-deliver.c Tue Jul 06 16:55:23 2010 +0100
@@ -115,7 +115,7 @@
return -1;
}
- if (*name == '\0' && (ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
+ if (*name == '\0' && (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
/* delivering to a namespace prefix means we actually want to
deliver to the INBOX instead */
name = "INBOX";
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Jul 06 16:55:23 2010 +0100
@@ -545,7 +545,7 @@
int ret = 0;
if (ctx->default_list == NULL ||
- (ns->flags & NAMESPACE_FLAG_INBOX) != 0)
+ (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0)
ctx->default_list = ns->list;
iter = mailbox_list_iter_init(ns->list, "*",
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/index/index-storage.c Tue Jul 06 16:55:23 2010 +0100
@@ -280,8 +280,10 @@
MAILBOX_LIST_PATH_TYPE_MAILBOX);
box->path = p_strdup(box->pool, path);
box->index = index_storage_alloc(box->list, name, flags, index_prefix);
- box->inbox = strcmp(name, "INBOX") == 0 &&
- (box->list->ns->flags & NAMESPACE_FLAG_INBOX) != 0;
+ box->inbox_user = strcmp(name, "INBOX") == 0 &&
+ (box->list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0;
+ box->inbox_any = strcmp(name, "INBOX") == 0 &&
+ (box->list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0;
if (box->file_create_mode == 0)
mailbox_refresh_permissions(box);
mail_index_set_permissions(box->index, box->file_create_mode,
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-storage.c Tue Jul 06 16:55:23 2010 +0100
@@ -57,7 +57,7 @@
mailbox_list_get_temp_prefix(list));
if (list->set.control_dir == NULL && list->set.inbox_path == NULL &&
- (ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
+ (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
/* put the temp files into tmp/ directory preferrably */
storage->temp_prefix = p_strconcat(_storage->pool, "tmp/",
storage->temp_prefix, NULL);
@@ -84,7 +84,7 @@
if (set->inbox_path == NULL && set->maildir_name == NULL &&
(strcmp(set->layout, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) == 0 ||
strcmp(set->layout, MAILBOX_LIST_NAME_FS) == 0) &&
- (ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
+ (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
/* Maildir++ INBOX is the Maildir base itself */
set->inbox_path = set->root_dir;
}
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/index/mbox/mbox-lock.c
--- a/src/lib-storage/index/mbox/mbox-lock.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/index/mbox/mbox-lock.c Tue Jul 06 16:55:23 2010 +0100
@@ -348,7 +348,7 @@
errmsg = eacces_error_get_creating("file_dotlock_create", path);
dir = strrchr(path, '/');
dir = dir == NULL ? "." : t_strdup_until(path, dir);
- if (!mbox->box.inbox) {
+ if (!mbox->box.inbox_any) {
mail_storage_set_critical(&mbox->storage->storage,
"%s (not INBOX -> no privileged locking)", errmsg);
} else if (!mbox->mbox_privileged_locking) {
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/index/mbox/mbox-storage.c Tue Jul 06 16:55:23 2010 +0100
@@ -403,7 +403,7 @@
}
move_to_memory = want_memory_indexes(mbox->storage, box->path);
- if (box->inbox) {
+ if (box->inbox_any) {
/* if INBOX isn't under the root directory, it's probably in
/var/mail and we want to allow privileged dotlocking */
rootdir = mailbox_list_get_path(box->list, NULL,
@@ -518,7 +518,7 @@
(box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0)
return 0;
- if (box->inbox) {
+ if (box->inbox_any) {
if (create_inbox(box) < 0)
return -1;
} else {
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/index/shared/shared-storage.c
--- a/src/lib-storage/index/shared/shared-storage.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/index/shared/shared-storage.c Tue Jul 06 16:55:23 2010 +0100
@@ -257,7 +257,7 @@
new_ns->owner = owner;
new_ns->flags = (NAMESPACE_FLAG_SUBSCRIPTIONS & ns->flags) |
NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_HIDDEN |
- NAMESPACE_FLAG_AUTOCREATED;
+ NAMESPACE_FLAG_AUTOCREATED | NAMESPACE_FLAG_INBOX_ANY;
new_ns->sep = ns->sep;
new_ns->mail_set = _storage->set;
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/list/mailbox-list-delete.c
--- a/src/lib-storage/list/mailbox-list-delete.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-delete.c Tue Jul 06 16:55:23 2010 +0100
@@ -25,7 +25,7 @@
return 0;
if (strcmp(name, "INBOX") == 0 &&
- (list->ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
+ (list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE,
"INBOX can't be deleted.");
return -1;
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/list/mailbox-list-fs-iter.c
--- a/src/lib-storage/list/mailbox-list-fs-iter.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-fs-iter.c Tue Jul 06 16:55:23 2010 +0100
@@ -393,10 +393,13 @@
static void inbox_flags_set(struct fs_list_iterate_context *ctx)
{
+ struct mail_namespace *ns = ctx->ctx.list->ns;
+
/* INBOX is always selectable */
ctx->info.flags &= ~(MAILBOX_NOSELECT | MAILBOX_NONEXISTENT);
- if (*ctx->ctx.list->ns->prefix != '\0') {
+ if (*ns->prefix != '\0' &&
+ (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
/* we're listing INBOX for a namespace with a prefix.
if there are children for the INBOX, they're returned under
the mailbox prefix, not under the INBOX itself. */
@@ -407,8 +410,15 @@
static struct mailbox_info *fs_list_inbox(struct fs_list_iterate_context *ctx)
{
+ struct mail_namespace *ns = ctx->ctx.list->ns;
+
ctx->info.flags = 0;
- ctx->info.name = "INBOX";
+ if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0)
+ ctx->info.name = "INBOX";
+ else {
+ ctx->info.name = p_strconcat(ctx->info_pool,
+ ns->prefix, "INBOX", NULL);
+ }
if (mailbox_list_mailbox(ctx->ctx.list, "INBOX", &ctx->info.flags) < 0)
ctx->ctx.failed = TRUE;
@@ -594,7 +604,7 @@
ctx->info.flags |= fs_list_get_subscription_flags(ctx, list_path);
/* make sure we give only one correct INBOX */
- if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
+ if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
if (strcasecmp(list_path, "INBOX") == 0) {
if (!list_file_inbox(ctx, fname))
return 0;
@@ -605,6 +615,13 @@
prefix unless it has children. */
return 0;
}
+ } else if ((ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
+ /* shared namespace */
+ if (strcasecmp(fname, "INBOX") == 0 &&
+ list_file_is_inbox(ctx, fname)) {
+ if (!list_file_inbox(ctx, fname))
+ return 0;
+ }
}
if ((ctx->info.flags & MAILBOX_NOINFERIORS) == 0)
@@ -778,7 +795,7 @@
}
if (!ctx->inbox_found &&
- (ctx->ctx.list->ns->flags & NAMESPACE_FLAG_INBOX) != 0 &&
+ (ctx->ctx.list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0 &&
((ctx->glob != NULL &&
imap_match(ctx->glob, "INBOX") == IMAP_MATCH_YES) ||
ctx->inbox_match)) {
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/list/mailbox-list-fs.c
--- a/src/lib-storage/list/mailbox-list-fs.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-fs.c Tue Jul 06 16:55:23 2010 +0100
@@ -220,7 +220,7 @@
enum mailbox_info_flags flags;
if (strcmp(name, "INBOX") == 0 &&
- (_list->ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
+ (_list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
*status = MAILBOX_NAME_EXISTS_MAILBOX;
return 0;
}
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/list/mailbox-list-maildir-iter.c
--- a/src/lib-storage/list/mailbox-list-maildir-iter.c Tue Jul 06 15:06:10 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-maildir-iter.c Tue Jul 06 16:55:23 2010 +0100
@@ -121,7 +121,7 @@
static int
maildir_fill_inbox(struct maildir_list_iterate_context *ctx,
- struct imap_match_glob *glob,
+ struct imap_match_glob *glob, const char *inbox_name,
bool update_only)
{
struct mailbox_node *node;
@@ -143,17 +143,17 @@
}
if (update_only) {
- node = mailbox_tree_lookup(ctx->tree_ctx, "INBOX");
+ node = mailbox_tree_lookup(ctx->tree_ctx, inbox_name);
if (node != NULL)
node->flags &= ~MAILBOX_NONEXISTENT;
} else {
- node = mailbox_tree_get(ctx->tree_ctx, "INBOX", &created);
+ node = mailbox_tree_get(ctx->tree_ctx, inbox_name, &created);
if (created)
node->flags = MAILBOX_NOCHILDREN;
else
node->flags &= ~MAILBOX_NONEXISTENT;
- match = imap_match(glob, "INBOX");
+ match = imap_match(glob, inbox_name);
if ((match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) != 0)
node->flags |= MAILBOX_MATCHED;
}
@@ -391,11 +391,15 @@
return -1;
}
- if ((ns->flags & NAMESPACE_FLAG_INBOX) == 0)
+ if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
+ /* make sure INBOX is listed */
+ return maildir_fill_inbox(ctx, glob, "INBOX", update_only);
+ } else if ((ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
+ /* show shared INBOX. */
+ return maildir_fill_inbox(ctx, glob,
+ t_strconcat(ns->prefix, "INBOX", NULL), update_only);
+ } else {
return 0;
- else {
- /* make sure INBOX is listed */
- return maildir_fill_inbox(ctx, glob, update_only);
}
}
diff -r c52acd672735 -r 07353259bb41 src/lib-storage/list/mailbox-list-maildir.c
--- a/src/lib-storage/list/mailbox-list-maildir.c Tue Jul 06 15:06:10 2010 +0100
More information about the dovecot-cvs
mailing list