mail-storage.c revision 3857e2945a3b6744d603f0f5a656849ed8436ba3
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenextern struct mail_search_register *mail_search_register_imap;
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainenextern struct mail_search_register *mail_search_register_human;
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainenstruct mail_storage_module_register mail_storage_module_register = { 0 };
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainenstruct mail_module_register mail_module_register = { 0 };
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainenstruct mail_storage_mail_index_module mail_storage_mail_index_module =
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen MODULE_CONTEXT_INIT(&mail_index_module_register);
c28f6aa0b70af4811c9ace9114fe827c2f503455Timo Sirainen mail_search_register_deinit(&mail_search_register_human);
c28f6aa0b70af4811c9ace9114fe827c2f503455Timo Sirainen mail_search_register_deinit(&mail_search_register_imap);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenvoid mail_storage_class_register(struct mail_storage *storage_class)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen i_assert(mail_storage_find_class(storage_class->name) == NULL);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* append it after the list, so the autodetection order is correct */
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen array_append(&mail_storage_classes, &storage_class, 1);
7db932bd4934cd967eeae643300aef5b91caeaeaTimo Sirainenvoid mail_storage_class_unregister(struct mail_storage *storage_class)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen unsigned int i, count;
7662010b03ffe5f2a6ecf4b4eb220d1c65efea76Timo Sirainen classes = array_get(&mail_storage_classes, &count);
7662010b03ffe5f2a6ecf4b4eb220d1c65efea76Timo Sirainen for (i = 0; i < count; i++) {
0a49b316fc729e5d57268ffa63c7122ac73f994cTimo Sirainenstruct mail_storage *mail_storage_find_class(const char *name)
0a49b316fc729e5d57268ffa63c7122ac73f994cTimo Sirainen unsigned int i, count;
51e1a1c280ccb461a15827f7987d09cb9708b6e3Timo Sirainen classes = array_get(&mail_storage_classes, &count);
51e1a1c280ccb461a15827f7987d09cb9708b6e3Timo Sirainen for (i = 0; i < count; i++) {
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainenmail_storage_autodetect(const struct mail_namespace *ns,
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen unsigned int i, count;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen classes = array_get(&mail_storage_classes, &count);
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen for (i = 0; i < count; i++) {
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainenmail_storage_set_autodetection(const char **data, const char **driver)
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen const char *p;
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen /* check if data is in driver:data format (eg. mbox:~/mail) */
0a0cd45a633112a2ae6aad801c1e6afe53ab95deTimo Sirainen /* no autodetection if the storage driver is given. */
d66ef20c30fee728899ee168c75fcc5ff8fbdac1Timo Sirainenmail_storage_get_class(struct mail_namespace *ns, const char *driver,
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainen enum mail_storage_flags flags, const char **error_r)
0a0cd45a633112a2ae6aad801c1e6afe53ab95deTimo Sirainen /* no mail_location, autodetect */
e4c81823af1fc43ca3f2ce9eb4af7fc8f57b13a5Timo Sirainen /* explicit autodetection with "auto" driver. */
e4c81823af1fc43ca3f2ce9eb4af7fc8f57b13a5Timo Sirainen /* handle the same as with driver=NULL */
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainen storage_class = mail_user_get_storage_class(ns->user, driver);
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen if (list_set->root_dir == NULL || *list_set->root_dir == '\0') {
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen /* no root directory given. is this allowed? */
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen (flags & MAIL_STORAGE_FLAG_NO_AUTODETECTION) == 0) {
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen /* autodetection should take care of this */
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen (storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) != 0) {
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen /* root not required for this storage */
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen (list->props & MAILBOX_LIST_PROP_NO_ROOT) != 0) {
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen /* root not required for this layout */
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen storage_class->v.get_list_settings(ns, list_set);
61e6367a259e2473f33df42fda8ceeb3b8b48416Timo Sirainen storage_class = mail_storage_autodetect(ns, list_set);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen if (home == NULL || *home == '\0') home = "(not set)";
20344c0e814139e3c365fbb9287478f91512089eTimo Sirainen if (ns->set->location == NULL || *ns->set->location == '\0') {
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "Mail storage autodetection failed with home=%s", home);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen } else if (strncmp(ns->set->location, "auto:", 5) == 0) {
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "Autodetection failed for %s (home=%s)",
20344c0e814139e3c365fbb9287478f91512089eTimo Sirainen "Ambiguous mail location setting, "
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "don't know what to do with it: %s "
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "(try prefixing it with mbox: or maildir:)",
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenmail_storage_verify_root(const char *root_dir, bool autocreate,
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen const char **error_r)
e3fc1874694a8ddba9552ec23f9952f74f33d1d5Timo Sirainen *error_r = mail_error_eacces_msg("stat", root_dir);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen } else if (errno != ENOENT && errno != ENOTDIR) {
e3fc1874694a8ddba9552ec23f9952f74f33d1d5Timo Sirainen *error_r = t_strdup_printf("stat(%s) failed: %m", root_dir);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen } else if (!autocreate) {
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen "Root mail directory doesn't exist: %s", root_dir);
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen /* doesn't exist */
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainenmail_storage_create_root(struct mailbox_list *list,
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen enum mail_storage_flags flags, const char **error_r)
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainen if (!mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_MAILBOX,
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainen /* storage doesn't use directories (e.g. shared root) */
602a0434db30d8e3292d1c161a803d96a879a74fTimo Sirainen if ((flags & MAIL_STORAGE_FLAG_NO_AUTOVERIFY) != 0) {
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* we don't need to verify, but since debugging is
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen enabled, check and log if the root doesn't exist */
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen if (mail_storage_verify_root(root_dir, FALSE, &error) < 0) {
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen i_debug("Namespace %s: Creating storage despite: %s",
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen autocreate = (flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) == 0;
4334b9b032298defd4d3906f5357698ff016ead0Timo Sirainen ret = mail_storage_verify_root(root_dir, autocreate, error_r);
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen ret = mailbox_list_try_mkdir_root(list, root_dir,
548e394330621952db0f03dd667b70184c4a37b6Timo Sirainenmail_storage_match_class(struct mail_storage *storage,
01f4ee4a0243f3fe9af763e1a540cd5cff0d63f5Timo Sirainen if (strcmp(storage->name, storage_class->name) != 0)
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen if ((storage->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0 &&
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen (set->root_dir != NULL ? set->root_dir : "")) != 0)
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen /* allow multiple independent shared namespaces */
a3c197999dfe2b0c8ea38cb77cfa5e95026005c0Timo Sirainen struct mail_storage *storage = user->storages;
a3c197999dfe2b0c8ea38cb77cfa5e95026005c0Timo Sirainen for (; storage != NULL; storage = storage->next) {
a3c197999dfe2b0c8ea38cb77cfa5e95026005c0Timo Sirainen if (mail_storage_match_class(storage, storage_class, set))
923115fd382904fa13bb09bf307bf2835b52df60Timo Sirainenint mail_storage_create_full(struct mail_namespace *ns, const char *driver,
923115fd382904fa13bb09bf307bf2835b52df60Timo Sirainen const char *data, enum mail_storage_flags flags,
923115fd382904fa13bb09bf307bf2835b52df60Timo Sirainen const char **error_r)
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen struct mail_storage *storage_class, *storage = NULL;
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen const char *p;
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen if ((flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) == 0 &&
6f08b98ac63c25b747120d0c8f8e319b4e26ab0fTimo Sirainen /* if pop3_uidl_format contains %m, we want to keep the
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen header MD5 sums stored even if we're not running POP3
6f08b98ac63c25b747120d0c8f8e319b4e26ab0fTimo Sirainen right now. */
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen mailbox_list_settings_init_defaults(&list_set);
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen /* autodetect */
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen } else if (driver != NULL && strcmp(driver, "shared") == 0) {
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen /* internal shared namespace */
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen mail_storage_set_autodetection(&data, &driver);
e0c3d5460d1cc0c440cb7723c8c2eef8d0afe9b9Timo Sirainen if (mailbox_list_settings_parse(ns->user, data, &list_set,
51e1a1c280ccb461a15827f7987d09cb9708b6e3Timo Sirainen storage_class = mail_storage_get_class(ns, driver, &list_set, flags,
51e1a1c280ccb461a15827f7987d09cb9708b6e3Timo Sirainen /* first storage for namespace */
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen if (mail_storage_is_mailbox_file(storage_class))
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen list_flags |= MAILBOX_LIST_FLAG_MAILBOX_FILES;
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen if ((storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) != 0)
7b42d6cbee8186195d8c5e66078043a0fa1f25c1Timo Sirainen list_flags |= MAILBOX_LIST_FLAG_NO_MAIL_FILES;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen if ((storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES) != 0)
df16c7e87511fed827e6890a2a47d13ca48716deTimo Sirainen if (mailbox_list_create(list_set.layout, ns, &list_set,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen *error_r = t_strdup_printf("Mailbox list driver %s: %s",
7b42d6cbee8186195d8c5e66078043a0fa1f25c1Timo Sirainen if ((storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) == 0) {
b7651d283ca261015ef3c445f1f27f340f0864e2Timo Sirainen if (mail_storage_create_root(ns->list, flags, error_r) < 0)
7b42d6cbee8186195d8c5e66078043a0fa1f25c1Timo Sirainen storage = mail_storage_find(ns->user, storage_class, &list_set);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* using an existing storage */
c0b1543512bc3e0a3a9f526056a3678a07ce32f5Timo Sirainen p_array_init(&storage->module_contexts, storage->pool, 5);
51e1a1c280ccb461a15827f7987d09cb9708b6e3Timo Sirainen storage->v.create(storage, ns, error_r) < 0) {
a0b6b441fc679e562e79be0fb2819ffc24ab5b74Timo Sirainen *error_r = t_strdup_printf("%s: %s", storage->name, *error_r);
68a4946b12583b88fa802e52ebee45cd96056772Timo Sirainenint mail_storage_create(struct mail_namespace *ns, const char *driver,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen enum mail_storage_flags flags, const char **error_r)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen return mail_storage_create_full(ns, driver, ns->set->location,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenvoid mail_storage_unref(struct mail_storage **_storage)
3785910c303507db5f629684e6dde2cc7f83668eTimo Sirainen /* set *_storage=NULL only after calling destroy() callback.
3785910c303507db5f629684e6dde2cc7f83668eTimo Sirainen for example mdbox wants to access ns->storage */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen i_panic("Trying to deinit storage without freeing mailbox %s",
c06f4017027263cf3a08becc551f5126409e2a83Timo Sirainen i_panic("Trying to deinit storage before freeing its objects");
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen DLLIST_REMOVE(&storage->user->storages, storage);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen if (array_is_created(&storage->error_stack)) {
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen i_assert(array_count(&storage->error_stack) == 0);
37ab3cde96bfa4bc5304c0c348fc420aec79572dTimo Sirainenvoid mail_storage_obj_ref(struct mail_storage *storage)
c06f4017027263cf3a08becc551f5126409e2a83Timo Sirainenvoid mail_storage_obj_unref(struct mail_storage *storage)
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainenvoid mail_storage_clear_error(struct mail_storage *storage)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenvoid mail_storage_set_error(struct mail_storage *storage,
904f9d5654b9c39edcdf32883e5e88771faf4d69Timo Sirainenvoid mail_storage_set_internal_error(struct mail_storage *storage)
904f9d5654b9c39edcdf32883e5e88771faf4d69Timo Sirainen const char *str;
7ef5ca6fb59a318c821a852ae48a2edbb671d7ddTimo Sirainen str = t_strflocaltime(MAIL_ERRSTR_CRITICAL_MSG_STAMP, ioloop_time);
7ef5ca6fb59a318c821a852ae48a2edbb671d7ddTimo Sirainenvoid mail_storage_set_critical(struct mail_storage *storage,
7662010b03ffe5f2a6ecf4b4eb220d1c65efea76Timo Sirainen const char *fmt, ...)
7d5d50dd9a8c2539d7025a69e39d34fca56daeafTimo Sirainen /* critical errors may contain sensitive data, so let user
7d5d50dd9a8c2539d7025a69e39d34fca56daeafTimo Sirainen see only "Internal error" with a timestamp to make it
7d5d50dd9a8c2539d7025a69e39d34fca56daeafTimo Sirainen easier to look from log files the actual error message. */
7d5d50dd9a8c2539d7025a69e39d34fca56daeafTimo Sirainenvoid mail_storage_copy_error(struct mail_storage *dest,
dd2df6a67f10792ce31a3666197c0b6885893a3aTimo Sirainen const char *str;
14175321ddb88619015866978c05a27786ca4814Timo Sirainen str = mail_storage_get_last_error(src, &error);
14175321ddb88619015866978c05a27786ca4814Timo Sirainenvoid mail_storage_copy_list_error(struct mail_storage *storage,
14175321ddb88619015866978c05a27786ca4814Timo Sirainen const char *str;
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen str = mailbox_list_get_last_error(list, &error);
439dd06aec3301e65d650f6dc1d4a1a00b356b4fTimo Sirainenvoid mailbox_set_index_error(struct mailbox *box)
c7acd38cd4ef76a0f4652f9ca659ea5e64458b52Timo Sirainen mail_storage_set_internal_error(box->storage);
c7acd38cd4ef76a0f4652f9ca659ea5e64458b52Timo Sirainenmail_storage_get_settings(struct mail_storage *storage)
c7acd38cd4ef76a0f4652f9ca659ea5e64458b52Timo Sirainenstruct mail_user *mail_storage_get_user(struct mail_storage *storage)
282a436a74d8835edb45cc019b1c916013013fd3Timo Sirainenvoid mail_storage_set_callbacks(struct mail_storage *storage,
282a436a74d8835edb45cc019b1c916013013fd3Timo Sirainenint mail_storage_purge(struct mail_storage *storage)
282a436a74d8835edb45cc019b1c916013013fd3Timo Sirainenconst char *mail_storage_get_last_error(struct mail_storage *storage,
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen /* We get here only in error situations, so we have to return some
7ef5ca6fb59a318c821a852ae48a2edbb671d7ddTimo Sirainen error. If storage->error is NONE, it means we forgot to set it at
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen some point.. */
01e606cda5192c4254c090624a0b2ca92da6da8eTimo Sirainen return storage->error_string != NULL ? storage->error_string :
01e606cda5192c4254c090624a0b2ca92da6da8eTimo Sirainen "BUG: Unknown internal error";
01e606cda5192c4254c090624a0b2ca92da6da8eTimo Sirainen /* This shouldn't happen.. */
032964c7cc6788188b63ae6270fc26cbd4a3ca26Timo Sirainenconst char *mailbox_get_last_error(struct mailbox *box,
032964c7cc6788188b63ae6270fc26cbd4a3ca26Timo Sirainen return mail_storage_get_last_error(box->storage, error_r);
12a3540693ab69ec622e04d1b3b66962b8b2a3d9Timo Sirainenenum mail_error mailbox_get_last_mail_error(struct mailbox *box)
12a3540693ab69ec622e04d1b3b66962b8b2a3d9Timo Sirainen mail_storage_get_last_error(box->storage, &error);
12a3540693ab69ec622e04d1b3b66962b8b2a3d9Timo Sirainenvoid mail_storage_last_error_push(struct mail_storage *storage)
12a3540693ab69ec622e04d1b3b66962b8b2a3d9Timo Sirainen err = array_append_space(&storage->error_stack);
12a3540693ab69ec622e04d1b3b66962b8b2a3d9Timo Sirainen err->error_string = i_strdup(storage->error_string);
12a3540693ab69ec622e04d1b3b66962b8b2a3d9Timo Sirainenvoid mail_storage_last_error_pop(struct mail_storage *storage)
12a3540693ab69ec622e04d1b3b66962b8b2a3d9Timo Sirainen unsigned int count = array_count(&storage->error_stack);
5df8396a7cbad0b38b83a86667fb3d4c223f6f7cTimo Sirainen array_delete(&storage->error_stack, count-1, 1);
01f4ee4a0243f3fe9af763e1a540cd5cff0d63f5Timo Sirainenbool mail_storage_is_mailbox_file(struct mail_storage *storage)
9db5ade1c16c7f67c51004f28c28ea335755d3f0Timo Sirainen MAIL_STORAGE_CLASS_FLAG_MAILBOX_IS_FILE) != 0;
9db5ade1c16c7f67c51004f28c28ea335755d3f0Timo Sirainenbool mail_storage_set_error_from_errno(struct mail_storage *storage)
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen if (!mail_error_from_errno(&error, &error_string))
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen if (storage->set->mail_debug && error != MAIL_ERROR_NOTFOUND) {
01f4ee4a0243f3fe9af763e1a540cd5cff0d63f5Timo Sirainen /* debugging is enabled - admin may be debugging a
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen (permission) problem, so return FALSE to get the caller to
01f4ee4a0243f3fe9af763e1a540cd5cff0d63f5Timo Sirainen log the full error message. */
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainen mail_storage_set_error(storage, error, error_string);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenmailbox_settings_find(struct mail_namespace *ns, const char *vname)
9511a40d933181045343110c8101b75887062aaeTimo Sirainen strncmp(ns->prefix, vname, ns->prefix_len-1) == 0) {
01e606cda5192c4254c090624a0b2ca92da6da8eTimo Sirainen if (vname[ns->prefix_len-1] == mail_namespace_get_sep(ns))
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* namespace prefix itself */
4b9f99761df5014c659cd87fddaf6854af428cfcTimo Sirainenstruct mailbox *mailbox_alloc(struct mailbox_list *list, const char *vname,
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen /* make sure INBOX shows up in uppercase everywhere. do this
252db51b6c0a605163326b3ea5d09e9936ca3b29Timo Sirainen regardless of whether we're in inbox=yes namespace, because
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen clients expect INBOX to be case insensitive regardless of
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen server's internal configuration. */
0c1835a90dd1dcedaeaedd1cd91672299cbeb5beTimo Sirainen else if (vname[5] != mail_namespace_get_sep(list->ns))
0c1835a90dd1dcedaeaedd1cd91672299cbeb5beTimo Sirainen /* not INBOX prefix */ ;
0c1835a90dd1dcedaeaedd1cd91672299cbeb5beTimo Sirainen else if (strncasecmp(list->ns->prefix, vname, 6) == 0 &&
0c1835a90dd1dcedaeaedd1cd91672299cbeb5beTimo Sirainen "Invalid server configuration: "
0c1835a90dd1dcedaeaedd1cd91672299cbeb5beTimo Sirainen "Namespace prefix=%s must be uppercase INBOX",
0c1835a90dd1dcedaeaedd1cd91672299cbeb5beTimo Sirainen vname = t_strconcat("INBOX", vname + 5, NULL);
T_BEGIN {
if (open_error != 0)
} T_END;
return box;
const char *vname;
&metadata) < 0) {
return box;
return box;
return TRUE;
const char *errstr;
MAILBOX_SET_AUTO_SUBSCRIBE) == 0) {
int ret;
return ret;
const char **error_r)
if (prev_sep) {
return FALSE;
if (prev_sep && i > 0) {
return FALSE;
return TRUE;
vname++;
const char *path;
&path) < 0)
return TRUE;
return FALSE;
const char *name;
name++;
const char *name)
NAMESPACE_FLAG_LIST_CHILDREN)) == 0)
return TRUE;
return FALSE;
case MAIL_ERROR_NOTFOUND:
int ret;
case MAIL_ERROR_NOTFOUND:
MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0) {
T_BEGIN {
} T_END;
} T_END;
if (ret < 0) {
return FALSE;
return FALSE;
return FALSE;
if (ret < 0)
return FALSE;
return TRUE;
const char *index_dir;
int ret;
&index_dir);
if (ret <= 0)
int ret;
return ret;
const char *name1;
return FALSE;
return TRUE;
bool directory)
int ret;
if (ret == 0) {
return ret;
int ret;
return ret;
int ret;
if (ret < 0)
if (del)
if (ret < 0)
int ret;
return ret;
int ret;
return ret;
const char **error_r)
return TRUE;
return FALSE;
return FALSE;
return TRUE;
const char **error_r)
return FALSE;
return FALSE;
return FALSE;
return TRUE;
int ret = 0;
return ret;
struct mail_namespace *
return FALSE;
i_unreached();
struct mailbox_sync_context *
T_BEGIN {
} T_END;
return ctx;
const char *errormsg;
int ret;
if (ret == 0)
return ret;
struct mail_search_context *
int ret;
return ret;
bool tryagain;
if (!tryagain)
return FALSE;
return TRUE;
return FALSE;
return TRUE;
int ret;
if (ret < 0)
return ret;
struct mailbox_transaction_context *
return trans;
int ret;
return ret;
int ret;
T_BEGIN {
} T_END;
return ret;
struct mailbox *
return t->box;
struct mail_save_context *
T_BEGIN {
} T_END;
return ctx;
const char *const *keywords_list;
const char *envelope)
unsigned int order)
int ret;
} else T_BEGIN {
} T_END;
if (ret < 0) {
int ret;
T_BEGIN {
} T_END;
return ret;
int ret;
T_BEGIN {
} T_END;
if (pvt_flags != 0)
t->save_count++;
return ret;
T_BEGIN {
} T_END;
struct mailbox_transaction_context *
int ret;
T_BEGIN {
} T_END;
if (ret == 0) {
if (pvt_flags != 0)
t->save_count++;
return ret;
int ret;
return ret;
const char **path_r)
int ret;
if (ret < 0) {
return ret;
int *fd_r)
int fd;
const char *root_dir;
int ret;
return ret;
&mail_dir) < 0)
unsigned int secs)
#ifndef MMAP_CONFLICTS_WRITE
return index_flags;
bool *utc_r)
unsigned int secs;
const char *error;