maildir-storage.c revision 406a92a344f789e6ec763104b03de3f0b8fcfdb7
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen/* Copyright (C) 2002 Timo Sirainen */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "subscription-file/subscription-file.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define CREATE_MODE 0770 /* umask() should limit it more */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic const char *maildirs[] = { "cur", "new", "tmp", NULL };
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic struct mail_storage *maildir_create(const char *data, const char *user)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char *home, *path, *root_dir, *index_dir, *control_dir, *p;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* we'll need to figure out the maildir location ourself.
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen it's either root dir if we've already chroot()ed, or
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen $HOME/Maildir otherwise */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen /* <Maildir> [:INDEX=<dir>] [:CONTROL=<dir>] */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen } while (p != NULL);
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen memcpy(storage, &maildir_storage, sizeof(struct mail_storage));
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen storage->callbacks = i_new(struct mail_storage_callbacks, 1);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic void maildir_free(struct mail_storage *storage)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int maildir_autodetect(const char *data)
b9f564d00b7a115f465ffd6840341c7b8f9bfc8aTimo Sirainen return stat(t_strconcat(data, "/cur", NULL), &st) == 0 &&
c3d9da3955043aef88c17b71f2081e894186aa6bTimo Sirainenstatic int maildir_is_valid_create_name(struct mail_storage *storage,
c3d9da3955043aef88c17b71f2081e894186aa6bTimo Sirainen if (name[0] == '\0' || name[strlen(name)-1] == storage->hierarchy_sep ||
c3d9da3955043aef88c17b71f2081e894186aa6bTimo Sirainen strchr(name, '*') != NULL || strchr(name, '%') != NULL)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen strchr(name, '/') == NULL && strchr(name, '\\') == NULL;
1f19649986397419d014febd1337c6eb7b530f26Timo Sirainenstatic int maildir_is_valid_existing_name(const char *name)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen strchr(name, '/') == NULL && strchr(name, '\\') == NULL;
1f19649986397419d014febd1337c6eb7b530f26Timo Sirainenstatic const char *maildir_get_absolute_path(const char *name)
1f19649986397419d014febd1337c6eb7b530f26Timo Sirainen const char *p;
1f19649986397419d014febd1337c6eb7b530f26Timo Sirainen /* insert "/" if it's missing */
1f19649986397419d014febd1337c6eb7b530f26Timo Sirainen return t_strconcat(t_strdup_until(name, p), "/", p, NULL);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenconst char *maildir_get_path(struct mail_storage *storage, const char *name)
7cd7bd65aba6d84f4e4f5066d248437eaa4e5e54Timo Sirainen if (full_filesystem_access && (*name == '/' || *name == '~'))
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen return t_strconcat(storage->dir, "/.", name, NULL);
de62ce819d59a529530da4b57be1b8d6dad13d6bTimo Sirainenstatic const char *maildir_get_index_path(struct mail_storage *storage,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (full_filesystem_access && (*name == '/' || *name == '~'))
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen return t_strconcat(storage->index_dir, "/.", name, NULL);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic const char *maildir_get_control_path(struct mail_storage *storage,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (full_filesystem_access && (*name == '/' || *name == '~'))
if (verify) {
return TRUE;
return FALSE;
return FALSE;
return TRUE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return TRUE;
const char *dir;
return TRUE;
return TRUE;
return FALSE;
return TRUE;
const char *dir;
return TRUE;
return FALSE;
return TRUE;
const char *inbox;
return FALSE;
return FALSE;
static struct mailbox *
const char *name)
return name;
static struct mailbox *
const char *path;
return NULL;
return FALSE;
return FALSE;
name);
return NULL;
return NULL;
const char *path;
return FALSE;
if (only_hierarchy) {
return TRUE;
return FALSE;
return TRUE;
const char *name)
int count;
return FALSE;
return FALSE;
name);
return FALSE;
return FALSE;
count = 0;
return FALSE;
return FALSE;
count++;
return TRUE;
return TRUE;
return FALSE;
return TRUE;
ret = 0;
t_push();
t_pop();
t_pop();
return ret;
return FALSE;
return FALSE;
if (ret < 0)
return FALSE;
return FALSE;
return TRUE;
return FALSE;
return FALSE;
const char *name,
const char *path;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return FALSE;
unsigned int min_newmail_notify_interval)
NULL,
NULL,
NULL,
NULL,
NULL,