dovecot-2.2: acl: If mailbox is autocreated, assume it already e...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 26 15:21:09 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/c7d384bc3964
changeset: 19333:c7d384bc3964
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 26 17:20:49 2015 +0200
description:
acl: If mailbox is autocreated, assume it already exists and don't require "create" ACL

diffstat:

 src/plugins/acl/acl-mailbox.c |  20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 0660772fb1dd -r c7d384bc3964 src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c	Mon Oct 26 16:28:51 2015 +0200
+++ b/src/plugins/acl/acl-mailbox.c	Mon Oct 26 17:20:49 2015 +0200
@@ -111,6 +111,14 @@
 	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 @@
 	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);


More information about the dovecot-cvs mailing list