dovecot-1.2: mail_full_filesystem_access=yes was broken when lis...

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 22 19:31:47 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/b03b937dadcf
changeset: 8104:b03b937dadcf
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Aug 22 19:31:12 2008 +0300
description:
mail_full_filesystem_access=yes was broken when listing mailboxes.

diffstat:

1 file changed, 37 insertions(+), 2 deletions(-)
src/lib-storage/list/mailbox-list-fs-iter.c |   39 +++++++++++++++++++++++++--

diffs (61 lines):

diff -r 360ade35792f -r b03b937dadcf src/lib-storage/list/mailbox-list-fs-iter.c
--- a/src/lib-storage/list/mailbox-list-fs-iter.c	Fri Aug 22 02:24:38 2008 +0300
+++ b/src/lib-storage/list/mailbox-list-fs-iter.c	Fri Aug 22 19:31:12 2008 +0300
@@ -174,12 +174,46 @@ static int list_opendir(struct fs_list_i
 	return -1;
 }
 
+static const char *list_get_rootdir(struct fs_list_iterate_context *ctx,
+				    const char **vpath)
+{
+	const char *const *patterns, *name, *p, *last;
+
+	if ((ctx->ctx.list->flags & MAILBOX_LIST_FLAG_FULL_FS_ACCESS) == 0)
+		return NULL;
+
+	/* see if there are any absolute paths in patterns */
+	patterns = (const void *)array_idx(&ctx->valid_patterns, 0);
+	for (; *patterns != NULL; patterns++) {
+		name = *patterns;
+
+		if (*name == '/') {
+			*vpath = "/";
+			return "/";
+		}
+		if (*name == '~') {
+			for (p = last = name; *p != '\0'; p++) {
+				if (*p == '%' || *p == '*')
+					break;
+				if (*p == '/')
+					last = p;
+			}
+			name = p = t_strdup_until(name, last+1);
+			if (home_try_expand(&name) == 0) {
+				*vpath = p;
+				return name;
+			}
+		}
+	}
+	return NULL;
+}
+
 struct mailbox_list_iterate_context *
 fs_list_iter_init(struct mailbox_list *_list, const char *const *patterns,
 		  enum mailbox_list_iter_flags flags)
 {
 	struct fs_list_iterate_context *ctx;
-	const char *path, *vpath;
+	const char *path, *vpath, *rootdir;
 	char *pattern;
 	DIR *dirp;
 	int ret;
@@ -235,7 +269,8 @@ fs_list_iter_init(struct mailbox_list *_
 
 	vpath = (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ?
 		_list->ns->prefix : "";
-	path = mailbox_list_get_path(_list, NULL, MAILBOX_LIST_PATH_TYPE_DIR);
+	rootdir = list_get_rootdir(ctx, &vpath);
+	path = mailbox_list_get_path(_list, rootdir, MAILBOX_LIST_PATH_TYPE_DIR);
 	if ((ret = list_opendir(ctx, path, vpath, &dirp)) < 0)
 		return &ctx->ctx;
 


More information about the dovecot-cvs mailing list