]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail_full_filesystem_access = yes fixes
authorTimo Sirainen <tss@iki.fi>
Tue, 1 Jul 2003 18:14:18 +0000 (21:14 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 1 Jul 2003 18:14:18 +0000 (21:14 +0300)
--HG--
branch : HEAD

src/lib-storage/index/maildir/maildir-list.c
src/lib-storage/index/maildir/maildir-storage.c

index c2cdca22810469bed1764b3b4c0c6b0f371eeae4..ab2bfac33382810d578c8fcdeaaf0e7dbb3ac600 100644 (file)
@@ -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;
                                }
                        }
index 2d22ef2eb3aa0531fdf5ad7bc6881c138246c8fe..a96186dcb3bf9836ca0f2834acb91aa240022fef 100644 (file)
@@ -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);