[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-list.c,1.11,1.12 maildir-storage.c,1.24,1.25
cras at procontrol.fi
cras at procontrol.fi
Wed Feb 12 20:17:00 EET 2003
Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory danu:/tmp/cvs-serv30608/lib-storage/index/maildir
Modified Files:
maildir-list.c maildir-storage.c
Log Message:
Several fixes to mail_full_filesystem_access = yes handling
Index: maildir-list.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-list.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- maildir-list.c 11 Feb 2003 19:37:16 -0000 1.11
+++ maildir-list.c 12 Feb 2003 18:16:57 -0000 1.12
@@ -90,12 +90,15 @@
dir = storage->dir;
prefix = "";
} else {
- if (mask == p)
- dir = prefix = "/";
- else {
- dir = t_strdup_until(mask, p);
- prefix = t_strdup_until(mask, p+1);
+ p = strchr(p, storage->hierarchy_sep);
+ if (p == NULL) {
+ /* this isn't going to work */
+ mail_storage_set_error(storage, "Invalid list mask");
+ return FALSE;
}
+
+ dir = t_strdup_until(mask, p);
+ prefix = t_strdup_until(mask, p+1);
if (*mask != '/' && *mask != '~')
dir = t_strconcat(storage->dir, "/", dir, NULL);
Index: maildir-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- maildir-storage.c 22 Jan 2003 19:23:28 -0000 1.24
+++ maildir-storage.c 12 Feb 2003 18:16:58 -0000 1.25
@@ -1,6 +1,7 @@
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
+#include "home-expand.h"
#include "unlink-directory.h"
#include "subscription-file/subscription-file.h"
#include "maildir-index.h"
@@ -95,18 +96,48 @@
static int maildir_is_valid_name(struct mail_storage *storage, const char *name)
{
- return name[0] != '\0' && name[0] != storage->hierarchy_sep &&
- name[strlen(name)-1] != storage->hierarchy_sep &&
- strchr(name, '/') == NULL && strchr(name, '\\') == NULL &&
- strchr(name, '*') == NULL && strchr(name, '%') == NULL;
+ if (name[0] == '\0' || name[strlen(name)-1] == storage->hierarchy_sep ||
+ strchr(name, '*') != NULL || strchr(name, '%') != NULL)
+ return FALSE;
+
+ if (full_filesystem_access)
+ return TRUE;
+
+ return *name != '~' &&
+ strchr(name, '/') == NULL && strchr(name, '\\') == NULL;
+}
+
+static const char *maildir_get_absolute_path(const char *name)
+{
+ const char *p;
+
+ name = home_expand(name);
+
+ /* insert "/" if it's missing */
+ p = strchr(name, '.');
+ if (p == NULL || p[-1] == '/')
+ return name;
+ return t_strconcat(t_strdup_until(name, p), "/", p, NULL);
}
static const char *maildir_get_path(struct mail_storage *storage,
const char *name)
{
+ if (full_filesystem_access && (*name == '/' || *name == '~'))
+ return maildir_get_absolute_path(name);
+
return t_strconcat(storage->dir, "/.", name, NULL);
}
+static const char *maildir_get_index_path(struct mail_storage *storage,
+ const char *name)
+{
+ if (full_filesystem_access && (*name == '/' || *name == '~'))
+ return maildir_get_absolute_path(name);
+
+ return t_strconcat(storage->index_dir, "/.", name, NULL);
+}
+
/* create or fix maildir, ignore if it already exists */
static int create_maildir(const char *dir, int verify)
{
@@ -182,8 +213,8 @@
struct mail_index *index;
const char *path, *index_dir;
- path = t_strconcat(storage->dir, "/.", name, NULL);
- index_dir = t_strconcat(storage->index_dir, "/.", name, NULL);
+ path = maildir_get_path(storage, name);
+ index_dir = maildir_get_index_path(storage, name);
index = index_storage_lookup_ref(index_dir);
if (index == NULL) {
@@ -304,14 +335,15 @@
deleted. delete indexes before the actual maildir. this way we
never see partially deleted mailboxes. */
src = maildir_get_path(storage, name);
- dest = t_strconcat(storage->dir, "/..", name, NULL);
+ dest = maildir_get_path(storage, t_strconcat(".", name, NULL));
if (stat(src, &st) != 0 && errno == ENOENT) {
mail_storage_set_error(storage, "Mailbox doesn't exist: %s",
name);
return FALSE;
}
- if (strcmp(storage->index_dir, storage->dir) != 0) {
+ if (strcmp(storage->index_dir, storage->dir) != 0 &&
+ *name != '/' && *name != '~') {
index_dir = t_strconcat(storage->index_dir, "/.", name, NULL);
if (unlink_directory(index_dir, TRUE) < 0) {
mail_storage_set_critical(storage,
More information about the dovecot-cvs
mailing list