[Dovecot] Another minor IMAP LIST issue
Chris Wakelin
c.d.wakelin at reading.ac.uk
Wed Jul 20 18:52:21 EEST 2005
I've just noticed that Dovecot 1.0-stable and 1.0-test78 don't include
mbox folders with names beginning with "." in the IMAP LIST output.
These are often used to store "hidden" folders for storing things like
IMAP client configuration (e.g. Pine 4.x, IMHO, Prayer). Usually the
user shouldn't be able to see these, but there are occassions when they
might. It seems to me to be better to let the client decide.
As I understand it, the IMAP RFC suggests that if you can "SELECT
folderpath" a folder, you should also be able to list it with 'LIST ""
"folderpath"'
I've written a patch against 1.0-stable (it also works with test78) to
add an extra namespace option "showdotfiles" (default "no"), to include
folders beginning with "." (but excluding ".imap" and "." and ".." for
obvious reasons!). It's used as follows :-
# default namespace
namespace private {
separator = "/"
prefix =
inbox = yes
showdotfiles = yes
}
# for backwards compatibility with UW-IMAP:
namespace private {
separator = "/"
prefix = "mail/"
hidden = yes
showdotfiles = yes
}
...
Let me know if you find it useful!
Best Wishes,
Chris
--
--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
Christopher Wakelin, c.d.wakelin at reading.ac.uk
IT Services Centre, The University of Reading, Tel: +44 (0)118 378 8439
Whiteknights, Reading, RG6 2AF, UK Fax: +44 (0)118 975 3094
-------------- next part --------------
diff -ruN dovecot-1.0-stable.orig/src/imap/cmd-list.c dovecot-1.0-stable/src/imap/cmd-list.c
--- dovecot-1.0-stable.orig/src/imap/cmd-list.c Fri Mar 18 20:00:44 2005
+++ dovecot-1.0-stable/src/imap/cmd-list.c Wed Jul 20 16:36:51 2005
@@ -293,6 +293,8 @@
list_flags = ctx->list_flags;
if (*ns->prefix == '\0' || ns->inbox)
list_flags |= MAILBOX_LIST_INBOX;
+ if (ns->showdotfiles)
+ list_flags |= MAILBOX_LIST_DOTFILES;
ctx->list_ctx = mail_storage_mailbox_list_init(ns->storage,
cur_ref, cur_mask,
list_flags);
diff -ruN dovecot-1.0-stable.orig/src/imap/namespace.c dovecot-1.0-stable/src/imap/namespace.c
--- dovecot-1.0-stable.orig/src/imap/namespace.c Mon Jan 31 16:37:54 2005
+++ dovecot-1.0-stable/src/imap/namespace.c Wed Jul 20 16:36:51 2005
@@ -31,7 +31,7 @@
{
struct namespace *ns;
const char *sep, *type, *prefix;
- int inbox, hidden, subscriptions;
+ int inbox, hidden, showdotfiles, subscriptions;
ns = p_new(pool, struct namespace, 1);
@@ -40,6 +40,7 @@
prefix = getenv(t_strdup_printf("NAMESPACE_%u_PREFIX", num));
inbox = getenv(t_strdup_printf("NAMESPACE_%u_INBOX", num)) != NULL;
hidden = getenv(t_strdup_printf("NAMESPACE_%u_HIDDEN", num)) != NULL;
+ showdotfiles = getenv(t_strdup_printf("NAMESPACE_%u_SHOWDOTFILES", num)) != NULL;
subscriptions = getenv(t_strdup_printf("NAMESPACE_%u_SUBSCRIPTIONS",
num)) != NULL;
@@ -58,6 +59,7 @@
ns->prefix = p_strdup(pool, prefix);
ns->inbox = inbox;
ns->hidden = hidden;
+ ns->showdotfiles = showdotfiles;
ns->subscriptions = subscriptions;
ns->storage = mail_storage_create_with_data(data, user);
if (ns->storage == NULL) {
diff -ruN dovecot-1.0-stable.orig/src/imap/namespace.h dovecot-1.0-stable/src/imap/namespace.h
--- dovecot-1.0-stable.orig/src/imap/namespace.h Mon Jan 31 16:37:54 2005
+++ dovecot-1.0-stable/src/imap/namespace.h Wed Jul 20 16:36:51 2005
@@ -16,7 +16,7 @@
char *prefix;
size_t prefix_len;
- int inbox, hidden, subscriptions;
+ int inbox, hidden, showdotfiles, subscriptions;
struct mail_storage *storage;
};
diff -ruN dovecot-1.0-stable.orig/src/lib-storage/index/mbox/mbox-list.c dovecot-1.0-stable/src/lib-storage/index/mbox/mbox-list.c
--- dovecot-1.0-stable.orig/src/lib-storage/index/mbox/mbox-list.c Mon Jan 31 16:37:55 2005
+++ dovecot-1.0-stable/src/lib-storage/index/mbox/mbox-list.c Wed Jul 20 16:36:51 2005
@@ -225,13 +225,19 @@
enum imap_match_result match, match2;
int ret, noselect;
- /* skip all hidden files */
- if (fname[0] == '.')
+ /* skip all hidden files unless show dotfiles is set*/
+ if (fname[0] == '.' && !(ctx->flags & MAILBOX_LIST_DOTFILES))
return 0;
/* skip all .lock files */
len = strlen(fname);
if (len > 5 && strcmp(fname+len-5, ".lock") == 0)
+ return 0;
+
+ /* skip ".imap" "." and ".." directories in case we show dotfiles */
+ if (((len == 5) && strcmp(fname, ".imap") == 0) ||
+ ((len == 1) && fname[0] == '.') ||
+ ((len == 2) && strcmp(fname, "..") == 0))
return 0;
/* check the mask */
diff -ruN dovecot-1.0-stable.orig/src/lib-storage/mail-storage.h dovecot-1.0-stable/src/lib-storage/mail-storage.h
--- dovecot-1.0-stable.orig/src/lib-storage/mail-storage.h Mon Jan 31 16:37:55 2005
+++ dovecot-1.0-stable/src/lib-storage/mail-storage.h Wed Jul 20 16:36:51 2005
@@ -16,7 +16,8 @@
MAILBOX_LIST_SUBSCRIBED = 0x01,
MAILBOX_LIST_FAST_FLAGS = 0x02,
MAILBOX_LIST_CHILDREN = 0x04,
- MAILBOX_LIST_INBOX = 0x04
+ MAILBOX_LIST_INBOX = 0x04,
+ MAILBOX_LIST_DOTFILES = 0x08
};
enum mailbox_flags {
diff -ruN dovecot-1.0-stable.orig/src/master/mail-process.c dovecot-1.0-stable/src/master/mail-process.c
--- dovecot-1.0-stable.orig/src/master/mail-process.c Tue Feb 8 10:30:11 2005
+++ dovecot-1.0-stable/src/master/mail-process.c Wed Jul 20 16:36:51 2005
@@ -175,6 +175,8 @@
env_put(t_strdup_printf("NAMESPACE_%u_INBOX=1", i));
if (ns->hidden)
env_put(t_strdup_printf("NAMESPACE_%u_HIDDEN=1", i));
+ if (ns->showdotfiles)
+ env_put(t_strdup_printf("NAMESPACE_%u_SHOWDOTFILES=1", i));
t_pop();
}
}
diff -ruN dovecot-1.0-stable.orig/src/master/master-settings.c dovecot-1.0-stable/src/master/master-settings.c
--- dovecot-1.0-stable.orig/src/master/master-settings.c Mon Jan 31 16:37:55 2005
+++ dovecot-1.0-stable/src/master/master-settings.c Wed Jul 20 16:36:51 2005
@@ -194,6 +194,7 @@
DEF(SET_STR, location),
DEF(SET_BOOL, inbox),
DEF(SET_BOOL, hidden),
+ DEF(SET_BOOL, showdotfiles),
{ 0, NULL, 0 }
};
diff -ruN dovecot-1.0-stable.orig/src/master/master-settings.h dovecot-1.0-stable/src/master/master-settings.h
--- dovecot-1.0-stable.orig/src/master/master-settings.h Mon Jan 31 16:37:55 2005
+++ dovecot-1.0-stable/src/master/master-settings.h Wed Jul 20 16:36:51 2005
@@ -163,6 +163,7 @@
int inbox;
int hidden;
+ int showdotfiles;
};
struct server_settings {
More information about the dovecot
mailing list