Add macOS support #34
Some checks failed
BlockStorage/repertory_mac/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2025-08-03 10:41:21 -05:00
parent eee832ce49
commit 29aaf625c7
16 changed files with 292 additions and 133 deletions

View File

@@ -88,11 +88,16 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
-> api_error {
#endif
REPERTORY_USES_FUNCTION_NAME();
return check_and_perform(
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
meta.clear();
if (uid != static_cast<uid_t>(-1)) {
if (get_effective_uid() != 0 && get_effective_uid() != uid) {
utils::error::raise_error(
function_name, fmt::format("failed user|{}|{}",
get_effective_uid(), getuid()));
return api_error::permission_denied;
}
@@ -102,6 +107,9 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
if (gid != static_cast<gid_t>(-1)) {
if (get_effective_uid() != 0 &&
not utils::is_uid_member_of_group(get_effective_uid(), gid)) {
utils::error::raise_error(
function_name, fmt::format("failed group|{}|{}",
get_effective_gid(), getgid()));
return api_error::permission_denied;
}

View File

@@ -36,20 +36,20 @@ auto client::get_drive_information() -> rpc_response {
auto resp = cli.Get("/api/v1/" + rpc_method::get_drive_information);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = json::parse(resp->body),
};
}
@@ -63,20 +63,20 @@ auto client::get_config() -> rpc_response {
auto resp = cli.Get("/api/v1/" + rpc_method::get_config);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = json::parse(resp->body),
};
}
@@ -92,20 +92,20 @@ auto client::get_config_value_by_name(const std::string &name) -> rpc_response {
cli.Get("/api/v1/" + rpc_method::get_config_value_by_name, params, {});
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = json::parse(resp->body),
};
}
@@ -120,20 +120,20 @@ auto client::get_directory_items(const std::string &api_path) -> rpc_response {
auto resp = cli.Get("/api/v1/" + rpc_method::get_directory_items, params, {});
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = json::parse(resp->body),
};
}
@@ -147,20 +147,20 @@ auto client::get_open_files() -> rpc_response {
auto resp = cli.Get("/api/v1/" + rpc_method::get_open_files);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = json::parse(resp->body),
};
}
@@ -174,20 +174,20 @@ auto client::get_pinned_files() -> rpc_response {
auto resp = cli.Get("/api/v1/" + rpc_method::get_pinned_files);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = json::parse(resp->body),
};
}
@@ -202,20 +202,20 @@ auto client::pin_file(const std::string &api_path) -> rpc_response {
auto resp = cli.Post("/api/v1/" + rpc_method::pin_file, params);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
{},
.response_type = rpc_response_type::success,
.data = {},
};
}
@@ -230,20 +230,20 @@ auto client::pinned_status(const std::string &api_path) -> rpc_response {
auto resp = cli.Get("/api/v1/" + rpc_method::pinned_status, params, {});
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = json::parse(resp->body),
};
}
@@ -265,20 +265,20 @@ auto client::set_config_value_by_name(const std::string &name,
cli.Post("/api/v1/" + rpc_method::set_config_value_by_name, params);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
};
return rpc_response{
rpc_response_type::success,
nlohmann::json::parse(resp->body),
.response_type = rpc_response_type::success,
.data = nlohmann::json::parse(resp->body),
};
}
@@ -292,20 +292,20 @@ auto client::unmount() -> rpc_response {
auto resp = cli.Post("/api/v1/" + rpc_method::unmount);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
{},
.response_type = rpc_response_type::success,
.data = {},
};
}
@@ -320,20 +320,20 @@ auto client::unpin_file(const std::string &api_path) -> rpc_response {
auto resp = cli.Post("/api/v1/" + rpc_method::unpin_file, params);
if (resp.error() != httplib::Error::Success) {
return rpc_response{
rpc_response_type::http_error,
{{"error", httplib::to_string(resp.error())}},
.response_type = rpc_response_type::http_error,
.data = {{"error", httplib::to_string(resp.error())}},
};
}
if (resp->status != http_error_codes::ok) {
return rpc_response{
rpc_response_type::http_error,
{{"error", std::to_string(resp->status)}},
.response_type = rpc_response_type::http_error,
.data = {{"error", std::to_string(resp->status)}},
};
}
return rpc_response{
rpc_response_type::success,
{},
.response_type = rpc_response_type::success,
.data = {},
};
}
} // namespace repertory