mirror of
https://github.com/ceph/ceph
synced 2025-01-19 17:41:39 +00:00
rgw/acl/swift: create_container_policy() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
parent
064b562c2b
commit
33bc63e8d6
@ -153,19 +153,19 @@ static auto parse_grant(const DoutPrefixProvider* dpp,
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
namespace rgw::swift {
|
||||
|
||||
int RGWAccessControlPolicy_SWIFT::create(const DoutPrefixProvider *dpp,
|
||||
rgw::sal::Driver* driver,
|
||||
const rgw_user& id,
|
||||
const std::string& name,
|
||||
const char* read_list,
|
||||
const char* write_list,
|
||||
uint32_t& rw_mask)
|
||||
int create_container_policy(const DoutPrefixProvider *dpp,
|
||||
rgw::sal::Driver* driver,
|
||||
const rgw_user& id,
|
||||
const std::string& name,
|
||||
const char* read_list,
|
||||
const char* write_list,
|
||||
uint32_t& rw_mask,
|
||||
RGWAccessControlPolicy& policy)
|
||||
{
|
||||
acl.create_default(id, name);
|
||||
owner.id = id;
|
||||
owner.display_name = name;
|
||||
rw_mask = 0;
|
||||
policy.create_default(id, name);
|
||||
auto& acl = policy.get_acl();
|
||||
|
||||
if (read_list) {
|
||||
for (std::string_view uid : ceph::split(read_list, " ,")) {
|
||||
@ -194,6 +194,8 @@ int RGWAccessControlPolicy_SWIFT::create(const DoutPrefixProvider *dpp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace rgw::swift
|
||||
|
||||
void RGWAccessControlPolicy_SWIFT::filter_merge(uint32_t rw_mask,
|
||||
RGWAccessControlPolicy_SWIFT *old)
|
||||
{
|
||||
|
@ -14,16 +14,24 @@
|
||||
|
||||
class RGWUserCtl;
|
||||
|
||||
namespace rgw::swift {
|
||||
|
||||
/// Create a policy based on swift container acl headers
|
||||
/// X-Container-Read/X-Container-Write.
|
||||
int create_container_policy(const DoutPrefixProvider *dpp,
|
||||
rgw::sal::Driver* driver,
|
||||
const rgw_user& id,
|
||||
const std::string& name,
|
||||
const char* read_list,
|
||||
const char* write_list,
|
||||
uint32_t& rw_mask,
|
||||
RGWAccessControlPolicy& policy);
|
||||
|
||||
} // namespace rgw::swift
|
||||
|
||||
class RGWAccessControlPolicy_SWIFT : public RGWAccessControlPolicy
|
||||
{
|
||||
public:
|
||||
int create(const DoutPrefixProvider *dpp,
|
||||
rgw::sal::Driver* driver,
|
||||
const rgw_user& id,
|
||||
const std::string& name,
|
||||
const char* read_list,
|
||||
const char* write_list,
|
||||
uint32_t& rw_mask);
|
||||
void filter_merge(uint32_t mask, RGWAccessControlPolicy_SWIFT *policy);
|
||||
void to_str(std::string& read, std::string& write);
|
||||
};
|
||||
|
@ -607,18 +607,17 @@ static int get_swift_container_settings(req_state * const s,
|
||||
*has_policy = false;
|
||||
|
||||
if (read_list || write_list) {
|
||||
RGWAccessControlPolicy_SWIFT swift_policy;
|
||||
const auto r = swift_policy.create(s, driver,
|
||||
s->user->get_id(),
|
||||
s->user->get_display_name(),
|
||||
read_list,
|
||||
write_list,
|
||||
*rw_mask);
|
||||
int r = rgw::swift::create_container_policy(s, driver,
|
||||
s->user->get_id(),
|
||||
s->user->get_display_name(),
|
||||
read_list,
|
||||
write_list,
|
||||
*rw_mask,
|
||||
*policy);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
*policy = swift_policy;
|
||||
*has_policy = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user