From dae702b7ff81cf38291d4f2cb49334bfaf5cc1ba Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 1 Jul 2003 21:14:18 +0300 Subject: [PATCH] mail_full_filesystem_access = yes fixes --HG-- branch : HEAD --- src/lib-storage/index/maildir/maildir-list.c | 15 +++-------- .../index/maildir/maildir-storage.c | 27 ++++++++++++------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/lib-storage/index/maildir/maildir-list.c b/src/lib-storage/index/maildir/maildir-list.c index c2cdca2281..ab2bfac333 100644 --- a/src/lib-storage/index/maildir/maildir-list.c +++ b/src/lib-storage/index/maildir/maildir-list.c @@ -80,14 +80,6 @@ maildir_list_mailbox_init(struct mail_storage *storage, ctx->dir = storage->dir; ctx->prefix = ""; } else { - p = strchr(p, storage->hierarchy_sep); - if (p == NULL) { - /* this isn't going to work */ - mail_storage_set_error(storage, "Invalid list mask"); - pool_unref(pool); - return FALSE; - } - dir = t_strdup_until(mask, p); ctx->prefix = t_strdup_until(mask, p+1); @@ -97,7 +89,7 @@ maildir_list_mailbox_init(struct mail_storage *storage, } ctx->dirp = opendir(ctx->dir); - if (ctx->dirp == NULL) { + if (ctx->dirp == NULL && errno != ENOENT) { mail_storage_set_critical(storage, "opendir(%s) failed: %m", ctx->dir); pool_unref(pool); @@ -246,8 +238,9 @@ static struct mailbox_list *maildir_list_next(struct mailbox_list_context *ctx) MAILBOX_PLACEHOLDER | MAILBOX_CHILDREN; while ((p = strrchr(fname, '.')) != NULL) { fname = t_strdup_until(fname, p); - if (imap_match(ctx->glob, fname) > 0) { - ctx->list.name = fname; + p = t_strconcat(ctx->prefix, fname, NULL); + if (imap_match(ctx->glob, p) > 0) { + ctx->list.name = p; return &ctx->list; } } diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index 2d22ef2eb3..a96186dcb3 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -132,23 +132,23 @@ static int maildir_is_valid_existing_name(const char *name) strchr(name, '/') == NULL && strchr(name, '\\') == NULL; } -static const char *maildir_get_absolute_path(const char *name) +static const char *maildir_get_absolute_path(const char *name, int unlink) { const char *p; name = home_expand(name); - /* insert "/" if it's missing */ - p = strchr(name, '.'); - if (p == NULL || p[-1] == '/') + p = strrchr(name, '/'); + if (p == NULL) return name; - return t_strconcat(t_strdup_until(name, p), "/", p, NULL); + return t_strconcat(t_strdup_until(name, p+1), + unlink ? ".." : ".", p+1, NULL); } 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 maildir_get_absolute_path(name, FALSE); if (strcasecmp(name, "INBOX") == 0) return storage->dir; @@ -156,6 +156,15 @@ const char *maildir_get_path(struct mail_storage *storage, const char *name) return t_strconcat(storage->dir, "/.", name, NULL); } +static const char * +maildir_get_unlink_path(struct mail_storage *storage, const char *name) +{ + if (full_filesystem_access && (*name == '/' || *name == '~')) + return maildir_get_absolute_path(name, TRUE); + + return maildir_get_path(storage, t_strconcat(".", name, NULL)); +} + static const char *maildir_get_index_path(struct mail_storage *storage, const char *name) { @@ -163,7 +172,7 @@ static const char *maildir_get_index_path(struct mail_storage *storage, return NULL; if (full_filesystem_access && (*name == '/' || *name == '~')) - return maildir_get_absolute_path(name); + return maildir_get_absolute_path(name, FALSE); return t_strconcat(storage->index_dir, "/.", name, NULL); } @@ -175,7 +184,7 @@ static const char *maildir_get_control_path(struct mail_storage *storage, return maildir_get_path(storage, name); if (full_filesystem_access && (*name == '/' || *name == '~')) - return maildir_get_absolute_path(name); + return maildir_get_absolute_path(name, FALSE); return t_strconcat(storage->control_dir, "/.", name, NULL); } @@ -421,7 +430,7 @@ static int maildir_delete_mailbox(struct mail_storage *storage, deleted. delete indexes before the actual maildir. this way we never see partially deleted mailboxes. */ src = maildir_get_path(storage, name); - dest = maildir_get_path(storage, t_strconcat(".", name, NULL)); + dest = maildir_get_unlink_path(storage, name); if (stat(src, &st) != 0 && errno == ENOENT) { mail_storage_set_error(storage, "Mailbox doesn't exist: %s", name); -- 2.47.3