]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-crypt: Allow writing without encryption only if crypt_write_algorithm is empty
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 26 Aug 2023 21:16:22 +0000 (17:16 -0400)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
This removes the check for crypt_plain_fallback setting.

src/plugins/mail-crypt/fs-crypt.c
src/plugins/mail-crypt/test-fs-crypt.c

index 9e73b97185c4ac6aa3f0ecbc117e22fcba2ff5b1..92eb5a6fc0a5760f82783cd95025a9c4057a0aa6 100644 (file)
@@ -227,19 +227,16 @@ static void fs_crypt_write_stream(struct fs_file *_file)
                return;
        }
 
-       if (file->fs->keys.public_key == NULL) {
-               if (!file->fs->set->crypt_plain_fallback) {
-                       _file->output = o_stream_create_error_str(EINVAL,
-                               "Encryption required, but no public key available");
-                       return;
-               } else {
-                       e_debug(event,
-                               "No public key provided, NOT encrypting stream %s",
-                                fs_file_path(_file));
-               }
+       if (file->fs->set->crypt_write_algorithm[0] == '\0') {
+               e_debug(event, "Empty crypt_write_algorithm, "
+                       "NOT encrypting stream %s", fs_file_path(_file));
                file->super_output = fs_write_stream(_file->parent);
                _file->output = file->super_output;
                return;
+       } else if (file->fs->keys.public_key == NULL) {
+               _file->output = o_stream_create_error_str(EINVAL,
+                       "Encryption required, but no public key available");
+               return;
        }
 
        enum io_stream_encrypt_flags flags;
index 02e203f29adf72c7645f7c091a235c60dde904eb..34203902ae47ba5e7e0599e96ed8e48752f14cae 100644 (file)
@@ -158,6 +158,7 @@ static void test_fs_crypt_read_write_unencrypted(void)
                "fs_parent/fs_driver", "posix",
                "fs_driver", "crypt",
                "crypt_plain_fallback", "yes",
+               "crypt_write_algorithm", "",
                "crypt_global_private_key", "main",
                "crypt_global_private_key/main/crypt_private_key", PRIVATE_KEY_PEM,
                NULL
@@ -208,6 +209,7 @@ static void test_fs_crypt_read_write_unencrypted(void)
                "fs_parent/fs_driver", "posix",
                "fs_driver", "crypt",
                "crypt_plain_fallback", "yes",
+               "crypt_write_algorithm", "",
                "crypt_global_public_key", PUBLIC_KEY_PEM,
                "crypt_global_private_key", "main",
                "crypt_global_private_key/main/crypt_private_key", PRIVATE_KEY_PEM,