From: Timo Sirainen Date: Tue, 6 Jul 2010 15:55:23 +0000 (+0100) Subject: Fixes to INBOX sharing. X-Git-Tag: 2.0.rc2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb64c3586d854cddd693f0b811d897399076a441;p=thirdparty%2Fdovecot%2Fcore.git 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). --HG-- branch : HEAD --- diff --git a/src/imap/cmd-list.c b/src/imap/cmd-list.c index cb766c5180..3c5f64a8b5 100644 --- a/src/imap/cmd-list.c +++ b/src/imap/cmd-list.c @@ -177,7 +177,7 @@ list_get_inbox_flags(struct cmd_list_context *ctx) 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 @@ list_namespace_mailboxes(struct cmd_list_context *ctx) 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 @@ list_use_inboxcase(struct cmd_list_context *ctx) 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 @@ static void list_namespace_init(struct cmd_list_context *ctx) 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 @@ static void list_inbox(struct cmd_list_context *ctx) /* 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 --git a/src/lib-lda/mail-deliver.c b/src/lib-lda/mail-deliver.c index 1d66eff95d..22b2a51e3d 100644 --- a/src/lib-lda/mail-deliver.c +++ b/src/lib-lda/mail-deliver.c @@ -115,7 +115,7 @@ int mail_deliver_save_open(struct mail_deliver_save_open_context *ctx, 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 --git a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c index 64d16d93d0..693d751729 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c @@ -545,7 +545,7 @@ rebuild_namespace_mailboxes(struct mdbox_storage_rebuild_context *ctx, 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 --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index 657f77bd22..7728f6fc52 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -280,8 +280,10 @@ void index_storage_mailbox_alloc(struct mailbox *box, const char *name, 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 --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index ea6723b327..a1b37c58a1 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -57,7 +57,7 @@ maildir_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, 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 @@ static void maildir_storage_get_list_settings(const struct mail_namespace *ns, 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 --git a/src/lib-storage/index/mbox/mbox-lock.c b/src/lib-storage/index/mbox/mbox-lock.c index e84554ff62..d65513cf70 100644 --- a/src/lib-storage/index/mbox/mbox-lock.c +++ b/src/lib-storage/index/mbox/mbox-lock.c @@ -348,7 +348,7 @@ mbox_dotlock_log_eacces_error(struct mbox_mailbox *mbox, const char *path) 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 --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 29cf94dad3..77787ba586 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -403,7 +403,7 @@ static int mbox_mailbox_open_existing(struct mbox_mailbox *mbox) } 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 @@ mbox_mailbox_create(struct mailbox *box, const struct mailbox_update *update, (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 --git a/src/lib-storage/index/shared/shared-storage.c b/src/lib-storage/index/shared/shared-storage.c index decc81000e..61466b4656 100644 --- a/src/lib-storage/index/shared/shared-storage.c +++ b/src/lib-storage/index/shared/shared-storage.c @@ -257,7 +257,7 @@ int shared_storage_get_namespace(struct mail_namespace **_ns, 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 --git a/src/lib-storage/list/mailbox-list-delete.c b/src/lib-storage/list/mailbox-list-delete.c index 4d02738570..3598dadc89 100644 --- a/src/lib-storage/list/mailbox-list-delete.c +++ b/src/lib-storage/list/mailbox-list-delete.c @@ -25,7 +25,7 @@ mailbox_list_check_root_delete(struct mailbox_list *list, const char *name, 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 --git a/src/lib-storage/list/mailbox-list-fs-iter.c b/src/lib-storage/list/mailbox-list-fs-iter.c index 65a36d9948..adaa9f8123 100644 --- a/src/lib-storage/list/mailbox-list-fs-iter.c +++ b/src/lib-storage/list/mailbox-list-fs-iter.c @@ -393,10 +393,13 @@ fs_list_get_subscription_flags(struct fs_list_iterate_context *ctx, 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 void inbox_flags_set(struct fs_list_iterate_context *ctx) 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 @@ list_file(struct fs_list_iterate_context *ctx, 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 @@ list_file(struct fs_list_iterate_context *ctx, 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 @@ fs_list_next(struct fs_list_iterate_context *ctx) } 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 --git a/src/lib-storage/list/mailbox-list-fs.c b/src/lib-storage/list/mailbox-list-fs.c index 8a1efa064a..2261e53dfc 100644 --- a/src/lib-storage/list/mailbox-list-fs.c +++ b/src/lib-storage/list/mailbox-list-fs.c @@ -220,7 +220,7 @@ fs_list_get_mailbox_name_status(struct mailbox_list *_list, const char *name, 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 --git a/src/lib-storage/list/mailbox-list-maildir-iter.c b/src/lib-storage/list/mailbox-list-maildir-iter.c index 549f9b35d9..2bbe87da1d 100644 --- a/src/lib-storage/list/mailbox-list-maildir-iter.c +++ b/src/lib-storage/list/mailbox-list-maildir-iter.c @@ -121,7 +121,7 @@ static void maildir_set_children(struct maildir_list_iterate_context *ctx, 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 @@ maildir_fill_inbox(struct maildir_list_iterate_context *ctx, } 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 @@ maildir_fill_readdir(struct maildir_list_iterate_context *ctx, return -1; } - if ((ns->flags & NAMESPACE_FLAG_INBOX) == 0) - return 0; - else { + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { /* make sure INBOX is listed */ - return maildir_fill_inbox(ctx, glob, update_only); + 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; } } diff --git a/src/lib-storage/list/mailbox-list-maildir.c b/src/lib-storage/list/mailbox-list-maildir.c index 252b1d5c16..dc23e61b0e 100644 --- a/src/lib-storage/list/mailbox-list-maildir.c +++ b/src/lib-storage/list/mailbox-list-maildir.c @@ -232,7 +232,7 @@ maildir_list_get_mailbox_name_status(struct mailbox_list *_list, MAILBOX_LIST_PATH_TYPE_MAILBOX); if ((strcmp(name, "INBOX") == 0 && - (_list->ns->flags & NAMESPACE_FLAG_INBOX) != 0) || + (_list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) || stat(path, &st) == 0) { *status = MAILBOX_NAME_EXISTS_MAILBOX; return 0; diff --git a/src/lib-storage/mail-namespace.c b/src/lib-storage/mail-namespace.c index c5ef2a042b..f587f19929 100644 --- a/src/lib-storage/mail-namespace.c +++ b/src/lib-storage/mail-namespace.c @@ -94,8 +94,10 @@ namespace_add(struct mail_user *user, return -1; } - if (ns_set->inbox) - ns->flags |= NAMESPACE_FLAG_INBOX; + if (ns_set->inbox) { + ns->flags |= NAMESPACE_FLAG_INBOX_USER | + NAMESPACE_FLAG_INBOX_ANY; + } if (ns_set->hidden) ns->flags |= NAMESPACE_FLAG_HIDDEN; if (ns_set->subscriptions) @@ -199,7 +201,7 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r) for (ns = namespaces; ns != NULL; ns = ns->next) { if (namespace_set_alias_for(ns, namespaces, error_r) < 0) return FALSE; - if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0) { + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { if (inbox_ns != NULL) { *error_r = "namespace configuration error: " "There can be only one namespace with " @@ -302,8 +304,8 @@ int mail_namespaces_init(struct mail_user *user, const char **error_r) /* no namespaces defined, create a default one */ ns = i_new(struct mail_namespace, 1); ns->type = NAMESPACE_PRIVATE; - ns->flags = NAMESPACE_FLAG_INBOX | NAMESPACE_FLAG_LIST_PREFIX | - NAMESPACE_FLAG_SUBSCRIPTIONS; + ns->flags = NAMESPACE_FLAG_INBOX_USER | NAMESPACE_FLAG_INBOX_ANY | + NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_SUBSCRIPTIONS; ns->owner = user; inbox_set = p_new(user->pool, struct mail_namespace_settings, 1); @@ -377,8 +379,8 @@ struct mail_namespace *mail_namespaces_init_empty(struct mail_user *user) ns->user = user; ns->owner = user; ns->prefix = i_strdup(""); - ns->flags = NAMESPACE_FLAG_INBOX | NAMESPACE_FLAG_LIST_PREFIX | - NAMESPACE_FLAG_SUBSCRIPTIONS; + ns->flags = NAMESPACE_FLAG_INBOX_USER | NAMESPACE_FLAG_INBOX_ANY | + NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_SUBSCRIPTIONS; ns->mail_set = mail_user_set_get_storage_set(user); user->namespaces = ns; return ns; @@ -465,7 +467,7 @@ const char *mail_namespace_get_vname(struct mail_namespace *ns, string_t *dest, const char *name) { str_truncate(dest, 0); - if ((ns->flags & NAMESPACE_FLAG_INBOX) == 0 || + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) == 0 || strcasecmp(name, "INBOX") != 0 || ns->user != ns->owner) str_append(dest, ns->prefix); @@ -535,7 +537,7 @@ mail_namespace_find_mask(struct mail_namespace *namespaces, /* find the INBOX namespace */ *mailbox = "INBOX"; while (ns != NULL) { - if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0 && + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && (ns->flags & mask) == flags) return ns; if (*ns->prefix == '\0') @@ -620,7 +622,7 @@ mail_namespace_find_unsubscribable(struct mail_namespace *namespaces, struct mail_namespace * mail_namespace_find_inbox(struct mail_namespace *namespaces) { - while ((namespaces->flags & NAMESPACE_FLAG_INBOX) == 0) + while ((namespaces->flags & NAMESPACE_FLAG_INBOX_USER) == 0) namespaces = namespaces->next; return namespaces; } diff --git a/src/lib-storage/mail-namespace.h b/src/lib-storage/mail-namespace.h index 994c8f6ccc..e206c391c7 100644 --- a/src/lib-storage/mail-namespace.h +++ b/src/lib-storage/mail-namespace.h @@ -12,16 +12,20 @@ enum namespace_type { }; enum namespace_flags { - /* Namespace contains the INBOX mailbox (there can be only one) */ - NAMESPACE_FLAG_INBOX = 0x01, + /* Namespace contains the user's INBOX mailbox (there can be only + one) */ + NAMESPACE_FLAG_INBOX_USER = 0x01, + /* Namespace contains someone's INBOX. This is set for both user's + INBOX namespace and also for any other users' shared namespaces. */ + NAMESPACE_FLAG_INBOX_ANY = 0x02, /* Namespace is visible only by explicitly using its full prefix */ - NAMESPACE_FLAG_HIDDEN = 0x02, + NAMESPACE_FLAG_HIDDEN = 0x04, /* Namespace prefix is visible with LIST */ - NAMESPACE_FLAG_LIST_PREFIX = 0x04, + NAMESPACE_FLAG_LIST_PREFIX = 0x08, /* Namespace prefix isn't visible with LIST, but child mailboxes are */ - NAMESPACE_FLAG_LIST_CHILDREN = 0x08, + NAMESPACE_FLAG_LIST_CHILDREN = 0x10, /* Namespace uses its own subscriptions. */ - NAMESPACE_FLAG_SUBSCRIPTIONS = 0x10, + NAMESPACE_FLAG_SUBSCRIPTIONS = 0x20, /* Namespace was created automatically (for shared mailboxes) */ NAMESPACE_FLAG_AUTOCREATED = 0x1000, diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 9c743f9acc..3f32677fd5 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -268,8 +268,10 @@ struct mailbox { unsigned int backend_readonly:1; /* Mailbox is being deleted */ unsigned int deleting:1; - /* TRUE if this is the INBOX */ - unsigned int inbox:1; + /* TRUE if this is an INBOX for this user */ + unsigned int inbox_user:1; + /* TRUE if this is an INBOX for this namespace (user or shared) */ + unsigned int inbox_any:1; }; struct mail_vfuncs { diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 6b53b1f20d..d054b91f2b 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -569,7 +569,7 @@ static int mailbox_open_full(struct mailbox *box, struct istream *input) } T_END; if (ret < 0 && box->storage->error == MAIL_ERROR_NOTFOUND && - box->input == NULL && box->inbox) T_BEGIN { + box->input == NULL && box->inbox_user) T_BEGIN { /* INBOX should always exist. try to create it and retry. */ (void)mailbox_create(box, NULL, FALSE); mailbox_close(box); @@ -711,7 +711,7 @@ int mailbox_delete(struct mailbox *box) "Storage root can't be deleted"); return -1; } - if (box->inbox) { + if (box->inbox_any) { mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, "INBOX can't be deleted."); return -1; @@ -907,7 +907,7 @@ int mailbox_sync_deinit(struct mailbox_sync_context **_ctx, memset(status_r, 0, sizeof(*status_r)); ret = box->v.sync_deinit(ctx, status_r); - if (ret < 0 && box->inbox && + if (ret < 0 && box->inbox_user && !box->storage->user->inbox_open_error_logged) { errormsg = mail_storage_get_last_error(box->storage, &error); if (error == MAIL_ERROR_NOTPOSSIBLE) { diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index 46fc8691af..e2c92c4e23 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -813,7 +813,7 @@ ns_match_inbox(struct mail_namespace *ns, const char *pattern) { struct imap_match_glob *glob; - if ((ns->flags & NAMESPACE_FLAG_INBOX) == 0) + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) == 0) return FALSE; glob = imap_match_init(pool_datastack_create(), pattern, @@ -1091,7 +1091,7 @@ int mailbox_list_mailbox(struct mailbox_list *list, const char *name, fname = ""; } if (*fname == '\0' && *name == '\0' && - (list->ns->flags & NAMESPACE_FLAG_INBOX) != 0) { + (list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { /* if INBOX is in e.g. ~/Maildir, it shouldn't be possible to access it also via namespace prefix. */ inbox = mailbox_list_get_path(list, "INBOX", diff --git a/src/plugins/acl/acl-mailbox-list.c b/src/plugins/acl/acl-mailbox-list.c index 2b0cb1e512..4b199e3c30 100644 --- a/src/plugins/acl/acl-mailbox-list.c +++ b/src/plugins/acl/acl-mailbox-list.c @@ -118,7 +118,7 @@ acl_mailbox_try_list_fast(struct acl_mailbox_list_iterate_context *ctx) update_ctx.iter_ctx = &ctx->ctx; update_ctx.glob = imap_match_init(pool_datastack_create(), "*", - (ns->flags & NAMESPACE_FLAG_INBOX) != 0, + (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0, ctx->sep); update_ctx.match_parents = TRUE; update_ctx.tree_ctx = mailbox_tree_init(ctx->sep); @@ -172,7 +172,7 @@ acl_mailbox_list_iter_init(struct mailbox_list *list, ctx->ctx.list = list; ctx->ctx.flags = flags; - inboxcase = (list->ns->flags & NAMESPACE_FLAG_INBOX) != 0; + inboxcase = (list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0; ctx->sep = (ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ? list->ns->sep : list->ns->real_sep; ctx->glob = imap_match_init_multiple(default_pool, patterns, diff --git a/src/plugins/fts/fts-storage.c b/src/plugins/fts/fts-storage.c index 605d7ee41a..c425336aff 100644 --- a/src/plugins/fts/fts-storage.c +++ b/src/plugins/fts/fts-storage.c @@ -434,7 +434,7 @@ fts_box_get_root(struct mailbox *box, struct mail_namespace **ns_r) *ns_r = ns; if (*name == '\0' && ns != mailbox_get_namespace(box) && - (ns->flags & NAMESPACE_FLAG_INBOX) != 0) { + (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { /* ugly workaround to allow selecting INBOX from a Maildir/ when it's not in the inbox=yes namespace. */ return "INBOX"; diff --git a/src/plugins/listescape/listescape-plugin.c b/src/plugins/listescape/listescape-plugin.c index ea0d3b450f..3edaf71a44 100644 --- a/src/plugins/listescape/listescape-plugin.c +++ b/src/plugins/listescape/listescape-plugin.c @@ -177,7 +177,7 @@ listescape_mailbox_list_iter_next(struct mailbox_list_iterate_context *ctx) ctx->list->ns : listescape_find_orig_ns(ctx->list->ns, info->name); - if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0 && + if ((ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 && strcasecmp(info->name, "INBOX") == 0) return info; diff --git a/src/plugins/quota/quota-maildir.c b/src/plugins/quota/quota-maildir.c index a2b60fc548..a823b6bc84 100644 --- a/src/plugins/quota/quota-maildir.c +++ b/src/plugins/quota/quota-maildir.c @@ -237,7 +237,7 @@ static int maildirsize_write(struct maildir_quota_root *root, const char *path) namespaces = array_get(&root->root.quota->namespaces, &count); i_assert(count > 0); for (i = 0; i < count; i++) { - if ((namespaces[i]->flags & NAMESPACE_FLAG_INBOX) != 0) { + if ((namespaces[i]->flags & NAMESPACE_FLAG_INBOX_USER) != 0) { mailbox_list_get_permissions(namespaces[i]->list, NULL, &mode, &gid, &gid_origin);