fixes
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
8692541e7f
commit
57b007759e
@ -164,7 +164,9 @@ public:
|
|||||||
|
|
||||||
auto opt_size = utils::file::file{file_path}.size();
|
auto opt_size = utils::file::file{file_path}.size();
|
||||||
EXPECT_TRUE(opt_size.has_value());
|
EXPECT_TRUE(opt_size.has_value());
|
||||||
EXPECT_EQ(0U, opt_size.value());
|
if (opt_size.has_value()) {
|
||||||
|
EXPECT_EQ(0U, opt_size.value());
|
||||||
|
}
|
||||||
|
|
||||||
EXPECT_EQ(0, close(fd));
|
EXPECT_EQ(0, close(fd));
|
||||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||||
@ -174,10 +176,7 @@ public:
|
|||||||
|
|
||||||
static auto create_root_file(std::string &file_name) -> std::string {
|
static auto create_root_file(std::string &file_name) -> std::string {
|
||||||
auto file_path = create_file_and_test(file_name);
|
auto file_path = create_file_and_test(file_name);
|
||||||
std::cout << file_path << std::endl;
|
|
||||||
|
|
||||||
auto api_path = utils::path::create_api_path(file_name);
|
auto api_path = utils::path::create_api_path(file_name);
|
||||||
std::cout << api_path << std::endl;
|
|
||||||
|
|
||||||
meta->set_item_meta(api_path, {
|
meta->set_item_meta(api_path, {
|
||||||
{META_UID, "0"},
|
{META_UID, "0"},
|
||||||
@ -205,8 +204,9 @@ public:
|
|||||||
|
|
||||||
for (int i = 0; not unmounted && (i < 50); i++) {
|
for (int i = 0; not unmounted && (i < 50); i++) {
|
||||||
std::cout << "unmount command: " << unmount_cmd << std::endl;
|
std::cout << "unmount command: " << unmount_cmd << std::endl;
|
||||||
ASSERT_EQ(0, system(unmount_cmd.c_str()));
|
auto res = system(unmount_cmd.c_str());
|
||||||
unmounted = not utils::file::directory{mount_location}.exists();
|
unmounted = res == 0;
|
||||||
|
ASSERT_EQ(0, res);
|
||||||
if (not unmounted) {
|
if (not unmounted) {
|
||||||
std::this_thread::sleep_for(5s);
|
std::this_thread::sleep_for(5s);
|
||||||
}
|
}
|
||||||
|
@ -581,6 +581,7 @@ TYPED_TEST(fuse_test, can_chown_group_if_owner_and_a_member_of_the_group) {
|
|||||||
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st));
|
||||||
|
|
||||||
EXPECT_EQ(0, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
|
EXPECT_EQ(0, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
|
||||||
|
std::cout << errno << std::endl;
|
||||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||||
|
|
||||||
struct stat64 unix_st2 {};
|
struct stat64 unix_st2 {};
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
|
|
||||||
namespace repertory::utils {
|
namespace repertory::utils {
|
||||||
struct result final {
|
struct result final {
|
||||||
std::string_view function_name;
|
std::string function_name;
|
||||||
bool ok{false};
|
bool ok{true};
|
||||||
std::string reason{};
|
std::string reason{"success"};
|
||||||
|
|
||||||
[[nodiscard]] operator bool() const { return ok; }
|
[[nodiscard]] operator bool() const { return ok; }
|
||||||
};
|
};
|
||||||
|
@ -41,8 +41,7 @@ convert_to_uint64(const thread_t *thread_ptr) -> std::uint64_t;
|
|||||||
|
|
||||||
[[nodiscard]] auto get_thread_id() -> std::uint64_t;
|
[[nodiscard]] auto get_thread_id() -> std::uint64_t;
|
||||||
|
|
||||||
[[nodiscard]] auto is_uid_member_of_group(const uid_t &uid,
|
[[nodiscard]] auto is_uid_member_of_group(uid_t uid, gid_t gid) -> bool;
|
||||||
const gid_t &gid) -> bool;
|
|
||||||
|
|
||||||
void set_last_error_code(int error_code);
|
void set_last_error_code(int error_code);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace {
|
|||||||
home = repertory::utils::path::combine("/home", {pw->pw_name});
|
home = repertory::utils::path::combine("/home", {pw->pw_name});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (res) {
|
if (not res) {
|
||||||
throw repertory::utils::error::create_exception(function_name,
|
throw repertory::utils::error::create_exception(function_name,
|
||||||
{
|
{
|
||||||
"failed to getpwuid",
|
"failed to getpwuid",
|
||||||
|
@ -19,11 +19,10 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <utils/config.hpp>
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|
||||||
#include "utils/collection.hpp"
|
|
||||||
#include "utils/unix.hpp"
|
#include "utils/unix.hpp"
|
||||||
|
#include "utils/collection.hpp"
|
||||||
|
|
||||||
namespace repertory::utils {
|
namespace repertory::utils {
|
||||||
#if !defined(__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
@ -38,7 +37,7 @@ auto get_thread_id() -> std::uint64_t {
|
|||||||
return convert_to_uint64(pthread_self());
|
return convert_to_uint64(pthread_self());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
|
auto is_uid_member_of_group(uid_t uid, gid_t gid) -> bool {
|
||||||
std::vector<gid_t> groups{};
|
std::vector<gid_t> groups{};
|
||||||
auto res = use_getpwuid(uid, [&groups](struct passwd *pass) {
|
auto res = use_getpwuid(uid, [&groups](struct passwd *pass) {
|
||||||
int group_count{};
|
int group_count{};
|
||||||
@ -53,7 +52,7 @@ auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (not res.ok) {
|
if (not res) {
|
||||||
throw utils::error::create_exception(res.function_name,
|
throw utils::error::create_exception(res.function_name,
|
||||||
{"use_getpwuid failed", res.reason});
|
{"use_getpwuid failed", res.reason});
|
||||||
}
|
}
|
||||||
@ -69,11 +68,15 @@ auto use_getpwuid(uid_t uid, passwd_callback_t callback) -> result {
|
|||||||
|
|
||||||
auto *temp_pw = getpwuid(uid);
|
auto *temp_pw = getpwuid(uid);
|
||||||
if (temp_pw == nullptr) {
|
if (temp_pw == nullptr) {
|
||||||
return {function_name, false, "'getpwuid' returned nullptr"};
|
return {
|
||||||
|
std::string{function_name},
|
||||||
|
false,
|
||||||
|
"'getpwuid' returned nullptr",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(temp_pw);
|
callback(temp_pw);
|
||||||
return {function_name};
|
return {std::string{function_name}};
|
||||||
}
|
}
|
||||||
} // namespace repertory::utils
|
} // namespace repertory::utils
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user