From d88ce01b58534dba87fd7657a1c3d52a329ea1d4 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 26 Aug 2023 17:19:01 -0400 Subject: [PATCH] fs-crypt: Rename crypt_plain_fallback setting fs_crypt_read_plain_fallback This is now consistent with fs_compress_read_plain_fallback setting. --- src/plugins/mail-crypt/crypt-settings.c | 6 ++++-- src/plugins/mail-crypt/crypt-settings.h | 3 ++- src/plugins/mail-crypt/fs-crypt.c | 2 +- src/plugins/mail-crypt/test-fs-crypt.c | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/plugins/mail-crypt/crypt-settings.c b/src/plugins/mail-crypt/crypt-settings.c index 7fef5833b9..652775a7c4 100644 --- a/src/plugins/mail-crypt/crypt-settings.c +++ b/src/plugins/mail-crypt/crypt-settings.c @@ -35,6 +35,8 @@ const struct setting_parser_info crypt_private_key_setting_parser_info = { #define DEF(type, name) \ SETTING_DEFINE_STRUCT_##type(#name, name, struct crypt_settings) static const struct setting_define crypt_setting_defines[] = { + DEF(BOOL, fs_crypt_read_plain_fallback), + DEF(STR, crypt_global_public_key), { .type = SET_FILTER_ARRAY, .key = "crypt_global_private_key", .offset = offsetof(struct crypt_settings, crypt_global_private_keys), @@ -42,7 +44,6 @@ static const struct setting_define crypt_setting_defines[] = { DEF(STR, crypt_write_algorithm), DEF(UINT, crypt_write_version), - DEF(BOOL, crypt_plain_fallback), { .type = SET_FILTER_ARRAY, .key = "crypt_user_key_encryption_key", .offset = offsetof(struct crypt_settings, crypt_user_key_encryption_keys), @@ -55,12 +56,13 @@ static const struct setting_define crypt_setting_defines[] = { }; static const struct crypt_settings crypt_default_settings = { + .fs_crypt_read_plain_fallback = FALSE, + .crypt_global_public_key = "", .crypt_global_private_keys = ARRAY_INIT, .crypt_write_algorithm = "aes-256-gcm-sha256", .crypt_write_version = UINT_MAX, - .crypt_plain_fallback = FALSE, .crypt_user_key_encryption_keys = ARRAY_INIT, .crypt_user_key_password = "", diff --git a/src/plugins/mail-crypt/crypt-settings.h b/src/plugins/mail-crypt/crypt-settings.h index 9ee57d9dbd..7934b6d62a 100644 --- a/src/plugins/mail-crypt/crypt-settings.h +++ b/src/plugins/mail-crypt/crypt-settings.h @@ -12,12 +12,13 @@ struct crypt_private_key_settings { struct crypt_settings { pool_t pool; + bool fs_crypt_read_plain_fallback; + const char *crypt_global_public_key; ARRAY_TYPE(const_string) crypt_global_private_keys; const char *crypt_write_algorithm; unsigned int crypt_write_version; - bool crypt_plain_fallback; /* for user-specific keys: */ ARRAY_TYPE(const_string) crypt_user_key_encryption_keys; diff --git a/src/plugins/mail-crypt/fs-crypt.c b/src/plugins/mail-crypt/fs-crypt.c index 92eb5a6fc0..018028a75d 100644 --- a/src/plugins/mail-crypt/fs-crypt.c +++ b/src/plugins/mail-crypt/fs-crypt.c @@ -187,7 +187,7 @@ fs_crypt_read_stream(struct fs_file *_file, size_t max_buffer_size) input = fs_read_stream(file->super_read, I_MAX(FS_CRYPT_ISTREAM_MIN_BUFFER_SIZE, max_buffer_size)); - if (file->fs->set->crypt_plain_fallback) { + if (file->fs->set->fs_crypt_read_plain_fallback) { struct istream *decrypted_input = i_stream_create_decrypt_callback(input, fs_crypt_istream_get_key, file); diff --git a/src/plugins/mail-crypt/test-fs-crypt.c b/src/plugins/mail-crypt/test-fs-crypt.c index 34203902ae..7b8e23f123 100644 --- a/src/plugins/mail-crypt/test-fs-crypt.c +++ b/src/plugins/mail-crypt/test-fs-crypt.c @@ -157,7 +157,7 @@ static void test_fs_crypt_read_write_unencrypted(void) const char *const test_settings[] = { "fs_parent/fs_driver", "posix", "fs_driver", "crypt", - "crypt_plain_fallback", "yes", + "fs_crypt_read_plain_fallback", "yes", "crypt_write_algorithm", "", "crypt_global_private_key", "main", "crypt_global_private_key/main/crypt_private_key", PRIVATE_KEY_PEM, @@ -208,7 +208,7 @@ static void test_fs_crypt_read_write_unencrypted(void) const char *const test_settings2[] = { "fs_parent/fs_driver", "posix", "fs_driver", "crypt", - "crypt_plain_fallback", "yes", + "fs_crypt_read_plain_fallback", "yes", "crypt_write_algorithm", "", "crypt_global_public_key", PUBLIC_KEY_PEM, "crypt_global_private_key", "main", -- 2.47.3