dovecot: APPEND and COPY ignored s/t/w flag rights.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jul 18 00:03:26 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/840fb333defd
changeset: 6045:840fb333defd
user: Timo Sirainen <tss at iki.fi>
date: Tue Jul 17 23:58:58 2007 +0300
description:
APPEND and COPY ignored s/t/w flag rights.
diffstat:
1 file changed, 29 insertions(+), 7 deletions(-)
src/plugins/acl/acl-mailbox.c | 36 +++++++++++++++++++++++++++++-------
diffs (81 lines):
diff -r 3ca063521d9a -r 840fb333defd src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c Tue Jul 17 23:58:04 2007 +0300
+++ b/src/plugins/acl/acl-mailbox.c Tue Jul 17 23:58:58 2007 +0300
@@ -73,7 +73,7 @@ acl_get_write_rights(struct mailbox *box
if (ret < 0)
return -1;
*flag_del_r = ret > 0;
- return 1;
+ return 0;
}
static int
@@ -83,11 +83,9 @@ acl_mail_update_flags(struct mail *_mail
struct mail_private *mail = (struct mail_private *)_mail;
union mail_module_context *amail = ACL_MAIL_CONTEXT(mail);
bool acl_flags, acl_flag_seen, acl_flag_del;
- int ret;
-
- ret = acl_get_write_rights(_mail->box, &acl_flags, &acl_flag_seen,
- &acl_flag_del);
- if (ret < 0)
+
+ if (acl_get_write_rights(_mail->box, &acl_flags, &acl_flag_seen,
+ &acl_flag_del) < 0)
return -1;
if (modify_type != MODIFY_REPLACE) {
@@ -99,7 +97,7 @@ acl_mail_update_flags(struct mail *_mail
flags &= ~MAIL_SEEN;
if (!acl_flag_del)
flags &= ~MAIL_DELETED;
- } else if (!acl_flags || acl_flag_seen || !acl_flag_del) {
+ } else if (!acl_flags || !acl_flag_seen || !acl_flag_del) {
/* we don't have permission to replace all the flags. */
if (!acl_flags && !acl_flag_seen && !acl_flag_del) {
/* no flag changes allowed. ignore silently. */
@@ -175,6 +173,26 @@ acl_mail_alloc(struct mailbox_transactio
return _mail;
}
+static int acl_save_get_flags(struct mailbox *box, enum mail_flags *flags,
+ struct mail_keywords **keywords)
+{
+ bool acl_flags, acl_flag_seen, acl_flag_del;
+
+ if (acl_get_write_rights(box, &acl_flags, &acl_flag_seen,
+ &acl_flag_del) < 0)
+ return -1;
+
+ if (!acl_flag_seen)
+ *flags &= ~MAIL_SEEN;
+ if (!acl_flag_del)
+ *flags &= ~MAIL_DELETED;
+ if (!acl_flags) {
+ *flags &= MAIL_SEEN | MAIL_DELETED;
+ *keywords = NULL;
+ }
+ return 0;
+}
+
static int
acl_save_init(struct mailbox_transaction_context *t,
enum mail_flags flags, struct mail_keywords *keywords,
@@ -186,6 +204,8 @@ acl_save_init(struct mailbox_transaction
if (mailbox_acl_right_lookup(t->box, ACL_STORAGE_RIGHT_INSERT) <= 0)
return -1;
+ if (acl_save_get_flags(t->box, &flags, &keywords) < 0)
+ return -1;
return abox->module_ctx.super.
save_init(t, flags, keywords, received_date,
@@ -201,6 +221,8 @@ acl_copy(struct mailbox_transaction_cont
struct acl_mailbox *abox = ACL_CONTEXT(t->box);
if (mailbox_acl_right_lookup(t->box, ACL_STORAGE_RIGHT_INSERT) <= 0)
+ return -1;
+ if (acl_save_get_flags(t->box, &flags, &keywords) < 0)
return -1;
return abox->module_ctx.super.copy(t, mail, flags, keywords, dest_mail);
More information about the dovecot-cvs
mailing list