]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Fixes to INBOX sharing.
authorTimo Sirainen <tss@iki.fi>
Tue, 6 Jul 2010 15:55:23 +0000 (16:55 +0100)
committerTimo Sirainen <tss@iki.fi>
Tue, 6 Jul 2010 15:55:23 +0000 (16:55 +0100)
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

22 files changed:
src/imap/cmd-list.c
src/lib-lda/mail-deliver.c
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-lock.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/shared/shared-storage.c
src/lib-storage/list/mailbox-list-delete.c
src/lib-storage/list/mailbox-list-fs-iter.c
src/lib-storage/list/mailbox-list-fs.c
src/lib-storage/list/mailbox-list-maildir-iter.c
src/lib-storage/list/mailbox-list-maildir.c
src/lib-storage/mail-namespace.c
src/lib-storage/mail-namespace.h
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list.c
src/plugins/acl/acl-mailbox-list.c
src/plugins/fts/fts-storage.c
src/plugins/listescape/listescape-plugin.c
src/plugins/quota/quota-maildir.c

index cb766c5180b2f51b462c2bbaa915e749c085e410..3c5f64a8b5ee0a80e7a0add483d94cc402ed3183 100644 (file)
@@ -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);
index 1d66eff95df1631a9a6050366eb73ce3154fa774..22b2a51e3d6f4aff2b04be7b90fdaf404c6f5b66 100644 (file)
@@ -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";
index 64d16d93d0cf89f77e3992c2fbb2f993252809f5..693d751729364fe14b5314e428aa9f46fcc6d1b7 100644 (file)
@@ -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, "*",
index 657f77bd225892ce2dc2da6fd3b4a5c416030e14..7728f6fc5220d25aeb25215604c894c53d112e2b 100644 (file)
@@ -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,
index ea6723b327b8e7f1c74216ead0fcdb2d6d085ab1..a1b37c58a139add544cb5081f8c2f47dbaf1e969 100644 (file)
@@ -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;
        }
index e84554ff62a3acb6957060e4035d4dbfc6fc1934..d65513cf70b712e8174a8c4f011b84fd7e95ee31 100644 (file)
@@ -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) {
index 29cf94dad3f1437d9412e0fb8db14543e1c0288a..77787ba58625af95ac9eae7cc38be157d102fd6e 100644 (file)
@@ -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 {
index decc81000e3ef8872a56a68333917367ff064f19..61466b465677633a0751941dfd91e5bee161b988 100644 (file)
@@ -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;
 
index 4d027385703336bb263f69facbf0b54a01a0b939..3598dadc89f7b9fa77e62e05d19dd3b5c0a4079c 100644 (file)
@@ -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;
index 65a36d99487013445573306f22d8921e39348788..adaa9f812360dcb45b2052896f02809a7ea788a3 100644 (file)
@@ -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)) {
index 8a1efa064a220b5038b4fa08cefec05b7360efa6..2261e53dfc5ad9af747acf855165bc16f3cf168b 100644 (file)
@@ -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;
        }
index 549f9b35d9991fa57e7a6f4a8633244787111d78..2bbe87da1ddc866e357ca70535efc1c60603a373 100644 (file)
@@ -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;
        }
 }
 
index 252b1d5c16e1a91f1657f811dec666071dc484de..dc23e61b0e3a137245f4070ccb9ff4c85e200bd0 100644 (file)
@@ -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;
index c5ef2a042b7d0b54cd3a8c5c9bec53a606e10d3d..f587f19929e367a88c21611e0ece14f856b9fe6f 100644 (file)
@@ -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;
 }
index 994c8f6cccc2a616fe4b22822fa364847c19f96b..e206c391c7d04b53b6333d957ed4dee70990d9a8 100644 (file)
@@ -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,
index 9c743f9acc5ceecdd1269e9a2796ebfe5a492683..3f32677fd54dee60e257fe8e008fd7c515cbbf80 100644 (file)
@@ -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 {
index 6b53b1f20d5c35e024072b8c23967a54179c8d38..d054b91f2b2ebc8adda38a180aae32a77c8a8e8f 100644 (file)
@@ -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) {
index 46fc8691af6a2833e43880b91c760a9da06a0502..e2c92c4e23d6c807e1dc1a5ac664125462814677 100644 (file)
@@ -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",
index 2b0cb1e51283f8fc815a28947f995af157755cc1..4b199e3c305041cbfd5cc5c14ec45d6e0468973e 100644 (file)
@@ -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,
index 605d7ee41ac0a69e34982ab5e13bdaa9e7d9ae94..c425336aff268ab44933168d9d5533c8cc8335a9 100644 (file)
@@ -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";
index ea0d3b450f46dcc8e9b0e6413183d773d7c64558..3edaf71a44b55ff1aa8bf96d14b9dc3068ce3066 100644 (file)
@@ -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;
 
index a2b60fc548e5ea96aa6738adb6747d1c22fd1252..a823b6bc84a8cf1d95af60f9be46c0b34e467a40 100644 (file)
@@ -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);