summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-02-20 12:39:37 -0800
committerYehuda Sadeh <yehuda@inktank.com>2013-02-20 12:39:37 -0800
commit0201cc80d4d205bb0fd2ee56633490d741ce0690 (patch)
treef5717889931e3f5c5c6636319333a314fe224ebb
parenteb0f49d4b68062701b842b9cfdde708868769bef (diff)
downloadceph-0201cc80d4d205bb0fd2ee56633490d741ce0690.tar.gz
rgw: refactor header grants
Move definition to a static array. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_acl_s3.cc33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/rgw/rgw_acl_s3.cc b/src/rgw/rgw_acl_s3.cc
index e67f77642a6..df4d2958d30 100644
--- a/src/rgw/rgw_acl_s3.cc
+++ b/src/rgw/rgw_acl_s3.cc
@@ -267,11 +267,6 @@ bool RGWAccessControlList_S3::xml_end(const char *el) {
struct s3_acl_header {
int rgw_perm;
const char *http_header;
-
- s3_acl_header(int perm, const char *head) {
- rgw_perm = perm;
- http_header = head;
- }
};
static const char *get_acl_header(RGWEnv *env,
@@ -424,28 +419,22 @@ bool RGWAccessControlPolicy_S3::xml_end(const char *el) {
return true;
}
+static const s3_acl_header acl_header_perms[] = {
+ {RGW_PERM_READ, "HTTP_X_AMZ_GRANT_READ"},
+ {RGW_PERM_WRITE, "HTTP_X_AMZ_GRANT_WRITE"},
+ {RGW_PERM_READ_ACP,"HTTP_X_AMZ_GRANT_READ_ACP"},
+ {RGW_PERM_WRITE_ACP, "HTTP_X_AMZ_GRANT_WRITE_ACP"},
+ {RGW_PERM_FULL_CONTROL, "HTTP_X_AMZ_GRANT_FULL_CONTROL"},
+ {0, NULL}
+};
+
int RGWAccessControlPolicy_S3::create_from_headers(RGWRados *store, RGWEnv *env, ACLOwner& _owner)
{
std::list<ACLGrant> grants;
int ret;
- const s3_acl_header grant_read(RGW_PERM_READ,"HTTP_X_AMZ_GRANT_READ");
- const s3_acl_header grant_write(RGW_PERM_WRITE, "HTTP_X_AMZ_GRANT_WRITE");
- const s3_acl_header grant_read_acp(RGW_PERM_READ_ACP,"HTTP_X_AMZ_GRANT_READ_ACP");
- const s3_acl_header grant_write_acp(RGW_PERM_WRITE_ACP, "HTTP_X_AMZ_GRANT_WRITE_ACP");
- const s3_acl_header grant_full_control(RGW_PERM_FULL_CONTROL, "HTTP_X_AMZ_GRANT_FULL_CONTROL");
-
- const s3_acl_header *perms[] = {
- &grant_read,
- &grant_write,
- &grant_read_acp,
- &grant_write_acp,
- &grant_full_control,
- NULL
- };
-
- for (const struct s3_acl_header **p = perms; *p; p++) {
- ret = parse_acl_header(store, env, *p, grants);
+ for (const struct s3_acl_header *p = acl_header_perms; p->rgw_perm; p++) {
+ ret = parse_acl_header(store, env, p, grants);
if (ret < 0)
return false;
}