]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: Add test for fscrypt dummy encryption
authorChristopher Hoffman <choffman@redhat.com>
Wed, 17 Sep 2025 15:47:44 +0000 (15:47 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Wed, 5 Nov 2025 13:59:36 +0000 (13:59 +0000)
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/Client.cc
src/test/libcephfs/fscrypt.cc

index 8e5777e73b60c15065d325f555a922801c6b39e9..5eb4c90c5ff0c999062d188c36f16eef92957b56 100644 (file)
@@ -18446,11 +18446,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)
index ac70b91dfcec6fca8ac97c6bae1083fd820a729e..764131aa8aecdada98ee833498ce4beeaf3b9268 100644 (file)
@@ -1148,6 +1148,32 @@ 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();