From 195ceed0a34fc46751c77e86fe766b932b5f91f2 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 19 Jan 2016 15:33:48 -0800 Subject: [PATCH] rgw: init_permissions() shouldn't return ENOENT in a specific case If op is bucket creation it should ignore ENOENT. Otherwise we should make sure we return the appropriate error. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_main.cc | 2 +- src/rgw/rgw_op.cc | 2 +- src/rgw/rgw_op.h | 2 +- src/rgw/rgw_rest.cc | 5 ++++- src/rgw/rgw_rest.h | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index a878017617d8f..246f016367114 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -598,7 +598,7 @@ static int process_request(RGWRados *store, RGWREST *rest, RGWRequest *req, RGWC } req->log(s, "init permissions"); - ret = handler->init_permissions(); + ret = handler->init_permissions(op); if (ret < 0) { abort_early(s, op, ret, handler); goto done; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 01965891cd6d1..4225c69166131 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -425,7 +425,7 @@ static int rgw_build_bucket_policies(RGWRados *store, struct req_state *s) } } - return 0; + return ret; } /** diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 06d0f206c76c6..f0555d26a9341 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -1370,7 +1370,7 @@ public: virtual RGWOp *get_op(RGWRados *store); virtual void put_op(RGWOp *op); - virtual int init_permissions() { + virtual int init_permissions(RGWOp *op) { return 0; } virtual int retarget(RGWOp *op, RGWOp **new_op) { diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index db7a056f23884..b97d8b810176f 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -1348,8 +1348,11 @@ static http_op op_from_method(const char *method) return OP_UNKNOWN; } -int RGWHandler_ObjStore::init_permissions() +int RGWHandler_ObjStore::init_permissions(RGWOp *op) { + if (op->get_type() == RGW_OP_CREATE_BUCKET) + return 0; + return do_init_permissions(); } diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index ca143ce4da10e..3ddd1bfb0a9ac 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -356,7 +356,7 @@ protected: public: RGWHandler_ObjStore() {} virtual ~RGWHandler_ObjStore() {} - int init_permissions(); + int init_permissions(RGWOp *op); int read_permissions(RGWOp *op); virtual int retarget(RGWOp *op, RGWOp **new_op) { *new_op = op; -- 2.39.5