dovecot-2.2: imap: If mailbox doesn't have read ACL, hide APPEND...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 5 01:14:35 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/f74f1b14975d
changeset: 15550:f74f1b14975d
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Dec 08 10:43:21 2012 +0200
description:
imap: If mailbox doesn't have read ACL, hide APPENDUID/COPYUID resp-codes.

diffstat:

 src/imap/cmd-append.c          |   2 +-
 src/imap/cmd-copy.c            |   6 ++++--
 src/lib-storage/mail-storage.h |   3 +++
 src/plugins/acl/acl-mailbox.c  |  17 ++++++++++++++++-
 4 files changed, 24 insertions(+), 4 deletions(-)

diffs (88 lines):

diff -r cfa6fc9d2856 -r f74f1b14975d src/imap/cmd-append.c
--- a/src/imap/cmd-append.c	Sat Dec 08 09:35:33 2012 +0200
+++ b/src/imap/cmd-append.c	Sat Dec 08 10:43:21 2012 +0200
@@ -290,7 +290,7 @@
 
 		msg = t_str_new(256);
 		save_count = seq_range_count(&changes.saved_uids);
-		if (save_count == 0) {
+		if (save_count == 0 || changes.no_read_perm) {
 			/* not supported by backend (virtual) */
 			str_append(msg, "OK Append completed.");
 		} else {
diff -r cfa6fc9d2856 -r f74f1b14975d src/imap/cmd-copy.c
--- a/src/imap/cmd-copy.c	Sat Dec 08 09:35:33 2012 +0200
+++ b/src/imap/cmd-copy.c	Sat Dec 08 10:43:21 2012 +0200
@@ -125,8 +125,10 @@
 	else if (copy_count == 0) {
 		str_append(msg, "OK No messages copied.");
 		pool_unref(&changes.pool);
-	} else if (seq_range_count(&changes.saved_uids) == 0) {
-		/* not supported by backend (virtual) */
+	} else if (seq_range_count(&changes.saved_uids) == 0 ||
+		   changes.no_read_perm) {
+		/* not supported by backend (virtual) or no read permissions
+		   for mailbox */
 		str_append(msg, "OK Copy completed.");
 		pool_unref(&changes.pool);
 	} else {
diff -r cfa6fc9d2856 -r f74f1b14975d src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h	Sat Dec 08 09:35:33 2012 +0200
+++ b/src/lib-storage/mail-storage.h	Sat Dec 08 10:43:21 2012 +0200
@@ -268,6 +268,9 @@
 
 	/* TRUE if anything actually changed with this commit */
 	bool changed;
+	/* User doesn't have read ACL for the mailbox, so don't show the
+	   uid_validity / saved_uids. */
+	bool no_read_perm;
 };
 
 struct mailbox_sync_rec {
diff -r cfa6fc9d2856 -r f74f1b14975d src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c	Sat Dec 08 09:35:33 2012 +0200
+++ b/src/plugins/acl/acl-mailbox.c	Sat Dec 08 10:43:21 2012 +0200
@@ -21,6 +21,7 @@
 	struct acl_object *aclobj;
 	bool skip_acl_checks;
 	bool acl_enabled;
+	bool no_read_right;
 };
 
 struct acl_transaction_context {
@@ -408,13 +409,19 @@
 {
 	struct acl_mailbox *abox = ACL_CONTEXT(ctx->box);
 	void *at = ACL_CONTEXT(ctx);
+	int ret;
 
 	if (at != NULL) {
 		abox->module_ctx.super.transaction_rollback(ctx);
 		return -1;
 	}
 
-	return abox->module_ctx.super.transaction_commit(ctx, changes_r);
+	ret = abox->module_ctx.super.transaction_commit(ctx, changes_r);
+	if (abox->no_read_right) {
+		/* don't allow IMAP client to see what UIDs the messages got */
+		changes_r->no_read_perm = TRUE;
+	}
+	return ret;
 }
 
 static int acl_mailbox_exists(struct mailbox *box, bool auto_boxes,
@@ -473,6 +480,14 @@
 		}
 		return -1;
 	}
+	if (open_right != ACL_STORAGE_RIGHT_READ) {
+		ret = acl_object_have_right(abox->aclobj,
+					    idx_arr[ACL_STORAGE_RIGHT_READ]);
+		if (ret < 0)
+			return -1;
+		if (ret == 0)
+			abox->no_read_right = TRUE;
+	}
 	return 0;
 }
 


More information about the dovecot-cvs mailing list