We have to differentiate the error codes depending on whether user is
anonymous (401 Unauthorized) or he doesn't have necessary permissions
(403 Forbidden). The reason behind that is the change in Tempest. See
commit ID:
6b1cd29b763dbc556137c89c5fed54c624da7f69.
Fixes: http://tracker.ceph.com/issues/16590
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
if (ret < 0) {
/* We aren't trying to recover from ENOENT here. It's supposed that creating
* someone else's account isn't a thing we want to support in this filter. */
- throw ret;
+ if (ret == -ENOENT) {
+ throw -EACCES;
+ } else {
+ throw ret;
+ }
}
}
};
const static struct rgw_http_errors RGW_HTTP_SWIFT_ERRORS[] = {
- { EACCES, 401, "AccessDenied" },
+ { EACCES, 403, "AccessDenied" },
{ EPERM, 401, "AccessDenied" },
{ ERR_USER_SUSPENDED, 401, "UserSuspended" },
{ ERR_INVALID_UTF8, 412, "Invalid UTF8" },
* override in rgw_process.cc. This is the way to specify a given RGWOp
* expect extra privileges. */
if (new_quota_extracted) {
- return -EPERM;
+ return -EACCES;
}
return 0;
return 0;
}
+int RGWPutObj_ObjStore_SWIFT::verify_permission()
+{
+ op_ret = RGWPutObj_ObjStore::verify_permission();
+
+ /* We have to differentiate error codes depending on whether user is
+ * anonymous (401 Unauthorized) or he doesn't have necessary permissions
+ * (403 Forbidden). */
+ if (s->auth_identity->is_anonymous() && op_ret == -EACCES) {
+ return -EPERM;
+ } else {
+ return op_ret;
+ }
+}
+
int RGWPutObj_ObjStore_SWIFT::get_params()
{
if (s->has_bad_meta) {
formatter.close_section();
}
+int RGWDeleteObj_ObjStore_SWIFT::verify_permission()
+{
+ op_ret = RGWDeleteObj_ObjStore::verify_permission();
+
+ /* We have to differentiate error codes depending on whether user is
+ * anonymous (401 Unauthorized) or he doesn't have necessary permissions
+ * (403 Forbidden). */
+ if (s->auth_identity->is_anonymous() && op_ret == -EACCES) {
+ return -EPERM;
+ } else {
+ return op_ret;
+ }
+}
+
int RGWDeleteObj_ObjStore_SWIFT::get_params()
{
const string& mm = s->info.args.get("multipart-manifest");
RGWPutObj_ObjStore_SWIFT() {}
~RGWPutObj_ObjStore_SWIFT() {}
+ int verify_permission() override;
int get_params();
void send_response();
};
RGWDeleteObj_ObjStore_SWIFT() {}
~RGWDeleteObj_ObjStore_SWIFT() {}
+ int verify_permission() override;
int get_params();
bool need_object_expiration() { return true; }
void send_response();