This commit changes the Maildir INBOX default path when namespace_inbox=no.
Now the behavior is the same as with namespace_inbox=yes, i.e. INBOX is
created for Maildir/ root directory instead of Maildir/.INBOX/. Preserving
the original behavior would have been rather complex, and it likely doesn't
matter much, since INBOX isn't normally created for non-inbox namespaces
anyway. The original behavior can still be preserved by explicitly setting
mail_inbox_path= (to empty value) for the namespace_inbox=no namespaces.
static const struct setting_keyvalue maildir_default_filter_settings_keyvalue[] = {
{ "maildir/mailbox_list_layout", "maildir++" },
+ /* Use Maildir/ root as the INBOX, not Maildir/.INBOX/ */
+ { "maildir/layout_maildir++/mail_inbox_path", "." },
+ { "maildir/layout_fs/mail_inbox_path", "." },
{ NULL, NULL }
};
mailbox_list_get_temp_prefix(list));
if (list->mail_set->mail_control_path[0] == '\0' &&
- list->set.inbox_path == NULL &&
+ list->mail_set->mail_inbox_path[0] == '\0' &&
(ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
/* put the temp files into tmp/ directory preferably */
storage->temp_prefix = p_strconcat(_storage->pool, "tmp/",
index_storage_destroy(_storage);
}
-static void
-maildir_storage_get_list_settings(const struct mail_namespace *ns,
- struct mailbox_list_settings *set,
- const struct mail_storage_settings *mail_set)
-{
- if (set->inbox_path == NULL &&
- mail_set->mailbox_directory_name[0] == '\0' &&
- (strcmp(mail_set->mailbox_list_layout, MAILBOX_LIST_NAME_MAILDIRPLUSPLUS) == 0 ||
- strcmp(mail_set->mailbox_list_layout, MAILBOX_LIST_NAME_FS) == 0) &&
- (ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0) {
- /* Maildir++ INBOX is the Maildir base itself */
- set->inbox_path = set->root_dir;
- }
-}
-
static const char *
maildir_storage_find_root_dir(const struct mail_namespace *ns)
{
maildir_storage_create,
maildir_storage_destroy,
maildir_storage_add_list,
- maildir_storage_get_list_settings,
+ NULL,
maildir_storage_autodetect,
maildir_mailbox_alloc,
NULL,
static const struct setting_keyvalue mbox_default_filter_settings_keyvalue[] = {
{ "mbox/mailbox_subscriptions_filename", ".subscriptions" },
+ /* Use $mail_path/inbox as the INBOX, not $mail_path/INBOX */
+ { "mbox/layout_fs/mail_inbox_path", "inbox" },
{ NULL, NULL }
};
index_storage_destroy(_storage);
}
-static void
-mbox_storage_get_list_settings(const struct mail_namespace *ns,
- struct mailbox_list_settings *set,
- const struct mail_storage_settings *mail_set)
-{
- struct event *event = ns->user->event;
-
- if (set->inbox_path == NULL &&
- strcasecmp(mail_set->mailbox_list_layout, MAILBOX_LIST_NAME_FS) == 0) {
- set->inbox_path = t_strconcat(set->root_dir, "/inbox", NULL);
- e_debug(event, "mbox: INBOX defaulted to %s", set->inbox_path);
- }
-}
-
static bool mbox_is_file(const char *path, const char *name, struct event *event)
{
struct stat st;
static bool
mbox_storage_autodetect(const struct mail_namespace *ns,
struct mailbox_list_settings *set,
- const struct mail_storage_settings *mail_set ATTR_UNUSED,
+ const struct mail_storage_settings *mail_set,
const char **root_path_r, const char **inbox_path_r)
{
struct event *event = ns->user->event;
const char *root_dir, *inbox_path;
root_dir = set->root_dir;
- inbox_path = set->inbox_path;
+ inbox_path = mail_set->mail_inbox_path;
if (root_dir != NULL) {
if (inbox_path == NULL &&
mbox_storage_create,
mbox_storage_destroy,
mbox_storage_add_list,
- mbox_storage_get_list_settings,
+ NULL,
mbox_storage_autodetect,
mbox_mailbox_alloc,
NULL,
if (type == MAILBOX_LIST_PATH_TYPE_ALT_DIR ||
type == MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX) {
/* don't use inbox_path */
- } else if (strcmp(name, "INBOX") == 0 && set->inbox_path != NULL) {
+ } else if (strcmp(name, "INBOX") == 0 &&
+ mail_set->mail_inbox_path[0] != '\0') {
/* If INBOX is a file, index and control directories are
located in root directory. */
if ((_list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) == 0 ||
type == MAILBOX_LIST_PATH_TYPE_MAILBOX ||
type == MAILBOX_LIST_PATH_TYPE_DIR) {
- *path_r = set->inbox_path;
+ *path_r = mail_set->mail_inbox_path;
return 1;
}
}
if (type == MAILBOX_LIST_PATH_TYPE_ALT_DIR ||
type == MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX) {
/* don't use inbox_path */
- } else if (strcmp(name, "INBOX") == 0 && _list->set.inbox_path != NULL) {
- *path_r = _list->set.inbox_path;
+ } else if (strcmp(name, "INBOX") == 0 &&
+ _list->mail_set->mail_inbox_path[0] != '\0') {
+ *path_r = _list->mail_set->mail_inbox_path;
return 1;
}
DEF(BOOL, mailbox_directory_name_legacy),
DEF(STR_HIDDEN, mailbox_root_directory_name),
DEF(STR_HIDDEN, mailbox_subscriptions_filename),
+ DEF(STR, mail_inbox_path),
DEF(STR, mail_index_path),
DEF(STR, mail_index_private_path),
DEF(STR_HIDDEN, mail_cache_path),
.mailbox_directory_name_legacy = TRUE,
.mailbox_root_directory_name = "",
.mailbox_subscriptions_filename = "subscriptions",
+ .mail_inbox_path = "",
.mail_index_path = "",
.mail_index_private_path = "",
.mail_cache_path = "",
return FALSE;
}
+ const char *mail_path = strchr(set->mail_location, ':');
+ if (mail_path != NULL)
+ mail_path = t_strcut(mail_path + 1, ':');
+ if (mail_path != NULL &&
+ set->mail_inbox_path[0] != '\0' && set->mail_inbox_path[0] != '/') {
+ /* Convert to absolute path */
+ if (strcmp(set->mail_inbox_path, ".") == 0)
+ set->mail_inbox_path = mail_path;
+ else {
+ set->mail_inbox_path = p_strdup_printf(pool, "%s/%s",
+ mail_path, set->mail_inbox_path);
+ }
+ }
+
if (!mail_storage_settings_check_namespaces(event, set, error_r))
return FALSE;
return TRUE;
OFFSET(mailbox_directory_name_legacy),
OFFSET(mailbox_root_directory_name),
OFFSET(mailbox_subscriptions_filename),
+ OFFSET(mail_inbox_path),
OFFSET(mail_index_path),
OFFSET(mail_index_private_path),
OFFSET(mail_cache_path),
bool mailbox_directory_name_legacy;
const char *mailbox_root_directory_name;
const char *mailbox_subscriptions_filename;
+ const char *mail_inbox_path;
const char *mail_index_path;
const char *mail_index_private_path;
const char *mail_cache_path;
static struct mail_storage *
mail_storage_autodetect(const struct mail_namespace *ns,
struct mailbox_list_settings *set,
- const struct mail_storage_settings *mail_set)
+ const struct mail_storage_settings *mail_set,
+ const char **inbox_path_override)
{
struct mail_storage *const *classes;
const char *root_path, *inbox_path = NULL;
if (classes[i]->v.autodetect(ns, set, mail_set,
&root_path, &inbox_path)) {
set->root_dir = root_path;
- if (inbox_path != NULL)
- set->inbox_path = inbox_path;
+ *inbox_path_override = inbox_path;
return classes[i];
}
}
mail_storage_get_class(struct mail_namespace *ns, const char *driver,
const struct mail_storage_settings *mail_set,
struct mailbox_list_settings *list_set,
- enum mail_storage_flags flags, const char **error_r)
+ enum mail_storage_flags flags,
+ const char **inbox_path_override, const char **error_r)
{
struct mail_storage *storage_class = NULL;
const char *home;
if (storage_class != NULL)
return storage_class;
- storage_class = mail_storage_autodetect(ns, list_set, mail_set);
+ storage_class = mail_storage_autodetect(ns, list_set, mail_set,
+ inbox_path_override);
if (storage_class != NULL)
return storage_class;
struct event *set_event,
enum mail_storage_flags flags,
struct mailbox_list_settings *list_set,
+ const char *inbox_path_override,
const char **error_r)
{
enum mailbox_list_flags list_flags = 0;
event_set_ptr(set_event, SETTINGS_EVENT_FILTER_NAME, layout_filter);
settings_free(mail_set);
+ if (inbox_path_override != NULL) {
+ mail_storage_create_ns_instance(ns, set_event);
+ settings_override(ns->_set_instance, "*/mail_inbox_path",
+ inbox_path_override,
+ SETTINGS_OVERRIDE_TYPE_CODE);
+ }
+
if (settings_get(set_event, &mail_storage_setting_parser_info, 0,
&mail_set, error_r) < 0) {
event_unref(&set_event);
const struct mail_storage_settings *mail_set;
struct mailbox_list_settings list_set;
const char *p, *data, *driver = NULL;
+ const char *inbox_path_override = NULL;
/* Lookup initial mailbox list settings. Once they're found, another
settings lookup is done with mailbox format as an additional
}
storage_class = mail_storage_get_class(ns, driver, mail_set, &list_set,
- flags, error_r);
+ flags, &inbox_path_override,
+ error_r);
settings_free(mail_set);
if (storage_class == NULL)
return -1;
if (ns->list == NULL) {
/* first storage for namespace */
if (mail_storage_create_list(ns, storage_class, set_event,
- flags, &list_set, error_r) < 0)
+ flags, &list_set,
+ inbox_path_override, error_r) < 0)
return -1;
if ((storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) == 0) {
if (mail_storage_create_root(ns->list, flags, error_r) < 0)
if (set->root_dir != NULL)
list->set.root_dir = p_strdup(list->pool, set->root_dir);
- list->set.inbox_path = p_strdup(list->pool, set->inbox_path);
-
if (list->v.init != NULL) {
if (list->v.init(list, error_r) < 0) {
list->v.deinit(list);
mail_set->mail_index_path,
mail_set->mail_index_private_path,
mail_set->mail_control_path,
- list->set.inbox_path == NULL ?
- "" : list->set.inbox_path,
+ mail_set->mail_inbox_path,
mail_set->mail_alt_path);
if ((flags & MAILBOX_LIST_FLAG_SECONDARY) == 0)
mail_namespace_finish_list_init(ns, list);
struct mailbox_list_settings *set_r,
const char **error_r)
{
- const char *const *tmp, *key, *value, **dest, *str, *error;
+ const char *const *tmp, *key, *value, *str, *error;
*error_r = NULL;
value++;
}
- if (strcmp(key, "INBOX") == 0)
- dest = &set_r->inbox_path;
- else {
- *error_r = t_strdup_printf("Unknown setting: %s", key);
- return -1;
- }
- if (fix_path(user, value, expand_home, dest, &error) < 0) {
- *error_r = t_strconcat(error, key, " in: ", data, NULL);
- return -1;
- }
+ *error_r = t_strdup_printf("Unknown setting: %s", key);
+ return -1;
}
return 0;
}
struct mailbox_list_settings {
const char *root_dir;
-
- const char *inbox_path;
};
struct mailbox_permissions {