changeset 22089:d13ea491ecc4

mail-crypt-plugin: Set copy-hook only if save_version > 0 Otherwise we might use it in read-only mode, too.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 15 May 2017 15:35:37 +0300
parents 1e5a91e481ec
children 709d44395bf8
files src/plugins/mail-crypt/mail-crypt-plugin.c
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/mail-crypt/mail-crypt-plugin.c	Thu May 04 09:14:17 2017 +0300
+++ b/src/plugins/mail-crypt/mail-crypt-plugin.c	Mon May 15 15:35:37 2017 +0300
@@ -366,21 +366,22 @@
 	mbox = p_new(box->pool, struct mail_crypt_mailbox, 1);
 	mbox->module_ctx.super = *v;
 	box->vlast = &mbox->module_ctx.super;
-	/* if global keys are used, re-encrypting on copy/move
-	   is not necessary, so do not attempt to do it.
-
-	   with per-folder keys, emails must be re-encrypted
-	   when moving to another folder */
-	if (muser->global_keys.public_key == NULL)
-		v->copy = mail_crypt_mailbox_copy;
 	v->close = mail_crypt_mailbox_close;
 
 	MODULE_CONTEXT_SET(box, mail_crypt_storage_module, mbox);
 
 	if ((class_flags & MAIL_STORAGE_CLASS_FLAG_BINARY_DATA) != 0) {
 		if (muser != NULL) {
-			if (muser->save_version > 0)
+			if (muser->save_version > 0) {
 				v->save_begin = mail_crypt_mail_save_begin;
+				/* if global keys are used, re-encrypting on copy/move
+				   is not necessary, so do not attempt to do it.
+
+				   with per-folder keys, emails must be re-encrypted
+				   when moving to another folder */
+				if (muser->global_keys.public_key == NULL)
+					v->copy = mail_crypt_mailbox_copy;
+			}
 		} else {
 			v->save_finish = mail_crypt_mail_save_finish;
 		}