mail-namespace.c revision b4277135f30f053a32d292a945ad452bfcbaa68d
/* Copyright (c) 2005-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "file-lock.h"
#include "settings-parser.h"
#include "mailbox-list-private.h"
#include "mail-storage-private.h"
#include "mail-storage-settings.h"
#include "mail-namespace.h"
#include <stdlib.h>
static struct mail_namespace_settings prefixless_ns_unexpanded_set = {
.name = "",
.type = "private",
.separator = "",
.prefix = "0",
.location = "0fail::LAYOUT=none",
.list = "no",
.subscriptions = FALSE,
};
static struct mail_namespace_settings prefixless_ns_set;
struct mail_storage *storage)
{
}
struct mailbox_list *list)
{
}
{
struct mail_storage **storagep;
}
}
static bool
{
struct mailbox_settings *const *box_set;
return FALSE;
return TRUE;
}
return FALSE;
}
struct mail_namespace_settings *ns_set,
struct mail_namespace_settings *unexpanded_ns_set,
{
const struct mail_storage_settings *mail_set =
struct mail_namespace *ns;
else {
return -1;
}
return -1;
}
}
if (ns_set->subscriptions)
if (ns_set == &prefixless_ns_set) {
/* autocreated prefix="" namespace */
}
if (mail_set->mail_debug) {
i_debug("Namespace %s: type=%s, prefix=%s, sep=%s, "
"inbox=%s, hidden=%s, list=%s, subscriptions=%s "
"location=%s",
}
/* dynamic shared namespace. the above check catches wrong
mixed %% usage, but still allows for specifying a shared
namespace to an explicit location without any %% */
} else {
}
return -1;
}
return 0;
}
const char **error_r)
{
"Namespace %s can't have alias_for=%s "
"to a different storage type (%s vs %s)",
return FALSE;
}
"Namespace %s can't have alias_for=%s "
"to a different storage (different root dirs)",
return FALSE;
}
return TRUE;
}
static int
struct mail_namespace *all_namespaces,
const char **error_r)
{
return -1;
}
return -1;
}
return -1;
/* copy inbox=yes */
}
}
return 0;
}
static bool
{
unsigned int subscriptions_count = 0;
bool visible_namespaces = FALSE;
"Duplicate namespace prefix: \"%s\"",
return FALSE;
}
/* check the inbox=yes status before alias_for changes it */
*error_r = "There can be only one namespace with "
"inbox=yes";
return FALSE;
}
}
return FALSE;
NAMESPACE_FLAG_LIST_CHILDREN)) != 0 &&
"list=yes requires prefix=%s "
return FALSE;
}
NAMESPACE_FLAG_LIST_CHILDREN)) != 0 &&
"list=yes requires prefix=%s "
return FALSE;
}
NAMESPACE_FLAG_LIST_CHILDREN)) != 0) {
if (list_sep == '\0')
*error_r = "All list=yes namespaces must use "
"the same separator";
return FALSE;
}
}
}
*error_r = "inbox=yes namespace missing";
return FALSE;
}
if (list_sep == '\0') {
*error_r = "list=yes namespace missing";
return FALSE;
}
if (!visible_namespaces) {
*error_r = "hidden=no namespace missing";
return FALSE;
}
if (subscriptions_count == 0) {
*error_r = "subscriptions=yes namespace missing";
return FALSE;
}
return TRUE;
}
const char **error_r)
{
struct mail_namespace *ns;
bool prefixless_found = FALSE;
if (ns->prefix_len == 0)
}
if (!prefixless_found) {
/* a pretty evil way to expand the values */
i_unreached();
namespaces = ns;
}
while (namespaces != NULL) {
ns = namespaces;
}
return -1;
}
T_BEGIN {
} T_END;
return 0;
}
{
const struct mail_storage_settings *mail_set;
struct mail_namespace_settings *const *ns_set;
struct mail_namespace_settings *const *unexpanded_ns_set;
} else {
count = 0;
}
for (i = 0; i < count; i++) {
continue;
if (!ns_set[i]->ignore_on_failure) {
return -1;
}
if (mail_set->mail_debug) {
i_debug("Skipping namespace %s: %s",
}
} else {
}
}
if (namespaces != NULL)
/* no namespaces defined, create a default one */
}
const char **error_r)
{
struct mail_namespace *ns;
const struct mail_storage_settings *mail_set;
bool default_location = FALSE;
/* enums must be changed */
location_source = "mail_location parameter";
location_source = "mail_location setting";
} else {
location_source = "environment MAIL";
}
/* support also maildir-specific environment */
else {
driver = "maildir";
location_source = "environment MAILDIR";
}
}
if (default_location) {
/* treat this the same as if a namespace was created with
default settings. dsync relies on finding a namespace
without explicit location setting. */
} else {
}
"Initializing mail storage from %s "
} else {
"autodetection failed: %s", error);
}
return -1;
}
T_BEGIN {
} T_END;
return 0;
}
{
struct mail_namespace *ns;
return ns;
}
{
/* update *_namespaces as needed, instead of immediately setting it
to NULL. for example mdbox_storage.destroy() wants to go through
user's namespaces. */
while (*_namespaces != NULL) {
ns = *_namespaces;
*_namespaces = next;
}
}
struct mail_storage_callbacks *callbacks,
void *context)
{
struct mail_namespace *ns;
struct mail_storage *const *storagep;
}
}
{
}
{
return;
}
{
struct mail_namespace **nsp;
/* remove from user's namespaces list */
break;
}
}
}
struct mail_storage *
{
}
{
}
{
return mail_namespace_get_sep(namespaces);
}
{
/* true exact prefix match */
return TRUE;
}
/* we already checked that mailbox begins with case-insensitive
INBOX. this namespace also begins with INBOX and the rest
of the prefix matches too. */
return TRUE;
}
/* we're trying to access the namespace prefix itself */
return TRUE;
}
return FALSE;
}
static struct mail_namespace *
enum namespace_flags flags,
enum namespace_flags mask)
{
unsigned int best_len = 0;
bool inbox;
/* find the INBOX namespace */
return ns;
}
return best;
}
}
}
return best;
}
static struct mail_namespace *
{
struct mail_storage *storage;
return ns;
return mailbox_list_get_namespace(list);
}
struct mail_namespace *
{
struct mail_namespace *ns;
if (mail_namespace_is_shared_user_root(ns)) {
/* see if we need to autocreate a namespace for shared user */
}
return ns;
}
struct mail_namespace *
const char **mailbox)
{
struct mail_namespace *ns;
const char *storage_name;
}
return ns;
}
struct mail_namespace *
const char *mailbox)
{
}
struct mail_namespace *
const char *mailbox)
{
}
struct mail_namespace *
const char *mailbox)
{
}
struct mail_namespace *
{
return namespaces;
}
struct mail_namespace *
const char *prefix)
{
struct mail_namespace *ns;
return ns;
}
return NULL;
}
struct mail_namespace *
const char *prefix)
{
struct mail_namespace *ns;
return ns;
}
return NULL;
}
{
struct mail_storage *const *storagep;
return FALSE;
/* child of the shared root */
return FALSE;
}
/* if we have driver=shared storage, we're a real shared root */
return TRUE;
}
return FALSE;
}