env.set("SERVER_PORT", port_buf);
}
+int RGWLibRequest::read_permissions(RGWOp *op) {
+ int ret =
+ rgw_build_bucket_policies(librgw.get_store(), s);
+ if (ret < 0) {
+ ldout(s->cct, 10) << "read_permissions on "
+ << s->bucket << ":" << s->object << " ret=" << ret
+ << dendl;
+ if (ret == -ENODATA)
+ ret = -EACCES;
+ }
+
+ return ret;
+}
+
int process_request(RGWRados* store, RGWREST* rest, RGWRequest* base_req,
RGWLibIO* io, OpsLogSocket* olog)
{
req->log_format(s, "initializing for trans_id = %s", s->trans_id.c_str());
- /* XXX the following works, but we shouldn't need to pay for a
- * dynamic cast */
+ /* XXX programmer is enforcing (for now) */
RGWOp *op = reinterpret_cast<RGWOp*>(req); // req->op is already correct
bool should_log = true;
// just checks the HTTP header, and that the user can access the gateway
// may be able to skip this after MOUNT (revalidate the user info)
req->log(s, "authorizing");
-#warning need new authorize() mechanism
-#if 0
- ret = handler->authorize(); // validates s->user
+ ret = RGW_Auth_S3::authorize(store, s); // validates s->user
if (ret < 0) {
dout(10) << "failed to authorize request" << dendl;
- abort_early(s, op, ret, handler);
+ abort_early(s, op, ret, nullptr);
goto done;
}
-#endif
if (s->user.suspended) {
dout(10) << "user is suspended, uid=" << s->user.user_id << dendl;
goto done;
}
req->log(s, "reading permissions");
-#warning need a new read_permissions(op) mechanism
-#if 0
- ret = handler->read_permissions(op);
+ ret = req->read_permissions(op);
if (ret < 0) {
abort_early(s, op, ret, nullptr);
goto done;
}
-#endif
req->log(s, "init op");
ret = op->init_processing();
}; /* RGWLibIO */
-#if 0
-struct RGWLibRequest : public RGWRequest {
- string method;
- string resource;
- int content_length;
- atomic_t* fail_flag;
-
- RGWLibRequest(uint64_t req_id, const string& _m, const string& _r, int _cl,
- bool user_command, atomic_t* _ff)
- : RGWRequest(req_id), method(_m), resource(_r), content_length(_cl),
- fail_flag(_ff)
- {
- s->librgw_user_command = user_command;
- }
-
- virtual RGWHandler* get_handler() = 0; // XXX need req_state arg?
-
-}; /* RGWLibRequest */
-#else
class RGWLibRequest : public RGWRequest {
-public:
+private:
+ struct req_state* s;
+public:
RGWLibRequest(uint64_t req_id)
- : RGWRequest(req_id)
+ : RGWRequest(req_id), s(nullptr)
{}
+ void set_state(req_state* _s) {
+ s = _s;
+ }
+
+ virtual bool only_bucket() = 0;
+
virtual RGWHandler* get_handler() /* = 0; */ { return nullptr; }
- // virtual const char* get_method() = 0;
+
+ int read_permissions(RGWOp *op);
}; /* RGWLibRequest */
-#endif /* 0 */
#endif /* RGW_LIB_H */