refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-09-27 14:07:13 -05:00
parent 6e52474953
commit 51cb2c0b9a

View File

@ -43,17 +43,24 @@ auto fuse_drive_base::check_access(const std::string &api_path,
// Always allow root
auto current_uid = get_current_uid();
if (current_uid != 0) {
if (current_uid == 0) {
return api_error::success;
}
// Always allow forced user
if (not forced_uid_.has_value() || (current_uid != get_effective_uid())) {
if (forced_uid_.has_value() || (current_uid == get_effective_uid())) {
return api_error::success;
}
// Always allow if checking file exists
if (F_OK != mask) {
if (F_OK == mask) {
return api_error::success;
}
const auto effective_uid =
(forced_uid_.has_value() ? forced_uid_.value()
: get_uid_from_meta(meta));
(forced_uid_.has_value() ? forced_uid_.value() : get_uid_from_meta(meta));
const auto effective_gid =
(forced_gid_.has_value() ? forced_gid_.value()
: get_gid_from_meta(meta));
(forced_gid_.has_value() ? forced_gid_.value() : get_gid_from_meta(meta));
// Create file mode
mode_t effective_mode =
@ -101,9 +108,6 @@ auto fuse_drive_base::check_access(const std::string &api_path,
// Deny access if effective mode is 0
return api_error::access_denied;
}
}
}
}
return api_error::success;
}