fuse unit tests and fixes
This commit is contained in:
parent
86e5f0359d
commit
1ab36272f6
@ -88,7 +88,7 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid,
|
||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||
meta.clear();
|
||||
if (uid != static_cast<uid_t>(-1)) {
|
||||
if (get_effective_uid() != 0) {
|
||||
if (get_effective_uid() != 0 && get_effective_uid() != uid) {
|
||||
return api_error::permission_denied;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,26 @@ TYPED_TEST(fuse_test,
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(
|
||||
fuse_test,
|
||||
chown_can_chown_group_when_specifying_owner_and_a_member_of_the_group) {
|
||||
std::string file_name{"chown_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
struct stat64 unix_st {};
|
||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||
|
||||
EXPECT_EQ(0, chown(file_path.c_str(), getuid(), getgid()));
|
||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||
|
||||
struct stat64 unix_st2 {};
|
||||
stat64(file_path.c_str(), &unix_st2);
|
||||
EXPECT_EQ(getgid(), unix_st2.st_gid);
|
||||
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid);
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test,
|
||||
chown_can_not_chown_group_if_owner_but_not_a_member_of_the_group) {
|
||||
std::string file_name{"chown_test"};
|
||||
|
Loading…
x
Reference in New Issue
Block a user