[Dovecot] Another minor IMAP LIST issue
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@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 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 {
On Wed, 20 Jul 2005, Chris Wakelin wrote:
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.
You know, I was going to suggest the same thing this weekend. It is a problem with Pine remote address books, if the remote addrbook uses a dotfile folder. The addressbook folder doesn't show up in LIST, so Pine tries to create it, and upon create, it gets a "Folder exists" error because it does already exist. This change should go into Dovecot to improve Pine compatibility if nothing else.
I'm actually moving to maildir soon, but I think this option might be useful there too. Yes, I know that a directory named '.foo..bar' or '..foo.bar' looks odd, but it should IMHO be possible. The code to do so would be a little more complex, of course, because the first dot is a folder separator while the next dot(s) would be part of the folder name.
-- -- Todd Vierling tv@duh.org tv@pobox.com todd@vierling.name
Todd Vierling wrote:
On Wed, 20 Jul 2005, Chris Wakelin wrote:
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.
You know, I was going to suggest the same thing this weekend. It is a problem with Pine remote address books, if the remote addrbook uses a dotfile folder. The addressbook folder doesn't show up in LIST, so Pine tries to create it, and upon create, it gets a "Folder exists" error because it does already exist. This change should go into Dovecot to improve Pine compatibility if nothing else.
Actually, that's similar to one of the other LIST issues, namely 'LIST "" "~/mail/"' (where "~/mail/" is a namespace prefix).
Pine 4.x expects this to work, when adding a folder collection with a prefix, or it tries to create it. (This will still crash 1.0-stable, I think, but is fixed in 1.0-tests - in cmd-create.c, "maibox" ends up as the empty string and then its penultimate character gets tested to see if it's the separator!)
I've needed to do a lot for Pine 4.x compatability, which is ironic as it's supposed to be the "reference" IMAP client! Admittedly, if we didn't use a folder prefix and used SSL or didn't use AUTH=PLAIN, it would probably work OK out-of-the-box. As for Pine 3.x, it uses obsolete (according to RFC2062) IMAPv2 commands (FIND ALL.MAILBOXES) for folder listing!!
Best Wishes, Chris
-- --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+- Christopher Wakelin, c.d.wakelin@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
On Wed, 2005-07-20 at 16:52 +0100, Chris Wakelin wrote:
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 :-
Hmm. Perhaps it should be enabled unconditionally? Just make it skip those and .subscriptions file (you forgot that).
On Fri, 22 Jul 2005, Timo Sirainen wrote:
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 :-
Hmm. Perhaps it should be enabled unconditionally? Just make it skip those and .subscriptions file (you forgot that).
This would match UW's IMAP implementation, modulo the skiplist specific to Dovecot. I'd really like to see this implemented.
(Id love to see it for maildir too, but as I mentioned ealier, parsing is a little odd: a folder named .foo..bar...baz is the hierarchy foo/.bar/..baz)
-- -- Todd Vierling tv@duh.org tv@pobox.com todd@vierling.name
Todd Vierling wrote:
On Fri, 22 Jul 2005, Timo Sirainen wrote:
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 :-
Hmm. Perhaps it should be enabled unconditionally? Just make it skip those and .subscriptions file (you forgot that).
Yes, we've moved .subscriptions to .mailboxlist in the INDEX directory and changed that (with INDEX= ... ) to somewhere different from the folders, so I forgot it! It probably ought to exclude whatever SUSCRIPTION_FILE_NAME is defined as.
I thought it should be an option because I'm wary of changing the default behaviour (clients may start confusing users by suddenly showing dotfile folders). Only one of my UW-IMAP converts noticed they were missing, though!
Best Wishes, Chris
-- --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+- Christopher Wakelin, c.d.wakelin@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
participants (3)
-
Chris Wakelin
-
Timo Sirainen
-
Todd Vierling