Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9474:38d89637aa23 HEAD
acl: mailbox_name_status() shouldn't hide its existence if user has any rights to it.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 10 Nov 2009 19:12:51 -0500 |
parents | adcc779985bd |
children | 76ff6831c9ae |
files | src/plugins/acl/acl-mailbox-list.c |
diffstat | 1 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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 @@ 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)