mailbox-list.c revision c58906589cafc32df4c04ffbef933baadd3f2276
/* Copyright (C) 2006-2007 Timo Sirainen */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "mkdir-parents.h"
#include "unlink-directory.h"
#include "mailbox-list-private.h"
#include <time.h>
#include <dirent.h>
/* 20 * (200+1) < 4096 which is the standard PATH_MAX. Having these settings
prevents malicious user from creating eg. "a/a/a/.../a" mailbox name and
then start renaming them to larger names from end to beginning, which
eventually would start causing the failures when trying to use too
long mailbox names. */
#define MAILBOX_MAX_HIERARCHY_LEVELS 20
#define MAILBOX_MAX_HIERARCHY_NAME_LENGTH 200
/* Message to show to users when critical error occurs */
#define CRITICAL_MSG \
"Internal error occurred. Refer to server log for more information."
struct mailbox_list_module_register mailbox_list_module_register = { 0 };
{
const struct mailbox_list *const *drivers;
unsigned int i, count;
for (i = 0; i < count; i++) {
*idx_r = i;
return TRUE;
}
}
return FALSE;
}
{
if (!array_is_created(&mailbox_list_drivers))
else {
unsigned int idx;
i_fatal("mailbox_list_register(%s): duplicate driver",
}
}
}
{
unsigned int idx;
i_fatal("mailbox_list_unregister(%s): unknown driver",
}
if (array_count(&mailbox_list_drivers) == 0)
}
const struct mailbox_list_settings *set,
enum mailbox_list_flags flags,
{
const struct mailbox_list *const *class_p;
struct mailbox_list *list;
unsigned int idx;
*error_r = "Unknown mailbox list driver";
return -1;
}
/* copy settings */
}
}
if ((flags & MAILBOX_LIST_FLAG_DEBUG) != 0) {
i_info("%s: root=%s, index=%s, control=%s, inbox=%s",
}
if (hook_mailbox_list_created != NULL)
return 0;
}
{
}
{
}
{
return list->hierarchy_sep;
}
{
}
{
}
{
}
const char *name)
{
}
const char *name)
{
}
enum mailbox_list_path_type type)
{
}
{
}
{
/* the default implementation: */
if (*ref != '\0') {
/* merge reference and mask */
}
return mask;
}
const char *name,
enum mailbox_name_status *status)
{
return 0;
}
}
struct mailbox_list_iterate_context *
enum mailbox_list_iter_flags flags)
{
}
struct mailbox_info *
{
}
{
}
{
}
{
return -1;
}
return -1;
}
}
{
return -1;
}
}
const char *name)
{
/* delete the index directory first, so that if we crash we don't
leave indexes for deleted mailboxes lying around */
"unlink_directory(%s) failed: %m", index_dir);
return -1;
}
}
/* control directory next */
"unlink_directory(%s) failed: %m", dir);
return -1;
}
}
return 0;
}
{
return TRUE;
levels++;
level_len = 0;
} else {
level_len++;
}
}
return TRUE;
return TRUE;
return FALSE;
}
{
enum mailbox_list_file_type type;
#ifdef HAVE_DIRENT_D_TYPE
switch (d->d_type) {
case DT_UNKNOWN:
break;
case DT_REG:
break;
case DT_DIR:
break;
case DT_LNK:
break;
default:
break;
}
#else
#endif
return type;
}
bool *temporary_error_r)
{
}
{
}
{
}
{
char str[256];
}
{
/* critical errors may contain sensitive data, so let user
see only "Internal error" with a timestamp to make it
easier to look from log files the actual error message. */
}