From: Timo Sirainen Date: Mon, 26 Oct 2015 15:20:49 +0000 (+0200) Subject: acl: If mailbox is autocreated, assume it already exists and don't require "create... X-Git-Tag: 2.2.20.rc1~119 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c6884ab66c38f87d2198b840662a5546ca5d024;p=thirdparty%2Fdovecot%2Fcore.git acl: If mailbox is autocreated, assume it already exists and don't require "create" ACL --- diff --git a/src/plugins/acl/acl-mailbox.c b/src/plugins/acl/acl-mailbox.c index 8a02ceea35..bf92bdbcf0 100644 --- a/src/plugins/acl/acl-mailbox.c +++ b/src/plugins/acl/acl-mailbox.c @@ -111,6 +111,14 @@ static void acl_mailbox_copy_acls_from_parent(struct mailbox *box) acl_object_deinit(&parent_aclobj); } +static bool mailbox_is_autocreated(struct mailbox *box) +{ + if (box->inbox_user) + return TRUE; + return box->set != NULL && + strcmp(box->set->autocreate, MAILBOX_SET_AUTO_NO) != 0; +} + static int acl_mailbox_create(struct mailbox *box, const struct mailbox_update *update, bool directory) @@ -118,9 +126,15 @@ acl_mailbox_create(struct mailbox *box, const struct mailbox_update *update, struct acl_mailbox *abox = ACL_CONTEXT(box); int ret; - /* we're looking up CREATE permission from our parent's rights */ - ret = acl_mailbox_list_have_right(box->list, box->name, TRUE, - ACL_STORAGE_RIGHT_CREATE, NULL); + if (!mailbox_is_autocreated(box)) { + /* we're looking up CREATE permission from our parent's rights */ + ret = acl_mailbox_list_have_right(box->list, box->name, TRUE, + ACL_STORAGE_RIGHT_CREATE, NULL); + } else { + /* mailbox is autocreated, so we need to treat it as if it + already exists. ignore the "create" ACL here. */ + ret = 1; + } if (ret <= 0) { if (ret < 0) { mail_storage_set_internal_error(box->storage);