dovecot-2.2: acl: If copy() doesn't have enough permissions, fre...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Feb 20 15:53:24 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/cfdd31b26493
changeset: 15861:cfdd31b26493
user: Timo Sirainen <tss at iki.fi>
date: Wed Feb 20 15:49:46 2013 +0200
description:
acl: If copy() doesn't have enough permissions, free mail_save_context properly.
diffstat:
src/plugins/acl/acl-mailbox.c | 38 +++++++++++++++++++++++++-------------
1 files changed, 25 insertions(+), 13 deletions(-)
diffs (56 lines):
diff -r 990ff0e1eb6a -r cfdd31b26493 src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c Wed Feb 20 15:49:06 2013 +0200
+++ b/src/plugins/acl/acl-mailbox.c Wed Feb 20 15:49:46 2013 +0200
@@ -391,27 +391,39 @@
return abox->module_ctx.super.save_begin(ctx, input);
}
+static bool
+acl_copy_has_rights(struct mail_save_context *ctx, struct mail *mail)
+{
+ struct mailbox *destbox = ctx->transaction->box;
+ enum acl_storage_rights save_right;
+
+ if (ctx->moving) {
+ if (acl_mailbox_right_lookup(mail->box,
+ ACL_STORAGE_RIGHT_EXPUNGE) <= 0)
+ return FALSE;
+ }
+
+ save_right = (destbox->flags & MAILBOX_FLAG_POST_SESSION) != 0 ?
+ ACL_STORAGE_RIGHT_POST : ACL_STORAGE_RIGHT_INSERT;
+ if (acl_mailbox_right_lookup(destbox, save_right) <= 0)
+ return FALSE;
+ if (acl_save_get_flags(destbox, &ctx->data.flags,
+ &ctx->data.pvt_flags, &ctx->data.keywords) < 0)
+ return FALSE;
+ return TRUE;
+}
+
static int
acl_copy(struct mail_save_context *ctx, struct mail *mail)
{
struct mailbox_transaction_context *t = ctx->transaction;
struct acl_mailbox *abox = ACL_CONTEXT(t->box);
- enum acl_storage_rights save_right;
- if (ctx->moving) {
- if (acl_mailbox_right_lookup(mail->box,
- ACL_STORAGE_RIGHT_EXPUNGE) <= 0)
- return -1;
+ if (!acl_copy_has_rights(ctx, mail)) {
+ mailbox_save_cancel(&ctx);
+ return -1;
}
- save_right = (t->box->flags & MAILBOX_FLAG_POST_SESSION) != 0 ?
- ACL_STORAGE_RIGHT_POST : ACL_STORAGE_RIGHT_INSERT;
- if (acl_mailbox_right_lookup(t->box, save_right) <= 0)
- return -1;
- if (acl_save_get_flags(t->box, &ctx->data.flags,
- &ctx->data.pvt_flags, &ctx->data.keywords) < 0)
- return -1;
-
return abox->module_ctx.super.copy(ctx, mail);
}
More information about the dovecot-cvs
mailing list