]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_libcephfs: update test cases for libcephfs permission check
authorYan, Zheng <zyan@redhat.com>
Mon, 12 Oct 2015 08:47:33 +0000 (16:47 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 12 Jan 2016 09:21:01 +0000 (17:21 +0800)
libcephfs permission check does not allow some operations for
non-root user. so we temporarily disable the permission check
for some tests.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/test/libcephfs/access.cc
src/test/libcephfs/acl.cc
src/test/libcephfs/test.cc

index ac8cbd1674fd445c87fa6fd2a26037d87bb25f18..5843eab2f0c3e1dc540fa3999944fa78436c9a8c 100644 (file)
@@ -247,6 +247,7 @@ TEST(AccessTest, User) {
   ASSERT_EQ(0, ceph_create(&admin, NULL));
   ASSERT_EQ(0, ceph_conf_read_file(admin, NULL));
   ASSERT_EQ(0, ceph_conf_parse_env(admin, NULL));
+  ASSERT_EQ(0, ceph_conf_set(admin, "client_permissions", "0"));
   ASSERT_EQ(0, ceph_mount(admin, "/"));
   ASSERT_EQ(0, ceph_mkdir(admin, dir.c_str(), 0755));
 
@@ -266,6 +267,7 @@ TEST(AccessTest, User) {
   ASSERT_EQ(-EACCES, ceph_mount(cmount, "/"));
   ASSERT_EQ(0, ceph_conf_set(cmount, "client_mount_uid", "123"));
   ASSERT_EQ(0, ceph_conf_set(cmount, "client_mount_gid", "456"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "0"));
   ASSERT_EQ(0, ceph_mount(cmount, "/"));
 
   // user bits
@@ -337,8 +339,31 @@ TEST(AccessTest, User) {
   ceph_shutdown(admin);
 }
 
+static int update_root_mode()
+{
+  struct ceph_mount_info *admin;
+  int r = ceph_create(&admin, NULL);
+  if (r < 0)
+    return r;
+  ceph_conf_read_file(admin, NULL);
+  ceph_conf_parse_env(admin, NULL);
+  ceph_conf_set(admin, "client_permissions", "false");
+  r = ceph_mount(admin, "/");
+  if (r < 0)
+    goto out;
+  r = ceph_chmod(admin, "/", 0777);
+out:
+  ceph_shutdown(admin);
+  return r;
+}
+
+
 int main(int argc, char **argv)
 {
+  int r = update_root_mode();
+  if (r < 0)
+    exit(1);
+
   ::testing::InitGoogleTest(&argc, argv);
 
   srand(getpid());
@@ -346,7 +371,7 @@ int main(int argc, char **argv)
   rados_create(&cluster, NULL);
   rados_conf_read_file(cluster, NULL);
   rados_conf_parse_env(cluster, NULL);
-  int r = rados_connect(cluster);
+  r = rados_connect(cluster);
   if (r < 0)
     exit(1);
 
index aa52c90c7feb7c28a01d8ccd46236e626954e442..941cbb6a4719b0c5b479db987e053c6c0186892f 100644 (file)
@@ -134,6 +134,7 @@ TEST(ACL, SetACL) {
   ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
   ASSERT_EQ(0, ceph_mount(cmount, "/"));
   ASSERT_EQ(0, ceph_conf_set(cmount, "client_acl_type", "posix_acl"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "0"));
 
   char test_file[256];
   sprintf(test_file, "file1_setacl_%d", getpid());
@@ -143,7 +144,9 @@ TEST(ACL, SetACL) {
   // change ownership to nobody -- we assume nobody exists and id is always 65534
   ASSERT_EQ(ceph_fchown(cmount, fd, 65534, 65534), 0);
 
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "1"));
   ASSERT_EQ(ceph_open(cmount, test_file, O_RDWR, 0), -EACCES);
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "0"));
 
   size_t acl_buf_size = acl_ea_size(5);
   void *acl_buf = malloc(acl_buf_size);
index 6b088df5c427559f8651138d64f52d91da8fd4b8..890e9c62420c9c8811537fef179b7a6351fb2f25 100644 (file)
@@ -652,7 +652,9 @@ TEST(LibCephFS, Fchown) {
   ASSERT_EQ(ceph_fchmod(cmount, fd, 0600), 0);
 
   // change ownership to nobody -- we assume nobody exists and id is always 65534
+  ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "0"), 0);
   ASSERT_EQ(ceph_fchown(cmount, fd, 65534, 65534), 0);
+  ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "1"), 0);
 
   ceph_close(cmount, fd);