]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage, acl: Fix error trying to open autocreated mailbox without CREATE rights
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Jan 2020 13:40:41 +0000 (15:40 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 23 Jan 2020 12:36:05 +0000 (12:36 +0000)
The opening should fail with a regular error message rather than "internal
server error". Also no error message should be logged in this situation.

src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/plugins/acl/acl-mailbox.c

index 953aaa26113e060c0c078b642e87ebeaf2c1b117..65000e7d33f8d19f01669bdeef8c9e12df2f8de6 100644 (file)
@@ -467,6 +467,9 @@ struct mailbox {
        /* Using LAYOUT=index and mailbox is being opened with a corrupted
           mailbox name. Try to revert to the previously known good name. */
        bool corrupted_mailbox_name:1;
+       /* mailbox_open() returned MAIL_ERROR_NOTFOUND because the mailbox
+          doesn't have the LOOKUP ACL right. */
+       bool acl_no_lookup_right:1;
 };
 
 struct mail_vfuncs {
index ded8632aae8ce89031739be8da2f36698b1099dd..2572daba9402deef671ea6a8e5538cd95ec0ab69 100644 (file)
@@ -1094,6 +1094,10 @@ static int mailbox_autocreate(struct mailbox *box)
 
        if (mailbox_create(box, NULL, FALSE) < 0) {
                errstr = mailbox_get_last_internal_error(box, &error);
+               if (error == MAIL_ERROR_NOTFOUND && box->acl_no_lookup_right) {
+                       /* ACL prevents creating this mailbox */
+                       return -1;
+               }
                if (error != MAIL_ERROR_EXISTS) {
                        mailbox_set_critical(box,
                                "Failed to autocreate mailbox: %s",
@@ -1120,7 +1124,7 @@ static int mailbox_autocreate_and_reopen(struct mailbox *box)
        mailbox_close(box);
 
        ret = box->v.open(box);
-       if (ret < 0 && box->inbox_user &&
+       if (ret < 0 && box->inbox_user && !box->acl_no_lookup_right &&
            !box->storage->user->inbox_open_error_logged) {
                box->storage->user->inbox_open_error_logged = TRUE;
                mailbox_set_critical(box,
index 241ee3989ffce39fe889a8bf09abd5406e34163a..13ba0557d7475e6a4daf29634f68ae17f58599c3 100644 (file)
@@ -174,6 +174,7 @@ static void acl_mailbox_fail_not_found(struct mailbox *box)
                mail_storage_set_error(box->storage, MAIL_ERROR_PERM,
                                       MAIL_ERRSTR_NO_PERMISSION);
        } else if (ret == 0) {
+               box->acl_no_lookup_right = TRUE;
                mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
                                T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
        }