dovecot-1.2: acl: mailbox_name_status() shouldn't hide its exist...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 11 02:13:50 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/38d89637aa23
changeset: 9474:38d89637aa23
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 10 19:12:51 2009 -0500
description:
acl: mailbox_name_status() shouldn't hide its existence if user has any rights to it.

diffstat:

1 file changed, 21 insertions(+), 13 deletions(-)
src/plugins/acl/acl-mailbox-list.c |   34 +++++++++++++++++++++-------------

diffs (51 lines):

diff -r adcc779985bd -r 38d89637aa23 src/plugins/acl/acl-mailbox-list.c
--- a/src/plugins/acl/acl-mailbox-list.c	Mon Nov 09 21:38:20 2009 -0500
+++ b/src/plugins/acl/acl-mailbox-list.c	Tue Nov 10 19:12:51 2009 -0500
@@ -380,6 +380,24 @@ acl_mailbox_list_iter_deinit(struct mail
 	return ret;
 }
 
+static int acl_mailbox_have_any_rights(struct mailbox_list *list,
+				       const char *name)
+{
+	struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(list);
+	struct acl_object *aclobj;
+	const char *const *rights;
+	int ret;
+
+	aclobj = acl_object_init_from_name(alist->rights.backend,
+					   list->ns->storage, name);
+	ret = acl_object_get_my_rights(aclobj, pool_datastack_create(),
+				       &rights);
+	acl_object_deinit(&aclobj);
+
+	return ret < 0 ? -1 :
+		(*rights == NULL ? 0 : 1);
+}
+
 static int acl_get_mailbox_name_status(struct mailbox_list *list,
 				       const char *name,
 				       enum mailbox_name_status *status)
@@ -387,19 +405,9 @@ static int acl_get_mailbox_name_status(s
 	struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(list);
 	int ret;
 
-	ret = acl_mailbox_list_have_right(list, name, ACL_STORAGE_RIGHT_LOOKUP,
-					  NULL);
-	if (ret < 0)
-		return -1;
-	if (ret == 0) {
-		/* If we have INSERT right for the mailbox, we'll need to
-		   reveal its existence so that APPEND and COPY works. */
-		ret = acl_mailbox_list_have_right(list, name,
-						  ACL_STORAGE_RIGHT_INSERT,
-						  NULL);
-		if (ret < 0)
-			return -1;
-	}
+	T_BEGIN {
+		ret = acl_mailbox_have_any_rights(list, name);
+	} T_END;
 
 	if (alist->module_ctx.super.get_mailbox_name_status(list, name,
 							    status) < 0)


More information about the dovecot-cvs mailing list