From: Yan, Zheng Date: Mon, 12 Oct 2015 08:47:33 +0000 (+0800) Subject: test_libcephfs: update test cases for libcephfs permission check X-Git-Tag: v10.0.3~48^2~3^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f46513d4e64fa88fc0b521368fbfc74aa0a7b7b4;p=ceph.git test_libcephfs: update test cases for libcephfs permission check 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 --- diff --git a/src/test/libcephfs/access.cc b/src/test/libcephfs/access.cc index ac8cbd1674fd..5843eab2f0c3 100644 --- a/src/test/libcephfs/access.cc +++ b/src/test/libcephfs/access.cc @@ -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); diff --git a/src/test/libcephfs/acl.cc b/src/test/libcephfs/acl.cc index aa52c90c7feb..941cbb6a4719 100644 --- a/src/test/libcephfs/acl.cc +++ b/src/test/libcephfs/acl.cc @@ -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); diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 6b088df5c427..890e9c62420c 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -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);