From: Christopher Hoffman Date: Wed, 17 Sep 2025 15:47:44 +0000 (+0000) Subject: test: Add test for fscrypt dummy encryption X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cfa435f4ac185a0d00523f8d777b18cbc8357927;p=ceph-ci.git test: Add test for fscrypt dummy encryption Signed-off-by: Christopher Hoffman --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 0b89fcc2e6b..da8aeefd1c4 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -18328,11 +18328,11 @@ int Client::ll_get_fscrypt_policy_v2(Inode *in, struct fscrypt_policy_v2* policy if (in->is_fscrypt_enabled()) { in->fscrypt_ctx->convert_to(policy); if (policy->version != 2) { - return EINVAL; + return -EINVAL; } return 0; } - return ENODATA; + return -ENODATA; } int Client::is_encrypted(int fd, UserPerm& perms, char* enctag) diff --git a/src/test/libcephfs/fscrypt.cc b/src/test/libcephfs/fscrypt.cc index ac70b91dfce..aa80749668e 100644 --- a/src/test/libcephfs/fscrypt.cc +++ b/src/test/libcephfs/fscrypt.cc @@ -1148,6 +1148,31 @@ TEST(FSCrypt, SetPolicyAlreadyExistDifferentPolicyNotEmpty) { ceph_shutdown(cmount); } +TEST(FSCrypt, FSCryptDummyEncryptionNoExistingRegularPolicy) { + struct ceph_mount_info* cmount; + ASSERT_EQ(0, ceph_create(&cmount, NULL)); + ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL)); + ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL)); + + string name = get_unique_dir_name(); + name = string("/") + name; + + int r = ceph_mount(cmount, NULL); + ASSERT_EQ(0, ceph_mkdir(cmount, name.c_str(), 0777)); + ceph_unmount(cmount); + + ASSERT_EQ(0, ceph_conf_set(cmount, "client_fscrypt_dummy_encryption", "true")); + r = ceph_mount(cmount, name.c_str()); + ASSERT_EQ(0, r); + + int fd = ceph_open(cmount, ".", O_DIRECTORY, 0); + + fscrypt_policy_v2 policy; + ASSERT_EQ(0, ceph_get_fscrypt_policy_v2(cmount, fd, &policy)); + + ceph_shutdown(cmount); +} + int main(int argc, char **argv) { int r = update_root_mode();