mailbox-list.c revision ff26037994e5d77049aba7434dbe138f6474504c
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2006-2009 Dovecot authors, see the included COPYING file */
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainen/* 20 * (200+1) < 4096 which is the standard PATH_MAX. Having these settings
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen prevents malicious user from creating eg. "a/a/a/.../a" mailbox name and
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen then start renaming them to larger names from end to beginning, which
22535a9e685e29214082878e37a267157044618eTimo Sirainen eventually would start causing the failures when trying to use too
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen long mailbox names. */
b42f37ae6f65ed986315b6885568d32115e589b1Timo Sirainen struct mailbox_list_iterate_context *backend_ctx;
9ed2951bd0bb1878a27437d7c00611b2baadd614Timo Sirainenstruct mailbox_list_module_register mailbox_list_module_register = { 0 };
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainenvoid (*hook_mailbox_list_created)(struct mailbox_list *list);
04052d7cacaa866a3f00afb4e104fa46c04c1dd7Timo Sirainenstatic ARRAY_DEFINE(mailbox_list_drivers, const struct mailbox_list *);
b42f37ae6f65ed986315b6885568d32115e589b1Timo Sirainenstatic bool mailbox_list_driver_find(const char *name, unsigned int *idx_r)
f3d506e525a720f214020ca0f989a1966b30edaeTimo Sirainen unsigned int i, count;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen drivers = array_get(&mailbox_list_drivers, &count);
3b94ff5951db4d4eddb7a80ed4e3f61207202635Timo Sirainen for (i = 0; i < count; i++) {
66d2db642fe24d555d113ba463e446b038d476efTimo Sirainen if (strcasecmp(drivers[i]->name, name) == 0) {
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainenvoid mailbox_list_register(const struct mailbox_list *list)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen unsigned int idx;
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen if (mailbox_list_driver_find(list->name, &idx)) {
e48d89622047bd8bbd0475b881ca9377d592f535Timo Sirainen i_fatal("mailbox_list_register(%s): duplicate driver",
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen array_append(&mailbox_list_drivers, &list, 1);
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainenvoid mailbox_list_unregister(const struct mailbox_list *list)
be5c76fabc7439fd33bc799bc3ab3f570799977bTimo Sirainen unsigned int idx;
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen if (!mailbox_list_driver_find(list->name, &idx)) {
43a66a0b16299bd4f7615acd85e98bd3832c54d5Timo Sirainen i_fatal("mailbox_list_unregister(%s): unknown driver",
const char **error_r)
unsigned int idx;
driver);
const char **path_r)
const char **error_r)
tmp++;
value++;
struct mail_namespace *
return mode;
struct mail_user *
const char *path;
path);
const char *name,
const char *pattern)
const char *name)
const char *name)
int ret;
T_BEGIN {
} T_END;
return pattern;
const char *name,
struct mailbox_list_iterate_context *
struct mailbox_list_iterate_context *
const char *const *patterns,
static const struct mailbox_info *
return info;
int ret;
return ret;
struct mailbox_list_iterate_context *
const char *const *patterns,
unsigned int i, count;
for (i = 0; i < count; i++)
const struct mailbox_info *
return info;
const char *name)
const char *name)
if (created) {
if (create_flags != 0)
if (p == NULL)
const char *name)
T_BEGIN {
} T_END;
return TRUE;
levels++;
level_len = 0;
level_len++;
return TRUE;
return TRUE;
return FALSE;
#ifdef HAVE_DIRENT_D_TYPE
switch (d->d_type) {
case DT_UNKNOWN:
case DT_REG:
case DT_DIR:
case DT_LNK:
return type;
const char **name)
return FALSE;
return TRUE;
return FALSE;
return TRUE;
return TRUE;
return FALSE;
const char *error_string;
return FALSE;
return TRUE;