dovecot-1.0: APPEND and COPY ignored s/t/w flag rights.

dovecot at dovecot.org dovecot at dovecot.org
Wed Jul 18 00:03:23 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/60ec3834ee46
changeset: 5351:60ec3834ee46
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jul 17 23:58:57 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 e0b3d8f7883b -r 60ec3834ee46 src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c	Tue Jul 17 23:58:03 2007 +0300
+++ b/src/plugins/acl/acl-mailbox.c	Tue Jul 17 23:58:57 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;
 	struct acl_mail *amail = ACL_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. */
@@ -174,6 +172,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,
@@ -185,6 +203,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->super.save_init(t, flags, keywords, received_date,
 				     timezone_offset, from_envelope,
@@ -199,6 +219,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->super.copy(t, mail, flags, keywords, dest_mail);


More information about the dovecot-cvs mailing list