return EINVAL;
}
std::string script;
- const auto rc = rgw::lua::read_script(store, tenant, null_yield, script_ctx, script);
+ const auto rc = rgw::lua::read_script(dpp(), store, tenant, null_yield, script_ctx, script);
if (rc == -ENOENT) {
std::cout << "no script exists for context: " << *str_script_ctx <<
(tenant.empty() ? "" : (" in tenant: " + tenant)) << std::endl;
}
int authorize(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store) {
- int ret = store->get_user(dpp, key, null_yield, &user);
+ int ret = store->get_user_by_access_key(dpp, key.id, null_yield, &user);
if (ret == 0) {
RGWAccessKey* k = user->get_info().get_key(key.id);
if (!k || (k->key != key.key))
RGWUserInfo* get_user() { return &user->get_info(); }
void update_user(const DoutPrefixProvider *dpp) {
- (void) rgwlib.get_store()->get_user(dpp, key, null_yield, &user);
+ (void) rgwlib.get_store()->get_user_by_access_key(dpp, key.id, null_yield, &user);
}
void close();
}
-int read_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script)
+int read_script(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script)
{
- RGWSysObjectCtx obj_ctx(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj->init_obj_ctx());
RGWObjVersionTracker objv_tracker;
rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant));
bufferlist bl;
- const auto rc = rgw_get_system_obj(
- obj_ctx,
+ const auto rc = store->get_system_obj(
+ dpp,
obj.pool,
obj.oid,
bl,
int write_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script)
{
- RGWSysObjectCtx obj_ctx(static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj->init_obj_ctx());
RGWObjVersionTracker objv_tracker;
rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant));
bufferlist bl;
ceph::encode(script, bl);
- const auto rc = rgw_put_system_obj(
- obj_ctx,
+ const auto rc = store->put_system_obj(
obj.pool,
obj.oid,
bl,
rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant));
- const auto rc = rgw_delete_system_obj(
- static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sysobj,
+ const auto rc = store->delete_system_obj(
obj.pool,
obj.oid,
&objv_tracker,
int write_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script);
// read the stored lua script from a context
-int read_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script);
+int read_script(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script);
// delete the stored lua script from a context
int delete_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_yield y, context ctx);
void RGWPutMetadataAccount::execute(optional_yield y)
{
/* Params have been extracted earlier. See init_processing(). */
- op_ret = s->user->load_by_id(this, y, RGWUserCtl::GetParams().set_objv_tracker(&acct_op_tracker));
+ op_ret = s->user->load_by_id(this, y);
if (op_ret < 0) {
return;
}
+ acct_op_tracker = s->user->get_version_tracker();
/* Handle the TempURL-related stuff. */
if (!temp_url_keys.empty()) {
}
{
std::string script;
- auto rc = rgw::lua::read_script(store, s->bucket_tenant, s->yield, rgw::lua::context::preRequest, script);
+ auto rc = rgw::lua::read_script(s, store, s->bucket_tenant, s->yield, rgw::lua::context::preRequest, script);
if (rc == -ENOENT) {
// no script, nothing to do
} else if (rc < 0) {
done:
if (op) {
std::string script;
- auto rc = rgw::lua::read_script(store, s->bucket_tenant, s->yield, rgw::lua::context::postRequest, script);
+ auto rc = rgw::lua::read_script(s, store, s->bucket_tenant, s->yield, rgw::lua::context::postRequest, script);
if (rc == -ENOENT) {
// no script, nothing to do
} else if (rc < 0) {
{
/* get the user info */
std::unique_ptr<rgw::sal::RGWUser> user;
+ const std::string access_key_id(_access_key_id);
/* TODO(rzarzynski): we need to have string-view taking variant. */
- RGWAccessKey access_key;
- access_key.id = _access_key_id;
- if (store->get_user(dpp, access_key, y, &user) < 0) {
- ldpp_dout(dpp, 5) << "error reading user info, uid=" << access_key.id
+ if (store->get_user_by_access_key(dpp, access_key_id, y, &user) < 0) {
+ ldpp_dout(dpp, 5) << "error reading user info, uid=" << access_key_id
<< " can't authenticate" << dendl;
return result_t::deny(-ERR_INVALID_ACCESS_KEY);
}
}
}*/
- const auto iter = user->get_info().access_keys.find(access_key.id);
+ const auto iter = user->get_info().access_keys.find(access_key_id);
if (iter == std::end(user->get_info().access_keys)) {
ldpp_dout(dpp, 0) << "ERROR: access key not encoded in user info" << dendl;
return result_t::deny(-EPERM);
RGWStore() {}
virtual ~RGWStore() = default;
+ /* This one does not query the cluster for info */
virtual std::unique_ptr<RGWUser> get_user(const rgw_user& u) = 0;
- virtual int get_user(const DoutPrefixProvider *dpp, const RGWAccessKey& key, optional_yield y, std::unique_ptr<RGWUser>* user) = 0;
+ /* These three do query the cluster for info */
+ virtual int get_user_by_access_key(const DoutPrefixProvider *dpp, const std::string& key, optional_yield y, std::unique_ptr<RGWUser>* user) = 0;
virtual int get_user_by_email(const DoutPrefixProvider *dpp, const std::string& email, optional_yield y, std::unique_ptr<RGWUser>* user) = 0;
virtual int get_user_by_swift(const DoutPrefixProvider *dpp, const std::string& user_str, optional_yield y, std::unique_ptr<RGWUser>* user) = 0;
virtual std::unique_ptr<RGWObject> get_object(const rgw_obj_key& k) = 0;
class RGWUser {
protected:
RGWUserInfo info;
+ RGWObjVersionTracker objv_tracker;
public:
RGWUser() : info() {}
bool *is_truncated, RGWUsageIter& usage_iter,
map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) = 0;
+ virtual RGWObjVersionTracker& get_version_tracker() { return objv_tracker; }
/* Placeholders */
- virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::GetParams& params = {}) = 0;
+ virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y) = 0;
virtual int store_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::PutParams& params = {}) = 0;
/* dang temporary; will be removed when User is complete */
return store->getRados()->trim_usage(get_id(), bucket_name, start_epoch, end_epoch);
}
-int RGWRadosUser::load_by_id(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::GetParams& params)
+int RGWRadosUser::load_by_id(const DoutPrefixProvider *dpp, optional_yield y)
{
- return store->ctl()->user->get_info_by_uid(dpp, info.user_id, &info, y, params);
+ return store->ctl()->user->get_info_by_uid(dpp, info.user_id, &info, y, RGWUserCtl::GetParams().set_objv_tracker(&objv_tracker));
}
int RGWRadosUser::store_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::PutParams& params)
return std::unique_ptr<RGWUser>(new RGWRadosUser(this, u));
}
-int RGWRadosStore::get_user(const DoutPrefixProvider *dpp, const RGWAccessKey& key, optional_yield y, std::unique_ptr<RGWUser>* user)
+int RGWRadosStore::get_user_by_access_key(const DoutPrefixProvider *dpp, const std::string& key, optional_yield y, std::unique_ptr<RGWUser>* user)
{
RGWUserInfo uinfo;
RGWUser *u;
+ RGWObjVersionTracker objv_tracker;
- int r = ctl()->user->get_info_by_access_key(dpp, key.id, &uinfo, y);
+ int r = ctl()->user->get_info_by_access_key(dpp, key, &uinfo, y, RGWUserCtl::GetParams().set_objv_tracker(&objv_tracker));
if (r < 0)
return r;
if (!u)
return -ENOMEM;
+ u->get_version_tracker() = objv_tracker;
+
user->reset(u);
return 0;
}
{
RGWUserInfo uinfo;
RGWUser *u;
+ RGWObjVersionTracker objv_tracker;
- int r = ctl()->user->get_info_by_email(dpp, email, &uinfo, y);
+ int r = ctl()->user->get_info_by_email(dpp, email, &uinfo, y, RGWUserCtl::GetParams().set_objv_tracker(&objv_tracker));
if (r < 0)
return r;
if (!u)
return -ENOMEM;
+ u->get_version_tracker() = objv_tracker;
+
user->reset(u);
return 0;
}
{
RGWUserInfo uinfo;
RGWUser *u;
+ RGWObjVersionTracker objv_tracker;
- int r = ctl()->user->get_info_by_swift(dpp, user_str, &uinfo, y);
+ int r = ctl()->user->get_info_by_swift(dpp, user_str, &uinfo, y, RGWUserCtl::GetParams().set_objv_tracker(&objv_tracker));
if (r < 0)
return r;
if (!u)
return -ENOMEM;
+ u->get_version_tracker() = objv_tracker;
+
user->reset(u);
return 0;
}
virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) override;
/* Placeholders */
- virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::GetParams& params = {}) override;
+ virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y) override;
virtual int store_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::PutParams& params = {}) override;
friend class RGWRadosBucket;
}
virtual std::unique_ptr<RGWUser> get_user(const rgw_user& u) override;
- virtual int get_user(const DoutPrefixProvider *dpp, const RGWAccessKey& key, optional_yield y, std::unique_ptr<RGWUser>* user) override;
+ virtual int get_user_by_access_key(const DoutPrefixProvider *dpp, const std::string& key, optional_yield y, std::unique_ptr<RGWUser>* user) override;
virtual int get_user_by_email(const DoutPrefixProvider *dpp, const std::string& email, optional_yield y, std::unique_ptr<RGWUser>* user) override;
virtual int get_user_by_swift(const DoutPrefixProvider *dpp, const std::string& user_str, optional_yield y, std::unique_ptr<RGWUser>* user) override;
virtual std::unique_ptr<RGWObject> get_object(const rgw_obj_key& k) override;
access_key.clear();
}
- RGWUserInfo user_info;
+ std::unique_ptr<rgw::sal::RGWUser> user;
clear_populated();
}
if (!user_id.empty() && (user_id.compare(RGW_USER_ANON_ID) != 0)) {
- found = (rgw_get_user_info_by_uid(dpp, user_ctl, user_id, user_info, y, &op_state.objv) >= 0);
+ user = store->get_user(user_id);
+ found = (user->load_by_id(dpp, y) >= 0);
op_state.found_by_uid = found;
}
if (store->ctx()->_conf.get_val<bool>("rgw_user_unique_email")) {
if (!user_email.empty() && !found) {
- found = (rgw_get_user_info_by_email(dpp, user_ctl, user_email, user_info, y, &op_state.objv) >= 0);
+ found = (store->get_user_by_email(dpp, user_email, y, &user) >= 0);
op_state.found_by_email = found;
}
}
if (!swift_user.empty() && !found) {
- found = (rgw_get_user_info_by_swift(dpp, user_ctl, swift_user, user_info, y, &op_state.objv) >= 0);
+ found = (store->get_user_by_swift(dpp, swift_user, y, &user) >= 0);
op_state.found_by_key = found;
}
if (!access_key.empty() && !found) {
- found = (rgw_get_user_info_by_access_key(dpp, user_ctl, access_key, user_info, y, &op_state.objv) >= 0);
+ found = (store->get_user_by_access_key(dpp, access_key, y, &user) >= 0);
op_state.found_by_key = found;
}
op_state.set_existing_user(found);
if (found) {
- op_state.set_user_info(user_info);
+ op_state.set_user_info(user->get_info());
op_state.set_populated();
+ op_state.objv = user->get_version_tracker();
- old_info = user_info;
+ old_info = user->get_info();
set_populated();
}
if (user_id.empty()) {
- user_id = user_info.user_id;
+ user_id = user->get_id();
}
op_state.set_initialized();