changeset 1587:c390d5ac3327 HEAD

mail_full_filesystem_access = yes fixes
author Timo Sirainen <tss@iki.fi>
date Tue, 01 Jul 2003 21:14:18 +0300
parents 898a95426118
children e0006f30b496
files src/lib-storage/index/maildir/maildir-list.c src/lib-storage/index/maildir/maildir-storage.c
diffstat 2 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-list.c	Mon Jun 30 18:54:17 2003 +0300
+++ b/src/lib-storage/index/maildir/maildir-list.c	Tue Jul 01 21:14:18 2003 +0300
@@ -80,14 +80,6 @@
 		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 @@
 	}
 
 	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 @@
 				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;
 				}
 			}
--- a/src/lib-storage/index/maildir/maildir-storage.c	Mon Jun 30 18:54:17 2003 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Tue Jul 01 21:14:18 2003 +0300
@@ -132,23 +132,23 @@
 		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 @@
 	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 @@
 		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 @@
 		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 @@
 	   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);