Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6048:a4c03ced38c3 HEAD
Fail get_status() lookup if user has no READ right to the mailbox.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 18 Jul 2007 00:11:30 +0300 |
parents | f35ef260987c |
children | 1246c1c08742 |
files | src/plugins/acl/acl-mailbox.c |
diffstat | 1 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/acl/acl-mailbox.c Wed Jul 18 00:03:14 2007 +0300 +++ b/src/plugins/acl/acl-mailbox.c Wed Jul 18 00:11:30 2007 +0300 @@ -23,6 +23,8 @@ unsigned int save_hack:1; }; +static MODULE_CONTEXT_DEFINE_INIT(acl_mail_module, &mail_module_register); + static int acl_mailbox_close(struct mailbox *box) { struct acl_mailbox *abox = ACL_CONTEXT(box); @@ -31,8 +33,6 @@ return abox->module_ctx.super.close(box); } -static MODULE_CONTEXT_DEFINE_INIT(acl_mail_module, &mail_module_register); - static int mailbox_acl_right_lookup(struct mailbox *box, unsigned int right_idx) { struct acl_mailbox *abox = ACL_CONTEXT(box); @@ -53,6 +53,28 @@ return 0; } +static int acl_mailbox_get_status(struct mailbox *box, + enum mailbox_status_items items, + struct mailbox_status *status) +{ + struct acl_mailbox *abox = ACL_CONTEXT(box); + int ret; + + ret = mailbox_acl_right_lookup(box, ACL_STORAGE_RIGHT_READ); + if (ret < 0) + return -1; + if (ret == 0) { + /* No read rights. APPEND however wants to lookup keywords + and we don't want to fail that lookup. We could fail or + return empty keywords if user had no INSERT+WRITE rights, + but don't bother. */ + if (items != STATUS_KEYWORDS) + return -1; + } + + return abox->module_ctx.super.get_status(box, items, status); +} + static int acl_get_write_rights(struct mailbox *box, bool *flags_r, bool *flag_seen_r, bool *flag_del_r) @@ -240,6 +262,7 @@ mailbox_get_name(box)); box->v.close = acl_mailbox_close; + box->v.get_status = acl_mailbox_get_status; box->v.mail_alloc = acl_mail_alloc; box->v.save_init = acl_save_init; box->v.copy = acl_copy;