and add a few ops to the list of ops that complete aws4 signature.
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
// At some point when I have more time I want to make a version of
// rgw_rest_read_all_input that doesn't use malloc.
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
// And throws exceptions.
return op_ret;
int RGWPutBucketPublicAccessBlock::get_params(optional_yield y)
{
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
return op_ret;
}
namespace dmc = rgw::dmclock;
+std::tuple<int, bufferlist > rgw_rest_read_all_input(struct req_state *s,
+ const uint64_t max_len,
+ const bool allow_chunked=true);
+
+template <class T>
+int rgw_rest_get_json_input(CephContext *cct, req_state *s, T& out,
+ uint64_t max_len, bool *empty)
+{
+ if (empty)
+ *empty = false;
+
+ int rv = 0;
+ bufferlist data;
+ std::tie(rv, data) = rgw_rest_read_all_input(s, max_len);
+ if (rv < 0) {
+ return rv;
+ }
+
+ if (!data.length()) {
+ if (empty) {
+ *empty = true;
+ }
+
+ return -EINVAL;
+ }
+
+ JSONParser parser;
+
+ if (!parser.parse(data.c_str(), data.length())) {
+ return -EINVAL;
+ }
+
+ try {
+ decode_json_obj(out, &parser);
+ } catch (JSONDecoder::err& e) {
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/**
* Provide the base class for all ops.
*/
virtual int init_quota();
+ std::tuple<int, bufferlist> read_all_input(struct req_state *s,
+ const uint64_t max_len,
+ const bool allow_chunked=true) {
+
+ int rv = 0;
+ bufferlist data;
+ std::tie(rv, data) = rgw_rest_read_all_input(s, max_len);
+ if (rv >= 0) {
+ do_aws4_auth_completion();
+ }
+
+ return std::make_tuple(rv, std::move(data));
+ }
+
+ template <class T>
+ int get_json_input(CephContext *cct, req_state *s, T& out,
+ uint64_t max_len, bool *empty) {
+ int r = rgw_rest_get_json_input(cct, s, out, max_len, empty);
+ if (r >= 0) {
+ do_aws4_auth_completion();
+ }
+ return r;
+ }
+
public:
RGWOp()
: s(nullptr),
RGW_OP_CONFIG_BUCKET_META_SEARCH,
RGW_OP_GET_BUCKET_META_SEARCH,
RGW_OP_DEL_BUCKET_META_SEARCH,
+ RGW_OP_SYNC_DATALOG_NOTIFY,
+ RGW_OP_SYNC_MDLOG_NOTIFY,
+ RGW_OP_PERIOD_POST,
/* sts specific*/
RGW_STS_ASSUME_ROLE,
RGW_STS_GET_SESSION_TOKEN,
int RGWPutACLs_ObjStore::get_params(optional_yield y)
{
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
ldpp_dout(s, 0) << "RGWPutACLs_ObjStore::get_params read data is: " << data.c_str() << dendl;
return op_ret;
}
int RGWPutLC_ObjStore::get_params(optional_yield y)
{
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
return op_ret;
}
int RGWPutBucketObjectLock_ObjStore::get_params(optional_yield y)
{
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
return op_ret;
}
int RGWPutObjLegalHold_ObjStore::get_params(optional_yield y)
{
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
return op_ret;
}
}
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size);
+ std::tie(op_ret, data) = read_all_input(s, max_size);
if (op_ret < 0)
return op_ret;
bucket = s->bucket.get();
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
return op_ret;
}
extern void rgw_flush_formatter(struct req_state *s,
ceph::Formatter *formatter);
-std::tuple<int, bufferlist > rgw_rest_read_all_input(struct req_state *s,
- const uint64_t max_len,
- const bool allow_chunked=true);
-
inline std::string_view rgw_sanitized_hdrval(ceph::buffer::list& raw)
{
/* std::string and thus std::string_view ARE OBLIGED to carry multiple
return std::string_view(data, len);
}
-template <class T>
-int rgw_rest_get_json_input(CephContext *cct, req_state *s, T& out,
- uint64_t max_len, bool *empty)
-{
- if (empty)
- *empty = false;
-
- int rv = 0;
- bufferlist data;
- std::tie(rv, data) = rgw_rest_read_all_input(s, max_len);
- if (rv < 0) {
- return rv;
- }
-
- if (!data.length()) {
- if (empty) {
- *empty = true;
- }
-
- return -EINVAL;
- }
-
- JSONParser parser;
-
- if (!parser.parse(data.c_str(), data.length())) {
- return -EINVAL;
- }
-
- try {
- decode_json_obj(out, &parser);
- } catch (JSONDecoder::err& e) {
- return -EINVAL;
- }
-
- return 0;
-}
-
template <class T>
std::tuple<int, bufferlist > rgw_rest_get_json_input_keep_data(CephContext *cct, req_state *s, T& out, uint64_t max_len)
{
class RGWRESTOp : public RGWOp {
protected:
RGWRESTFlusher flusher;
+
public:
void init(rgw::sal::RGWStore *store, struct req_state *s,
RGWHandler *dialect_handler) override {
RGWQuotaInfo quota;
if (!use_http_params) {
bool empty;
- op_ret = rgw_rest_get_json_input(store->ctx(), s, quota, QUOTA_INPUT_MAX_LEN, &empty);
+ op_ret = get_json_input(store->ctx(), s, quota, QUOTA_INPUT_MAX_LEN, &empty);
if (op_ret < 0) {
if (!empty)
return;
int r = 0;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, LARGE_ENOUGH_BUF);
+ std::tie(r, data) = read_all_input(s, LARGE_ENOUGH_BUF);
if (r < 0) {
op_ret = r;
return;
int r = 0;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, LARGE_ENOUGH_BUF);
+ std::tie(r, data) = read_all_input(s, LARGE_ENOUGH_BUF);
if (r < 0) {
op_ret = r;
return;
const char* name() const override {
return "mdlog_notify";
}
+ RGWOpType get_type() override { return RGW_OP_SYNC_MDLOG_NOTIFY; }
};
class RGWOp_MDLog_Delete : public RGWRESTOp {
const char* name() const override {
return "datalog_notify";
}
+ RGWOpType get_type() override { return RGW_OP_SYNC_DATALOG_NOTIFY; }
};
class RGWOp_DATALog_Delete : public RGWRESTOp {
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
int r;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(r, data) = read_all_input(s, max_size, false);
if (r < 0) {
ldout(s->cct, 1) << "failed to read XML payload" << dendl;
return check_caps(s->user->get_caps());
}
const char* name() const override { return "post_period"; }
+ RGWOpType get_type() override { return RGW_OP_PERIOD_POST; }
};
void RGWOp_Period_Post::execute(optional_yield y)
// decode the period from input
const auto max_size = cct->_conf->rgw_max_put_param_size;
bool empty;
- op_ret = rgw_rest_get_json_input(cct, s, period, max_size, &empty);
+ op_ret = get_json_input(cct, s, period, max_size, &empty);
if (op_ret < 0) {
lderr(cct) << "failed to decode period" << dendl;
return;
int r = 0;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(r, data) = read_all_input(s, max_size, false);
if (r < 0)
return r;
int r = 0;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(r, data) = read_all_input(s, max_size, false);
if (r < 0)
return r;
int r = 0;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(r, data) = read_all_input(s, max_size, false);
if (r < 0)
return r;
int r = 0;
bufferlist data;
std::tie(r, data) =
- rgw_rest_read_all_input(s, s->cct->_conf->rgw_max_put_param_size, false);
- if (r < 0) {
- return r;
- }
-
- r = do_aws4_auth_completion();
+ read_all_input(s, s->cct->_conf->rgw_max_put_param_size, false);
if (r < 0) {
return r;
}
int r = 0;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, max_size, false);
-
- if (r < 0) {
- return r;
- }
+ std::tie(r, data) = read_all_input(s, max_size, false);
- r = do_aws4_auth_completion();
if (r < 0) {
return r;
}
int op_ret = 0;
bufferlist data;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
if ((op_ret < 0) && (op_ret != -ERR_LENGTH_REQUIRED))
return op_ret;
- const int auth_ret = do_aws4_auth_completion();
- if (auth_ret < 0) {
- return auth_ret;
- }
-
in_data.append(data);
if (data.length()) {
int r = 0;
bufferlist data;
- std::tie(r, data) = rgw_rest_read_all_input(s, max_size, false);
- if (r < 0) {
- return r;
- }
-
- r = do_aws4_auth_completion();
+ std::tie(r, data) = read_all_input(s, max_size, false);
if (r < 0) {
return r;
}
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
int r = 0;
- std::tie(r, in_data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(r, in_data) = read_all_input(s, max_size, false);
if (r < 0) {
return r;
}
const auto max_size = s->cct->_conf->rgw_max_put_param_size;
- std::tie(op_ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(op_ret, data) = read_all_input(s, max_size, false);
return op_ret;
}
case RGW_OP_SET_BUCKET_VERSIONING:
case RGW_OP_DELETE_MULTI_OBJ:
case RGW_OP_ADMIN_SET_METADATA:
+ case RGW_OP_SYNC_DATALOG_NOTIFY:
+ case RGW_OP_SYNC_MDLOG_NOTIFY:
+ case RGW_OP_PERIOD_POST:
case RGW_OP_SET_BUCKET_WEBSITE:
case RGW_OP_PUT_BUCKET_POLICY:
case RGW_OP_PUT_OBJ_TAGGING:
bufferlist data;
int ret;
int max_size = 4096;
- std::tie(ret, data) = rgw_rest_read_all_input(s, max_size, false);
+ std::tie(ret, data) = read_all_input(s, max_size, false);
if (ret != 0) {
ldout(s->cct, 10) << "s3-select query: failed to retrieve query; ret = " << ret << dendl;
return ret;
if (set_all) {
UserQuotas quotas;
- if ((op_ret = rgw_rest_get_json_input(store->ctx(), s, quotas, QUOTA_INPUT_MAX_LEN, NULL)) < 0) {
+ if ((op_ret = get_json_input(store->ctx(), s, quotas, QUOTA_INPUT_MAX_LEN, NULL)) < 0) {
ldpp_dout(this, 20) << "failed to retrieve input" << dendl;
return;
}
if (!use_http_params) {
bool empty;
- op_ret = rgw_rest_get_json_input(store->ctx(), s, quota, QUOTA_INPUT_MAX_LEN, &empty);
+ op_ret = get_json_input(store->ctx(), s, quota, QUOTA_INPUT_MAX_LEN, &empty);
if (op_ret < 0) {
ldpp_dout(this, 20) << "failed to retrieve input" << dendl;
if (!empty)