dovecot: Return mailbox as READ-WRITE only if mailbox has rights...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jul 18 00:47:51 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/e6f3f17da3e7
changeset: 6053:e6f3f17da3e7
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 18 00:47:47 2007 +0300
description:
Return mailbox as READ-WRITE only if mailbox has rights to expunge, insert
or change shared flags. Return \* in PERMANENTFLAGS only if mailbox has write
right.
diffstat:
1 file changed, 45 insertions(+), 8 deletions(-)
src/plugins/acl/acl-mailbox.c | 53 ++++++++++++++++++++++++++++++++++-------
diffs (77 lines):
diff -r 8a9b077d503e -r e6f3f17da3e7 src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c Wed Jul 18 00:42:56 2007 +0300
+++ b/src/plugins/acl/acl-mailbox.c Wed Jul 18 00:47:47 2007 +0300
@@ -25,14 +25,6 @@ struct acl_mailbox {
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);
-
- acl_object_deinit(&abox->aclobj);
- return abox->module_ctx.super.close(box);
-}
-
static int mailbox_acl_right_lookup(struct mailbox *box, unsigned int right_idx)
{
struct acl_mailbox *abox = ACL_CONTEXT(box);
@@ -51,6 +43,49 @@ static int mailbox_acl_right_lookup(stru
mail_storage_set_error(box->storage, MAIL_ERROR_PERM,
MAIL_ERRSTR_NO_PERMISSION);
return 0;
+}
+
+static bool acl_is_readonly(struct mailbox *box)
+{
+ struct acl_mailbox *abox = ACL_CONTEXT(box);
+
+ if (abox->module_ctx.super.is_readonly(box))
+ return TRUE;
+
+ if (mailbox_acl_right_lookup(box, ACL_STORAGE_RIGHT_INSERT) > 0)
+ return FALSE;
+ if (mailbox_acl_right_lookup(box, ACL_STORAGE_RIGHT_EXPUNGE) > 0)
+ return FALSE;
+
+ /* Next up is the "shared flag rights" */
+ if (mailbox_acl_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0)
+ return FALSE;
+ if ((box->private_flags_mask & MAIL_DELETED) == 0 &&
+ mailbox_acl_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_DELETED) > 0)
+ return FALSE;
+ if ((box->private_flags_mask & MAIL_SEEN) == 0 &&
+ mailbox_acl_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN) > 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+static bool acl_allow_new_keywords(struct mailbox *box)
+{
+ struct acl_mailbox *abox = ACL_CONTEXT(box);
+
+ if (!abox->module_ctx.super.allow_new_keywords(box))
+ return FALSE;
+
+ return mailbox_acl_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0;
+}
+
+static int acl_mailbox_close(struct mailbox *box)
+{
+ struct acl_mailbox *abox = ACL_CONTEXT(box);
+
+ acl_object_deinit(&abox->aclobj);
+ return abox->module_ctx.super.close(box);
}
static int acl_mailbox_get_status(struct mailbox *box,
@@ -261,6 +296,8 @@ struct mailbox *acl_mailbox_open_box(str
box->storage,
mailbox_get_name(box));
+ box->v.is_readonly = acl_is_readonly;
+ box->v.allow_new_keywords = acl_allow_new_keywords;
box->v.close = acl_mailbox_close;
box->v.get_status = acl_mailbox_get_status;
box->v.mail_alloc = acl_mail_alloc;
More information about the dovecot-cvs
mailing list