mailbox-list.c revision 15bfe73fb3988bb80e6afe6a60b9a715c7207600
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainen/* Copyright (c) 2006-2014 Dovecot authors, see the included COPYING file */
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainen/* 20 * (200+1) < 4096 which is the standard PATH_MAX. Having these settings
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainen prevents malicious user from creating eg. "a/a/a/.../a" mailbox name and
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainen then start renaming them to larger names from end to beginning, which
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainen eventually would start causing the failures when trying to use too
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainen long mailbox names. */
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainenstruct mailbox_list_module_register mailbox_list_module_register = { 0 };
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainenstatic ARRAY(const struct mailbox_list *) mailbox_list_drivers;
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainenstatic bool mailbox_list_driver_find(const char *name, unsigned int *idx_r)
74ab5ea66c0c4b388f1c774ae6a47ab94f1b4f18Timo Sirainen unsigned int i, count;
a3fc085ffb855d7b5e1dba611254a0db3f8c429dTimo Sirainen drivers = array_get(&mailbox_list_drivers, &count);
a3fc085ffb855d7b5e1dba611254a0db3f8c429dTimo Sirainen for (i = 0; i < count; i++) {
a3fc085ffb855d7b5e1dba611254a0db3f8c429dTimo Sirainen if (strcasecmp(drivers[i]->name, name) == 0) {
unsigned int idx;
unsigned int idx;
const struct mailbox_list *
unsigned int idx;
return NULL;
return *class_p;
unsigned int idx;
if (!expand_home) {
args++;
args++;
args++;
return str;
bool expand_home,
const char **error_r)
value++;
const char **error_r)
location++;
location++;
if (p == NULL)
return path;
unsigned int len;
return FALSE;
vname++;
(dirstart &&
unsigned char chr;
char *ret, *p;
if (*p == src)
*p = dest;
return ret;
const char *vname)
return storage_name;
return storage_name;
return ret;
const char *vname)
unsigned int num;
(unsigned char)*vname);
const char *storage_name)
return vname;
for (i = 0; i < name_len; i++) {
return vname;
const struct mailbox_list_settings *
struct mail_namespace *
return mode;
struct mail_user *
data++;
const char *name,
&path) < 0)
&path);
path);
if (p == NULL) {
const char *expanded_full)
const char *ret;
slash_count++;
slash2_count++;
if (slash_count == 0)
slash_count--;
if (slash_count != 0)
if (slash2_count == 0)
slash2_count--;
if (slash2_count != 0)
return ret;
const char **error_r)
i_unreached();
} else if (p == NULL) {
if (p == unexpanded)
i_unreached();
if (!home) {
const char **error_r)
i_unreached();
const char *error;
const char **error_r)
return TRUE;
return FALSE;
return FALSE;
T_BEGIN {
const char *const *names;
const char *n = *names;
if (!allow_internal_dirs &&
} T_END;
return ret;
return TRUE;
return FALSE;
const char **path_r)
int ret;
return ret;
const char **path_r)
int ret;
i_unreached();
if (ret == 0)
return ret > 0;
const char *path;
i_unreached();
return path;
const char **path_r)
switch (type) {
return pattern;
const char *pattern;
int ret;
return ret;
unsigned int len;
*flags_r = 0;
int ret;
if (ret < 0) {
switch (existence) {
case MAILBOX_EXISTENCE_NONE:
case MAILBOX_EXISTENCE_SELECT:
const char *vname;
i_unreached();
fname++;
&inbox) <= 0)
i_unreached();
flags_r);
const char *path;
return TRUE;
return FALSE;
return TRUE;
int ret;
&index_dir);
if (ret <= 0)
return ret;
&root_dir);
if (ret <= 0)
return ret;
int ret;
return ret;
const char *error;
const char *error;
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 *dir_path,
const struct dirent *d)
int ret;
T_BEGIN {
ret = 0;
} T_END;
return ret;
return FALSE;
return FALSE;
return TRUE;
const char **name)
unsigned int len;
return FALSE;
return FALSE;
return FALSE;
&path) <= 0)
return FALSE;
return FALSE;
return TRUE;
const char *str;
const char *error_string;
return FALSE;
return TRUE;