]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir: maildir_mailbox_open() - Disable maildir subdirectory creation for INBOX
authorMarkus Valentin <markus.valentin@open-xchange.com>
Fri, 20 Jan 2023 07:50:48 +0000 (08:50 +0100)
committerMarkus Valentin <markus.valentin@open-xchange.com>
Thu, 2 Feb 2023 07:20:11 +0000 (08:20 +0100)
This was added in 522925f6e9ff8fe9592511c2221b3d6526d4cbf4. In the
meantime autocreate code changed so this is no longer valid.

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

index 34b5e6118560f2b742d7d86c8c0912e15d2aa95b..0b3168fc37b578f861f5a2429c3b84e4b52a4d00 100644 (file)
@@ -375,8 +375,21 @@ static int maildir_mailbox_open(struct mailbox *box)
        }
        root_dir = mailbox_list_get_root_forced(box->list,
                                                MAILBOX_LIST_PATH_TYPE_MAILBOX);
-       if (strcmp(box_path, root_dir) == 0 && !box->inbox_any) {
-               /* root directory for some namespace. */
+
+       /* This code path is executed only for Maildir++ and imapdir layouts,
+          which don't support \Noselect mailboxes. If the mailbox root
+          directory exists, automatically create any missing cur/new/tmp
+          directories. Otherwise the mailbox would show up as selectable
+          in the mailbox list, but not actually be selectable.
+
+          As a special case we don't do this when the mailbox root directory
+          is the same as the namespace root directory. This especially means
+          that we don't autocreate Maildir INBOX when ~/Maildir directory
+          exists. Instead, we return that mailbox doesn't exist, so the
+          caller goes to the INBOX autocreation code path similarly as with
+          other mailboxes. This is needed e.g. for welcome plugin to work. */
+       if (strcmp(box_path, root_dir) == 0) {
+               /* root directory. either INBOX or some other namespace root */
                errno = ENOENT;
        } else if (stat(box_path, &st) == 0) {
                /* yes, we'll need to create the missing dirs */